├── .editorconfig ├── .gitattributes ├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── .vscode └── c_cpp_properties.json ├── CMakeLists.txt ├── CMakeSettings.json ├── LICENSE.txt ├── README.md ├── cmake ├── FindAssimp.cmake ├── FindCityGML.cmake ├── FindGDAL.cmake ├── FindGLFW.cmake ├── FindGLM.cmake ├── FindGeoTIFF.cmake ├── FindJsoncpp.cmake ├── FindLibLAS.cmake ├── FindProj.cmake ├── FindXerces.cmake └── cmake_apply_patches.cmake ├── docker ├── Dockerfile ├── build.bat ├── config.bat ├── env │ ├── enabledevtoolset-7.sh │ ├── entrypoint.sh │ ├── set-display.sh │ └── set-locale.sh └── run.bat ├── f4d.ico ├── f4d.rc ├── include ├── argdefinition.h └── predefinition.h ├── launch.vs.json ├── patch └── ifcplusplus │ └── fix-config-path.patch └── src ├── converter ├── ConverterManager.cpp ├── ConverterManager.h ├── LogWriter.cpp └── LogWriter.h ├── geometry ├── BoundingBox.cpp ├── BoundingBox.h ├── ColorU4.h ├── LegoBlock.cpp ├── LegoBlock.h ├── Matrix4.cpp ├── Matrix4.h ├── OctreeBox.cpp ├── OctreeBox.h ├── Point3D.cpp ├── Point3D.h ├── PointDistributionOctree.cpp ├── PointDistributionOctree.h ├── Quadtree.cpp ├── Quadtree.h ├── Quaternion.cpp ├── Quaternion.h ├── Surface.cpp ├── Surface.h ├── Triangle.cpp ├── Triangle.h ├── TrianglePolyhedron.cpp ├── TrianglePolyhedron.h ├── Vbo.h ├── Vertex.cpp └── Vertex.h ├── main.cpp ├── process ├── ConversionProcessor.cpp ├── ConversionProcessor.h ├── NetSurfaceMeshMaker.cpp ├── NetSurfaceMeshMaker.h ├── NetSurfaceMeshSetting.cpp ├── NetSurfaceMeshSetting.h ├── ProcessSetting.cpp ├── ProcessSetting.h ├── SceneControlVariables.cpp └── SceneControlVariables.h ├── reader ├── AvevaRevReader.cpp ├── AvevaRevReader.h ├── CityGMLReader.cpp ├── CityGMLReader.h ├── ClassicFormatReader.cpp ├── ClassicFormatReader.h ├── IfcLoader.h ├── IfcReader.cpp ├── IfcReader.h ├── IfcppLoader.cpp ├── IfcppLoader.h ├── IndoorGMLReader.cpp ├── IndoorGMLReader.h ├── PointCloudReader.cpp ├── PointCloudReader.h ├── Reader.cpp ├── Reader.h ├── ReaderFactory.cpp └── ReaderFactory.h ├── util ├── GeometryUtility.cpp ├── GeometryUtility.h ├── Image2D.cpp ├── Image2D.h ├── Image2DSplitData.cpp ├── Image2DSplitData.h ├── Image2DUtils.cpp ├── Image2DUtils.h ├── Rectangle.cpp ├── Rectangle.h ├── StringUtility.cpp └── StringUtility.h └── writer ├── F4DWriter.cpp └── F4DWriter.h /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8-bom 5 | end_of_line = lf 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .settings 2 | .vs 3 | [bB]uild 4 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: centos:7 2 | 3 | variables: 4 | GIT_STRATEGY: recursive 5 | 6 | stages: 7 | - prepare 8 | - build 9 | # - test 10 | # - package 11 | 12 | # cache: 13 | # untracked: true 14 | # paths: 15 | # - build 16 | # - external 17 | 18 | before_script: 19 | - yum -y install wget centos-release-scl 20 | - wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 21 | - rpm -Uvh epel-release-latest-7.noarch.rpm 22 | - yum -y update 23 | - yum -y install git openssh-server make gcc-c++ gdb gdb-gdbserver zip rsync devtoolset-4-toolchain scl-utils curl-devel expat-devel zlib-devel gettext openssl-devel ncurses-devel boost-devel libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel mesa-dri-drivers mesa-libGL-devel mesa-libGLU-devel xorg-x11-server-Xvfb proj-devel xerces-c-devel libgeotiff-devel gdal-devel liblas-devel 24 | - rm -fr /var/cache/yum/* 25 | - git submodule sync --recursive 26 | - git submodule update --init --recursive 27 | - wget --no-check-certificate https://cmake.org/files/v3.14/cmake-3.14.5.tar.gz 28 | - tar xvzf cmake-3.14.5.tar.gz && cd cmake-3.14.5 29 | - ./configure --prefix=/usr/local 30 | - make -j2 31 | - ./bin/cmake -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON . 32 | - make install && cd - 33 | 34 | prepare: 35 | stage: prepare 36 | script: 37 | - mkdir build 38 | - cd build 39 | - cmake .. 40 | - cd - 41 | 42 | build: 43 | stage: build 44 | script: 45 | - cd build 46 | - make 47 | - cd - 48 | # - make install 49 | 50 | # test: 51 | # stage: test 52 | # script: 53 | # - cd build 54 | # - make check 55 | 56 | # package: 57 | # stage: package 58 | # artifacts: 59 | # expire_in: 1 week 60 | # paths: 61 | # - build/out/ 62 | # script: 63 | # - cd build 64 | # - make package 65 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/glfw"] 2 | path = lib/glfw 3 | url = https://github.com/glfw/glfw.git 4 | branch = master 5 | [submodule "lib/glm"] 6 | path = lib/glm 7 | url = https://github.com/g-truc/glm.git 8 | branch = master 9 | [submodule "lib/glad"] 10 | path = lib/glad 11 | url = https://github.com/Dav1dde/glad.git 12 | branch = c 13 | [submodule "lib/assimp"] 14 | path = lib/assimp 15 | url = https://github.com/assimp/assimp.git 16 | branch = master 17 | [submodule "lib/stb"] 18 | path = lib/stb 19 | url = https://github.com/nothings/stb.git 20 | branch = master 21 | [submodule "lib/ifcplusplus"] 22 | path = lib/ifcplusplus 23 | url = https://github.com/ifcquery/ifcplusplus.git 24 | branch = master 25 | [submodule "lib/jsoncpp"] 26 | path = lib/jsoncpp 27 | url = https://github.com/open-source-parsers/jsoncpp.git 28 | branch = master 29 | [submodule "lib/libcitygml"] 30 | path = lib/libcitygml 31 | url = https://github.com/jklimke/libcitygml.git 32 | branch = master 33 | [submodule "lib/xerces"] 34 | path = lib/xerces 35 | url = https://github.com/apache/xerces-c.git 36 | branch = xerces-3.2 37 | [submodule "lib/proj"] 38 | path = lib/proj 39 | url = https://github.com/OSGeo/proj.4.git 40 | branch = master 41 | [submodule "lib/catch2"] 42 | path = lib/catch2 43 | url = https://github.com/catchorg/Catch2.git 44 | branch = master 45 | [submodule "lib/spdlog"] 46 | path = lib/spdlog 47 | url = https://github.com/gabime/spdlog.git 48 | branch = master 49 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Win32", 5 | "browse": { 6 | "path": [ 7 | "${workspaceFolder}" 8 | ], 9 | "limitSymbolsToIncludedHeaders": true 10 | }, 11 | "includePath": [ 12 | "${workspaceFolder}", 13 | "${workspaceFolder}/src", 14 | "${workspaceFolder}/lib/glad/include", 15 | "${workspaceFolder}/lib/glfw/include", 16 | "${workspaceFolder}/lib/assimp/include", 17 | "${workspaceFolder}/include", 18 | "${workspaceFolder}/lib/proj/src", 19 | "${workspaceFolder}/build/lib/assimp/include", 20 | "${workspaceFolder}/lib/jsoncpp/include", 21 | "${workspaceFolder}/lib/stb" 22 | ], 23 | "defines": [ 24 | "_DEBUG", 25 | "UNICODE", 26 | "_UNICODE" 27 | ], 28 | "cStandard": "c11", 29 | "cppStandard": "c++17", 30 | "intelliSenseMode": "msvc-x64", 31 | "configurationProvider": "vector-of-bool.cmake-tools" 32 | } 33 | ], 34 | "version": 4 35 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.9 FATAL_ERROR) 2 | 3 | #-------------------------------------------------------------------- 4 | # Project Information 5 | #-------------------------------------------------------------------- 6 | PROJECT(F4DConverter) 7 | 8 | IF(CMAKE_VERSION VERSION_LESS "3.1") 9 | IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 10 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") 11 | ENDIF() 12 | ELSE() 13 | SET(CMAKE_CXX_STANDARD 11) 14 | SET(CMAKE_CXX_STANDARD_REQUIRED ON) 15 | SET(CMAKE_CXX_EXTENSIONS OFF) 16 | ENDIF() 17 | 18 | IF(WIN32) 19 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS") 20 | ENDIF() 21 | 22 | LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 23 | INCLUDE("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_apply_patches.cmake") 24 | #-------------------------------------------------------------------- 25 | # Find Boost 26 | #-------------------------------------------------------------------- 27 | #SET(Boost_DEBUG ON) 28 | IF(WIN32) 29 | SET(Boost_USE_STATIC_LIBS ON CACHE INTERNAL "" FORCE) 30 | ENDIF() 31 | FIND_PACKAGE(Boost COMPONENTS thread locale system filesystem) 32 | IF(NOT Boost_FOUND) 33 | #SET(Boost_USE_STATIC_LIBS OFF) 34 | #SET(Boost_USE_MULTITHREADED ON) 35 | #SET(Boost_USE_STATIC_RUNTIME OFF) 36 | ENDIF() 37 | ADD_DEFINITIONS(-DBOOST_UUID_FORCE_AUTO_LINK) 38 | 39 | MESSAGE(STATUS "Boost_INCLUDE_DIRS : ${Boost_INCLUDE_DIRS}") 40 | MESSAGE(STATUS "Boost_LIBRARIES : ${Boost_LIBRARIES}") 41 | 42 | INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) 43 | #LINK_LIBRARIES(${Boost_LIBRARIES}) 44 | 45 | #-------------------------------------------------------------------- 46 | # Find GLFW 47 | #-------------------------------------------------------------------- 48 | FIND_PACKAGE(GLFW) 49 | IF(NOT GLFW_FOUND) 50 | MESSAGE(STATUS "GLFW not found! Using local source...") 51 | 52 | SET(GLFW_BUILD_DOCS OFF CACHE INTERNAL "" FORCE) 53 | SET(GLFW_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE) 54 | SET(GLFW_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) 55 | 56 | ADD_SUBDIRECTORY(lib/glfw) 57 | SET(GLFW_INCLUDE_DIRS "${glfw_INCLUDE_DIRS}" lib/glfw/include) 58 | SET(GLFW_LIBRARIES "${glfw_LIBRARIES}" glfw) 59 | ENDIF() 60 | 61 | MESSAGE(STATUS "${GLFW_INCLUDE_DIRS}") 62 | MESSAGE(STATUS "${GLFW_LIBRARIES}") 63 | 64 | INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS}) 65 | #LINK_LIBRARIES(${GLFW_LIBRARIES}) 66 | 67 | #-------------------------------------------------------------------- 68 | # Find GLM 69 | #-------------------------------------------------------------------- 70 | FIND_PACKAGE(GLM) 71 | IF(NOT GLM_FOUND) 72 | MESSAGE(STATUS "GLM not found! Using local source...") 73 | 74 | SET(GLM_TEST_ENABLE OFF CACHE INTERNAL "" FORCE) 75 | SET(GLM_STATIC_LIBRARY_ENABLE ON CACHE INTERNAL "" FORCE) 76 | 77 | ADD_SUBDIRECTORY(lib/glm) 78 | SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIRS}" lib/glm) 79 | ENDIF() 80 | 81 | MESSAGE(STATUS "${GLM_INCLUDE_DIRS}") 82 | 83 | INCLUDE_DIRECTORIES(${GLM_INCLUDE_DIRS}) 84 | 85 | #-------------------------------------------------------------------- 86 | # Find STB 87 | #-------------------------------------------------------------------- 88 | #FIND_PACKAGE(STB) 89 | #IF(NOT STB_FOUND) 90 | # MESSAGE(STATUS "STB not found! Using local source...") 91 | # 92 | # ADD_SUBDIRECTORY(lib/stb) 93 | SET(STB_INCLUDE_DIRS "${STB_INCLUDE_DIRS}" lib/stb) 94 | #ENDIF() 95 | 96 | MESSAGE(STATUS "${STB_INCLUDE_DIRS}") 97 | 98 | INCLUDE_DIRECTORIES(${STB_INCLUDE_DIRS}) 99 | 100 | #-------------------------------------------------------------------- 101 | # Find GLAD 102 | #-------------------------------------------------------------------- 103 | SET(GLAD_INCLUDE_DIRS lib/glad/include) 104 | IF(NOT WIN32) 105 | SET(GLAD_LIBRARIES dl) 106 | ENDIF() 107 | 108 | INCLUDE_DIRECTORIES(${GLAD_INCLUDE_DIRS}) 109 | #LINK_LIBRARIES(${GLAD_LIBRARIES}) 110 | 111 | #-------------------------------------------------------------------- 112 | # Find XercesC 113 | #-------------------------------------------------------------------- 114 | #SET(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE) 115 | #FIND_PACKAGE(XercesC) 116 | #IF(XercesC_FOUND) 117 | # SET(XERCESC_INCLUDE_DIRS "${XercesC_INCLUDE_DIRS}") 118 | # SET(XERCESC_LIBRARIES "${XercesC_LIBRARIES}") 119 | #ELSE() 120 | # MESSAGE(STATUS "Xerces not found! Using local source...") 121 | # 122 | # ADD_SUBDIRECTORY(lib/xerces) 123 | # 124 | # INCLUDE_DIRECTORIES( 125 | # ${xerces-c_BINARY_DIR} 126 | # ${xerces-c_SOURCE_DIR}/src 127 | # ${xerces-c_BINARY_DIR}/src 128 | # ) 129 | # SET(XERCESC_INCLUDE_DIRS "${xerces-c_BINARY_DIR}" 130 | # "${xerces-c_SOURCE_DIR}/src" 131 | # "${xerces-c_BINARY_DIR}/src") 132 | # SET(XERCESC_LIBRARIES xerces-c) 133 | #ENDIF() 134 | 135 | #MESSAGE(STATUS "${XERCESC_INCLUDE_DIRS}") 136 | #MESSAGE(STATUS "${XERCESC_LIBRARIES}") 137 | 138 | #INCLUDE_DIRECTORIES(${XERCESC_INCLUDE_DIRS}) 139 | #LINK_LIBRARIES(${XERCESC_LIBRARIES}) 140 | 141 | #-------------------------------------------------------------------- 142 | # Find Libcitygml 143 | #-------------------------------------------------------------------- 144 | SET(BUILD_DEBIAN_PACKAGE OFF CACHE INTERNAL "" FORCE) 145 | SET(LIBCITYGML_USE_GDAL OFF CACHE INTERNAL "" FORCE) 146 | SET(LIBCITYGML_DYNAMIC OFF CACHE INTERNAL "" FORCE) 147 | SET(LIBCITYGML_STATIC_CRT OFF CACHE INTERNAL "" FORCE) 148 | SET(LIBCITYGML_TESTS OFF CACHE INTERNAL "" FORCE) 149 | 150 | #FIND_PACKAGE(CityGML) 151 | IF(CITYGML_FOUND) 152 | SET(CITYGML_INCLUDE_DIRS "${CITYGML_INCLUDE_DIR}") 153 | SET(CITYGML_LIBRARIES "${CITYGML_LIBRARIES}") 154 | ELSE() 155 | MESSAGE(STATUS "Libcitygml not found! Using local source...") 156 | 157 | ADD_SUBDIRECTORY(lib/libcitygml) 158 | 159 | SET(CITYGML_INCLUDE_DIRS "${libcitygml_SOURCE_DIR}/sources/include" 160 | "${libcitygml_BINARY_DIR}/sources/include") 161 | SET(CITYGML_LIBRARIES citygml) 162 | ENDIF() 163 | MESSAGE(STATUS "${CITYGML_INCLUDE_DIRS}") 164 | MESSAGE(STATUS "${CITYGML_LIBRARIES}") 165 | 166 | INCLUDE_DIRECTORIES(${CITYGML_INCLUDE_DIRS}) 167 | #LINK_LIBRARIES(${CITYGML_LIBRARIES}) 168 | 169 | #-------------------------------------------------------------------- 170 | # Find Assimp 171 | #-------------------------------------------------------------------- 172 | FIND_PACKAGE(Assimp) 173 | IF(NOT ASSIMP_FOUND) 174 | MESSAGE(STATUS "ASSIMP not found! Using local source...") 175 | 176 | SET(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE INTERNAL "" FORCE) 177 | SET(ASSIMP_BUILD_SAMPLES OFF CACHE INTERNAL "" FORCE) 178 | SET(ASSIMP_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) 179 | #SET(INJECT_DEBUG_POSTFIX OFF CACHE INTERNAL "" FORCE) 180 | 181 | ADD_SUBDIRECTORY(lib/assimp) 182 | SET(ASSIMP_INCLUDE_DIRS ${Assimp_SOURCE_DIR} 183 | ${Assimp_SOURCE_DIR}/include 184 | ${Assimp_SOURCE_DIR}/code 185 | ${Assimp_BINARY_DIR} 186 | ${Assimp_BINARY_DIR}/include 187 | ${Assimp_BINARY_DIR}/code) 188 | SET(ASSIMP_LIBRARIES assimp) 189 | ENDIF() 190 | 191 | MESSAGE(STATUS "${ASSIMP_INCLUDE_DIRS}") 192 | MESSAGE(STATUS "${ASSIMP_LIBRARIES}") 193 | 194 | INCLUDE_DIRECTORIES(${ASSIMP_INCLUDE_DIRS}) 195 | #LINK_LIBRARIES(${ASSIMP_LIBRARIES}) 196 | 197 | #-------------------------------------------------------------------- 198 | # Find PROJ4 199 | #-------------------------------------------------------------------- 200 | FIND_PACKAGE(Proj) 201 | IF(NOT PROJ4_FOUND) 202 | MESSAGE(STATUS "Proj4 not found! Using local source...") 203 | SET(PROJ_TESTS OFF CACHE INTERNAL "" FORCE) 204 | ADD_SUBDIRECTORY(lib/proj) 205 | SET(PROJ4_INCLUDE_DIRS "${PROJ4_SOURCE_DIR}/src" "${PROJ4_BINARY_DIR}/src") 206 | SET(PROJ4_LIBRARIES proj) 207 | ENDIF() 208 | ADD_DEFINITIONS(-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H) 209 | MESSAGE(STATUS "${PROJ4_INCLUDE_DIRS}") 210 | MESSAGE(STATUS "${PROJ4_LIBRARIES}") 211 | 212 | INCLUDE_DIRECTORIES(${PROJ4_INCLUDE_DIRS}) 213 | LINK_LIBRARIES(${PROJ4_LIBRARIES}) 214 | 215 | #-------------------------------------------------------------------- 216 | # Find IfcPlusPlus 217 | #-------------------------------------------------------------------- 218 | #FIND_PACKAGE(IfcPlusPlus) 219 | #IF(NOT IfcPlusPlus_FOUND) 220 | # MESSAGE(STATUS "IfcPlusPlus not found! Using local source...") 221 | 222 | SET(BUILD_VIEWER_APPLICATION OFF CACHE INTERNAL "" FORCE) 223 | #SET(BUILD_STATIC_LIBRARY ON CACHE INTERNAL "" FORCE) 224 | 225 | ADD_SUBDIRECTORY(lib/ifcplusplus) 226 | 227 | cmake_apply_patches( 228 | SOURCE_PATH ${IFCPP_SOURCE_DIR} 229 | PATCHES 230 | patch/ifcplusplus/fix-config-path.patch 231 | ) 232 | 233 | SET(IFCPP_INCLUDE_DIRS "${IFCPP_SOURCE_DIR}/IfcPlusPlus/src/" 234 | "${IFCPP_SOURCE_DIR}/external/Carve/src/include" 235 | "${IFCPP_BINARY_DIR}/include") 236 | SET(IFCPP_LIBRARIES IfcPlusPlus) 237 | #ENDIF() 238 | 239 | MESSAGE(STATUS "${IFCPP_INCLUDE_DIRS}") 240 | MESSAGE(STATUS "${IFCPP_LIBRARIES}") 241 | 242 | INCLUDE_DIRECTORIES(${IFCPP_INCLUDE_DIRS}) 243 | #LINK_LIBRARIES(${IFCPP_LIBRARIES}) 244 | 245 | #-------------------------------------------------------------------- 246 | # Find Jsoncpp 247 | #-------------------------------------------------------------------- 248 | #FIND_PACKAGE(Jsoncpp) 249 | #IF(NOT Jsoncpp_FOUND) 250 | # MESSAGE(STATUS "Jsoncpp not found! Using local source...") 251 | # 252 | # SET(JSONCPP_WITH_PKGCONFIG_SUPPORT OFF) 253 | # SET(JSONCPP_WITH_CMAKE_PACKAGE OFF) 254 | # 255 | # ADD_SUBDIRECTORY(lib/jsoncpp) 256 | # SET(JSONCPP_INCLUDE_DIRS "${JSONCPP_INCLUDE_DIRS}") 257 | # SET(JSONCPP_LIBRARIES jsoncpp${STATIC_SUFFIX}) 258 | #ENDIF() 259 | # 260 | #MESSAGE(STATUS "${JSONCPP_INCLUDE_DIRS}") 261 | #MESSAGE(STATUS "${JSONCPP_LIBRARIES}") 262 | # 263 | #INCLUDE_DIRECTORIES(${JSONCPP_INCLUDE_DIRS}) 264 | #LINK_LIBRARIES(${JSONCPP_LIBRARIES}) 265 | 266 | #-------------------------------------------------------------------- 267 | # Build Jsoncpp as an external project. 268 | #-------------------------------------------------------------------- 269 | SET(JSONCPP_INSTALL_DIR ${CMAKE_BINARY_DIR}/lib/jsoncpp) 270 | SET(JSONCPP_INCLUDE_DIR ${JSONCPP_INSTALL_DIR}/include) 271 | SET(JSONCPP_LIBRARY_DIR ${JSONCPP_INSTALL_DIR}/lib) 272 | include(ExternalProject) 273 | ExternalProject_Add(jsoncpp_external_project 274 | SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/jsoncpp 275 | PREFIX ${JSONCPP_INSTALL_DIR} 276 | INSTALL_DIR ${JSONCPP_INSTALL_DIR} 277 | CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} 278 | -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} 279 | -DCMAKE_CXX_FLAGS=${EXTERNAL_PROJECT_CMAKE_CXX_FLAGS} 280 | -DCMAKE_INSTALL_PREFIX:PATH=${JSONCPP_INSTALL_DIR} 281 | -DCMAKE_INSTALL_LIBDIR=${JSONCPP_LIBRARY_DIR} 282 | ) 283 | 284 | SET(JSONCPP_INCLUDE_DIRS "${JSONCPP_INCLUDE_DIR}") 285 | SET(JSONCPP_LIBRARIES jsoncpp${STATIC_SUFFIX}) 286 | 287 | MESSAGE(STATUS "${JSONCPP_INCLUDE_DIRS}") 288 | MESSAGE(STATUS "${JSONCPP_LIBRARIES}") 289 | 290 | LINK_DIRECTORIES(${JSONCPP_LIBRARY_DIR}) 291 | INCLUDE_DIRECTORIES(BEFORE SYSTEM ${JSONCPP_INCLUDE_DIRS}) 292 | LINK_LIBRARIES(${JSONCPP_LIBRARIES}) 293 | 294 | # A target to combine all of the external projects. 295 | ADD_CUSTOM_TARGET(build_external_projects 296 | DEPENDS jsoncpp_external_project) 297 | 298 | #-------------------------------------------------------------------- 299 | # Find libGeoTiff 300 | #-------------------------------------------------------------------- 301 | FIND_PACKAGE(GeoTIFF REQUIRED) 302 | IF(NOT GEOTIFF_FOUND) 303 | MESSAGE(STATUS "libGeoTiff not found!") 304 | ENDIF() 305 | 306 | MESSAGE(STATUS "${GEOTIFF_INCLUDE_DIR}") 307 | MESSAGE(STATUS "${GEOTIFF_LIBRARY}") 308 | 309 | INCLUDE(CheckFunctionExists) 310 | INCLUDE_DIRECTORIES(${GEOTIFF_INCLUDE_DIR}) 311 | LINK_LIBRARIES(${GEOTIFF_LIBRARY}) 312 | 313 | #-------------------------------------------------------------------- 314 | # Find GDAL 315 | #-------------------------------------------------------------------- 316 | FIND_PACKAGE(GDAL REQUIRED) 317 | IF(NOT GDAL_FOUND) 318 | MESSAGE(STATUS "GDAL not found!") 319 | ENDIF() 320 | 321 | MESSAGE(STATUS "${GDAL_INCLUDE_DIR}") 322 | MESSAGE(STATUS "${GDAL_LIBRARY}") 323 | 324 | INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIR}) 325 | LINK_LIBRARIES(${GDAL_LIBRARY}) 326 | 327 | #-------------------------------------------------------------------- 328 | # Find LibLAS 329 | #-------------------------------------------------------------------- 330 | FIND_PACKAGE(LibLAS REQUIRED) 331 | IF(NOT LIBLAS_FOUND) 332 | MESSAGE(STATUS "LibLAS not found! Using local source...") 333 | ENDIF() 334 | 335 | MESSAGE(STATUS "${LIBLAS_INCLUDE_DIR}") 336 | MESSAGE(STATUS "${LIBLAS_LIBRARY}") 337 | 338 | INCLUDE_DIRECTORIES(${LIBLAS_INCLUDE_DIR}) 339 | LINK_LIBRARIES(${LIBLAS_LIBRARY}) 340 | 341 | #-------------------------------------------------------------------- 342 | # 343 | #-------------------------------------------------------------------- 344 | #ADD_DEFINITIONS(-DF4D_FORMAT_SUPPORT_SHIJT) 345 | ADD_DEFINITIONS(-DF4D_FORMAT_SUPPORT_IFC) 346 | ADD_DEFINITIONS(-DF4D_FORMAT_SUPPORT_CLASSIC) 347 | ADD_DEFINITIONS(-DF4D_FORMAT_SUPPORT_CITYGML) 348 | ADD_DEFINITIONS(-DF4D_FORMAT_SUPPORT_POINTCLOUD) 349 | ADD_DEFINITIONS(-DF4D_FORMAT_SUPPORT_AVEVAREVIEW) 350 | ADD_DEFINITIONS(-DF4D_FORMAT_SUPPORT_INDOORGML) 351 | 352 | INCLUDE_DIRECTORIES(include) 353 | 354 | FILE(GLOB PROJECT_HEADERS include/*.h) 355 | FILE(GLOB_RECURSE PROJECT_SOURCES src/*.cpp src/*.c lib/glad/src/glad.c) 356 | FILE(GLOB PROJECT_CONFIGS CMakeLists.txt) 357 | 358 | FOREACH(item ${PROJECT_SOURCES}) 359 | MESSAGE ("Now Globbing..... ${item}") 360 | ENDFOREACH() 361 | 362 | ADD_EXECUTABLE(${PROJECT_NAME} ${PROJECT_SOURCES}) 363 | ADD_DEPENDENCIES(${PROJECT_NAME} build_external_projects) 364 | 365 | TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES} 366 | ${GLFW_LIBRARIES} 367 | ${GLAD_LIBRARIES} 368 | ${CITYGML_LIBRARIES} 369 | ${ASSIMP_LIBRARIES} 370 | ${IFCPP_LIBRARIES} 371 | ${PROJ4_LIBRARIES} 372 | ${GDAL_LIBRARY}) 373 | 374 | SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES 375 | RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME}) 376 | 377 | INSTALL( 378 | TARGETS ${PROJECT_NAME} 379 | RUNTIME DESTINATION bin 380 | LIBRARY DESTINATION bin 381 | ARCHIVE DESTINATION lib 382 | ) -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x86-Debug", 5 | "generator": "Visual Studio 16 2019", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ "msvc_x86" ], 8 | "buildRoot": "${projectDir}\\build\\${name}", 9 | "installRoot": "${projectDir}\\install\\${name}", 10 | "cmakeCommandArgs": "", 11 | "buildCommandArgs": "", 12 | "ctestCommandArgs": "", 13 | "variables": [], 14 | "cmakeToolchain": "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" 15 | }, 16 | { 17 | "name": "x86-Release", 18 | "generator": "Visual Studio 16 2019", 19 | "configurationType": "RelWithDebInfo", 20 | "inheritEnvironments": [ "msvc_x86" ], 21 | "buildRoot": "${projectDir}\\build\\${name}", 22 | "installRoot": "${projectDir}\\install\\${name}", 23 | "cmakeCommandArgs": "", 24 | "buildCommandArgs": "", 25 | "ctestCommandArgs": "", 26 | "variables": [], 27 | "cmakeToolchain": "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" 28 | }, 29 | { 30 | "name": "x64-Debug", 31 | "generator": "Visual Studio 16 2019 Win64", 32 | "configurationType": "Debug", 33 | "inheritEnvironments": [ "msvc_x64_x64" ], 34 | "buildRoot": "${projectDir}\\build\\${name}", 35 | "installRoot": "${projectDir}\\install\\${name}", 36 | "cmakeCommandArgs": "", 37 | "buildCommandArgs": "", 38 | "ctestCommandArgs": "", 39 | "variables": [], 40 | "cmakeToolchain": "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" 41 | }, 42 | { 43 | "name": "x64-Release", 44 | "generator": "Visual Studio 16 2019 Win64", 45 | "configurationType": "RelWithDebInfo", 46 | "inheritEnvironments": [ "msvc_x64_x64" ], 47 | "buildRoot": "${projectDir}\\build\\${name}", 48 | "installRoot": "${projectDir}\\install\\${name}", 49 | "cmakeCommandArgs": "", 50 | "buildCommandArgs": "", 51 | "ctestCommandArgs": "", 52 | "variables": [], 53 | "cmakeToolchain": "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" 54 | } 55 | ] 56 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [F4DConverter] (https://github.com/Gaia3D/NewF4DConverter) 2 | 3 | ## Summary 4 | This application, F4DConverter, is for converting popular 3D model formats into F4D format which is devised for Mago3D - 3D web geo-platform. (www.mago3d.com). This project is of Multiplatform(UNIX, MAC OSX, Windows) C++ project. 5 | 6 | ## Getting Started 7 | Start by cloning this repository, making sure to pass the `--recursive` flag to grab all the dependencies. 8 | If you forgot, then you can `git submodule update --init` instead. 9 | 10 | ```bash 11 | git clone --recursive https://seoul.gaia3d.com:53000/mago3d/NewF4DConverter.git 12 | cd F4DConverter 13 | cd build 14 | ``` 15 | 16 | Now generate a project file or makefile for your platform. 17 | 18 | ```bash 19 | # UNIX Makefile 20 | cmake .. 21 | 22 | # Mac OSX 23 | cmake -G "Xcode" .. 24 | 25 | # Microsoft Windows 26 | cmake -G "Visual Studio 15 2017" .. 27 | cmake -G "Visual Studio 15 2017 Win64" .. 28 | ... 29 | ``` 30 | 31 | ## supported input formats ## 32 | - .ifc 33 | - .3ds 34 | - .obj 35 | - .dae 36 | - .gml / .xml / .citygml 37 | 38 | > Beside above formats, other formats which are supported by Assimp may be supported.(NOT TESTED!!) 39 | > 40 | > In this version, .JT(Jupiter Tessellation, a kind of cad design format) is not included. 41 | > 42 | > As you know, the file extension .gml and .xml are not only used in citygml. So we are considering if we have to limit the file extension for citygml. 43 | 44 | ## Dependencies 45 | 46 | Functionality | Version | Library 47 | ----------------------- | ------- | ------------------------------------------ 48 | Utility | 1.71.0 | [boost](https://github.com/boostorg/boost) 49 | Mesh Loading | 4.1.0 | [assimp](https://github.com/assimp/assimp) 50 | OpenGL Function Loader | 0.1.11 | [glad](https://github.com/Dav1dde/glad) 51 | Windowing and Input | 3.2.1 | [glfw](https://github.com/glfw/glfw) 52 | OpenGL Mathematics | 0.9.9.3 | [glm](https://github.com/g-truc/glm) 53 | Texture Loading | - | [stb](https://github.com/nothings/stb) 54 | IFC Loading | - | [ifcplusplus](https://github.com/ifcquery/ifcplusplus) 55 | Json Loading | 0.10.7 | [jsoncpp](https://github.com/open-source-parsers/jsoncpp) 56 | Projections | 4.9.3 | [proj.4](https://github.com/OSGeo/proj.4) 57 | XML Parserxerces-c | 3.2.2-11 | [xerces-c](https://github.com/apache/xerces-c) 58 | CityGML Loading | 2.0.9 | [libcitygml](https://github.com/jklimke/libcitygml) 59 | GDAL | 2.4.1-9 | [gdal](https://github.com/OSGeo/gdal) 60 | GeoTIFF Loading | 1.4.2-10 | [libgeotiff](https://github.com/OSGeo/libgeotiff) 61 | LAS LiDAR Loading | 1.8.1-3 | [liblas](https://github.com/libLAS/libLAS) 62 | 63 | 64 | ## License 65 | Copyright (c) 2012-2019, http://www.gaia3d.com 66 | All rights reserved. 67 | 68 | mago3D F4DConverter Commercial License for ISVs and VARs: 69 | Gaia3D provides its mago3D F4DConverter under a dual license model designed 70 | to meet the development and distribution needs of both commercial distributors 71 | (such as ISVs and VARs) and open source projects. 72 | 73 | For ISVs, VARs and Other Distributors of Commercial Applications: 74 | ISVs (Independent Software Vendors), VARs (Value Added Resellers) and 75 | other distributors that combine and distribute commercially licensed software with 76 | mago3D F4DConverter software and do not wish to distribute the source code 77 | or the commercially licensed software under version 3 of the GNU AFFERO GENERAL PUBLIC LICENSE 78 | (the "AGPL" https://www.gnu.org/licenses/agpl-3.0.en.html ) must enter into 79 | a commercial license agreement with Gaia3D. 80 | 81 | For Open Source Projects and Other Developers of Open Source Applications: 82 | For developers of Free Open Source Software ("FOSS") applications under the GPL or AGPL 83 | that want to combine and distribute those FOSS applications with mago3D F4DConverter software, 84 | Gaia3D's open source software licensed under the AGPL is the best option. 85 | -------------------------------------------------------------------------------- /cmake/FindAssimp.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # ASSIMP_INCLUDE_DIRS - include directories for Assimp 3 | # ASSIMP_LIBRARIES - libraries to link against Assimp 4 | # ASSIMP_FOUND - true if Assimp has been found and can be used 5 | #-------------------------------------------------------------------- 6 | 7 | IF(CMAKE_SIZEOF_VOID_P EQUAL 8) 8 | SET(ASSIMP_ARCHITECTURE "64") 9 | ELSEIF(CMAKE_SIZEOF_VOID_P EQUAL 4) 10 | SET(ASSIMP_ARCHITECTURE "32") 11 | ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8) 12 | 13 | IF(WIN32) 14 | SET(ASSIMP_ROOT_DIR CACHE PATH "ASSIMP root directory") 15 | 16 | # Find include files 17 | FIND_PATH(ASSIMP_INCLUDE_DIR 18 | NAMES 19 | assimp/scene.h 20 | HINTS 21 | $ENV{PROGRAMFILES}/include 22 | ${ASSIMP_ROOT_DIR}/include 23 | DOC "The directory where assimp/scene.h resides" 24 | ) 25 | 26 | # Find library files 27 | FIND_LIBRARY(ASSIMP_LIBRARY 28 | NAMES 29 | assimp 30 | PATHS 31 | $ENV{PROGRAMFILES}/lib 32 | ${ASSIMP_ROOT_DIR}/lib 33 | ) 34 | 35 | # IF(MSVC12) 36 | # SET(ASSIMP_MSVC_VERSION "vc120") 37 | # ELSEIF(MSVC14) 38 | # SET(ASSIMP_MSVC_VERSION "vc140") 39 | # ENDIF(MSVC12) 40 | 41 | # IF(MSVC12 OR MSVC14) 42 | # FIND_PATH(ASSIMP_LIBRARY_DIR 43 | # NAMES 44 | # assimp-${ASSIMP_MSVC_VERSION}-mt.lib 45 | # HINTS 46 | # ${ASSIMP_ROOT_DIR}/lib${ASSIMP_ARCHITECTURE} 47 | # ) 48 | 49 | # FIND_LIBRARY(ASSIMP_LIBRARY_RELEASE 50 | # NAMES 51 | # assimp-${ASSIMP_MSVC_VERSION}-mt.lib 52 | # PATHS 53 | # ${ASSIMP_LIBRARY_DIR} 54 | # ) 55 | # FIND_LIBRARY(ASSIMP_LIBRARY_DEBUG 56 | # NAMES 57 | # assimp-${ASSIMP_MSVC_VERSION}-mtd.lib 58 | # PATHS 59 | # ${ASSIMP_LIBRARY_DIR} 60 | # ) 61 | 62 | # SET(ASSIMP_LIBRARY 63 | # optimized ${ASSIMP_LIBRARY_RELEASE} 64 | # debug ${ASSIMP_LIBRARY_DEBUG} 65 | # ) 66 | 67 | # SET(ASSIMP_LIBRARIES "ASSIMP_LIBRARY_RELEASE" "ASSIMP_LIBRARY_DEBUG") 68 | 69 | # FUNCTION(ASSIMP_COPY_BINARIES TargetDirectory) 70 | # ADD_CUSTOM_TARGET(AssimpCopyBinaries 71 | # COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll ${TargetDirectory}/Debug/assimp-${ASSIMP_MSVC_VERSION}-mtd.dll 72 | # COMMAND ${CMAKE_COMMAND} -E copy ${ASSIMP_ROOT_DIR}/bin${ASSIMP_ARCHITECTURE}/assimp-${ASSIMP_MSVC_VERSION}-mt.dll ${TargetDirectory}/Release/assimp-${ASSIMP_MSVC_VERSION}-mt.dll 73 | # COMMENT "Copying Assimp binaries to '${TargetDirectory}'" 74 | # VERBATIM) 75 | # ENDFUNCTION(ASSIMP_COPY_BINARIES) 76 | # ENDIF() 77 | ELSE() 78 | # Find include files 79 | FIND_PATH(ASSIMP_INCLUDE_DIR 80 | NAMES 81 | assimp/scene.h 82 | PATHS 83 | /usr/include 84 | /usr/local/include 85 | /sw/include 86 | /opt/local/include 87 | DOC "The directory where assimp/scene.h resides" 88 | ) 89 | 90 | # Find library files 91 | FIND_LIBRARY(ASSIMP_LIBRARY 92 | NAMES 93 | assimp 94 | PATHS 95 | /usr/lib64 96 | /usr/lib 97 | /usr/local/lib64 98 | /usr/local/lib 99 | /sw/lib 100 | /opt/local/lib 101 | ${ASSIMP_ROOT_DIR}/lib 102 | DOC "The Assimp library" 103 | ) 104 | ENDIF() 105 | 106 | INCLUDE(FindPackageHandleStandardArgs) 107 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Assimp 108 | FOUND_VAR 109 | ASSIMP_FOUND 110 | REQUIRED_VARS 111 | ASSIMP_INCLUDE_DIR 112 | ASSIMP_LIBRARY 113 | ) 114 | 115 | IF(ASSIMP_FOUND) 116 | SET(ASSIMP_INCLUDE_DIRS "${ASSIMP_INCLUDE_DIR}") 117 | SET(ASSIMP_LIBRARIES "${ASSIMP_LIBRARY}") 118 | 119 | MESSAGE(STATUS "ASSIMP_INCLUDE_DIRS = ${ASSIMP_INCLUDE_DIRS}") 120 | MESSAGE(STATUS "ASSIMP_LIBRARIES = ${ASSIMP_LIBRARIES}") 121 | ENDIF() 122 | 123 | MARK_AS_ADVANCED(ASSIMP_INCLUDE_DIRS ASSIMP_LIBRARIES) -------------------------------------------------------------------------------- /cmake/FindCityGML.cmake: -------------------------------------------------------------------------------- 1 | # Locate libcitygml 2 | # This module defines 3 | # CITYGML_LIBRARY 4 | # CITYGML_LIBRARY_DEBUG 5 | # CITYGML_LIBRARIES, choses the correct debug or optimized library for linking, add this as Target Link library in your project 6 | # CITYGML_FOUND, if false, do not try to link to CITYGML 7 | # CITYGML_INCLUDE_DIR, where to find the headers 8 | # 9 | # $CITYGML_DIR is an environment variable that would 10 | # correspond to the ./configure --prefix=$CITYGML_DIR 11 | 12 | OPTION(CITYGML_DYNAMIC "Set to ON if libcitygml was built using dynamic linking. Use OFF for static." OFF) 13 | 14 | OPTION(CITYGML_USE_XERCESC "Set to ON to build libcitygml with Xerces-c library." ON) 15 | OPTION(CITYGML_USE_LIBXML2 "Set to ON to build libcitygml with LibXml2 library." OFF) 16 | 17 | IF( CITYGML_DYNAMIC ) 18 | ADD_DEFINITIONS( -DLIBCITYGML_DYNAMIC ) 19 | ENDIF( CITYGML_DYNAMIC ) 20 | 21 | IF ( CITYGML_USE_XERCESC AND CITYGML_USE_LIBXML2 ) 22 | MESSAGE("Error: You cannot build the library with Xerces-c AND LibXml2! Xerces library will be used by default.") 23 | SET( CITYGML_USE_LIBXML2 OFF CACHE BOOL "Set to ON to build libcitygml with LibXml2 library." FORCE) 24 | ENDIF( CITYGML_USE_XERCESC AND CITYGML_USE_LIBXML2 ) 25 | 26 | IF( CITYGML_USE_XERCESC ) 27 | FIND_PACKAGE( Xerces REQUIRED ) 28 | ADD_DEFINITIONS( -DUSE_XERCESC ) 29 | SET( LIBXML2_INCLUDE_DIR "" ) 30 | # SET( LIBXML2_LIBRARIES "" ) 31 | SET( LIBXML2_LIBRARY "" ) 32 | SET( LIBXML2_LIBRARY_DEBUG "" ) 33 | ENDIF( CITYGML_USE_XERCESC ) 34 | 35 | IF( CITYGML_USE_LIBXML2 ) 36 | FIND_PACKAGE( LibXml2 REQUIRED ) 37 | ADD_DEFINITIONS( -DUSE_LIBXML2 ) 38 | ADD_DEFINITIONS( ${LIBXML2_DEFINITIONS} ) 39 | SET( XERCESC_INCLUDE "" ) 40 | SET( XERCESC_LIBRARY "" ) 41 | SET( XERCESC_LIBRARY_DEBUG "" ) 42 | ENDIF( CITYGML_USE_LIBXML2 ) 43 | 44 | FIND_PATH( CITYGML_INCLUDE_DIR citygml/citygml.h 45 | ./include 46 | ../include 47 | $ENV{CITYGML_DIR}/include 48 | ~/Library/Frameworks 49 | /Library/Frameworks 50 | /usr/local/include 51 | /usr/include 52 | /sw/include # Fink 53 | /opt/local/include # DarwinPorts 54 | /opt/csw/include # Blastwave 55 | /opt/include 56 | /usr/freeware/include 57 | ) 58 | 59 | FIND_LIBRARY( CITYGML_LIBRARY 60 | NAMES citygml 61 | PATHS 62 | ./lib 63 | ../lib 64 | $ENV{CITYGML_DIR}/lib 65 | $ENV{CITYGML_DIR} 66 | ~/Library/Frameworks 67 | /Library/Frameworks 68 | /usr/local/lib 69 | /usr/lib 70 | /sw/lib 71 | /opt/local/lib 72 | /opt/csw/lib 73 | /opt/lib 74 | /usr/freeware/lib64 75 | ) 76 | 77 | FIND_LIBRARY( CITYGML_LIBRARY_DEBUG 78 | NAMES citygmld 79 | PATHS 80 | ./lib 81 | ../lib 82 | $ENV{CITYGML_DIR}/lib 83 | $ENV{CITYGML_DIR} 84 | ~/Library/Frameworks 85 | /Library/Frameworks 86 | /usr/local/lib 87 | /usr/lib 88 | /sw/lib 89 | /opt/local/lib 90 | /opt/csw/lib 91 | /opt/lib 92 | /usr/freeware/lib64 93 | ) 94 | 95 | SET( CITYGML_FOUND FALSE ) 96 | 97 | IF(CITYGML_LIBRARY AND CITYGML_INCLUDE_DIR) 98 | SET(CITYGML_FOUND TRUE) 99 | IF(NOT CITYGML_LIBRARY_DEBUG) 100 | MESSAGE("-- Warning Debug LibCityGML not found, using: ${CITYGML_LIBRARY}") 101 | SET(CITYGML_LIBRARY_DEBUG "${CITYGML_LIBRARY}" CACHE FILEPATH "Path to a library." FORCE) 102 | ENDIF(NOT CITYGML_LIBRARY_DEBUG) 103 | ENDIF(CITYGML_LIBRARY AND CITYGML_INCLUDE_DIR) 104 | 105 | SET(CITYGML_LIBRARIES optimized ${CITYGML_LIBRARY} debug ${CITYGML_LIBRARY_DEBUG}) 106 | 107 | -------------------------------------------------------------------------------- /cmake/FindGDAL.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # GDAL_FOUND = if the library found 3 | # GDAL_LIBRARY = full path to the library 4 | # GDAL_INCLUDE_DIR = where to find the library headers 5 | #-------------------------------------------------------------------- 6 | 7 | MACRO(COMPARE_VERSION_STRINGS a_in b_in result_out) 8 | # Since SEPARATE_ARGUMENTS using ' ' as the separation token, 9 | # replace '.' with ' ' to allow easy tokenization of the string. 10 | STRING(REPLACE "." " " a ${a_in}) 11 | STRING(REPLACE "." " " b ${b_in}) 12 | SEPARATE_ARGUMENTS(a) 13 | SEPARATE_ARGUMENTS(b) 14 | 15 | # Check the size of each list to see if they are equal. 16 | LIST(LENGTH a a_length) 17 | LIST(LENGTH b b_length) 18 | 19 | # Pad the shorter list with zeros. 20 | 21 | # Note that range needs to be one less than the length as the for 22 | # loop is inclusive (silly CMake). 23 | IF(a_length LESS b_length) 24 | # a is shorter 25 | SET(shorter a) 26 | MATH(EXPR range "${b_length} - 1") 27 | MATH(EXPR pad_range "${b_length} - ${a_length} - 1") 28 | ELSE(a_length LESS b_length) 29 | # b is shorter 30 | SET(shorter b) 31 | MATH(EXPR range "${a_length} - 1") 32 | MATH(EXPR pad_range "${a_length} - ${b_length} - 1") 33 | ENDIF(a_length LESS b_length) 34 | 35 | # PAD out if we need to 36 | IF(NOT pad_range LESS 0) 37 | FOREACH(pad RANGE ${pad_range}) 38 | # Since shorter is an alias for b, we need to get to it by by dereferencing shorter. 39 | LIST(APPEND ${shorter} 0) 40 | ENDFOREACH(pad RANGE ${pad_range}) 41 | ENDIF(NOT pad_range LESS 0) 42 | 43 | SET(result 0) 44 | FOREACH(index RANGE ${range}) 45 | IF(result EQUAL 0) 46 | # Only continue to compare things as long as they are equal 47 | LIST(GET a ${index} a_version) 48 | LIST(GET b ${index} b_version) 49 | # LESS 50 | IF(a_version LESS b_version) 51 | SET(result -1) 52 | ENDIF(a_version LESS b_version) 53 | # GREATER 54 | IF(a_version GREATER b_version) 55 | SET(result 1) 56 | ENDIF(a_version GREATER b_version) 57 | ENDIF(result EQUAL 0) 58 | ENDFOREACH(index) 59 | 60 | # Copy out the return result 61 | SET(${result_out} ${result}) 62 | ENDMACRO(COMPARE_VERSION_STRINGS) 63 | 64 | set (GDAL_VERSION_COUNT 3) 65 | 66 | SET(GDAL_NAMES gdal) 67 | 68 | IF(WIN32) 69 | 70 | SET(OSGEO4W_IMPORT_LIBRARY gdal_i) 71 | IF(DEFINED ENV{OSGEO4W_ROOT}) 72 | SET(OSGEO4W_ROOT_DIR $ENV{OSGEO4W_ROOT}) 73 | #MESSAGE(STATUS " FindGDAL: trying OSGeo4W using environment variable OSGEO4W_ROOT=$ENV{OSGEO4W_ROOT}") 74 | ELSE() 75 | SET(OSGEO4W_ROOT_DIR c:/OSGeo4W) 76 | #MESSAGE(STATUS " FindGDAL: trying OSGeo4W using default location OSGEO4W_ROOT=${OSGEO4W_ROOT_DIR}") 77 | ENDIF() 78 | 79 | IF(MINGW) 80 | FIND_PATH(GDAL_INCLUDE_DIR 81 | gdal.h 82 | PATH_PREFIXES gdal gdal-1.6 83 | PATHS 84 | /usr/local/include 85 | /usr/include 86 | c:/msys/local/include 87 | ${OSGEO4W_ROOT_DIR}/include) 88 | 89 | FIND_LIBRARY(GDAL_LIBRARY 90 | NAMES ${GDAL_NAMES} 91 | PATH_PREFIXES gdal gdal-1.6 92 | PATHS 93 | /usr/local/lib 94 | /usr/lib 95 | c:/msys/local/lib 96 | ${OSGEO4W_ROOT_DIR}/lib) 97 | ENDIF(MINGW) 98 | 99 | IF(MSVC) 100 | 101 | FIND_PATH(GDAL_INCLUDE_DIR 102 | NAMES gdal.h 103 | PATH_PREFIXES gdal gdal-1.6 104 | PATHS 105 | "${OSGEO4W_ROOT_DIR}/apps/gdal-dev/include" 106 | "$ENV{LIB_DIR}/include/gdal" 107 | ${OSGEO4W_ROOT_DIR}/include) 108 | 109 | SET(GDAL_NAMES ${OSGEO4W_IMPORT_LIBRARY} ${GDAL_NAMES}) 110 | FIND_LIBRARY(GDAL_LIBRARY 111 | NAMES ${GDAL_NAMES} 112 | PATH_PREFIXES gdal gdal-1.6 113 | PATHS 114 | "$ENV{LIB_DIR}/lib" 115 | /usr/lib 116 | c:/msys/local/lib 117 | "${OSGEO4W_ROOT_DIR}/apps/gdal-dev/lib" 118 | ${OSGEO4W_ROOT_DIR}/lib) 119 | 120 | IF(GDAL_LIBRARY) 121 | SET(GDAL_LIBRARY;odbc32;odbccp32 CACHE STRING INTERNAL) 122 | ENDIF() 123 | ENDIF(MSVC) 124 | 125 | ELSEIF(UNIX) 126 | 127 | # Try to use framework on Mac OS X 128 | IF(APPLE) 129 | SET(GDAL_MAC_PATH /Library/Frameworks/GDAL.framework/unix/bin) 130 | ENDIF() 131 | 132 | # Try to use GDAL_HOME location if specified 133 | IF(DEFINED ENV{GDAL_HOME}) 134 | SET(GDAL_CONFIG_PREFER_PATH 135 | "$ENV{GDAL_HOME}/bin" CACHE STRING "Search for gdal-config program in preferred location") 136 | ENDIF() 137 | 138 | # Try to use OSGeo4W installation 139 | IF(DEFINED ENV{OSGEO4W_HOME}) 140 | SET(GDAL_CONFIG_PREFER_OSGEO4W_PATH 141 | "$ENV{OSGEO4W_HOME}/bin" CACHE STRING "Search for gdal-config program provided by OSGeo4W") 142 | ENDIF() 143 | 144 | # Try to use FWTools installation 145 | IF(DEFINED ENV{FWTOOLS_HOME}) 146 | SET(GDAL_CONFIG_PREFER_FWTOOLS_PATH 147 | "$ENV{FWTOOLS_HOME}/bin_safe" CACHE STRING "Search for gdal-config program provided by FWTools") 148 | ENDIF() 149 | 150 | FIND_PROGRAM(GDAL_CONFIG gdal-config 151 | HINTS 152 | ${GDAL_CONFIG_PREFER_PATH} 153 | ${GDAL_CONFIG_PREFER_OSGEO4W_PATH} 154 | ${GDAL_CONFIG_PREFER_FWTOOLS_PATH} 155 | ${GDAL_MAC_PATH} 156 | /usr/local/bin/ 157 | /usr/bin/) 158 | 159 | IF(GDAL_CONFIG) 160 | 161 | # TODO: Replace the regex hacks with CMake version comparison feature: 162 | # if(version1 VERSION_LESS version2) 163 | 164 | # Extract GDAL version 165 | EXEC_PROGRAM(${GDAL_CONFIG} ARGS --version OUTPUT_VARIABLE GDAL_VERSION_STATED) 166 | SET(GDAL_VERSION_STRING "${GDAL_VERSION_STATED}" CACHE STRING "Version of GDAL package found") 167 | 168 | STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" GDAL_VERSION_MAJOR "${GDAL_VERSION_STATED}") 169 | STRING(REGEX REPLACE "([0-9]+)\\.(/^\\d{1,2}$/)\\.([0-9]+)" "\\2" GDAL_VERSION_MINOR "${GDAL_VERSION_STATED}") 170 | STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\3" GDAL_VERSION_PATCH "${GDAL_VERSION_STATED}") 171 | 172 | # Check for GDAL version 173 | if (GDAL_FIND_VERSION) 174 | COMPARE_VERSION_STRINGS( "${GDAL_VERSION_STATED}" "${GDAL_FIND_VERSION}" version_result) 175 | IF (version_result LESS 0) 176 | MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION_STATED}). Use ${GDAL_FIND_VERSION} or higher requested.") 177 | ENDIF() 178 | set (GDAL_VERSION_STRING ${GDAL_VERSION_STATED}) 179 | set (GDAL_VERSION_COMPATIBLE true) 180 | endif() 181 | 182 | set (GDAL_FOUND TRUE) 183 | # Set INCLUDE_DIR to prefix+include 184 | EXEC_PROGRAM(${GDAL_CONFIG} ARGS --prefix OUTPUT_VARIABLE GDAL_PREFIX) 185 | 186 | FIND_PATH(GDAL_INCLUDE_DIR 187 | gdal.h 188 | PATH_PREFIXES gdal 189 | HINTS 190 | ${GDAL_PREFIX}/include/gdal 191 | ${GDAL_PREFIX}/include 192 | /usr/local/include 193 | /usr/include) 194 | 195 | # Extract link dirs for rpath 196 | EXEC_PROGRAM(${GDAL_CONFIG} ARGS --libs OUTPUT_VARIABLE GDAL_CONFIG_LIBS) 197 | 198 | # Split off the link dirs (for rpath) 199 | # Use regular expression to match wildcard equivalent "-L*" 200 | # with is a space or a semicolon 201 | STRING(REGEX MATCHALL "[-][L]([^ ;])+" GDAL_LINK_DIRECTORIES_WITH_PREFIX "${GDAL_CONFIG_LIBS}") 202 | #MESSAGE("DBG GDAL_LINK_DIRECTORIES_WITH_PREFIX=${GDAL_LINK_DIRECTORIES_WITH_PREFIX}") 203 | 204 | # Remove prefix -L because we need the pure directory for LINK_DIRECTORIES 205 | IF(GDAL_LINK_DIRECTORIES_WITH_PREFIX) 206 | STRING(REGEX REPLACE "[-][L]" "" GDAL_LINK_DIRECTORIES "${GDAL_LINK_DIRECTORIES_WITH_PREFIX}" ) 207 | #MESSAGE("DBG GDAL_LINK_DIRECTORIES ${GDAL_LINK_DIRECTORIES}") 208 | ENDIF() 209 | 210 | # Split off the name 211 | # use regular expression to match wildcard equivalent "-l*" 212 | # with is a space or a semicolon 213 | STRING(REGEX MATCHALL "[-][l]([^ ;])+" GDAL_LIB_NAME_WITH_PREFIX "${GDAL_CONFIG_LIBS}") 214 | 215 | # Remove prefix -l because we need the pure name 216 | IF(GDAL_LIB_NAME_WITH_PREFIX) 217 | STRING(REGEX REPLACE "[-][l]" "" GDAL_LIB_NAME ${GDAL_LIB_NAME_WITH_PREFIX}) 218 | ENDIF() 219 | 220 | IF(APPLE) 221 | SET(GDAL_LIBRARY ${GDAL_LINK_DIRECTORIES}/lib${GDAL_LIB_NAME}.dylib CACHE STRING INTERNAL) 222 | ELSE() 223 | SET(GDAL_LIBRARY ${GDAL_LINK_DIRECTORIES}/lib${GDAL_LIB_NAME}.so CACHE STRING INTERNAL) 224 | ENDIF() 225 | 226 | ELSE() 227 | MESSAGE("FindGDAL.cmake: gdal-config not found. Please set it manually: GDAL_CONFIG=${GDAL_CONFIG}") 228 | ENDIF(GDAL_CONFIG) 229 | 230 | ELSE() 231 | MESSAGE("FindGDAL.cmake: unrecognized or unsupported operating system (use Unix or Windows)") 232 | ENDIF() 233 | 234 | # Handle the QUIETLY and REQUIRED arguments and set GDAL_FOUND to TRUE 235 | # if all listed variables are TRUE 236 | INCLUDE(FindPackageHandleStandardArgs) 237 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR) 238 | -------------------------------------------------------------------------------- /cmake/FindGLFW.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # GLFW_INCLUDE_DIRS - include directories for GLFW 3 | # GLFW_LIBRARIES - libraries to link against GLFW 4 | # GLFW_FOUND - true if GLFW has been found and can be used 5 | #-------------------------------------------------------------------- 6 | 7 | FIND_PATH(GLFW_INCLUDE_DIR GLFW/glfw3.h) 8 | FIND_LIBRARY(GLFW_LIBRARY glfw glfw3) 9 | 10 | INCLUDE(FindPackageHandleStandardArgs) 11 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW 12 | FOUND_VAR 13 | GLFW_FOUND 14 | REQUIRED_VARS 15 | GLFW_INCLUDE_DIR 16 | GLFW_LIBRARY 17 | ) 18 | 19 | IF(GLFW_FOUND) 20 | SET(GLFW_INCLUDE_DIRS "${GLFW_INCLUDE_DIR}") 21 | SET(GLFW_LIBRARIES "${GLFW_LIBRARY}") 22 | 23 | MESSAGE(STATUS "GLFW_INCLUDE_DIRS = ${GLFW_INCLUDE_DIRS}") 24 | MESSAGE(STATUS "GLFW_LIBRARIES = ${GLFW_LIBRARIES}") 25 | ENDIF() 26 | 27 | MARK_AS_ADVANCED(GLFW_INCLUDE_DIRS GLFW_LIBRARIES) 28 | -------------------------------------------------------------------------------- /cmake/FindGLM.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # GLM_INCLUDE_DIRS - include directories for GLM 3 | # GLM_FOUND - true if GLM has been found and can be used 4 | #-------------------------------------------------------------------- 5 | 6 | FIND_PATH(GLM_INCLUDE_DIR glm/glm.hpp) 7 | 8 | INCLUDE(FindPackageHandleStandardArgs) 9 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM 10 | FOUND_VAR 11 | GLM_FOUND 12 | REQUIRED_VARS 13 | GLM_INCLUDE_DIR 14 | ) 15 | 16 | IF(GLM_FOUND) 17 | SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") 18 | 19 | MESSAGE(STATUS "GLM_INCLUDE_DIRS = ${GLM_INCLUDE_DIRS}") 20 | ENDIF() 21 | 22 | mark_as_advanced(GLM_INCLUDE_DIRS) -------------------------------------------------------------------------------- /cmake/FindGeoTIFF.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # GEOTIFF_FOUND = if the library found 3 | # GEOTIFF_LIBRARIES = full path to the library 4 | # GEOTIFF_INCLUDE_DIR = where to find the library headers also defined, 5 | # but not for general use are 6 | # GEOTIFF_LIBRARY = where to find the library. 7 | # GEOTIFF_VERSION = version of library which was found, e.g. "1.2.5" 8 | #-------------------------------------------------------------------- 9 | 10 | MESSAGE(STATUS "Searching for GeoTIFF ${GeoTIFF_FIND_VERSION}+ library") 11 | 12 | IF(GEOTIFF_INCLUDE_DIR) 13 | # Already in cache, be silent 14 | SET(GEOTIFF_FIND_QUIETLY TRUE) 15 | ENDIF() 16 | 17 | IF(WIN32) 18 | SET(OSGEO4W_IMPORT_LIBRARY geotiff_i) 19 | IF(DEFINED ENV{OSGEO4W_ROOT}) 20 | SET(OSGEO4W_ROOT_DIR $ENV{OSGEO4W_ROOT}) 21 | #MESSAGE(STATUS " FindGeoTIFF: trying OSGeo4W using environment variable OSGEO4W_ROOT=$ENV{OSGEO4W_ROOT}") 22 | ELSE() 23 | SET(OSGEO4W_ROOT_DIR c:/OSGeo4W) 24 | #MESSAGE(STATUS " FindGeoTIFF: trying OSGeo4W using default location OSGEO4W_ROOT=${OSGEO4W_ROOT_DIR}") 25 | ENDIF() 26 | ENDIF() 27 | 28 | FIND_PATH(GEOTIFF_INCLUDE_DIR 29 | geotiff.h 30 | PATH_SUFFIXES geotiff libgeotiff 31 | PATHS 32 | ${OSGEO4W_ROOT_DIR}/include) 33 | 34 | SET(GEOTIFF_NAMES ${OSGEO4W_IMPORT_LIBRARY} geotiff) 35 | 36 | FIND_LIBRARY(GEOTIFF_LIBRARY 37 | NAMES ${GEOTIFF_NAMES} 38 | PATHS 39 | ${OSGEO4W_ROOT_DIR}/lib) 40 | 41 | IF(GEOTIFF_FOUND) 42 | SET(GEOTIFF_LIBRARIES ${GEOTIFF_LIBRARY}) 43 | ENDIF() 44 | 45 | IF(GEOTIFF_INCLUDE_DIR) 46 | SET(GEOTIFF_VERSION 0) 47 | 48 | SET(GEOTIFF_VERSION_H "${GEOTIFF_INCLUDE_DIR}/geotiff.h") 49 | FILE(READ ${GEOTIFF_VERSION_H} GEOTIFF_VERSION_H_CONTENTS) 50 | 51 | IF (DEFINED GEOTIFF_VERSION_H_CONTENTS) 52 | STRING(REGEX REPLACE ".*#define[ \t]LIBGEOTIFF_VERSION[ \t]+([0-9]+).*" "\\1" GEOTIFF_VERSION_NUM "${GEOTIFF_VERSION_H_CONTENTS}") 53 | 54 | IF(NOT ${GEOTIFF_VERSION_NULL} MATCHES "[0-9]+") 55 | MESSAGE(FATAL_ERROR "GeoTIFF version parsing failed!") 56 | ENDIF() 57 | 58 | IF(GEOTIFF_VERSION_NUM AND NOT "${GEOTIFF_VERSION_NUM}" STREQUAL "0") 59 | MATH(EXPR GTIFF_VERSION_MAJOR "${GEOTIFF_VERSION_NUM} / 1000") 60 | MATH(EXPR GTIFF_VERSION_MINOR "${GEOTIFF_VERSION_NUM} % 1000 / 100") 61 | MATH(EXPR GTIFF_VERSION_PATCH "${GEOTIFF_VERSION_NUM} % 100 / 10") 62 | ENDIF() 63 | 64 | SET(GEOTIFF_VERSION "${GTIFF_VERSION_MAJOR}.${GTIFF_VERSION_MINOR}.${GTIFF_VERSION_PATCH}" 65 | CACHE INTERNAL "The version string for GeoTIFF library") 66 | 67 | IF (GEOTIFF_VERSION VERSION_EQUAL GeoTIFF_FIND_VERSION OR 68 | GEOTIFF_VERSION VERSION_GREATER GeoTIFF_FIND_VERSION) 69 | MESSAGE(STATUS "Found GeoTIFF version: ${GEOTIFF_VERSION}") 70 | ELSE() 71 | MESSAGE(FATAL_ERROR "GeoTIFF version check failed. Version ${GEOTIFF_VERSION} was found, at least version ${GeoTIFF_FIND_VERSION} is required") 72 | ENDIF() 73 | ELSE() 74 | MESSAGE(FATAL_ERROR "Failed to open ${GEOTIFF_VERSION_H} file") 75 | ENDIF() 76 | 77 | ENDIF() 78 | 79 | # Handle the QUIETLY and REQUIRED arguments and set GEOTIFF_FOUND to TRUE 80 | # if all listed variables are TRUE 81 | INCLUDE(FindPackageHandleStandardArgs) 82 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GeoTIFF DEFAULT_MSG GEOTIFF_LIBRARY GEOTIFF_INCLUDE_DIR) -------------------------------------------------------------------------------- /cmake/FindJsoncpp.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # JSONCPP_INCLUDE_DIRS - include directories for Jsoncpp 3 | # JSONCPP_LIBRARIES - libraries to link against Jsoncpp 4 | # JSONCPP_FOUND - true if Jsoncpp has been found and can be used 5 | #-------------------------------------------------------------------- 6 | 7 | # Find include files 8 | FIND_PATH(JSONCPP_INCLUDE_DIR 9 | NAMES 10 | json/json.h jsoncpp/json/json.h 11 | HINTS 12 | $ENV{PROGRAMFILES}/include 13 | DOC "The directory where json/json.h resides" 14 | ) 15 | 16 | # Find library files 17 | FIND_LIBRARY(JSONCPP_LIBRARY 18 | NAMES 19 | jsoncpp 20 | PATHS 21 | $ENV{PROGRAMFILES}/lib 22 | ) 23 | 24 | FIND_LIBRARY(JSONCPP_LIBRARY_DEBUG 25 | NAMES 26 | jsoncppd 27 | PATHS 28 | $ENV{PROGRAMFILES}/lib 29 | ) 30 | 31 | INCLUDE(FindPackageHandleStandardArgs) 32 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jsoncpp 33 | FOUND_VAR 34 | JSONCPP_FOUND 35 | REQUIRED_VARS 36 | JSONCPP_INCLUDE_DIR 37 | JSONCPP_LIBRARY 38 | ) 39 | 40 | IF(JSONCPP_FOUND) 41 | SET(JSONCPP_INCLUDE_DIRS "${JSONCPP_INCLUDE_DIR}") 42 | SET(JSONCPP_LIBRARIES "${JSONCPP_LIBRARY}") 43 | 44 | MESSAGE(STATUS "JSONCPP_INCLUDE_DIRS = ${JSONCPP_INCLUDE_DIRS}") 45 | MESSAGE(STATUS "JSONCPP_LIBRARIES = ${JSONCPP_LIBRARIES}") 46 | ENDIF() 47 | 48 | MARK_AS_ADVANCED(JSONCPP_INCLUDE_DIRS JSONCPP_LIBRARIES) 49 | -------------------------------------------------------------------------------- /cmake/FindLibLAS.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # LIBLAS_FOUND = if the library found 3 | # LIBLAS_LIBRARIES = full path to the library 4 | # LIBLAS_INCLUDE_DIR = where to find the library headers also defined, 5 | # but not for general use are 6 | # LIBLAS_LIBRARY = where to find the PROJ.4 library. 7 | # LIBLAS_VERSION = version of library which was found, e.g. "1.2.5" 8 | #-------------------------------------------------------------------- 9 | MESSAGE(STATUS "Searching for LibLAS ${LibLAS_FIND_VERSION}+ library") 10 | 11 | IF(LIBLAS_INCLUDE_DIR) 12 | # Already in cache, be silent 13 | SET(LIBLAS_FIND_QUIETLY TRUE) 14 | ENDIF() 15 | 16 | IF(WIN32) 17 | SET(OSGEO4W_IMPORT_LIBRARY liblas) 18 | IF(DEFINED ENV{OSGEO4W_ROOT}) 19 | SET(OSGEO4W_ROOT_DIR $ENV{OSGEO4W_ROOT}) 20 | MESSAGE(STATUS " FindLibLAS: trying OSGeo4W using environment variable OSGEO4W_ROOT=$ENV{OSGEO4W_ROOT}") 21 | ELSE() 22 | SET(OSGEO4W_ROOT_DIR c:/OSGeo4W) 23 | MESSAGE(STATUS " FindLibLAS: trying OSGeo4W using default location OSGEO4W_ROOT=${OSGEO4W_ROOT_DIR}") 24 | ENDIF() 25 | ENDIF() 26 | 27 | 28 | FIND_PATH(LIBLAS_INCLUDE_DIR 29 | liblas.hpp 30 | PATH_PREFIXES liblas 31 | PATHS 32 | /usr/include 33 | /usr/local/include 34 | /tmp/lasjunk/include 35 | ${OSGEO4W_ROOT_DIR}/include) 36 | 37 | if(WIN32) 38 | SET(LIBLAS_NAMES ${OSGEO4W_IMPORT_LIBRARY} liblas) 39 | else() 40 | SET(LIBLAS_NAMES ${OSGEO4W_IMPORT_LIBRARY} las) 41 | endif() 42 | 43 | FIND_LIBRARY(LIBLAS_LIBRARY 44 | NAMES ${LIBLAS_NAMES} 45 | PATHS 46 | /usr/lib 47 | /usr/local/lib 48 | /tmp/lasjunk/lib 49 | ${OSGEO4W_ROOT_DIR}/lib) 50 | 51 | IF(LIBLAS_FOUND) 52 | SET(LIBLAS_LIBRARIES ${LIBLAS_LIBRARY}) 53 | ENDIF() 54 | 55 | IF(LIBLAS_INCLUDE_DIR) 56 | SET(LIBLAS_VERSION 0) 57 | 58 | SET(LIBLAS_VERSION_H "${LIBLAS_INCLUDE_DIR}/liblas/version.hpp") 59 | FILE(READ ${LIBLAS_VERSION_H} LIBLAS_VERSION_H_CONTENTS) 60 | 61 | IF (DEFINED LIBLAS_VERSION_H_CONTENTS) 62 | 63 | # string will be something like "106000", which is xyyzzz (x=major, y=minor, z=patch) 64 | string(REGEX REPLACE ".*#define[ \t]LIBLAS_VERSION[ \t]+([0-9]).*" "\\1" LIBLAS_VERSION_MAJOR "${LIBLAS_VERSION_H_CONTENTS}") 65 | string(REGEX REPLACE ".*#define[ \t]LIBLAS_VERSION[ \t]+[0-9]([0-9][0-9]).*" "\\1" LIBLAS_VERSION_MINOR "${LIBLAS_VERSION_H_CONTENTS}") 66 | string(REGEX REPLACE ".*#define[ \t]LIBLAS_VERSION[ \t]+[0-9][0-9][0-9]([0-9][0-9][0-9]).*" "\\1" LIBLAS_VERSION_PATCH "${LIBLAS_VERSION_H_CONTENTS}") 67 | #message(FATAL_ERROR "${LIBLAS_VERSION_MAJOR}.${LIBLAS_VERSION_MINOR}.${LIBLAS_VERSION_PATCH}") 68 | 69 | if(NOT ${LIBLAS_VERSION_MAJOR} MATCHES "[0-9]+") 70 | message(FATAL_ERROR "libLAS version parsing failed for LIBLAS_VERSION_MAJOR!") 71 | endif() 72 | if(NOT ${LIBLAS_VERSION_MINOR} MATCHES "[0-9]+") 73 | message(FATAL_ERROR "libLAS version parsing failed for LIBLAS_VERSION_MINOR!") 74 | endif() 75 | if(NOT ${LIBLAS_VERSION_PATCH} MATCHES "[0-9]+") 76 | message(FATAL_ERROR "libLAS version parsing failed for LIBLAS_VERSION_PATCH!") 77 | endif() 78 | 79 | 80 | SET(LIBLAS_VERSION "${LIBLAS_VERSION_MAJOR}.${LIBLAS_VERSION_MINOR}.${LIBLAS_VERSION_PATCH}" 81 | CACHE INTERNAL "The version string for libLAS library") 82 | 83 | IF (LIBLAS_VERSION VERSION_EQUAL LibLAS_FIND_VERSION OR 84 | LIBLAS_VERSION VERSION_GREATER LibLAS_FIND_VERSION) 85 | MESSAGE(STATUS "Found libLAS version: ${LIBLAS_VERSION}") 86 | ELSE() 87 | MESSAGE(FATAL_ERROR "libLAS version check failed. Version ${LIBLAS_VERSION} was found, at least version ${LibLAS_FIND_VERSION} is required") 88 | ENDIF() 89 | ELSE() 90 | MESSAGE(FATAL_ERROR "Failed to open ${LIBLAS_VERSION_H} file") 91 | ENDIF() 92 | 93 | ENDIF() 94 | 95 | # Handle the QUIETLY and REQUIRED arguments and set LIBLAS_FOUND to TRUE 96 | # if all listed variables are TRUE 97 | INCLUDE(FindPackageHandleStandardArgs) 98 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(libLAS DEFAULT_MSG LIBLAS_LIBRARY LIBLAS_INCLUDE_DIR) -------------------------------------------------------------------------------- /cmake/FindProj.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # PROJ4_FOUND = if the library found 3 | # PROJ4_LIBRARY = full path to the library 4 | # PROJ4_INCLUDE_DIR = where to find the library headers also defined, but not for general use are 5 | # PROJ4_LIBRARY, where to find the PROJ.4 library. 6 | #-------------------------------------------------------------------- 7 | 8 | # Try to use OSGeo4W installation 9 | IF(WIN32) 10 | IF(DEFINED ENV{OSGEO4W_ROOT}) 11 | SET(OSGEO4W_ROOT_DIR $ENV{OSGEO4W_ROOT}) 12 | MESSAGE(STATUS " FindProj: trying OSGeo4W using environment variable OSGEO4W_ROOT=$ENV{OSGEO4W_ROOT}") 13 | ELSE() 14 | SET(OSGEO4W_ROOT_DIR c:/OSGeo4W) 15 | MESSAGE(STATUS " FindProj: trying OSGeo4W using default location OSGEO4W_ROOT=${OSGEO4W_ROOT_DIR}") 16 | ENDIF() 17 | ENDIF() 18 | 19 | FIND_PATH(PROJ4_INCLUDE_DIR proj_api.h 20 | PATHS ${OSGEO4W_ROOT_DIR}/include 21 | DOC "Path to PROJ.4 library include directory") 22 | 23 | SET(PROJ4_NAMES ${PROJ4_NAMES} proj proj_i) 24 | FIND_LIBRARY(PROJ4_LIBRARY 25 | NAMES ${PROJ4_NAMES} 26 | PATHS ${OSGEO4W_ROOT_DIR}/lib 27 | DOC "Path to PROJ.4 library file") 28 | 29 | # Handle the QUIETLY and REQUIRED arguments and set SPATIALINDEX_FOUND to TRUE 30 | # if all listed variables are TRUE 31 | INCLUDE(FindPackageHandleStandardArgs) 32 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ4 DEFAULT_MSG PROJ4_LIBRARY PROJ4_INCLUDE_DIR) 33 | 34 | IF(PROJ4_FOUND) 35 | SET(PROJ4_LIBRARIES ${PROJ4_LIBRARY}) 36 | ENDIF() -------------------------------------------------------------------------------- /cmake/FindXerces.cmake: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------- 2 | # XERCESC_FOUND - system has Xerces-C 3 | # XERCESC_INCLUDE - the Xerces-C include directory 4 | # XERCESC_LIBRARY - Link these to use Xerces-C 5 | # XERCESC_VERSION - Xerces-C found version 6 | #-------------------------------------------------------------------- 7 | 8 | IF (XERCESC_INCLUDE AND XERCESC_LIBRARY) 9 | # in cache already 10 | SET(XERCESC_FIND_QUIETLY TRUE) 11 | ENDIF (XERCESC_INCLUDE AND XERCESC_LIBRARY) 12 | 13 | OPTION(XERCESC_STATIC "Set to ON to link your project with static library (instead of DLL)." ON) 14 | 15 | IF (NOT ${XERCESC_WAS_STATIC} STREQUAL ${XERCESC_STATIC}) 16 | UNSET(XERCESC_LIBRARY CACHE) 17 | UNSET(XERCESC_LIBRARY_DEBUG CACHE) 18 | ENDIF (NOT ${XERCESC_WAS_STATIC} STREQUAL ${XERCESC_STATIC}) 19 | 20 | SET(XERCESC_WAS_STATIC ${XERCESC_STATIC} CACHE INTERNAL "" ) 21 | 22 | IF(WIN32) 23 | IF(DEFINED ENV{OSGEO4W_ROOT}) 24 | SET(OSGEO4W_ROOT_DIR $ENV{OSGEO4W_ROOT}) 25 | MESSAGE(STATUS " FindXerces: trying OSGeo4W using environment variable OSGEO4W_ROOT=$ENV{OSGEO4W_ROOT}") 26 | ELSE() 27 | SET(OSGEO4W_ROOT_DIR c:/OSGeo4W) 28 | MESSAGE(STATUS " FindXerces: trying OSGeo4W using default location OSGEO4W_ROOT=${OSGEO4W_ROOT_DIR}") 29 | ENDIF() 30 | ENDIF() 31 | 32 | FIND_PATH(XERCESC_INCLUDE NAMES xercesc/util/XercesVersion.hpp 33 | PATHS 34 | $ENV{XERCESC_INCLUDE_DIR} 35 | ${XERCESC_INCLUDE_DIR} 36 | ${OSGEO4W_ROOT_DIR}/include 37 | /usr/local/include 38 | /usr/include 39 | ) 40 | 41 | IF (XERCESC_STATIC) 42 | FIND_LIBRARY(XERCESC_LIBRARY NAMES xerces-c_static_3 xerces-c-3.2 xerces-c-3.1 xerces-c xerces-c_3 43 | PATHS 44 | $ENV{XERCESC_LIBRARY_DIR} 45 | ${XERCESC_LIBRARY_DIR} 46 | ${OSGEO4W_ROOT_DIR}/lib 47 | /usr/lib 48 | /usr/local/lib 49 | ) 50 | FIND_LIBRARY(XERCESC_LIBRARY_DEBUG NAMES xerces-c_static_3D xerces-c-3.2D xerces-c-3.1D xerces-c_3D xerces-c_3D 51 | PATHS 52 | $ENV{XERCESC_LIBRARY_DIR} 53 | ${XERCESC_LIBRARY_DIR} 54 | ${OSGEO4W_ROOT_DIR}/lib 55 | /usr/lib 56 | /usr/local/lib 57 | ) 58 | ADD_DEFINITIONS( -DXERCES_STATIC_LIBRARY ) 59 | ELSE (XERCESC_STATIC) 60 | FIND_LIBRARY(XERCESC_LIBRARY NAMES xerces-c_3 61 | PATHS 62 | $ENV{XERCESC_LIBRARY_DIR} 63 | ${XERCESC_LIBRARY_DIR} 64 | ${OSGEO4W_ROOT_DIR}/lib 65 | ) 66 | FIND_LIBRARY(XERCESC_LIBRARY_DEBUG NAMES xerces-c_3D 67 | PATHS 68 | $ENV{XERCESC_LIBRARY_DIR} 69 | ${XERCESC_LIBRARY_DIR} 70 | ${OSGEO4W_ROOT_DIR}/lib 71 | ) 72 | ENDIF (XERCESC_STATIC) 73 | 74 | SET(XERCESC_FOUND FALSE) 75 | 76 | IF (XERCESC_INCLUDE AND XERCESC_LIBRARY) 77 | SET(XERCESC_FOUND TRUE) 78 | ENDIF (XERCESC_INCLUDE AND XERCESC_LIBRARY) 79 | 80 | IF(XERCESC_FOUND) 81 | 82 | IF(XERCESC_LIBRARY_DEBUG) 83 | SET(XERCESC_LIBRARIES 84 | optimized ${XERCESC_LIBRARY} 85 | debug ${XERCESC_LIBRARY_DEBUG}) 86 | ELSE(XERCESC_LIBRARY_DEBUG) 87 | SET(XERCESC_LIBRARIES ${XERCESC_LIBRARY}) 88 | ENDIF(XERCESC_LIBRARY_DEBUG) 89 | 90 | FIND_PATH(XERCESC_XVERHPPPATH NAMES XercesVersion.hpp PATHS 91 | ${XERCESC_INCLUDE} 92 | PATH_SUFFIXES xercesc/util) 93 | 94 | IF ( ${XERCESC_XVERHPPPATH} STREQUAL XERCESC_XVERHPPPATH-NOTFOUND ) 95 | SET(XERCES_VERSION "0") 96 | ELSE( ${XERCESC_XVERHPPPATH} STREQUAL XERCESC_XVERHPPPATH-NOTFOUND ) 97 | FILE(READ ${XERCESC_XVERHPPPATH}/XercesVersion.hpp XVERHPP) 98 | 99 | STRING(REGEX MATCHALL "\n *#define XERCES_VERSION_MAJOR +[0-9]+" XVERMAJ 100 | ${XVERHPP}) 101 | STRING(REGEX MATCH "\n *#define XERCES_VERSION_MINOR +[0-9]+" XVERMIN 102 | ${XVERHPP}) 103 | STRING(REGEX MATCH "\n *#define XERCES_VERSION_REVISION +[0-9]+" XVERREV 104 | ${XVERHPP}) 105 | 106 | STRING(REGEX REPLACE "\n *#define XERCES_VERSION_MAJOR +" "" 107 | XVERMAJ ${XVERMAJ}) 108 | STRING(REGEX REPLACE "\n *#define XERCES_VERSION_MINOR +" "" 109 | XVERMIN ${XVERMIN}) 110 | STRING(REGEX REPLACE "\n *#define XERCES_VERSION_REVISION +" "" 111 | XVERREV ${XVERREV}) 112 | 113 | SET(XERCESC_VERSION ${XVERMAJ}.${XVERMIN}.${XVERREV}) 114 | 115 | ENDIF ( ${XERCESC_XVERHPPPATH} STREQUAL XERCESC_XVERHPPPATH-NOTFOUND ) 116 | 117 | IF(NOT XERCESC_FIND_QUIETLY) 118 | MESSAGE(STATUS "Found Xerces-C: ${XERCESC_LIBRARY}") 119 | MESSAGE(STATUS " : ${XERCESC_INCLUDE}") 120 | MESSAGE(STATUS " Version: ${XERCESC_VERSION}") 121 | ENDIF(NOT XERCESC_FIND_QUIETLY) 122 | ELSE(XERCESC_FOUND) 123 | MESSAGE(FATAL_ERROR "Could not find Xerces-C !") 124 | ENDIF(XERCESC_FOUND) 125 | 126 | MARK_AS_ADVANCED(XERCESC_INCLUDE XERCESC_LIBRARY) 127 | -------------------------------------------------------------------------------- /cmake/cmake_apply_patches.cmake: -------------------------------------------------------------------------------- 1 | function(cmake_apply_patches) 2 | cmake_parse_arguments(_ap "QUIET" "SOURCE_PATH" "PATCHES" ${ARGN}) 3 | 4 | find_package(Git REQUIRED) 5 | set(PATCHNUM 0) 6 | foreach(PATCH ${_ap_PATCHES}) 7 | get_filename_component(ABSOLUTE_PATCH "${PATCH}" ABSOLUTE BASE_DIR "${CMAKE_SOURCE_DIR}") 8 | set(LOGNAME "patch-${PATCHNUM}") 9 | execute_process( 10 | COMMAND ${GIT_EXECUTABLE} apply "${ABSOLUTE_PATCH}" --ignore-whitespace --whitespace=nowarn --verbose 11 | OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${LOGNAME}-out.log 12 | ERROR_FILE ${CMAKE_CURRENT_BINARY_DIR}/${LOGNAME}-err.log 13 | WORKING_DIRECTORY ${_ap_SOURCE_PATH} 14 | RESULT_VARIABLE error_code 15 | ) 16 | 17 | if(error_code AND NOT _ap_QUIET) 18 | message(STATUS "Applying patch failed. This is expected if this patch was previously applied.") 19 | endif() 20 | 21 | math(EXPR PATCHNUM "${PATCHNUM}+1") 22 | endforeach() 23 | endfunction() 24 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # CentOS 3 | # 4 | ARG BUILD_DATE 5 | ARG IMAGE_VERSION 6 | ARG GIT_VERSION 7 | ARG CMAKE_VERSION 8 | ARG DISPLAY 9 | ARG SCREEN 10 | 11 | FROM centos:${IMAGE_VERSION:-centos7} 12 | 13 | LABEL maintainer="Gaia3D Inc. " \ 14 | description="Development environment for CentOS" \ 15 | org.label-schema.name="" \ 16 | org.label-schema.build-date=$BUILD_DATE \ 17 | org.label-schema.schema-version="1.0.0" 18 | 19 | ENV GIT_VERSION ${GIT_VERSION:-2.30.0} 20 | ENV CMAKE_VERSION ${CMAKE_VERSION:-3.19.2} 21 | ENV LIBLAS_VERSION ${LIBLAS_VERSION:-1.8.1} 22 | ENV DISPLAY ${DISPLAY:-:99} 23 | ENV SCREEN ${SCREEN:-1920x1080x24} 24 | 25 | # Dependencies for development environment 26 | RUN yum -y install wget centos-release-scl epel-release && \ 27 | yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm && \ 28 | yum -y update --exclude=kernel* && \ 29 | yum -y install \ 30 | make gcc-c++ \ 31 | devtoolset-7 \ 32 | boost-devel \ 33 | libX11-devel libXrandr-devel libXinerama-devel libXcursor-devel libXi-devel \ 34 | mesa-dri-drivers mesa-libGL-devel mesa-libGLU-devel \ 35 | xorg-x11-server-Xvfb xorg-x11-utils \ 36 | proj71-devel xerces-c-devel libgeotiff16-devel gdal31-devel geos38 \ 37 | openssl-devel curl-devel expat-devel zlib-devel gettext bzip2\ 38 | && \ 39 | yum clean all && \ 40 | rm -fr /var/cache/yum/* 41 | 42 | # Build and install git from source. 43 | WORKDIR /usr/src 44 | 45 | RUN wget --no-check-certificate https://www.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz && \ 46 | tar xvzf git-${GIT_VERSION}.tar.gz && \ 47 | cd git-${GIT_VERSION} && \ 48 | ./configure --with-expat --with-openssl --prefix=/usr/local && \ 49 | make -j$(grep -c processor /proc/cpuinfo) && \ 50 | make install && \ 51 | cd .. && rm -rf git-${GIT_VERSION}* 52 | 53 | # Build and install CMake from source. 54 | RUN VERSION="$(cut -d '.' -f 1 <<<"${CMAKE_VERSION}")"."$(cut -d '.' -f 2 <<<"${CMAKE_VERSION}")" && \ 55 | wget --no-check-certificate https://cmake.org/files/v${VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \ 56 | tar xvzf cmake-${CMAKE_VERSION}.tar.gz && \ 57 | cd cmake-${CMAKE_VERSION} && \ 58 | ./configure --prefix=/usr/local && \ 59 | make -j$(grep -c processor /proc/cpuinfo) && \ 60 | ./bin/cmake \ 61 | -DCMAKE_BUILD_TYPE:STRING=Release \ 62 | -DCMAKE_USE_OPENSSL:BOOL=ON . && \ 63 | make install && \ 64 | cd .. && rm -rf cmake-${CMAKE_VERSION}* 65 | 66 | # Build and install liblas from source. 67 | RUN wget http://download.osgeo.org/liblas/libLAS-${LIBLAS_VERSION}.tar.bz2 && \ 68 | tar xvf libLAS-${LIBLAS_VERSION}.tar.bz2 && \ 69 | cd libLAS-${LIBLAS_VERSION} && \ 70 | mkdir build && cd build && \ 71 | cmake .. -DGEOTIFF_INCLUDE_DIR=/usr/libgeotiff16/include -DGEOTIFF_LIBRARY=/usr/libgeotiff16/lib/libgeotiff.so && \ 72 | make -j$(grep -c processor /proc/cpuinfo) && \ 73 | make install && \ 74 | cd ../.. && rm -rf libLAS-${LIBLAS_VERSION}* 75 | 76 | RUN git clone --recursive https://github.com/Gaia3D/NewF4DConverter.git && \ 77 | cd NewF4DConverter && \ 78 | mkdir build && cd build && \ 79 | source scl_source enable devtoolset-7 && \ 80 | cmake .. -DCMAKE_INSTALL_PREFIX=/opt/gaia3d/f4dconverter -DGEOTIFF_INCLUDE_DIR=/usr/libgeotiff16/include -DGEOTIFF_LIBRARY=/usr/libgeotiff16/lib/libgeotiff.so -DPROJ4_INCLUDE_DIRS=/usr/proj71/include -DPROJ4_INCLUDE_DIR=/usr/proj71/include -DPROJ4_LIBRARY=/usr/proj71/lib/libproj.so -DGDAL_CONFIG=/usr/gdal31/bin/gdal-config && \ 81 | make -j$(grep -c processor /proc/cpuinfo) && \ 82 | make install && \ 83 | cp -r /usr/proj71/share/proj /opt/gaia3d/f4dconverter/bin &&\ 84 | cd ../.. && rm -rf NewF4DConverter 85 | 86 | WORKDIR /opt/gaia3d 87 | 88 | ENV PATH /opt/gaia3d/f4dconverter/bin:$PATH 89 | ENV LD_LIBRARY_PATH /opt/gaia3d/f4dconverter/lib:/usr/local/lib:$LD_LIBRARY_PATH 90 | 91 | # Set the locale 92 | RUN localedef -i ko_KR -f UTF-8 ko_KR.utf8 && \ 93 | ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime 94 | ENV LANG ko_KR.utf8 95 | ENV LC_ALL ko_KR.utf8 96 | 97 | # Enable the SCL for all bash scripts. 98 | # source scl_source enable devtoolset-7 99 | COPY env/enabledevtoolset-7.sh /etc/profile.d/ 100 | COPY env/set-locale.sh /etc/profile.d/ 101 | COPY env/set-display.sh /etc/profile.d/ 102 | 103 | RUN chmod 644 /etc/profile.d/set-locale.sh \ 104 | /etc/profile.d/set-display.sh \ 105 | /etc/profile.d/enabledevtoolset-7.sh 106 | 107 | # Copy our entrypoint into the container. 108 | COPY env/entrypoint.sh /usr/local/bin/entrypoint.sh 109 | 110 | RUN chmod +x /usr/local/bin/entrypoint.sh 111 | 112 | # Set the default command. 113 | ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] 114 | 115 | CMD ["/bin/bash"] 116 | 117 | -------------------------------------------------------------------------------- /docker/build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | CLS 4 | ECHO "Building Dockerfile" 5 | ECHO. 6 | 7 | CALL config.bat 8 | 9 | docker build ^ 10 | --tag "%IMAGE%" ^ 11 | --build-arg IMAGE_VERSION="%IMG_VER%" ^ 12 | --build-arg BUILD_DATE=%date% ^ 13 | --file Dockerfile ^ 14 | --compress ^ 15 | . 16 | 17 | docker build ^ 18 | --tag "%IMAGE_LATEST%" ^ 19 | --build-arg IMAGE_VERSION="%IMG_VER%" ^ 20 | --build-arg BUILD_DATE=%date% ^ 21 | --file Dockerfile ^ 22 | --compress ^ 23 | . -------------------------------------------------------------------------------- /docker/config.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Docker organization to pull the images from 4 | SET ORG=gaia3d 5 | 6 | REM Container 7 | SET CONTAINER=mago3d-converter 8 | 9 | REM Name of image 10 | SET IMG=centos 11 | 12 | REM root image version 13 | SET IMG_VER=centos7 14 | 15 | REM Docker TAG 16 | SET TAG=latest 17 | 18 | REM Docker Image 19 | SET IMAGE="%ORG%/%CONTAINER%:%IMG%-%IMG_VER%-%TAG%" 20 | SET IMAGE_LATEST="%ORG%/%CONTAINER%" 21 | -------------------------------------------------------------------------------- /docker/env/enabledevtoolset-7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source scl_source enable devtoolset-7 3 | -------------------------------------------------------------------------------- /docker/env/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -eq 0 ]; then 4 | echo "No command was given to run, exiting." 5 | exit 1 6 | else 7 | # Start Xvfb 8 | Xvfb "${DISPLAY}" -ac -screen 0 "${SCREEN}" -nolock -nolisten tcp +extension GLX +render -noreset 2>&1 & 9 | while ! xdpyinfo -display "${DISPLAY}" > /dev/null 2>&1; do 10 | sleep 0.1 11 | done 12 | 13 | # Execute passed command. 14 | exec "$@" 15 | fi 16 | -------------------------------------------------------------------------------- /docker/env/set-display.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export DISPLAY=:99 3 | -------------------------------------------------------------------------------- /docker/env/set-locale.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export LANG=ko_KR.utf8 3 | export LC_ALL=ko_KR.utf8 4 | -------------------------------------------------------------------------------- /docker/run.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | CALL config.bat 4 | 5 | SET ERROR=0 6 | SET RUN_DOCKER= 7 | SET RUNNING= 8 | 9 | :findDocker 10 | FOR /f %%i IN ('where docker') do SET RUN_DOCKER=%%i 11 | IF "%RUN_DOCKER%" == "" ( 12 | SET ERROR=1 13 | ECHO "Error: the 'docker' command was not found. Please install docker." 14 | GOTO end 15 | REM EXIT /b %ERRORLEVEL% 16 | ) 17 | GOTO checkContainer 18 | 19 | :checkContainer 20 | FOR /f %%i IN ('docker ps -a -q --filter "name=%CONTAINER%"') do SET RUNNING=%%i 21 | IF /i not "%RUNNING%" == "" ( 22 | ECHO "Stopping and removing the previous session..." 23 | GOTO cleanContainer 24 | ) 25 | GOTO run 26 | 27 | :cleanContainer 28 | docker stop %CONTAINER% 29 | docker rm %CONTAINER% 30 | GOTO run 31 | 32 | :run 33 | docker run ^ 34 | -d ^ 35 | --privileged ^ 36 | --name "%CONTAINER%" ^ 37 | -p %PORT_SSH%:22 ^ 38 | "%IMAGE%" 39 | GOTO end 40 | 41 | :printHelp 42 | REM Pint Help 43 | ECHO "Print Help" 44 | GOTO end 45 | 46 | :end 47 | IF %ERROR% == 1 ECHO "Startup of Docker container was unsuccessful. 48 | ECHO. 49 | PAUSE -------------------------------------------------------------------------------- /f4d.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Gaia3D/NewF4DConverter/254e5a68d24ceed5e09feb567524fff84955f9cf/f4d.ico -------------------------------------------------------------------------------- /f4d.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "f4d.ico" 2 | -------------------------------------------------------------------------------- /include/argdefinition.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ArgDefinition Header 3 | */ 4 | #ifndef _ARGDEFINITION_H_ 5 | #define _ARGDEFINITION_H_ 6 | #pragma once 7 | 8 | // arguments for conversion configuration 9 | #define InputFolderW L"-inputFolder" ///< The path of the Input Folder. 10 | #define OutputFolderW L"-outputFolder" ///< The path of the Output Folder. 11 | #define LogFilePathW L"-log" ///< The path of the log file. 12 | #define CreateIndexW L"-indexing" ///< The argument for creating a index file for mago3D. 13 | #define IdPrefixW L"-idPrefix" ///< The prefix which will be attached in front of the name of F4D folder name. 14 | #define IdSuffixW L"-idSuffix" ///< The postfix which will be attached at the end of the name of F4D folder name. 15 | 16 | // arguments for processing parameters 17 | #define PerformOCW L"-oc" ///< The argument for asking whether Occlusion culling is done or not. 18 | #define UnitScaleFactorW L"-usf" ///< Unit scale factor. 19 | #define SkinLevelNsmW L"-skinLevel" ///< This is the scale unit of the surface of geometry data. Default value is 4 for single building. 20 | ///< Smaller value is used for smaller surface(Usually 3). 21 | #define IsYAxisUpW L"-isYAxisUp" ///< For specific axis this argument is used. If this argument is set then y axis and z axis values are swapped. 22 | #define ReferenceLonLatW L"-referenceLonLat" ///< Origin coordinate of geometry data. 23 | #define MeshTypeW L"-meshType" ///< MeshType 0 : The data with syntax and inner structure. 24 | #define AlignToW L"-alignTo" ///< Move the origin of the data to the specific position. 25 | #define EpsgW L"-epsg" ///< If the geometry data is written in specific CRS then this argument is used. 26 | #define OffsetXW L"-offsetX" ///< If this is set then the offset value is added to the x coordinate value. 27 | #define OffsetYW L"-offsetY" ///< If this is set then the offset value is added to the y coordinate value. 28 | #define OffsetZW L"-offsetZ" ///< If this is set then the offset value is added to the z coordinate value. 29 | #define ProjectNameW L"-projectName" ///< The sub folder is created with this name under output folder. 30 | #define SplitFilterW L"-splitFilter" ///< If the data has the identifier and that is matched with this filter then the converter create single F4D 31 | ///< and put that data into the single F4D file. 32 | 33 | // arguments for conversion configuration 34 | #define ProgramPath "programPath" 35 | #define InputFolder "-inputFolder" 36 | #define OutputFolder "-outputFolder" 37 | #define LogFilePath "-log" 38 | #define CreateIndex "-indexing" 39 | #define IdPrefix "-idPrefix" 40 | #define IdSuffix "-idSuffix" 41 | 42 | // arguments for processing parameters 43 | #define PerformOC "-oc" 44 | #define UnitScaleFactor "-usf" 45 | #define SkinLevelNsm "-skinLevel" 46 | #define IsYAxisUp "-isYAxisUp" 47 | #define ReferenceLonLat "-referenceLonLat" 48 | #define MeshType "-meshType" 49 | #define AlignTo "-alignTo" 50 | #define Epsg "-epsg" 51 | #define OffsetX "-offsetX" 52 | #define OffsetY "-offsetY" 53 | #define OffsetZ "-offsetZ" 54 | #define ProjectName "-projectName" 55 | #define SplitFilter "-splitFilter" 56 | 57 | #endif // _ARGDEFINITION_H_ -------------------------------------------------------------------------------- /include/predefinition.h: -------------------------------------------------------------------------------- 1 | /** 2 | * PreDefinition Header 3 | */ 4 | #ifndef _PREDEFINITION_H_ 5 | #define _PREDEFINITION_H_ 6 | #pragma once 7 | 8 | #define WindowTitle "F4DConverter" 9 | ///< 더미 윈도우의 크기(px) 10 | #define WindowWidth 1024 11 | #define WindowHeight 1024 12 | 13 | ///< Deffered rendering시 찍는 이미지의 가로 세로 사이즈(px) 14 | #define MemoryDeviceContextEdgeLength 512 15 | 16 | ///< Deffered rendering시 해당 픽셀 이상 외부(Exterior)에 노출되어 있으면 이는 외부에 있는 객체라고 할 수 있다. 17 | #define ExteriorDetectionThreshold 6 18 | 19 | #define DisplayListIdForOcclusionCulling 1 20 | ///< Occlusion Culling 시 찍는 이미지의 가로 세로 사이즈(px) 21 | #define OcclusionCullingScreenSize 512 22 | 23 | ///< 큰 물체라고 인식할 수 있는 threshold값 24 | #define BigObjectThreshold 5.0 25 | ///< 중간 물체라고 인식할 수 있는 threshold값 26 | #define MediumObjectThreshold 2.0 27 | #define BoneObjectThreshold 5.0 28 | 29 | #define SpatialIndexingDepth ((unsigned char)3) 30 | 31 | #define MaxLod 5 32 | 33 | #define VboVertexMaxCount 65532 34 | 35 | #define MaxUnsignedLong 65532 36 | 37 | ///< 삼각형의 기본 사이즈 레벨 38 | #define TriangleSizeLevels 4 39 | ///< 삼각형의 기본 사이즈 레벨 구간. 0.05이하, 1.0 이상을 포함해 5개의 구간이 있다. 40 | #define TriangleSizeThresholds {1.0, 0.5, 0.1, 0.05} 41 | 42 | // attribute key names 43 | #define ObjectGuid "objectGuid" 44 | #define TextureName "textureName" 45 | #define F4DID "id" 46 | 47 | #endif // _PREDEFINITION_H_ -------------------------------------------------------------------------------- /launch.vs.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.1", 3 | "defaults": {}, 4 | "configurations": [ 5 | { 6 | "name": "F4DConverter.exe (Window for Debug)", 7 | "type": "default", 8 | "project": "CMakeLists.txt", 9 | "projectTarget": "F4DConverter.exe (F4DConverter\\Debug\\F4DConverter.exe)", 10 | "args": [ 11 | "-inputFolder", 12 | "C:/DATA/conversionData", 13 | "-outputFolder", 14 | "C:/DATA/conversionResult", 15 | "-log", 16 | "C:/DATA/conversionResult/logTest.txt", 17 | "-meshType", 18 | "0", 19 | "-skinLevel", 20 | "4", 21 | "-indexing", 22 | "y" 23 | ] 24 | }, 25 | { 26 | "name": "F4DConverter.exe (Window for Release)", 27 | "type": "default", 28 | "project": "CMakeLists.txt", 29 | "projectTarget": "F4DConverter.exe (F4DConverter\\RelWithDebInfo\\F4DConverter.exe)", 30 | "args": [ 31 | "-inputFolder", 32 | "C:/DATA/conversionData", 33 | "-outputFolder", 34 | "C:/DATA/conversionResult", 35 | "-log", 36 | "C:/DATA/conversionResult/logTest.txt", 37 | "-meshType", 38 | "0", 39 | "-indexing", 40 | "y" 41 | ] 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /patch/ifcplusplus/fix-config-path.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index 3dc80913..7173f0f7 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -1,4 +1,4 @@ 6 | -CMAKE_MINIMUM_REQUIRED (VERSION 3.7.2) 7 | +CMAKE_MINIMUM_REQUIRED (VERSION 3.7.2) 8 | 9 | # Set a default build type if none was specified https://blog.kitware.com/cmake-and-the-default-build-type/ 10 | set(default_build_type "Release") 11 | @@ -39,8 +39,8 @@ ADD_SUBDIRECTORY (IfcPlusPlus) 12 | 13 | # Install configuration file 14 | INCLUDE(CMakePackageConfigHelpers) 15 | -SET(config_file_input "${CMAKE_SOURCE_DIR}/cmake/IFCPPConfig.cmake.in") 16 | -SET(config_file_output "${CMAKE_BINARY_DIR}/cmake/IFCPPConfig.cmake") 17 | +SET(config_file_input "${CMAKE_CURRENT_SOURCE_DIR}/cmake/IFCPPConfig.cmake.in") 18 | +SET(config_file_output "${CMAKE_CURRENT_BINARY_DIR}/cmake/IFCPPConfig.cmake") 19 | 20 | CONFIGURE_PACKAGE_CONFIG_FILE( 21 | ${config_file_input} 22 | -------------------------------------------------------------------------------- /src/converter/ConverterManager.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ConverterManager Header 3 | */ 4 | #ifndef _CONVERTERMANAGER_H_ 5 | #define _CONVERTERMANAGER_H_ 6 | #pragma once 7 | 8 | #include "../reader/Reader.h" 9 | #include "../process/ConversionProcessor.h" 10 | 11 | #include 12 | 13 | //class Reader; 14 | //class ConversionProcessor; 15 | 16 | class ConverterManager 17 | { 18 | private: 19 | ConverterManager(); 20 | 21 | public: 22 | virtual ~ConverterManager(); 23 | 24 | private: 25 | static ConverterManager m_ConverterManager; 26 | 27 | ConversionProcessor* processor; 28 | 29 | bool bCreateIndices, bConversion; 30 | 31 | std::string programPath; 32 | bool bOcclusionCulling; 33 | double unitScaleFactor; 34 | unsigned char skinLevel; 35 | bool bYAxisUp; 36 | int alignType; 37 | ///< ReferenceLonLat is used or not? Default value is false. 38 | bool bUseReferenceLonLat; 39 | double referenceLon, referenceLat; 40 | int meshType; 41 | ///< EPSG Code is used or not? 42 | bool bUseEpsg; 43 | std::string epsgCode; 44 | double offsetX, offsetY, offsetZ; 45 | std::string projectName; 46 | std::map splitFilter; 47 | 48 | std::string inputFolderPath, outputFolderPath; 49 | 50 | std::string idPrefix, idSuffix; 51 | 52 | public: 53 | static ConverterManager* getConverterManager() { return &m_ConverterManager; } 54 | 55 | public: 56 | bool initialize(std::map& arguments); 57 | 58 | //bool processSingleFile(std::string& filePath); 59 | 60 | void process(); 61 | 62 | void uninitialize(); 63 | 64 | private: 65 | //Set the passed arguments at here for the program configuration 66 | ///< Set the passed arguments at here for the program configuration 67 | bool setProcessConfiguration(std::map& arguments); 68 | 69 | ///< Traverse data folders to find target data. 70 | 71 | bool processDataFolder(); 72 | 73 | ///< Collect target files which will be converted.. 74 | void collectTargetFiles(std::string& inputFolder, std::map& targetFiles); 75 | 76 | ///< It writes the index file. 77 | bool writeIndexFile(); 78 | 79 | ///< Convert and create F4D files at this function. 80 | void processDataFiles(std::map& targetFiles); 81 | 82 | ///< Write each reference lat and lon at here. 83 | void writeRepresentativeLonLatOfEachData(std::map& posXs, std::map& posYs); 84 | 85 | ///< Write additional information which doesn't go through converting process. 86 | void writeAdditionalInfosOfEachData(std::map& additionalInfos); 87 | 88 | ///< Write relative path of each data for hierarchy structure of F4D files. 89 | void writeRelativePathOfEachData(std::map& relativePaths); 90 | 91 | ///< relationship when 1 raw data to multiple F4D or multiple raw data to single F4D cases happen 92 | void writeSplitInfo(std::map>& splitInfo ); 93 | 94 | ///< This function treats the single process of the converting 95 | void processSingleLoop( 96 | std::map& targetFiles, 97 | std::map& centerXs, 98 | std::map& centerYs, 99 | std::map& additionalInfos, 100 | std::map& relativePaths, 101 | std::map>& splitInfo, 102 | unsigned char depth 103 | ); 104 | }; 105 | 106 | #endif // _CONVERTERMANAGER_H_ -------------------------------------------------------------------------------- /src/converter/LogWriter.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the LogWriter class 3 | */ 4 | #include "LogWriter.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | LogWriter LogWriter::logWriter; 12 | Json::Value logObject(Json::objectValue); 13 | Json::Value currentConversionJob(Json::objectValue); 14 | bool isConversionJobGoing = false; 15 | 16 | LogWriter::LogWriter() 17 | { 18 | numberOfFilesToBeConverted = 0; 19 | 20 | numberOfFilesConverted = 0; 21 | 22 | isSuccess = true; 23 | } 24 | 25 | LogWriter::~LogWriter() 26 | { 27 | } 28 | 29 | ///< Set full path of the program 30 | void LogWriter::setFullPath(std::string& path) 31 | { 32 | fullPath = path; 33 | } 34 | 35 | ///< Add log contents 36 | void LogWriter::addContents(const std::string& contents, bool newLine) 37 | { 38 | logContents += contents; 39 | if(newLine) 40 | logContents += std::string("\n"); 41 | } 42 | 43 | ///< Clear log contents 44 | void LogWriter::clearContents() 45 | { 46 | logContents.clear(); 47 | } 48 | 49 | void LogWriter::save() 50 | { 51 | Json::StyledWriter writer; 52 | std::string documentContent = writer.write(logObject); 53 | FILE* file = fopen(fullPath.c_str(), "wt"); 54 | fprintf(file, "%s", documentContent.c_str()); 55 | fclose(file); 56 | 57 | logObject.clear(); 58 | currentConversionJob.clear(); 59 | } 60 | 61 | /* 62 | void LogWriter::save() 63 | { 64 | std::ofstream outFile; 65 | outFile.open(fullPath); 66 | 67 | // 1. result 68 | char stringLine[1024]; 69 | std::memset(stringLine, 0x00, sizeof(char)* 1024); 70 | sprintf(stringLine, "%u of %u files have been converted.\n", numberOfFilesConverted, numberOfFilesToBeConverted); 71 | outFile << stringLine; 72 | 73 | outFile << "-----------------------------------------------------\n"; 74 | 75 | // 2. conversion time 76 | outFile << "start time : " << startTime << "\n"; 77 | outFile << "end time : " << endTime << "\n"; 78 | 79 | outFile << "-----------------------------------------------------\n"; 80 | 81 | 82 | // 3. detailed result 83 | 84 | outFile << logContents; 85 | 86 | outFile.close(); 87 | } 88 | */ 89 | 90 | void LogWriter::setStatus(bool bSuccess, std::string message) 91 | { 92 | isSuccess = bSuccess; 93 | logObject["isSuccess"] = isSuccess; 94 | if (!bSuccess) 95 | logObject["failureLog"] = message; 96 | } 97 | 98 | ///< Record the start time of conversion 99 | void LogWriter::start() 100 | { 101 | startTime = getCurrentTimeString(); 102 | logObject["startTime"] = startTime; 103 | logObject["numberOfFilesToBeConverted"] = 0; 104 | logObject["numberOfFilesConverted"] = 0; 105 | logObject["isSuccess"] = true; 106 | logObject["conversionJobResult"] = Json::Value(Json::arrayValue); 107 | } 108 | 109 | ///< Record the finishing time of conversion 110 | void LogWriter::finish() 111 | { 112 | endTime = getCurrentTimeString(); 113 | logObject["endTime"] = endTime; 114 | logObject["numberOfFilesToBeConverted"] = numberOfFilesToBeConverted; 115 | logObject["numberOfFilesConverted"] = numberOfFilesConverted; 116 | } 117 | 118 | ///< Check conversion is started or not 119 | bool LogWriter::isStarted() 120 | { 121 | return !(startTime.empty()); 122 | } 123 | 124 | ///< Get current system time 125 | std::string LogWriter::getCurrentTimeString() 126 | { 127 | std::chrono::time_point nowTime = std::chrono::system_clock::now(); 128 | std::time_t currentTime = std::chrono::system_clock::to_time_t(nowTime); 129 | 130 | //return std::string(std::ctime(¤tTime)); 131 | char timeStringLine[256]; 132 | memset(timeStringLine, 0x00, 256); 133 | std::strftime(timeStringLine, 256, "%Y-%m-%d %H:%M:%S", std::localtime(¤tTime)); 134 | 135 | std::string timeString(timeStringLine); 136 | /*if (timeString.find_last_of(std::string("\n")) != std::string::npos) 137 | timeString = timeString.substr(0, timeString.find_last_of(std::string("\n")));*/ 138 | 139 | return timeString; 140 | } 141 | 142 | void LogWriter::createNewConversionJobLog(std::string fileName, std::string fullPath) 143 | { 144 | if (isConversionJobGoing) 145 | return; 146 | 147 | currentConversionJob["fileName"] = fileName; 148 | currentConversionJob["fullPath"] = fullPath; 149 | currentConversionJob["startTime"] = getCurrentTimeString(); 150 | currentConversionJob["resultStatus"] = std::string("success"); 151 | currentConversionJob["message"] = std::string(""); 152 | 153 | isConversionJobGoing = true; 154 | } 155 | 156 | void LogWriter::changeCurrentConversionJobStatus(CONVERSION_JOB_STATUS jobStatus) 157 | { 158 | if (!isConversionJobGoing) 159 | return; 160 | 161 | switch (jobStatus) 162 | { 163 | case success: 164 | currentConversionJob["resultStatus"] = std::string("success"); 165 | break; 166 | case warning: 167 | currentConversionJob["resultStatus"] = std::string("warning"); 168 | break; 169 | case failure: 170 | currentConversionJob["resultStatus"] = std::string("failure"); 171 | break; 172 | } 173 | } 174 | 175 | void LogWriter::addDescriptionToCurrentConversionJobLog(std::string content) 176 | { 177 | if (!isConversionJobGoing) 178 | return; 179 | 180 | if (currentConversionJob["message"].asString().empty()) 181 | currentConversionJob["message"] = content; 182 | else 183 | currentConversionJob["message"] = currentConversionJob["message"].asString() + std::string(" | ") + content; 184 | } 185 | 186 | void LogWriter::closeCurrentConversionJobLog() 187 | { 188 | if (!isConversionJobGoing) 189 | return; 190 | 191 | currentConversionJob["endTime"] = getCurrentTimeString(); 192 | logObject["conversionJobResult"].append(currentConversionJob); 193 | currentConversionJob.clear(); 194 | 195 | isConversionJobGoing = false; 196 | } 197 | 198 | void LogWriter::setGeoReferencingInfo(bool bHasInfo, double minx, double miny, double minz, double maxx, double maxy, double maxz) 199 | { 200 | if (bHasInfo) 201 | { 202 | currentConversionJob["bGeoReferenced"] = true; 203 | } 204 | else 205 | { 206 | currentConversionJob["bGeoReferenced"] = false; 207 | 208 | Json::Value bbox(Json::arrayValue); 209 | bbox.append(minx); 210 | bbox.append(miny); 211 | bbox.append(minz); 212 | bbox.append(maxx); 213 | bbox.append(maxy); 214 | bbox.append(maxz); 215 | 216 | currentConversionJob["bbox"] = bbox; 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /src/converter/LogWriter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * LogWriter Header 3 | */ 4 | #ifndef _LOGWRITER_H_ 5 | #define _LOGWRITER_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #define ERROR_FLAG "[ERROR]" 12 | #define WARNING_FLAG "[WARNING]" 13 | #define NO_BLOCK_ID "[No block ID]" 14 | #define NO_OBJECT_ID "[No object ID]" 15 | #define NO_TRANSFORM_MATRIX "[No Transform Matrix]" 16 | #define NO_VERTEX_COUNT "[No vertex count]" 17 | #define NO_VERTEX_ARRAY "[No vertex array]" 18 | #define NO_INDEX_COUNT "[No index count]" 19 | #define NO_INDEX_ARRAY "[No index array]" 20 | #define NO_NORMAL_COUNT "[No normal vector count]" 21 | #define NO_NORMAL_ARRAY "[No normal vector array]" 22 | #define INVALID_TRIANGLE_COUNT "[Invalid triangle count]" 23 | #define UNKNOWN_NODE_TYPE "[Unknown node type]" 24 | #define NO_FILES "[No files exist in input path]" 25 | #define INVALID_OUTPUT_PATH "[Output path not exist]" 26 | #define INVALID_INPUT_PATH "[Input path not exist]" 27 | #define UNSUPPORTED_FORMAT "[Unsupported raw data format]" 28 | #define CANNOT_LOAD_FILE "[Unable to read data file]" 29 | #define NO_DATA_IN_RAW_DATA "[No data in raw data file]" 30 | #define CONVERSION_FAILURE "[Conversion Failed]" 31 | #define CANNOT_INITIALIZE "[Unable to initialize OpenGL]" 32 | #define CANNOT_CHOOSE_PF "[Unable to choose appropriate pixel format for device context]" 33 | #define CANNOT_SET_PF "[Unable to set up pixel format for device context]" 34 | #define CANNOT_CREATE_GL_CONTEXT "[Unable to create OpenGL context for device context]" 35 | #define CANNOT_CONNECT_GLC_TO_DC "[Unable to connect OpenGL context to device context]" 36 | #define CANNOT_INITIALIZE_GLEW "[Unable to initialize GLEW]" 37 | #define CANNOT_INITIALIZE_WND "[Unable to initialize window]" 38 | #define CANNOT_INITIALIZE_DC "[Unable to initialize device context]" 39 | #define CANNOT_CREATE_DIRECTORY "[Unable to create the conversion result directory]" 40 | #define UNLOADABLE_MESH_EXISTS "[At least 1 unloadable mesh exists]" 41 | #define INVAID_ORIGINAL_MESH_TYPE "[Invalid original mesh type]" 42 | #define UNSUPPERTED_EPSG_CODE "[Unable to understand the EPSG code]" 43 | #define CANNOT_DELETE_FILE "[Unable to delete a file]" 44 | 45 | class LogWriter 46 | { 47 | private: 48 | LogWriter(); 49 | 50 | public: 51 | virtual ~LogWriter(); 52 | 53 | enum CONVERSION_JOB_STATUS { success, warning, failure }; 54 | 55 | unsigned int numberOfFilesToBeConverted; 56 | 57 | unsigned int numberOfFilesConverted; 58 | 59 | void createNewConversionJobLog(std::string fileName, std::string fullPath); 60 | 61 | void changeCurrentConversionJobStatus(CONVERSION_JOB_STATUS jobStatus); 62 | 63 | void addDescriptionToCurrentConversionJobLog(std::string content); 64 | 65 | void closeCurrentConversionJobLog(); 66 | 67 | void setGeoReferencingInfo(bool bHasInfo, double minx, double miny, double minz, double maxx, double maxy, double maxz); 68 | 69 | 70 | private: 71 | static LogWriter logWriter; 72 | 73 | std::string startTime; 74 | 75 | std::string endTime; 76 | 77 | std::string logContents; 78 | 79 | std::string fullPath; 80 | 81 | bool isSuccess; 82 | 83 | public: 84 | static LogWriter* getLogWriter() { return &logWriter; } 85 | 86 | void setFullPath(std::string& path); 87 | 88 | void addContents(const std::string& contents, bool newLine); 89 | 90 | void clearContents(); 91 | 92 | void save(); 93 | 94 | void setStatus(bool bSuccess, std::string message = std::string()); 95 | 96 | void start(); 97 | 98 | void finish(); 99 | 100 | bool isStarted(); 101 | 102 | private: 103 | std::string getCurrentTimeString(); 104 | }; 105 | 106 | #endif // _LOGWRITER_H_ 107 | -------------------------------------------------------------------------------- /src/geometry/BoundingBox.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the BoundingBox class 3 | */ 4 | #include "BoundingBox.h" 5 | 6 | namespace gaia3d 7 | { 8 | BoundingBox::BoundingBox() 9 | { 10 | minX = minY = minZ = 10E9; 11 | 12 | maxX = maxY = maxZ = -10E9; 13 | 14 | isInitialized = false; 15 | } 16 | 17 | BoundingBox::~BoundingBox() 18 | { 19 | } 20 | 21 | void BoundingBox::addBox(BoundingBox& bbox) 22 | { 23 | addPoint(bbox.maxX, bbox.maxY, bbox.maxZ); 24 | addPoint(bbox.minX, bbox.minY, bbox.minZ); 25 | } 26 | 27 | void BoundingBox::addPoint(double x, double y, double z) 28 | { 29 | if(!isInitialized) 30 | { 31 | init(x, y, z); 32 | return; 33 | } 34 | 35 | if(x < minX) minX = x; 36 | else if(x > maxX) maxX = x; 37 | 38 | if(y < minY) minY = y; 39 | else if(y > maxY) maxY= y; 40 | 41 | if(z < minZ) minZ= z; 42 | else if(z > maxZ) maxZ = z; 43 | } 44 | 45 | void BoundingBox::getCenterPoint(double& x, double& y, double& z) 46 | { 47 | x = (minX + maxX) / 2.0; 48 | y = (minY + maxY) / 2.0; 49 | z = (minZ + maxZ) / 2.0; 50 | } 51 | 52 | double BoundingBox::getMaxLength() 53 | { 54 | double xlen = getXLength(); 55 | double ylen = getYLength(); 56 | double zlen = getZLength(); 57 | return ( xlen > ylen ? (xlen > zlen ? xlen : zlen) : (ylen > zlen ? ylen : zlen)); 58 | } 59 | 60 | double BoundingBox::getXLength() 61 | { 62 | return maxX - minX; 63 | } 64 | 65 | double BoundingBox::getYLength() 66 | { 67 | return maxY - minY; 68 | } 69 | 70 | double BoundingBox::getZLength() 71 | { 72 | return maxZ - minZ; 73 | } 74 | 75 | void BoundingBox::init(double x, double y, double z) 76 | { 77 | minX = maxX = x; 78 | minY = maxY = y; 79 | minZ = maxZ = z; 80 | 81 | isInitialized = true; 82 | } 83 | 84 | void BoundingBox::divideBbox(int edgeDivisionCount, std::vector& result) 85 | { 86 | for (int i = 0; i < edgeDivisionCount; i++) 87 | { 88 | double minx = (minX * (edgeDivisionCount - i) + maxX * i) / edgeDivisionCount; 89 | double maxx = (minX * (edgeDivisionCount - i - 1) + maxX * (i + 1)) / edgeDivisionCount; 90 | for (int j = 0; j < edgeDivisionCount; j++) 91 | { 92 | double miny = (minY * (edgeDivisionCount - j) + maxY * j) / edgeDivisionCount; 93 | double maxy = (minY * (edgeDivisionCount - j - 1) + maxY * (j + 1)) / edgeDivisionCount; 94 | for (int k = 0; k < edgeDivisionCount; k++) 95 | { 96 | double minz = (minZ * (edgeDivisionCount - k) + maxZ * k) / edgeDivisionCount; 97 | double maxz = (minZ * (edgeDivisionCount - k - 1) + maxZ * (k + 1)) / edgeDivisionCount; 98 | 99 | BoundingBox thisBox; 100 | thisBox.addPoint(minx, miny, minz); 101 | thisBox.addPoint(maxx, maxy, maxz); 102 | 103 | result.push_back(thisBox); 104 | } 105 | } 106 | } 107 | } 108 | 109 | void BoundingBox::expand(double dist) 110 | { 111 | if (!isInitialized) 112 | return; 113 | 114 | minX -= dist; 115 | minY -= dist; 116 | minZ -= dist; 117 | 118 | maxX += dist; 119 | maxY += dist; 120 | maxZ += dist; 121 | } 122 | } -------------------------------------------------------------------------------- /src/geometry/BoundingBox.h: -------------------------------------------------------------------------------- 1 | /** 2 | * BoundingBox Header 3 | */ 4 | #ifndef _BOUNDINGBOX_H_ 5 | #define _BOUNDINGBOX_H_ 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace gaia3d 11 | { 12 | class BoundingBox 13 | { 14 | public: 15 | BoundingBox(); 16 | 17 | virtual ~BoundingBox(); 18 | 19 | public: 20 | double minX, minY, minZ, maxX, maxY, maxZ; 21 | 22 | ///< init 함수를 실행시키고 난 후 이 변수가 true로 변함 23 | bool isInitialized; 24 | 25 | ///< 기존 박스에 새로운 박스를 포함시켜 새로운 경계를 갱신 26 | void addBox(BoundingBox& bbox); 27 | 28 | ///< 기존 박스에 새로운 포인트를 포함시켜 새로운 경계를 갱신 29 | void addPoint(double x, double y, double z); 30 | 31 | ///< 박스의 중심점을 계산 32 | void getCenterPoint(double& x, double& y, double& z); 33 | 34 | ///< 박스의 제일 긴 변을 계산 35 | double getMaxLength(); 36 | 37 | ///< 박스의 x축과 나란한 변의 길이를 계산 38 | double getXLength(); 39 | 40 | ///< 박스의 y축과 나란한 변의 길이를 계산 41 | double getYLength(); 42 | 43 | ///< 박스의 z축과 나란한 변의 길이를 계산 44 | double getZLength(); 45 | 46 | ///< 박스의 점들을 해당 점으로 초기화 47 | void init(double x, double y, double z); 48 | 49 | ///< 박스의 변을 edgeDivisionCount만큼 나눠서 result로 리턴 50 | void divideBbox(int edgeDivisionCount, std::vector& result); 51 | 52 | ///< 박스의 가로세로높이를 dist*2만큼 확장 53 | void expand(double dist); 54 | }; 55 | } 56 | 57 | #endif // _BOUNDINGBOX_H_ 58 | 59 | -------------------------------------------------------------------------------- /src/geometry/ColorU4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ColorU4 Header 3 | */ 4 | #ifndef _ColorU4_H_ 5 | #define _ColorU4_H_ 6 | #pragma once 7 | 8 | namespace gaia3d 9 | { 10 | typedef unsigned long ColorU4; 11 | 12 | enum ColorMode {NoColor, SingleColor, ColorsOnVertices}; 13 | } 14 | 15 | ///< 가장 최하위 바이트를 가지고 오는 매크로(R채널) 16 | #define LOWBYTE(w) ((unsigned char)(((unsigned long)(w)) & 0xff)) 17 | ///< RGB값을 입력해 mesh의 색을 결정하는 매크로 18 | #define MakeColorU4(r,g,b) ((gaia3d::ColorU4)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16))) 19 | ///< R채널 값을 가져오는 매크로 20 | #define GetRedValue(rgb) (LOWBYTE(rgb)) 21 | ///< G채널 값을 가져오는 매크로 22 | #define GetGreenValue(rgb) (LOWBYTE(((unsigned short)(rgb)) >> 8)) 23 | ///< B채널 값을 가져오는 매크로 24 | #define GetBlueValue(rgb) (LOWBYTE((rgb)>>16)) 25 | ///< 기본 값을 설정하는 매크로. 회색. 26 | #define DefaultColor MakeColorU4(204, 204, 204) 27 | 28 | #endif // _ColorU4_H_ 29 | -------------------------------------------------------------------------------- /src/geometry/LegoBlock.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the LegoBlock class 3 | */ 4 | #include "LegoBlock.h" 5 | 6 | namespace gaia3d 7 | { 8 | LegoBlock::LegoBlock() 9 | {} 10 | 11 | LegoBlock::~LegoBlock() 12 | {} 13 | } -------------------------------------------------------------------------------- /src/geometry/LegoBlock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * LegoBlock Header 3 | */ 4 | #ifndef _LEGOBLOCK_H_ 5 | #define _LEGOBLOCK_H_ 6 | #pragma once 7 | 8 | #include "ColorU4.h" 9 | 10 | namespace gaia3d 11 | { 12 | class LegoBlock 13 | { 14 | public: 15 | LegoBlock(); 16 | 17 | virtual ~LegoBlock(); 18 | 19 | public: 20 | double minX, minY, minZ, maxX, maxY, maxZ; 21 | 22 | ColorU4 color; 23 | 24 | void setSize(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax) 25 | {minX = xMin; minY = yMin; minZ = zMin; maxX = xMax; maxY = yMax; maxZ = zMax;} 26 | }; 27 | } 28 | 29 | #endif // _LEGOBLOCK_H_ -------------------------------------------------------------------------------- /src/geometry/Matrix4.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Matrix4 class 3 | */ 4 | #include "Matrix4.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace gaia3d 10 | { 11 | Matrix4::Matrix4() 12 | { 13 | identity(); 14 | } 15 | 16 | Matrix4::~Matrix4() 17 | {} 18 | 19 | void Matrix4::rotation(Quaternion *q) 20 | { 21 | const double w = q->w; 22 | const double x = q->x; 23 | const double y = q->y; 24 | const double z = q->z; 25 | m[0][0] = 1 - 2 * y*y - 2 * z*z; m[1][0] = 2 * x*y - 2 * z*w; m[2][0] = 2 * x*z + 2 * y*w; m[3][0] = 0.0; 26 | m[0][1] = 2 * x*y + 2 * z*w; m[1][1] = 1 - 2 * x*x - 2 * z*z; m[2][1] = 2 * y*z - 2 * x*w; m[3][1] = 0.0; 27 | m[0][2] = 2 * x*z - 2 * y*w; m[1][2] = 2 * y*z + 2 * x*w; m[2][2] = 1 - 2 * x*x - 2 * y*y; m[3][2] = 0.0; 28 | m[0][3] = 0.0; m[1][3] = 0.0; m[2][3] = 0.0; m[3][3] = 1.0; 29 | } 30 | 31 | void Matrix4::rotation(double ang_rad, Point3D *axis) 32 | { 33 | Quaternion q; 34 | q.rotation(ang_rad, axis); 35 | this->rotation(&q); 36 | } 37 | 38 | void Matrix4::rotation(double ang_rad, double axis_x, double axis_y, double axis_z) 39 | { 40 | Quaternion q; 41 | 42 | q.rotation(ang_rad, axis_x, axis_y, axis_z); 43 | this->rotation(&q); 44 | } 45 | 46 | void Matrix4::rotationInDegree(double ang_degree, double axis_x, double axis_y, double axis_z) 47 | { 48 | double m_pi = 3.14159265358979323846; 49 | double ang_rad = ang_degree * m_pi / 180.0; 50 | this->rotation(ang_rad, axis_x, axis_y, axis_z); 51 | } 52 | 53 | void Matrix4::perspective(double fov, double n, double f) 54 | { 55 | double s; 56 | double MPI_Div_180 = 3.14159265358979323846 / 180.0; 57 | 58 | s = 1.0 / (tan(fov*0.5*MPI_Div_180)); 59 | 60 | m[0][0] = s; m[1][0] = 0.0; m[2][0] = 0.0; m[3][0] = 0.0; 61 | m[0][1] = 0.0; m[1][1] = s; m[2][1] = 0.0; m[3][1] = 0.0; 62 | m[0][2] = 0.0; m[1][2] = 0.0; m[2][2] = -f / (f - n); m[3][2] = -f*n / (f - n); 63 | m[0][3] = 0.0; m[1][3] = 0.0; m[2][3] = -1.0; m[3][3] = 0.0; 64 | } 65 | 66 | void Matrix4::perspective(double fov, double aspect, double n, double f) 67 | { 68 | double s, dp; 69 | double MPI_Div_180 = 3.14159265358979323846 / 180.0; 70 | 71 | s = 1.0 / (tan(fov*0.5*MPI_Div_180)); 72 | dp = n - f; 73 | 74 | m[0][0] = s / aspect; m[1][0] = 0.0; m[2][0] = 0.0; m[3][0] = 0.0; 75 | m[0][1] = 0.0; m[1][1] = s; m[2][1] = 0.0; m[3][1] = 0.0; 76 | m[0][2] = 0.0; m[1][2] = 0.0; m[2][2] = (f + n) / dp; m[3][2] = (2.0*f*n) / dp; 77 | m[0][3] = 0.0; m[1][3] = 0.0; m[2][3] = -1.0; m[3][3] = 0.0; 78 | } 79 | 80 | void Matrix4::perspectiveInverse(double fov, double aspect, double n, double f) 81 | { 82 | double s, dp; 83 | double MPI_Div_180 = 3.14159265358979323846 / 180.0; 84 | 85 | s = 1.0 / (tan(fov*0.5*MPI_Div_180)); 86 | dp = n - f; 87 | 88 | m[0][0] = aspect / s; m[1][0] = 0.0; m[2][0] = 0.0; m[3][0] = 0.0; 89 | m[0][1] = 0.0; m[1][1] = 1.0 / s; m[2][1] = 0.0; m[3][1] = 0.0; 90 | m[0][2] = 0.0; m[1][2] = 0.0; m[2][2] = 0.0; m[3][2] = -1.0; 91 | m[0][3] = 0.0; m[1][3] = 0.0; m[2][3] = dp / (2.0*f*n); m[3][3] = (f + n) / (2.0*f*n); 92 | } 93 | 94 | Point3D Matrix4::operator * (const Point3D &q) const 95 | { 96 | Point3D t; 97 | 98 | t.x = q.x*m[0][0] + q.y*m[1][0] + q.z*m[2][0] + m[3][0]; 99 | t.y = q.x*m[0][1] + q.y*m[1][1] + q.z*m[2][1] + m[3][1]; 100 | t.z = q.x*m[0][2] + q.y*m[1][2] + q.z*m[2][2] + m[3][2]; 101 | 102 | return t; 103 | } 104 | 105 | void Matrix4::applyOnlyRotationOnPoint(Point3D& q) 106 | { 107 | double x = q.x*m[0][0] + q.y*m[1][0] + q.z*m[2][0]; 108 | double y = q.x*m[0][1] + q.y*m[1][1] + q.z*m[2][1]; 109 | double z = q.x*m[0][2] + q.y*m[1][2] + q.z*m[2][2]; 110 | 111 | q.set(x, y, z); 112 | } 113 | 114 | Matrix4 Matrix4::operator * (const Matrix4 &A) 115 | { 116 | Matrix4 c; 117 | for (int i = 0; i < 4; i++) { 118 | for (int j = 0; j < 4; j++) { 119 | c.m[i][j] = 0.0; 120 | for (int k = 0; k < 4; k++) { 121 | c.m[i][j] += A.m[k][j] * m[i][k]; 122 | } 123 | } 124 | } 125 | 126 | return c; 127 | } 128 | 129 | Matrix4 Matrix4::inverse() 130 | { 131 | Matrix4 inv; 132 | 133 | double src0 = m[0][0]; 134 | double src1 = m[0][1]; 135 | double src2 = m[0][2]; 136 | double src3 = m[0][3]; 137 | double src4 = m[1][0]; 138 | double src5 = m[1][1]; 139 | double src6 = m[1][2]; 140 | double src7 = m[1][3]; 141 | double src8 = m[2][0]; 142 | double src9 = m[2][1]; 143 | double src10 = m[2][2]; 144 | double src11 = m[2][3]; 145 | double src12 = m[3][0]; 146 | double src13 = m[3][1]; 147 | double src14 = m[3][2]; 148 | double src15 = m[3][3]; 149 | 150 | // calculate pairs for first 8 elements (cofactors) 151 | double tmp0 = src10 * src15; 152 | double tmp1 = src11 * src14; 153 | double tmp2 = src9 * src15; 154 | double tmp3 = src11 * src13; 155 | double tmp4 = src9 * src14; 156 | double tmp5 = src10 * src13; 157 | double tmp6 = src8 * src15; 158 | double tmp7 = src11 * src12; 159 | double tmp8 = src8 * src14; 160 | double tmp9 = src10 * src12; 161 | double tmp10 = src8 * src13; 162 | double tmp11 = src9 * src12; 163 | 164 | // calculate first 8 elements (cofactors) 165 | double dst0 = (tmp0 * src5 + tmp3 * src6 + tmp4 * src7) - (tmp1 * src5 + tmp2 * src6 + tmp5 * src7); 166 | double dst1 = (tmp1 * src4 + tmp6 * src6 + tmp9 * src7) - (tmp0 * src4 + tmp7 * src6 + tmp8 * src7); 167 | double dst2 = (tmp2 * src4 + tmp7 * src5 + tmp10 * src7) - (tmp3 * src4 + tmp6 * src5 + tmp11 * src7); 168 | double dst3 = (tmp5 * src4 + tmp8 * src5 + tmp11 * src6) - (tmp4 * src4 + tmp9 * src5 + tmp10 * src6); 169 | double dst4 = (tmp1 * src1 + tmp2 * src2 + tmp5 * src3) - (tmp0 * src1 + tmp3 * src2 + tmp4 * src3); 170 | double dst5 = (tmp0 * src0 + tmp7 * src2 + tmp8 * src3) - (tmp1 * src0 + tmp6 * src2 + tmp9 * src3); 171 | double dst6 = (tmp3 * src0 + tmp6 * src1 + tmp11 * src3) - (tmp2 * src0 + tmp7 * src1 + tmp10 * src3); 172 | double dst7 = (tmp4 * src0 + tmp9 * src1 + tmp10 * src2) - (tmp5 * src0 + tmp8 * src1 + tmp11 * src2); 173 | 174 | // calculate pairs for second 8 elements (cofactors) 175 | tmp0 = src2 * src7; 176 | tmp1 = src3 * src6; 177 | tmp2 = src1 * src7; 178 | tmp3 = src3 * src5; 179 | tmp4 = src1 * src6; 180 | tmp5 = src2 * src5; 181 | tmp6 = src0 * src7; 182 | tmp7 = src3 * src4; 183 | tmp8 = src0 * src6; 184 | tmp9 = src2 * src4; 185 | tmp10 = src0 * src5; 186 | tmp11 = src1 * src4; 187 | 188 | // calculate second 8 elements (cofactors) 189 | double dst8 = (tmp0 * src13 + tmp3 * src14 + tmp4 * src15) - (tmp1 * src13 + tmp2 * src14 + tmp5 * src15); 190 | double dst9 = (tmp1 * src12 + tmp6 * src14 + tmp9 * src15) - (tmp0 * src12 + tmp7 * src14 + tmp8 * src15); 191 | double dst10 = (tmp2 * src12 + tmp7 * src13 + tmp10 * src15) - (tmp3 * src12 + tmp6 * src13 + tmp11 * src15); 192 | double dst11 = (tmp5 * src12 + tmp8 * src13 + tmp11 * src14) - (tmp4 * src12 + tmp9 * src13 + tmp10 * src14); 193 | double dst12 = (tmp2 * src10 + tmp5 * src11 + tmp1 * src9) - (tmp4 * src11 + tmp0 * src9 + tmp3 * src10); 194 | double dst13 = (tmp8 * src11 + tmp0 * src8 + tmp7 * src10) - (tmp6 * src10 + tmp9 * src11 + tmp1 * src8); 195 | double dst14 = (tmp6 * src9 + tmp11 * src11 + tmp3 * src8) - (tmp10 * src11 + tmp2 * src8 + tmp7 * src9); 196 | double dst15 = (tmp10 * src10 + tmp4 * src8 + tmp9 * src9) - (tmp8 * src9 + tmp11 * src10 + tmp5 * src8); 197 | 198 | // calculate determinant 199 | double epsilon20 = 0.00000000000000000001; 200 | double det = src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3; 201 | 202 | if (fabs(det) < epsilon20) { 203 | throw std::runtime_error("matrix is not invertible because its determinate is zero."); 204 | } 205 | 206 | // calculate matrix inverse 207 | det = 1.0 / det; 208 | 209 | inv.m[0][0] = dst0 * det; 210 | inv.m[1][0] = dst1 * det; 211 | inv.m[2][0] = dst2 * det; 212 | inv.m[3][0] = dst3 * det; 213 | inv.m[0][1] = dst4 * det; 214 | inv.m[1][1] = dst5 * det; 215 | inv.m[2][1] = dst6 * det; 216 | inv.m[3][1] = dst7 * det; 217 | inv.m[0][2] = dst8 * det; 218 | inv.m[1][2] = dst9 * det; 219 | inv.m[2][2] = dst10 * det; 220 | inv.m[3][2] = dst11 * det; 221 | inv.m[0][3] = dst12 * det; 222 | inv.m[1][3] = dst13 * det; 223 | inv.m[2][3] = dst14 * det; 224 | inv.m[3][3] = dst15 * det; 225 | 226 | return inv; 227 | } 228 | 229 | Matrix4 Matrix4::transpose() 230 | { 231 | Matrix4 trans; 232 | 233 | double matrix10 = m[1][0]; 234 | double matrix20 = m[2][0]; 235 | double matrix30 = m[3][0]; 236 | double matrix21 = m[2][1]; 237 | double matrix31 = m[3][1]; 238 | double matrix32 = m[3][2]; 239 | 240 | trans.m[0][0] = m[0][0]; 241 | trans.m[1][0] = m[0][1]; 242 | trans.m[2][0] = m[0][2]; 243 | trans.m[3][0] = m[0][3]; 244 | trans.m[0][1] = matrix10; 245 | trans.m[1][1] = m[1][1]; 246 | trans.m[2][1] = m[1][2]; 247 | trans.m[3][1] = m[1][3]; 248 | trans.m[0][2] = matrix20; 249 | trans.m[1][2] = matrix21; 250 | trans.m[2][2] = m[2][2]; 251 | trans.m[3][2] = m[2][3]; 252 | trans.m[0][3] = matrix30; 253 | trans.m[1][3] = matrix31; 254 | trans.m[2][3] = matrix32; 255 | trans.m[3][3] = m[3][3]; 256 | 257 | return trans; 258 | } 259 | 260 | void Matrix4::getOnlyRotationFloatArray(float* rotation) 261 | { 262 | rotation[0] = float(m[0][0]); // col 0, row 0 263 | rotation[1] = float(m[1][0]); // col 1, row 0 264 | rotation[2] = float(m[2][0]); // col 2, row 0 265 | rotation[3] = float(m[0][1]); // col 0, row 1 266 | rotation[4] = float(m[1][1]); // col 1, row 1 267 | rotation[5] = float(m[2][1]); // col 2, row 1 268 | rotation[6] = float(m[0][2]); // col 0, row 2 269 | rotation[7] = float(m[1][2]); // col 1, row 2 270 | rotation[8] = float(m[2][2]); // col 2, row 2 271 | } 272 | 273 | void Matrix4::getOnlyRotationDoubleArray(double* rotation) 274 | { 275 | rotation[0] = (m[0][0]); // col 0, row 0 276 | rotation[1] = (m[1][0]); // col 1, row 0 277 | rotation[2] = (m[2][0]); // col 2, row 0 278 | rotation[3] = (m[0][1]); // col 0, row 1 279 | rotation[4] = (m[1][1]); // col 1, row 1 280 | rotation[5] = (m[2][1]); // col 2, row 1 281 | rotation[6] = (m[0][2]); // col 0, row 2 282 | rotation[7] = (m[1][2]); // col 1, row 2 283 | rotation[8] = (m[2][2]); // col 2, row 2 284 | } 285 | 286 | unsigned char Matrix4::getMatrixType(double error) 287 | { 288 | // matrixType = 0 -> identity matrix. 289 | // matrixType = 1 -> translate matrix. 290 | // matrixType = 2 -> transform matrix. 291 | bool is3by3PartIdentity = false; 292 | if (m[0][0] < 1.0 + error && m[0][0] > 1.0 - error) 293 | { 294 | if (m[0][1] < error && m[0][1] > -error) 295 | if (m[0][2] < error && m[0][2] > -error) 296 | if (m[1][0] < error && m[1][0] > -error) 297 | if (m[1][1] < 1.0 + error && m[1][1] > 1.0 - error) 298 | if (m[1][2] < error && m[1][2] > -error) 299 | if (m[2][0] < error && m[2][0] > -error) 300 | if (m[2][1] < error && m[2][1] > -error) 301 | if (m[2][2] < 1.0 + error && m[2][2] > 1.0 - error) 302 | is3by3PartIdentity = true; 303 | } 304 | 305 | unsigned char type = 2; 306 | if (is3by3PartIdentity) 307 | { 308 | type = 1; 309 | // check if there are translation. 310 | if (m[0][3] < error && m[0][3] > -error) 311 | { 312 | if (m[1][3] < error && m[1][3] > -error) 313 | if (m[2][3] < error && m[2][3] > -error) 314 | if (m[3][0] < error && m[3][0] > -error) 315 | if (m[3][1] < error && m[3][1] > -error) 316 | if (m[3][2] < error && m[3][2] > -error) 317 | if (m[3][3] < 1.0 + error && m[3][3] > 1.0 - error) 318 | type = 0; 319 | } 320 | } 321 | 322 | return type; 323 | } 324 | } 325 | -------------------------------------------------------------------------------- /src/geometry/Matrix4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Matrix4 Header 3 | */ 4 | #ifndef _MATRIX4_H_ 5 | #define _MATRIX4_H_ 6 | #pragma once 7 | 8 | #include "Point3D.h" 9 | #include "Quaternion.h" 10 | 11 | namespace gaia3d 12 | { 13 | class Matrix4 14 | { 15 | public: 16 | Matrix4(); 17 | 18 | virtual ~Matrix4(); 19 | 20 | public: 21 | double m[4][4]; // m[col][row] 22 | 23 | void identity() 24 | { 25 | m[0][0]=1.0; m[1][0]=0.0; m[2][0]=0.0; m[3][0]=0.0; 26 | m[0][1]=0.0; m[1][1]=1.0; m[2][1]=0.0; m[3][1]=0.0; 27 | m[0][2]=0.0; m[1][2]=0.0; m[2][2]=1.0; m[3][2]=0.0; 28 | m[0][3]=0.0; m[1][3]=0.0; m[2][3]=0.0; m[3][3]=1.0; 29 | } 30 | 31 | void set(Matrix4 *mat) 32 | { 33 | this->set(mat->m[0][0], mat->m[0][1], mat->m[0][2], mat->m[0][3], 34 | mat->m[1][0], mat->m[1][1], mat->m[1][2], mat->m[1][3], 35 | mat->m[2][0], mat->m[2][1], mat->m[2][2], mat->m[2][3], 36 | mat->m[3][0], mat->m[3][1], mat->m[3][2], mat->m[3][3]); 37 | } 38 | void set(Matrix4& mat) 39 | { 40 | this->set(mat.m[0][0], mat.m[0][1], mat.m[0][2], mat.m[0][3], 41 | mat.m[1][0], mat.m[1][1], mat.m[1][2], mat.m[1][3], 42 | mat.m[2][0], mat.m[2][1], mat.m[2][2], mat.m[2][3], 43 | mat.m[3][0], mat.m[3][1], mat.m[3][2], mat.m[3][3]); 44 | } 45 | 46 | void set(double value_11, double value_12, double value_13, double value_14, 47 | double value_21, double value_22, double value_23, double value_24, 48 | double value_31, double value_32, double value_33, double value_34, 49 | double value_41, double value_42, double value_43, double value_44) 50 | { 51 | m[0][0]=value_11; m[1][0]=value_21; m[2][0]=value_31; m[3][0]=value_41; 52 | m[0][1]=value_12; m[1][1]=value_22; m[2][1]=value_32; m[3][1]=value_42; 53 | m[0][2]=value_13; m[1][2]=value_23; m[2][2]=value_33; m[3][2]=value_43; 54 | m[0][3]=value_14; m[1][3]=value_24; m[2][3]=value_34; m[3][3]=value_44; 55 | } 56 | ///< Quaternion으로 회전 계산을 한다 57 | void rotation(Quaternion* q); 58 | ///< 회전시킬 축과 radian를 통해 회전 계산을 한다 59 | void rotation(double ang_rad, Point3D* axis); 60 | 61 | void rotation(double ang_rad, double axis_x, double axis_y, double axis_z); 62 | ///< 회전시킬 축과 degree를 통해 회전 계산을 한다 63 | void rotationInDegree(double ang_degree, double axis_x, double axis_y, double axis_z); 64 | ///< 주어진 점을 기준으로 변환만 하는 함수 65 | void translation(Point3D *pos) 66 | { 67 | translation(pos->x, pos->y, pos->z); 68 | } 69 | 70 | void translation(double x, double y, double z) 71 | { 72 | m[0][0]=1.0; m[1][0]=0.0; m[2][0]=0.0; m[3][0]=x; 73 | m[0][1]=0.0; m[1][1]=1.0; m[2][1]=0.0; m[3][1]=y; 74 | m[0][2]=0.0; m[1][2]=0.0; m[2][2]=1.0; m[3][2]=z; 75 | m[0][3]=0.0; m[1][3]=0.0; m[2][3]=0.0; m[3][3]=1.0; 76 | } 77 | 78 | ///< 절대 좌표계에서 frustum 좌표계로 변환 79 | void perspective(double fov, double n, double f); 80 | 81 | void perspective(double fov, double aspect, double n, double f); 82 | 83 | void perspectiveInverse(double fov, double aspect, double n, double f); 84 | 85 | ///< frustum 좌표계로 변환 86 | void frustum(double l, double r, double t, double b, double n, double f) 87 | { 88 | m[0][0]=2.0*n/(r-l); m[1][0]=0.0; m[2][0]=(t+l)/(r-l); m[3][0]=0.0; 89 | m[0][1]=0.0; m[1][1]=2.0*n/(t-b); m[2][1]=(t+b)/(t-b); m[3][1]=0.0; 90 | m[0][2]=0.0; m[1][2]=0.0; m[2][2]=-(f+n)/(f-n); m[3][2]=-2.0*f*n/(f-n); 91 | m[0][3]=0.0; m[1][3]=0.0; m[2][3]=-1.0; m[3][3]=0.0; 92 | 93 | } 94 | 95 | Point3D operator * (const Point3D &q) const; 96 | 97 | ///< Rotation만 적용 98 | void applyOnlyRotationOnPoint(Point3D& q); 99 | 100 | Matrix4 operator * (const Matrix4 &A); 101 | 102 | void operator = (const Matrix4& A) 103 | { 104 | for (unsigned char i = 0; i < 4; i++) 105 | for (unsigned char j = 0; j < 4; j++) 106 | m[i][j] = A.m[i][j]; 107 | } 108 | 109 | void getFloatArray(float* result) 110 | { 111 | for (unsigned char i = 0; i < 4; i++) 112 | { 113 | for (unsigned char j = 0; j < 4; j++) 114 | { 115 | result[i*4 + j] = (float)m[j][i]; 116 | } 117 | } 118 | } 119 | 120 | void getDoubleArray(double* result) 121 | { 122 | for (unsigned char i = 0; i < 4; i++) 123 | { 124 | for (unsigned char j = 0; j < 4; j++) 125 | { 126 | result[j + i * 4] = m[j][i]; 127 | } 128 | } 129 | } 130 | 131 | Matrix4 inverse(); 132 | 133 | Matrix4 transpose(); 134 | ///< Rotation만 적용. 점 정보를 Array로 넣는다. 135 | void getOnlyRotationFloatArray(float* rotation); 136 | ///< Rotation만 적용. 점 정보를 double로 넣는다. 137 | void getOnlyRotationDoubleArray(double* rotation); 138 | ///< Identity matrix를 바인딩을 하지 않기 위해 매트릭스의 타입을 구한다 139 | unsigned char getMatrixType(double error); 140 | }; 141 | } 142 | 143 | #endif // _MATRIX4_H_ -------------------------------------------------------------------------------- /src/geometry/OctreeBox.h: -------------------------------------------------------------------------------- 1 | /** 2 | * OctreeBox Header 3 | */ 4 | #ifndef _OCTREEBOX_H_ 5 | #define _OCTREEBOX_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "TrianglePolyhedron.h" 12 | 13 | namespace gaia3d 14 | { 15 | class OctreeBox 16 | { 17 | public: 18 | OctreeBox(OctreeBox* owner); 19 | 20 | virtual ~OctreeBox(); 21 | 22 | public: 23 | OctreeBox* parent; 24 | std::vector children; 25 | 26 | std::vector meshes; 27 | 28 | unsigned char level; 29 | 30 | double minX, minY, minZ, maxX, maxY, maxZ; 31 | 32 | void setSize(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax) 33 | {minX = xMin; minY = yMin; minZ = zMin; maxX = xMax; maxY = yMax; maxZ = zMax;} 34 | 35 | void clear(); 36 | 37 | void getAllLeafBoxes(std::vector& container, bool bExceptEmptyBox = false); 38 | 39 | void getAllBoxes(std::vector& container, bool bExceptEmptyBox); 40 | 41 | void copyDimensionsFromOtherOctreeBox(OctreeBox& input); 42 | 43 | void makeTree(unsigned char depth); 44 | 45 | unsigned char getDepth(); 46 | 47 | virtual OctreeBox* makeChild() = 0; 48 | }; 49 | 50 | class VisionOctreeBox : public OctreeBox 51 | { 52 | public: 53 | VisionOctreeBox(OctreeBox* owner); 54 | 55 | virtual ~VisionOctreeBox(); 56 | 57 | public: 58 | void getInternalDivisionPoints(std::vector& container, double scanStepX, double scanStepY, double scanStepZ); 59 | 60 | virtual OctreeBox* makeChild() {return new VisionOctreeBox(this);} 61 | }; 62 | 63 | class SpatialOctreeBox : public OctreeBox 64 | { 65 | public: 66 | SpatialOctreeBox(OctreeBox* owner); 67 | 68 | virtual ~SpatialOctreeBox(); 69 | 70 | public: 71 | size_t octreeId; 72 | 73 | gaia3d::VisionOctreeBox* interiorOcclusionInfo; 74 | gaia3d::VisionOctreeBox* exteriorOcclusionInfo; 75 | 76 | gaia3d::TrianglePolyhedron* netSurfaceMesh; 77 | 78 | virtual OctreeBox* makeChild() {return new SpatialOctreeBox(this);} 79 | 80 | virtual void makeTreeOfUnfixedDepth(double minSize, bool isObjectInOnlyOneLeaf, bool bSplitMesh = false); 81 | 82 | void makeFullCubePyramid(double minCubeSize, bool bObjectInOnlyOneCube, bool bBasedOnMesh); 83 | 84 | void setOctreeId(size_t parentId = 0, size_t orderOfChild = 0); 85 | ///< 이미 나눠진 메쉬를 children에게 배분한다. 86 | void distributeMeshesIntoEachChildren(bool isObjectInOnlyOneLeaf, bool propagateToDescendents = true); 87 | ///< 강제로 메쉬를 쪼개서 각 children에게 넣어준다. 88 | void splitMeshIntoEachChildren(); 89 | 90 | void clipIntersectedPartWithBox(gaia3d::TrianglePolyhedron* mesh, 91 | double minx, double miny, double minz, double maxx, double maxy, double maxz, 92 | gaia3d::TrianglePolyhedron** intersected, 93 | gaia3d::TrianglePolyhedron** nonIntersected); 94 | 95 | void calculateBoundingBox(gaia3d::TrianglePolyhedron* mesh); 96 | 97 | }; 98 | } 99 | 100 | #endif // _OCTREEBOX_H_ 101 | -------------------------------------------------------------------------------- /src/geometry/Point3D.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Point3D class 3 | */ 4 | #include 5 | 6 | #include "Point3D.h" 7 | 8 | namespace gaia3d 9 | { 10 | Point3D::Point3D() 11 | { 12 | } 13 | 14 | Point3D::~Point3D() 15 | { 16 | } 17 | 18 | void Point3D::set(double x, double y, double z) 19 | { 20 | this->x = x; 21 | this->y = y; 22 | this->z = z; 23 | } 24 | 25 | double Point3D::squaredDistanceTo(Point3D& target) 26 | { 27 | return ((x - target.x)*(x - target.x) + (y - target.y)*(y - target.y) + (z - target.z)*(z - target.z)); 28 | } 29 | 30 | double Point3D::magnitude() 31 | { 32 | return sqrt(x*x + y*y + z*z); 33 | } 34 | 35 | bool Point3D::normalize(double tolerance) 36 | { 37 | double mag = this->magnitude(); 38 | if( mag >= tolerance || mag <= -tolerance) 39 | { 40 | x /= mag; y /= mag; z /= mag; 41 | return true; 42 | } 43 | else 44 | { 45 | x = 0.0; y = 0.0; z = 0.0; 46 | return false; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/geometry/Point3D.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Point3D Header 3 | */ 4 | #ifndef _POINT3D_H_ 5 | #define _POINT3D_H_ 6 | #pragma once 7 | 8 | namespace gaia3d 9 | { 10 | class Point3D 11 | { 12 | public: 13 | Point3D(); 14 | 15 | virtual ~Point3D(); 16 | 17 | public: 18 | double x, y, z; 19 | 20 | void set(double x, double y, double z); 21 | 22 | ///< 해당 점까지의 거리를 계산 23 | double squaredDistanceTo(Point3D& target); 24 | 25 | ///< 백터의 크기 26 | double magnitude(); 27 | 28 | ///< 백터를 정규화 29 | bool normalize(double tolerance = 1E-7); 30 | 31 | // operator overriding 32 | void operator = (const Point3D &q){x=q.x; y=q.y; z=q.z;} 33 | 34 | Point3D operator - (const Point3D &q) const 35 | { 36 | Point3D t; 37 | t.x=x-q.x; t.y=y-q.y; t.z=z-q.z; 38 | return t; 39 | } 40 | 41 | void operator -= (const Point3D& q) 42 | { 43 | x -= q.x; y -= q.y; z -= q.z; 44 | } 45 | 46 | Point3D operator + (const Point3D &q) const 47 | { 48 | Point3D t; 49 | t.x = x + q.x; t.y = y + q.y; t.z = z + q.z; 50 | return t; 51 | } 52 | 53 | void operator += (const Point3D& q) 54 | { 55 | x += q.x; y += q.y; z += q.z; 56 | } 57 | 58 | Point3D operator ^ (const Point3D &v) const 59 | { 60 | Point3D t; 61 | t.x = y * v.z - v.y*z; t.y = v.x*z - x * v.z; t.z = x * v.y - v.x*y; 62 | return t; 63 | } 64 | 65 | Point3D operator * (double valor) 66 | { 67 | Point3D t; 68 | t.x = x * valor; t.y = y * valor; t.z = z * valor; 69 | return t; 70 | } 71 | 72 | void operator *= (double valor) 73 | { 74 | x *= valor; y *= valor; z *= valor; 75 | } 76 | 77 | Point3D operator / (double valor) 78 | { 79 | Point3D t; 80 | t.x = x / valor; t.y = y / valor; t.z = z / valor; 81 | return t; 82 | } 83 | 84 | void operator /= (double valor) 85 | { 86 | x /= valor; y /= valor; z /= valor; 87 | } 88 | }; 89 | } 90 | 91 | #endif // _POINT3D_H_ -------------------------------------------------------------------------------- /src/geometry/PointDistributionOctree.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the PointDistributionOctree class 3 | */ 4 | #include "PointDistributionOctree.h" 5 | 6 | namespace gaia3d 7 | { 8 | PointDistributionOctree::PointDistributionOctree(PointDistributionOctree* owner) 9 | :parent(owner) 10 | { 11 | level = (parent == NULL) ? 0 : parent->level + 1; 12 | 13 | minX = minY = minZ = maxX = maxY = maxZ = 0.0; 14 | } 15 | 16 | PointDistributionOctree::~PointDistributionOctree() 17 | { 18 | clear(); 19 | } 20 | 21 | void PointDistributionOctree::makeTreeOfUnfixedDepth(double minSize, bool isObjectInOnlyOneLeaf) 22 | { 23 | double xLength = maxX - minX, yLength = maxY - minY, zLength = maxZ - minZ; 24 | double maxEdgeLength = (xLength > yLength) ? ((xLength > zLength) ? xLength : zLength) : ((yLength > zLength) ? yLength : zLength); 25 | double tolerance = minSize * 0.4; 26 | ///< 제일 긴 변이 해당 기준 임계값을 넘을때 27 | if (maxEdgeLength > minSize + tolerance) 28 | { 29 | // 1) make 8 children 30 | for (size_t i = 0; i < 8; i++) 31 | { 32 | PointDistributionOctree* child = new PointDistributionOctree(this); 33 | children.push_back(child); 34 | } 35 | 36 | // 2) set size of each child octree 37 | //this->Set_SizesSubBoxes(); 38 | double halfX, halfY, halfZ; 39 | halfX = (maxX + minX) / 2.0; 40 | halfY = (maxY + minY) / 2.0; 41 | halfZ = (maxZ + minZ) / 2.0; 42 | children[0]->setSize(minX, minY, minZ, halfX, halfY, halfZ); 43 | children[1]->setSize(halfX, minY, minZ, maxX, halfY, halfZ); 44 | children[2]->setSize(halfX, halfY, minZ, maxX, maxY, halfZ); 45 | children[3]->setSize(minX, halfY, minZ, halfX, maxY, halfZ); 46 | children[4]->setSize(minX, minY, halfZ, halfX, halfY, maxZ); 47 | children[5]->setSize(halfX, minY, halfZ, maxX, halfY, maxZ); 48 | children[6]->setSize(halfX, halfY, halfZ, maxX, maxY, maxZ); 49 | children[7]->setSize(minX, halfY, halfZ, halfX, maxY, maxZ); 50 | 51 | // 3) distribute meshes into each children 52 | distributeVerticesIntoEachChildren(isObjectInOnlyOneLeaf); 53 | 54 | // 4) Make tree for subBoxes.*** 55 | for (size_t i = 0; i < 8; i++) 56 | { 57 | if (children[i]->vertices.size() > 0) 58 | children[i]->makeTreeOfUnfixedDepth(minSize, isObjectInOnlyOneLeaf); 59 | } 60 | } 61 | } 62 | 63 | void PointDistributionOctree::distributeVerticesIntoEachChildren(bool isObjectInOnlyOneLeaf) 64 | { 65 | size_t childCount = children.size(); 66 | if (childCount == 0) 67 | return; 68 | 69 | size_t vertexCount = vertices.size(); 70 | for (size_t i = 0; i < vertexCount; i++) 71 | { 72 | gaia3d::Vertex* vertex = vertices[i]; 73 | 74 | for (size_t j = 0; j < childCount; j++) 75 | { 76 | if (children[j]->maxX < vertex->position.x || children[j]->minX > vertex->position.x || 77 | children[j]->maxY < vertex->position.y || children[j]->minY > vertex->position.y || 78 | children[j]->maxZ < vertex->position.z || children[j]->minZ > vertex->position.z) 79 | continue; 80 | 81 | children[j]->vertices.push_back(vertex); 82 | 83 | break; 84 | } 85 | } 86 | 87 | if (isObjectInOnlyOneLeaf) 88 | vertices.clear(); 89 | } 90 | 91 | void PointDistributionOctree::setOctreeId(size_t parentId, size_t orderOfChild) 92 | { 93 | if (level == 0) 94 | octreeId = 0; 95 | else 96 | octreeId = parentId * 10 + (orderOfChild + 1); 97 | 98 | size_t childCount = children.size(); 99 | for (size_t i = 0; i < childCount; i++) 100 | { 101 | children[i]->setOctreeId(octreeId, i); 102 | } 103 | } 104 | 105 | void PointDistributionOctree::getAllLeafBoxes(std::vector& container) 106 | { 107 | size_t childCount = children.size(); 108 | if (childCount >0) 109 | { 110 | for (size_t i = 0; i< childCount; i++) 111 | { 112 | children[i]->getAllLeafBoxes(container); 113 | } 114 | } 115 | else 116 | { 117 | if (vertices.size() > 0) 118 | container.push_back(this); 119 | } 120 | } 121 | 122 | PointDistributionOctree* PointDistributionOctree::getIntersectedLeafOctree(Vertex* vertex) 123 | { 124 | if (maxX < vertex->position.x || minX > vertex->position.x || 125 | maxY < vertex->position.y || minY > vertex->position.y || 126 | maxZ < vertex->position.z || minZ > vertex->position.z) 127 | return NULL; 128 | 129 | if (children.empty()) 130 | return this; 131 | 132 | size_t childCount = children.size(); 133 | for (size_t i = 0; i < childCount; i++) 134 | { 135 | PointDistributionOctree* child = children[i]->getIntersectedLeafOctree(vertex); 136 | if (child != NULL) 137 | return child; 138 | } 139 | 140 | return NULL; 141 | } 142 | 143 | void PointDistributionOctree::clear() 144 | { 145 | size_t childCount = children.size(); 146 | for (size_t i = 0; i < childCount; i++) 147 | { 148 | children[i]->clear(); 149 | delete children[i]; 150 | } 151 | children.clear(); 152 | 153 | vertices.clear(); 154 | } 155 | } -------------------------------------------------------------------------------- /src/geometry/PointDistributionOctree.h: -------------------------------------------------------------------------------- 1 | /** 2 | * PointDistributionOctree Header 3 | */ 4 | #ifndef _POINTDISTRIBUTIONOCTREE_H_ 5 | #define _POINTDISTRIBUTIONOCTREE_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "Vertex.h" 12 | 13 | namespace gaia3d 14 | { 15 | class PointDistributionOctree 16 | { 17 | public: 18 | PointDistributionOctree(PointDistributionOctree* owner); 19 | ~PointDistributionOctree(); 20 | 21 | size_t octreeId; 22 | 23 | PointDistributionOctree* parent; 24 | std::vector children; 25 | 26 | unsigned char level; 27 | 28 | std::vector vertices; 29 | 30 | double minX, minY, minZ, maxX, maxY, maxZ; 31 | 32 | void setSize(double xMin, double yMin, double zMin, double xMax, double yMax, double zMax) 33 | { 34 | minX = xMin; minY = yMin; minZ = zMin; maxX = xMax; maxY = yMax; maxZ = zMax; 35 | } 36 | 37 | void makeTreeOfUnfixedDepth(double minSize, bool isObjectInOnlyOneLeaf); 38 | 39 | void distributeVerticesIntoEachChildren(bool isObjectInOnlyOneLeaf); 40 | 41 | void setOctreeId(size_t parentId = 0, size_t orderOfChild = 0); 42 | 43 | void getAllLeafBoxes(std::vector& container); 44 | 45 | ///< 어느 leaf octree box와 겹치는가 46 | PointDistributionOctree* getIntersectedLeafOctree(Vertex* vertex); 47 | 48 | void clear(); 49 | }; 50 | } 51 | 52 | #endif // _POINTDISTRIBUTIONOCTREE_H_ 53 | -------------------------------------------------------------------------------- /src/geometry/Quadtree.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Quadtree class 3 | */ 4 | #include "Quadtree.h" 5 | 6 | namespace gaia3d 7 | { 8 | Quadtree::Quadtree(Quadtree* owner) 9 | :parent(owner) 10 | { 11 | level = (parent == NULL) ? 0 : parent->level + 1; 12 | 13 | } 14 | 15 | Quadtree::~Quadtree() 16 | { 17 | size_t childCount = children.size(); 18 | for(size_t i = 0; i < childCount; i++) 19 | delete children[i]; 20 | children.clear(); 21 | 22 | legos.clear(); 23 | } 24 | 25 | void Quadtree::getAllLeafQuadtrees(std::vector& leafContainer, bool onlyNotEmptyLeaf) 26 | { 27 | size_t childCount = children.size(); 28 | if(childCount > 0) 29 | { 30 | for(size_t i = 0; i < childCount; i++) 31 | children[i]->getAllLeafQuadtrees(leafContainer, onlyNotEmptyLeaf); 32 | } 33 | else 34 | { 35 | if(onlyNotEmptyLeaf) 36 | { 37 | if(legos.size() > 0) 38 | leafContainer.push_back(this); 39 | } 40 | else 41 | leafContainer.push_back(this); 42 | } 43 | } 44 | 45 | void Quadtree::makeTreeOfUnfixedDepth(double minLeafSize, bool isObjectInOnlyOneLeaf) 46 | { 47 | double xLength = maxX - minX, yLength = maxY - minY; 48 | double maxEdgeLength = (xLength > yLength) ? xLength : yLength; 49 | double tolerance = minLeafSize * 0.4; 50 | 51 | if(maxEdgeLength > minLeafSize + tolerance) 52 | { 53 | for(size_t i = 0; i < 4; i++) 54 | { 55 | children.push_back(new Quadtree(this)); 56 | } 57 | 58 | double halfX, halfY; 59 | halfX= (maxX+minX)/2.0; 60 | halfY= (maxY+minY)/2.0; 61 | children[0]->setSize(minX, minY, halfX, halfY); 62 | children[1]->setSize(halfX, minY, maxX, halfY); 63 | children[2]->setSize(halfX, halfY,maxX, maxY); 64 | children[3]->setSize(minX, halfY, halfX, maxY); 65 | 66 | distributeLegosIntoEachChildren(isObjectInOnlyOneLeaf); 67 | 68 | for(size_t i = 0; i < 4; i++) 69 | { 70 | if(children[i]->legos.size() == 0) 71 | continue; 72 | 73 | children[i]->makeTreeOfUnfixedDepth(minLeafSize, isObjectInOnlyOneLeaf); 74 | } 75 | } 76 | } 77 | 78 | void Quadtree::setQuadtreeId(size_t parentId, size_t orderOfChild) 79 | { 80 | if(level == 0) 81 | quadtreeId = 0; 82 | else 83 | quadtreeId = parentId*10 + (orderOfChild+1); 84 | 85 | size_t childCount = children.size(); 86 | for(size_t i = 0; i < childCount; i++) 87 | { 88 | children[i]->setQuadtreeId(quadtreeId, i); 89 | } 90 | } 91 | 92 | void Quadtree::distributeLegosIntoEachChildren(bool isObjectInOnlyOneLeaf) 93 | { 94 | size_t childCount = children.size(); 95 | if(childCount == 0) 96 | return; 97 | 98 | size_t legoCount = legos.size(); 99 | double centerX, centerY; 100 | for(size_t i = 0; i < legoCount; i++) 101 | { 102 | centerX = (legos[i]->minX + legos[i]->maxX)*0.5; 103 | centerY = (legos[i]->minY + legos[i]->maxY)*0.5; 104 | 105 | for(size_t j = 0; j < childCount; j++) 106 | { 107 | if( centerX >= children[j]->maxX || centerX <= children[j]->minX || 108 | centerY >= children[j]->maxY || centerY <= children[j]->minY ) 109 | continue; 110 | 111 | children[j]->legos.push_back(legos[i]); 112 | 113 | if(isObjectInOnlyOneLeaf) 114 | { 115 | legos.erase(legos.begin() + i); 116 | legoCount--; 117 | i--; 118 | } 119 | } 120 | } 121 | } 122 | } -------------------------------------------------------------------------------- /src/geometry/Quadtree.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Quadtree Header 3 | */ 4 | #ifndef _QUADTREE_H_ 5 | #define _QUADTREE_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "LegoBlock.h" 12 | 13 | namespace gaia3d 14 | { 15 | class Quadtree 16 | { 17 | public: 18 | Quadtree(Quadtree* owner); 19 | 20 | virtual ~Quadtree(); 21 | 22 | public: 23 | Quadtree* parent; 24 | 25 | std::vector children; 26 | 27 | std::vector legos; 28 | 29 | unsigned char level; 30 | 31 | size_t quadtreeId; 32 | 33 | double minX, minY, maxX, maxY; 34 | 35 | void setSize(double xMin, double yMin, double xMax, double yMax) {minX = xMin, minY = yMin, maxX = xMax, maxY = yMax;} 36 | 37 | void getAllLeafQuadtrees(std::vector& leafContainer, bool onlyNotEmptyLeaf = true); 38 | 39 | void makeTreeOfUnfixedDepth(double minLeafSize, bool isObjectInOnlyOneLeaf); 40 | 41 | void setQuadtreeId(size_t parentId = 0, size_t orderOfChild = 0); 42 | 43 | void distributeLegosIntoEachChildren(bool isObjectInOnlyOneLeaf); 44 | }; 45 | } 46 | 47 | #endif // _QUADTREE_H_ 48 | -------------------------------------------------------------------------------- /src/geometry/Quaternion.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Quaternion class 3 | */ 4 | #include "Quaternion.h" 5 | 6 | #include 7 | 8 | namespace gaia3d 9 | { 10 | Quaternion::Quaternion(void) 11 | { 12 | } 13 | 14 | 15 | Quaternion::~Quaternion(void) 16 | { 17 | } 18 | 19 | void Quaternion::set(double sw, double sx, double sy, double sz) 20 | { 21 | w=sw; x=sx; y=sy; z=sz; 22 | } 23 | 24 | double Quaternion::module() 25 | { 26 | return (sqrt(w*w+x*x+y*y+z*z)); 27 | } 28 | 29 | void Quaternion::unitary() 30 | { 31 | double modul=this->module(); 32 | w/=modul; 33 | x/=modul; 34 | y/=modul; 35 | z/=modul; 36 | } 37 | 38 | void Quaternion::rotation(double ang_radians) 39 | { 40 | this->unitary(); 41 | 42 | w=cos(ang_radians/2.0); 43 | x*=sin(ang_radians/2.0); 44 | y*=sin(ang_radians/2.0); 45 | z*=sin(ang_radians/2.0); 46 | } 47 | 48 | Quaternion Quaternion::conjugate() 49 | { 50 | Quaternion q; 51 | q.w=w; q.x=-x; q.y=-y; q.z=-z; 52 | return q; 53 | } 54 | 55 | double Quaternion::angleFrom(Quaternion v) 56 | { 57 | // a*b = |a|*|b|*cos(alfa) 58 | // Nota: a*b = ab 59 | // Nota: |a|*|b| = ab2 60 | double ang; 61 | double ab, ab2; 62 | double m_pi = 3.14159265358979323846; 63 | 64 | ab= x*v.x+ y*v.y+ z*v.z; 65 | ab2= module()*v.module(); 66 | 67 | if(ab/ab2<=-1.0)ang=m_pi; 68 | else 69 | { 70 | if(ab/ab2>=1.0)ang=0.0; 71 | else ang=cos(ab/ab2); 72 | } 73 | return ang;// Sempre dona ang petit. L'ang entre(1,1,1) i (-1,-1,-1) dona zero...comprobar.*** 74 | } 75 | 76 | bool Quaternion::isParallelTo(Quaternion v) 77 | { 78 | // Perque 2 vectors siguin paralels => prod vectorial = zero.*** 79 | bool es_paralel; 80 | Quaternion vProd; 81 | double error=10E-11; 82 | 83 | vProd=this->operator^(v); 84 | 85 | if(vProd.x >= error || vProd.x <= -error || 86 | vProd.y >= error || vProd.y <= -error || 87 | vProd.z >= error || vProd.z <= -error) 88 | es_paralel=false; 89 | else 90 | es_paralel=true; 91 | 92 | return es_paralel; 93 | } 94 | 95 | bool Quaternion::signsAreOppositeToEachOther(double a, double b) 96 | { 97 | // Aquesta funcio serveix per la seguent funcio: bool Es_Oposat_a(Quaternion v).*** 98 | bool son_oposats; 99 | 100 | if(a>0.0 && b<0.0)son_oposats=true; 101 | else 102 | { 103 | if(a<0.0 && b>0.0)son_oposats=true; 104 | else son_oposats=false; 105 | } 106 | return son_oposats; 107 | } 108 | 109 | bool Quaternion::isOppositeTo(Quaternion v) 110 | { 111 | bool son_oposats; 112 | bool oposat_x, oposat_y, oposat_z; 113 | double tolerance=10E-13; 114 | 115 | // x.*** 116 | if(x >= tolerance || x <= -tolerance) 117 | { 118 | if(this->signsAreOppositeToEachOther(x, v.x))oposat_x=true; 119 | else oposat_x=false; 120 | } 121 | else 122 | { 123 | if(v.x >= tolerance || v.x <= - tolerance) oposat_x=false; 124 | else oposat_x=true; 125 | } 126 | 127 | // y.*** 128 | if(y >= tolerance || y <= -tolerance) 129 | { 130 | if(this->signsAreOppositeToEachOther(y, v.y))oposat_y=true; 131 | else oposat_y=false; 132 | } 133 | else 134 | { 135 | if(v.y >= tolerance || v.y <= -tolerance) oposat_y=false; 136 | else oposat_y=true; 137 | } 138 | 139 | // z.*** 140 | if(z >= tolerance || z <= -tolerance) 141 | { 142 | if(this->signsAreOppositeToEachOther(z, v.z))oposat_z=true; 143 | else oposat_z=false; 144 | } 145 | else 146 | { 147 | if(v.z >= tolerance || v.z <= -tolerance) oposat_z=false; 148 | else oposat_z=true; 149 | } 150 | 151 | if(oposat_x && oposat_y && oposat_z)son_oposats=true; 152 | else son_oposats=false; 153 | return son_oposats; 154 | } 155 | 156 | double Quaternion::angleFromXAxis() 157 | { 158 | // Funcio 2D.*** 159 | double ang; 160 | double tolerance=10E-11; 161 | double m_pi = 3.14159265358979323846; 162 | 163 | double xa, ya; 164 | 165 | xa=x*100000.0;// Per salvar vectors molt petits.*** 166 | ya=y*100000.0;// Per salvar vectors molt petits.*** 167 | 168 | // Hem de salvar divisions per zero.*** 169 | 170 | if(xa >= tolerance || xa <= -tolerance) 171 | { 172 | ang=atan(ya/xa); 173 | // Hem de fer un post-tractament.*** 174 | if(xa>=0.0) 175 | { 176 | if(ya<0.0)ang+=2.0*m_pi; 177 | } 178 | else 179 | { 180 | if(ya>0.0)ang=m_pi+ang; 181 | else ang+=m_pi;// Aquesta sentencia es igual a l'anterior.*** 182 | } 183 | } 184 | else 185 | { 186 | // El vector sembla vertical.*** 187 | if(ya>0.0)ang=m_pi*0.5; 188 | else ang=m_pi*1.5; 189 | } 190 | return ang; 191 | } 192 | 193 | double Quaternion::projectionAngleFrom(Quaternion v) 194 | { 195 | // Funcio 2D.*** 196 | // L'ang que busquem es per anar desde el Meu_Vector cap a v.*** 197 | // L'ang pot ser positiu o negatiu.*** 198 | double ang_v, ang_meu_v; 199 | double ang; 200 | double m_pi = 3.14159265358979323846; 201 | 202 | ang_v=v.angleFromXAxis(); 203 | ang_meu_v=this->angleFromXAxis(); 204 | // Hem de fer un tractament.*** 205 | if(ang_meu_v>ang_v)ang_v+=2.0*m_pi; 206 | ang=ang_v-ang_meu_v; 207 | if(ang>m_pi)ang-=m_pi*2.0; 208 | 209 | return ang; 210 | } 211 | 212 | void Quaternion::rotation(double ang, double axis_x, double axis_y, double axis_z) 213 | { 214 | // Code copied From Carve.*** 215 | double tolerance = 10E-13; 216 | double s = sqrt(axis_x*axis_x + axis_y*axis_y + axis_z*axis_z); 217 | if (s >= tolerance || s<= -tolerance) { 218 | double c = 1.0 / s; 219 | double omega = -0.5 * ang; 220 | s = sin(omega); 221 | x = axis_x * c * s; 222 | y = axis_y * c * s; 223 | z = axis_z * c * s; 224 | w = cos(omega); 225 | unitary(); 226 | } else { 227 | x = y = z = 0.0; 228 | w = 1.0; 229 | } 230 | } 231 | 232 | void Quaternion::rotation(double ang, Point3D *axis) 233 | { 234 | rotation(ang, axis->x, axis->y, axis->z); 235 | } 236 | 237 | TSentitPerfil Quaternion::sense2DFrom(Quaternion v) 238 | { 239 | TSentitPerfil sentit; 240 | if(this->projectionAngleFrom(v)>=0.0)sentit=CCW; 241 | else sentit=CW; 242 | return sentit; 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /src/geometry/Quaternion.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Quaternion Header 3 | */ 4 | #ifndef _QUATERNION_H_ 5 | #define _QUATERNION_H_ 6 | #pragma once 7 | 8 | #include "Point3D.h" 9 | 10 | namespace gaia3d 11 | { 12 | enum TSentitPerfil {DESCONEGUT, CW, CCW}; 13 | 14 | class Quaternion 15 | { 16 | public: 17 | 18 | double w, x, y, z; 19 | 20 | Quaternion(void); 21 | ~Quaternion(void); 22 | 23 | void operator = (const Quaternion &q){w=q.w; x=q.x; y=q.y; z=q.z;} 24 | 25 | Quaternion operator *(const Quaternion &q)const 26 | { 27 | Quaternion t; 28 | t.w=(w*q.w - x*q.x - y*q.y - z*q.z); 29 | t.x=(w*q.x + x*q.w + y*q.z - z*q.y); 30 | t.y=(w*q.y - x*q.z + y*q.w + z*q.x); 31 | t.z=(w*q.z + x*q.y - y*q.x + z*q.w); 32 | return t; 33 | } 34 | 35 | Quaternion operator / (double d) const 36 | { 37 | Quaternion t; 38 | t.w=w/d; t.x=x/d; t.y=y/d; t.z=z/d; 39 | return t; 40 | } 41 | 42 | Quaternion operator + (const Quaternion &q) const 43 | { 44 | Quaternion t; 45 | t.w=w+q.w; t.x=x+q.x; t.y=y+q.y; t.z=z+q.z; 46 | return t; 47 | } 48 | 49 | Quaternion operator - (const Quaternion &q) const 50 | { 51 | Quaternion t; 52 | t.w=w-q.w; t.x=x-q.x; t.y=y-q.y; t.z=z-q.z; 53 | return t; 54 | } 55 | 56 | Quaternion operator ^ (const Quaternion &q) const // Prod Vectorial.*** 57 | { 58 | Quaternion t; 59 | t.w=0.0; t.x=y*q.z-q.y*z; t.y=q.x*z-x*q.z; t.z=x*q.y-q.x*y; 60 | return t; 61 | } 62 | 63 | double operator % (const Quaternion &q) const // Prod Escalar.*** 64 | { 65 | double prodEscalar; 66 | prodEscalar=w*q.w + x*q.x + y*q.y + z*q.z; 67 | return prodEscalar; 68 | } 69 | 70 | void set(double sw, double sx, double sy, double sz); 71 | double module(); // module.*** 72 | void unitary(); // unitary.*** 73 | void rotation(double ang_radians); 74 | Quaternion conjugate(); ///< 허수부의 부호 바꾸기 75 | double angleFrom(Quaternion v); // angle_respectVector.*** 76 | bool isParallelTo(Quaternion v); // isParalelTo 77 | bool signsAreOppositeToEachOther(double a, double b);// areThereOppositeSign? 78 | bool isOppositeTo(Quaternion v);// isOppositeTo? 79 | double angleFromXAxis();// angle2d_respectXAxis 80 | double projectionAngleFrom(Quaternion v); // angle2d_respectVector 81 | void rotation(double ang, double axis_x, double axis_y, double axis_z); 82 | void rotation(double ang, Point3D *axis); 83 | TSentitPerfil sense2DFrom(Quaternion v); // sense2d_respectVector.*** 84 | }; 85 | } 86 | 87 | #endif // _QUATERNION_H_ -------------------------------------------------------------------------------- /src/geometry/Surface.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Surface class 3 | */ 4 | #include "Surface.h" 5 | 6 | namespace gaia3d 7 | { 8 | Surface::Surface() 9 | { 10 | bExterior = false; 11 | } 12 | 13 | Surface::~Surface() 14 | { 15 | size_t triangleCount = triangles.size(); 16 | for (size_t i = 0; i < triangleCount; i++) 17 | { 18 | delete triangles[i]; 19 | } 20 | triangles.clear(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/geometry/Surface.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Surface Header 3 | */ 4 | #ifndef _SURFACE_H_ 5 | #define _SURFACE_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "Triangle.h" 12 | 13 | namespace gaia3d 14 | { 15 | ///< Surface는 triangle의 집합으로 이루어져 있다. 16 | class Surface 17 | { 18 | public: 19 | Surface(); 20 | 21 | virtual ~Surface(); 22 | 23 | protected: 24 | std::vector triangles; 25 | 26 | ///< 자신이 가지고 있는 triangle중 하나라도 외부에 노출되어 있다면, 이 surface는 외부에 노출된 surface이다. 27 | bool bExterior; 28 | 29 | public: 30 | std::vector& getTriangles() { return triangles; } 31 | 32 | bool isExterior() { return bExterior; } 33 | 34 | void setIsExterior(bool bExterior) { this->bExterior = bExterior; } 35 | }; 36 | } 37 | 38 | #endif // _SURFACE_H_ -------------------------------------------------------------------------------- /src/geometry/Triangle.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Triangle class 3 | */ 4 | #include "Triangle.h" 5 | 6 | namespace gaia3d 7 | { 8 | 9 | Triangle::Triangle() 10 | { 11 | } 12 | 13 | Triangle::~Triangle() 14 | { 15 | } 16 | 17 | void Triangle::alignVertexNormalsToPlaneNormal() 18 | { 19 | vertex[0]->normal.set(this->normal.x, this->normal.y, this->normal.z); 20 | vertex[1]->normal.set(this->normal.x, this->normal.y, this->normal.z); 21 | vertex[2]->normal.set(this->normal.x, this->normal.y, this->normal.z); 22 | } 23 | } -------------------------------------------------------------------------------- /src/geometry/Triangle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Triangle Header 3 | */ 4 | #ifndef _TRIANGLE_H_ 5 | #define _TRIANGLE_H_ 6 | #pragma once 7 | 8 | #include 9 | 10 | #include "Vertex.h" 11 | 12 | namespace gaia3d 13 | { 14 | class Triangle 15 | { 16 | public: 17 | Triangle(); 18 | 19 | ~Triangle(); 20 | 21 | protected: 22 | ///< 그래픽 카드의 element 모드를 위한 변수들 23 | size_t vertexIndex[3]; 24 | 25 | Vertex* vertex[3]; 26 | 27 | Point3D normal; 28 | 29 | public: 30 | void setVertices(Vertex* vertex0, Vertex* vertex1, Vertex* vertex2) {vertex[0] = vertex0; vertex[1]= vertex1; vertex[2] = vertex2;} 31 | 32 | Vertex** getVertices() {return vertex;} 33 | 34 | void setVertexIndices(size_t id0, size_t id1, size_t id2) {vertexIndex[0] = id0; vertexIndex[1] = id1; vertexIndex[2] = id2;} 35 | 36 | size_t* getVertexIndices() {return vertexIndex;} 37 | 38 | Point3D* getNormal() {return &normal;} 39 | 40 | void setNormal(double x, double y, double z) {this->normal.set(x, y, z);} 41 | 42 | ///< plane normal을 vertex normal에 뒤집어씌운다 43 | void alignVertexNormalsToPlaneNormal(); 44 | 45 | }; 46 | } 47 | 48 | #endif // _TRIANGLE_H_ 49 | -------------------------------------------------------------------------------- /src/geometry/TrianglePolyhedron.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the TrianglePolyhedron class 3 | */ 4 | #include "TrianglePolyhedron.h" 5 | #include "predefinition.h" 6 | #include "../converter/LogWriter.h" 7 | 8 | #include 9 | 10 | namespace gaia3d 11 | { 12 | TrianglePolyhedron::TrianglePolyhedron() 13 | { 14 | refInfo.model = NULL; 15 | refInfo.mat.identity(); 16 | refInfo.modelIndex = MaxUnsignedLong; 17 | 18 | hasNormals = hasTextureCoordinates = false; 19 | 20 | colorMode = NoColor; 21 | singleColor = 0UL; 22 | 23 | id = MaxUnsignedLong; 24 | } 25 | 26 | TrianglePolyhedron::~TrianglePolyhedron() 27 | { 28 | size_t vertexCount = vertices.size(); 29 | for(size_t i = 0; i < vertexCount; i++) 30 | delete vertices[i]; 31 | vertices.clear(); 32 | 33 | size_t surfaceCount = surfaces.size(); 34 | for(size_t i = 0; i < surfaceCount; i++) 35 | delete surfaces[i]; 36 | surfaces.clear(); 37 | 38 | size_t vboCount = vbos.size(); 39 | for(size_t i = 0; i < vboCount; i++) 40 | delete vbos[i]; 41 | vbos.clear(); 42 | } 43 | 44 | void TrianglePolyhedron::addStringAttribute(std::string keyString, std::string valueString) 45 | { 46 | stringAttributes.insert(std::map::value_type(keyString, valueString)); 47 | } 48 | 49 | bool TrianglePolyhedron::doesStringAttributeExist(std::string keyString) 50 | { 51 | if (stringAttributes.find(keyString) == stringAttributes.end()) 52 | return false; 53 | 54 | return true; 55 | } 56 | 57 | std::string TrianglePolyhedron::getStringAttribute(std::string keyString) 58 | { 59 | if (!doesStringAttributeExist(keyString)) 60 | return std::string(); 61 | 62 | return stringAttributes[keyString]; 63 | } 64 | 65 | bool TrianglePolyhedron::doesHaveAnyExteriorSurface() 66 | { 67 | size_t surfaceCount = surfaces.size(); 68 | for(size_t i = 0; i < surfaceCount; i++) 69 | { 70 | if(surfaces[i]->isExterior()) 71 | return true; 72 | } 73 | 74 | return false; 75 | } 76 | 77 | void TrianglePolyhedron::TexCoord_Flip_Y() 78 | { 79 | if (hasTextureCoordinates) 80 | { 81 | gaia3d::Surface* surface; 82 | gaia3d::Triangle* triangle; 83 | gaia3d::Vertex** vertices; 84 | gaia3d::Vbo* vbo; 85 | 86 | size_t surfaceCount = surfaces.size(); 87 | for (size_t i = 0; i < surfaceCount; i++) 88 | { 89 | surface = surfaces[i]; 90 | size_t triangleCount = surface->getTriangles().size(); 91 | LogWriter::getLogWriter()->addContents("Total Count of triangle : " + std::to_string(triangleCount), true); 92 | for (size_t j = 0; j < triangleCount; j++) 93 | { 94 | triangle = surface->getTriangles()[j]; 95 | vertices = triangle->getVertices(); 96 | for (size_t k = 0; k < 3; k++) 97 | { 98 | vertices[k]->textureCoordinate[1] = 1.0 - vertices[k]->textureCoordinate[1]; 99 | //std::cout << k <<":"<< vertices[k]->textureCoordinate[0] << ":" << vertices[k]->textureCoordinate[1] << std::endl; 100 | LogWriter::getLogWriter()->addContents(std::to_string(k) + ":" + std::to_string(vertices[k]->textureCoordinate[0]) + ":" + std::to_string(vertices[k]->textureCoordinate[1]), true); 101 | } 102 | } 103 | } 104 | 105 | size_t vboCount = vbos.size(); 106 | if (vboCount == 0) return; 107 | LogWriter::getLogWriter()->addContents("Total Count of VBO : " + std::to_string(vboCount), true); 108 | for (size_t i = 0; i < vboCount; i++) 109 | { 110 | vbo = vbos[i]; 111 | size_t vertexCount = vbo->vertices.size(); 112 | for (size_t j = 0; j < vertexCount; j++) 113 | { 114 | vbo->vertices[j]->textureCoordinate[1] = 1.0 - vbo->vertices[j]->textureCoordinate[1]; 115 | LogWriter::getLogWriter()->addContents(std::to_string(j) + ":" + std::to_string(vbo->vertices[j]->textureCoordinate[0]) + ":" + std::to_string(vbo->vertices[j]->textureCoordinate[1]), true); 116 | } 117 | } 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /src/geometry/TrianglePolyhedron.h: -------------------------------------------------------------------------------- 1 | /** 2 | * TrianglePolyhedron Header 3 | */ 4 | #ifndef _TRIANGLEPOLYHEDRON_H_ 5 | #define _TRIANGLEPOLYHEDRON_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Surface.h" 13 | #include "Matrix4.h" 14 | #include "ColorU4.h" 15 | 16 | #include "BoundingBox.h" 17 | #include "Vbo.h" 18 | 19 | namespace gaia3d 20 | { 21 | ///< TrianglePolyhedron은 vertices와 surfaces로 이루어져 있다. 22 | class TrianglePolyhedron 23 | { 24 | public: 25 | TrianglePolyhedron(); 26 | 27 | virtual ~TrianglePolyhedron(); 28 | 29 | struct REFERENCE_INFO 30 | { 31 | ///< 어떤 모델을 원본으로 가지는가 32 | TrianglePolyhedron* model; 33 | Matrix4 mat; 34 | size_t modelIndex; 35 | }; 36 | 37 | protected: 38 | std::vector vertices; 39 | std::vector surfaces; 40 | 41 | ///< 추가로 설정할 속성들을 (이름, 값)의 쌍으로 저장한다. 42 | std::map stringAttributes; 43 | 44 | ///< texture가 있으면 normal이 거의 의미가 없다. 45 | bool hasNormals; 46 | bool hasTextureCoordinates; 47 | ColorMode colorMode; ///< non/single/colors on vertices 48 | 49 | ColorU4 singleColor; 50 | 51 | REFERENCE_INFO refInfo; 52 | 53 | BoundingBox bbox; 54 | ///< writing 직전에 vbo형태로 쓰게 된다. 55 | std::vector vbos; 56 | ///< 메쉬를 구분하는 unique 숫자 57 | size_t id; 58 | 59 | 60 | 61 | public: 62 | ///< surface의 리스트를 가져온다 63 | std::vector& getSurfaces() { return surfaces; } 64 | ///< vertex의 리스트를 가져온다 65 | std::vector& getVertices() { return vertices; } 66 | ///< trianglepolyhedron에 해당 속성과 값을 추가한다 67 | void addStringAttribute(std::string keyString, std::string valueString); 68 | ///< trianglepolyhedron이 해당 속성을 가지고 있는지 확인한다 69 | bool doesStringAttributeExist(std::string keyString); 70 | ///< trianglepolyhedron에서 해당 속성의 값을 가져온다 71 | std::string getStringAttribute(std::string keyString); 72 | ///< trianglepolyhedron이 가지고 있는 속성값을 가져온다 73 | std::map& getStringAttributes() { return stringAttributes; } 74 | 75 | ///< trianglepolyhedron이 normal값을 가지고 있는지를 설정한다 76 | void setHasNormals(bool bHas) { hasNormals = bHas; } 77 | ///< trianglepolyhedron이 normal값을 가지고 있는지를 확인한다 78 | bool doesThisHaveNormals() { return hasNormals; } 79 | ///< trianglepolyhedron이 texture coordinate를 가지고 있다고 설정한다 80 | void setHasTextureCoordinates(bool bHas) { hasTextureCoordinates = bHas; } 81 | ///< trianglepolyhedron에 texture coordinate가 설정되어있는지의 여부를 얻는다 82 | bool doesThisHaveTextureCoordinates() { return hasTextureCoordinates; } 83 | ///< trianglepolyhedron에 colormode를 설정한다 84 | void setColorMode(ColorMode mode) { colorMode = mode; } 85 | ///< trianglepolyhedron에 설정된 colormode 값을 얻는다 86 | ColorMode getColorMode() { return colorMode; } 87 | ///< trianglepolyhedron에 색깔을 설정한다. 88 | void setSingleColor(ColorU4 color) { singleColor = color; } 89 | ///< trianglepolyhedron에 설정된 색깔을 얻는다 90 | ColorU4 getSingleColor() { return singleColor; } 91 | ///< reference model 정보를 얻는다 92 | gaia3d::TrianglePolyhedron::REFERENCE_INFO& getReferenceInfo() { return refInfo; } 93 | ///< reference model을 설정한다 94 | void setReferenceModel(TrianglePolyhedron* model) { refInfo.model = model; } 95 | ///< 원래의 referenceModel를 얻으려면 이 메트릭스로 연산하면 된다 96 | void setReferenceMatrix(Matrix4& matrix) 97 | { 98 | refInfo.mat.set(matrix); 99 | } 100 | ///< ReferenceModel의 id를 index로 정한다 101 | void setReferenceModelIndex(size_t id) { refInfo.modelIndex = id; } 102 | ///< trianglepolyheron의 boundingbox를 얻는다 103 | BoundingBox& getBoundingBox() { return bbox; } 104 | ///< 이 trianglepolyhedron을 이루는 vbo들의 리스트를 얻는다 105 | std::vector& getVbos() { return vbos; } 106 | ///< 고유 identifier를 설정한다 107 | void setId(size_t indexNumber) { id = indexNumber; } 108 | ///< 고유 identifier를 준다 109 | size_t getId() { return id; } 110 | ///< 바깥으로 노출된 Surface가 있는가 111 | bool doesHaveAnyExteriorSurface(); 112 | 113 | void TexCoord_Flip_Y(); 114 | }; 115 | } 116 | 117 | #endif // _TRIANGLEPOLYHEDRON_H_ -------------------------------------------------------------------------------- /src/geometry/Vbo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Vbo Header 3 | */ 4 | #ifndef _VBO_H_ 5 | #define _VBO_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "predefinition.h" 12 | #include "Vertex.h" 13 | 14 | namespace gaia3d 15 | { 16 | class Vertex; 17 | ///< 해당 구조체는 그래픽카드가 이해하는 데이터로 변환하기 쉬운 형식으로 이루어져 있다. 18 | ///< Vbo로 변환할 때, 삼각형의 가장 큰 변을 삼각형의 크기로 간주하고 이를 기준으로 정렬해서 크기순으로 정렬한다. 19 | ///< Vbo로 변환되는 단위는 삼각형 단위이면서, 삼각형들을 이루는 vertex의 총 수가 65532개를 넘지 않도록 변환한다. 20 | struct Vbo 21 | { 22 | std::vector vertices; 23 | std::vector indices; 24 | double triangleSizeThresholds[TriangleSizeLevels]; 25 | unsigned int indexMarker[TriangleSizeLevels]; 26 | Vbo() 27 | { 28 | double value[TriangleSizeLevels] = TriangleSizeThresholds; 29 | std::memcpy(triangleSizeThresholds, value, sizeof(double)*TriangleSizeLevels); 30 | } 31 | }; 32 | } 33 | 34 | #endif // _VBO_H_ 35 | -------------------------------------------------------------------------------- /src/geometry/Vertex.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Vertex class 3 | */ 4 | #include "Vertex.h" 5 | 6 | namespace gaia3d 7 | { 8 | Vertex::Vertex() 9 | { 10 | textureCoordinate[0] = textureCoordinate[1] = 0.0; 11 | color = DefaultColor; 12 | } 13 | 14 | Vertex::~Vertex() 15 | { 16 | } 17 | } -------------------------------------------------------------------------------- /src/geometry/Vertex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Vertex Header 3 | */ 4 | #ifndef _VERTEX_H_ 5 | #define _VERTEX_H_ 6 | #pragma once 7 | 8 | #include "Point3D.h" 9 | #include "ColorU4.h" 10 | 11 | namespace gaia3d 12 | { 13 | class Vertex 14 | { 15 | public: 16 | Vertex(); 17 | 18 | virtual ~Vertex(); 19 | 20 | public: 21 | ///< vertex의 위치 22 | Point3D position; 23 | ///< vertex의 normal 24 | Point3D normal; 25 | ///< vertex의 tetureCoordinate. 2차원 좌표. 각각 0부터 1사이의 값을 가진다. 26 | double textureCoordinate[2]; 27 | ///< vertex의 색 28 | ColorU4 color; 29 | }; 30 | } 31 | #endif // _VERTEX_H_ -------------------------------------------------------------------------------- /src/process/ConversionProcessor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Conversion Processor Header 3 | */ 4 | #ifndef _CONVERSIONPROCESSOR_H_ 5 | #define _CONVERSIONPROCESSOR_H_ 6 | #pragma once 7 | 8 | #ifdef _WIN32 9 | #define APIENTRY __stdcall 10 | #endif 11 | 12 | #include 13 | 14 | // confirm that GLAD didn't include windows.h 15 | #ifdef _WINDOWS_ 16 | #error windows.h was included! 17 | #endif 18 | 19 | #include 20 | 21 | #if USE_NATIVE_OSMESA 22 | #define GLFW_EXPOSE_NATIVE_OSMESA 23 | #include 24 | #endif 25 | 26 | #include 27 | #include 28 | 29 | #include "../geometry/TrianglePolyhedron.h" 30 | #include "../geometry/BoundingBox.h" 31 | #include "../geometry/ColorU4.h" 32 | #include "../geometry/OctreeBox.h" 33 | #include "../geometry/PointDistributionOctree.h" 34 | #include "ProcessSetting.h" 35 | 36 | 37 | class SceneControlVariables; 38 | 39 | class ConversionProcessor 40 | { 41 | public: 42 | ConversionProcessor(); 43 | 44 | virtual ~ConversionProcessor(); 45 | 46 | void setNsmSettingIndex(unsigned char index) { settings.netSurfaceMeshSettingIndex = index; } 47 | void setUseNsm(bool bUse) { settings.bUseNsm = bUse; } 48 | void setExteriorExtraction(bool bDo) { settings.bExtractExterior = bDo; } 49 | void setVisibilityIndexing(bool bDo) { settings.bOcclusionCulling = bDo; } 50 | void setLeafSpatialOctreeSize(float fSize) { settings.leafSpatialOctreeSize = fSize; } 51 | void setTextureCoordinateVFlip(bool bDo) { settings.bFlipTextureCoordinateV = bDo; } 52 | void setInteriorVisibilityIndexingCameraStep(float step) { settings.interiorVisibilityIndexingCameraStep = step; } 53 | void setExteriorVisibilityIndexingCameraStep(float step) { settings.exteriorVisibilityIndexingCameraStep = step; } 54 | void setInteriorVisibilityIndexingOctreeDepth(unsigned char depth) { settings.interiorVisibilityIndexingOctreeDepth = depth; } 55 | void setExteriorVisibilityIndexingOctreeDepth(unsigned char depth) { settings.exteriorVisibilityIndexingOctreeDepth = depth; } 56 | void clearNsmSettings() { settings.clearNsmSettings(); } 57 | void setSkinLevel(unsigned char level) { settings.netSurfaceMeshSettingIndex = level; } 58 | void setAlignPostionToCenter(bool bAlign) { settings.bAlignPositionToCenter = bAlign; } 59 | void setMeshType(int type) { settings.meshType = type; } 60 | int getMeshType() { return settings.meshType; } 61 | 62 | protected: 63 | ProcessSetting settings; 64 | 65 | SceneControlVariables* scv; 66 | 67 | std::vector allMeshes; 68 | 69 | std::map allTextureInfo; 70 | std::map resizedTextures; 71 | std::map allTextureWidths; 72 | std::map allTextureHeights; 73 | 74 | gaia3d::BoundingBox fullBbox; 75 | 76 | gaia3d::SpatialOctreeBox thisSpatialOctree; 77 | 78 | std::map netSurfaceMeshes; 79 | std::map netSurfaceTextures; 80 | std::map netSurfaceTextureWidth; 81 | std::map netSurfaceTextureHeight; 82 | 83 | bool textureFlip[2]; 84 | 85 | gaia3d::Matrix4 bboxCenterToLocalOrigin; 86 | 87 | std::map attributes; 88 | 89 | double longitude, latitude; 90 | float altitude; 91 | 92 | bool bResponsibleDisposingGeometries; 93 | 94 | public: 95 | bool initialize(); 96 | 97 | void uninitialize(); 98 | 99 | void clear(); 100 | 101 | void defaultSpaceSetupForVisualization(int width, int height); 102 | 103 | bool proceedConversion(std::vector& originalMeshes, 104 | std::map& originalTextureInfo); 105 | 106 | gaia3d::SpatialOctreeBox* getSpatialOctree() { return &thisSpatialOctree; } 107 | 108 | std::map& getTextureInfo() { return allTextureInfo; } 109 | 110 | void getMatrixForBboxCenterToLocalOrigin(gaia3d::Matrix4* matrix) { matrix->set(&bboxCenterToLocalOrigin); } 111 | 112 | void setMatrixForBboxCenterToLocalOrigin(gaia3d::Matrix4* matrix) { bboxCenterToLocalOrigin.set(matrix); } 113 | 114 | void changeSceneControlVariables(); 115 | 116 | SceneControlVariables* getSceneControlVariables() { return scv; } 117 | 118 | void addAttribute(std::string key, std::string value); 119 | 120 | std::map& getAttributes() { return attributes; } 121 | 122 | std::string getAttribute(std::string key) { return attributes[key]; } 123 | 124 | bool doesAttributeExist(std::string key) { return attributes.find(key) != attributes.end(); } 125 | 126 | double getLongitude() { return longitude; } 127 | void setLongitude(double lon) { longitude = lon; } 128 | double getLatitude() { return latitude; } 129 | void setLatitude(double lat) { latitude = lat; } 130 | float getAltitude() { return altitude; } 131 | void setAltitude(float alt) { altitude = alt; } 132 | gaia3d::BoundingBox& getBoundingBox() { return fullBbox; } 133 | std::vector& getAllMeshes() { return allMeshes; } 134 | 135 | std::map& getResizedTextures() { return resizedTextures; } 136 | std::map& getAllTextureWidths() { return allTextureWidths; } 137 | std::map& getAllTextureHeights() { return allTextureHeights; } 138 | std::map& getNetSurfaceMeshes() { return netSurfaceMeshes; } 139 | std::map& getNetSurfaceTextures() { return netSurfaceTextures; } 140 | std::map& getNetSurfaceTextureWidth() { return netSurfaceTextureWidth; } 141 | std::map& getNetSurfaceTextureHeight() { return netSurfaceTextureHeight; } 142 | 143 | void setResponsibilityForDisposing(bool bDispose) { bResponsibleDisposingGeometries = bDispose; } 144 | 145 | bool isTextureFlipX() { return textureFlip[0]; } 146 | bool isTextureFlipY() { return textureFlip[1]; } 147 | protected: 148 | // main processing steps - start 149 | void convertPointCloud(std::vector& originalMeshes); 150 | 151 | void convertSemanticData(std::vector& originalMeshes, 152 | std::map& originalTextureInfo); 153 | 154 | void convertSingleRealisticMesh(std::vector& originalMeshes, 155 | std::map& originalTextureInfo); 156 | 157 | void convertSplittedRealisticMesh(std::vector& originalMeshes, 158 | std::map& originalTextureInfo); 159 | 160 | void trimVertexNormals(std::vector& meshes); 161 | 162 | void calculateBoundingBox(std::vector& meshes, gaia3d::BoundingBox& bbox); 163 | 164 | void makeVboObjects(std::vector& meshes, bool bBind = false); 165 | 166 | void determineWhichSurfacesAreExterior(std::vector& meshes, gaia3d::BoundingBox& bbox); 167 | 168 | void determineModelAndReference(std::vector& meshes); 169 | 170 | void assignReferencesIntoExteriorAndInterior(std::vector& meshes, 171 | std::vector& interiors, 172 | std::vector& exteriors); 173 | 174 | void assignReferencesIntoEachSpatialOctrees(gaia3d::SpatialOctreeBox& spatialOctree, 175 | std::vector& meshes, 176 | gaia3d::BoundingBox& bbox, 177 | bool bFixedDepth = true, 178 | double leafBoxSize = 0.0, 179 | bool bRefOnOnlyOneLeaf = false); 180 | 181 | void splitOriginalMeshIntoEachSpatialOctrees(gaia3d::SpatialOctreeBox& spatialOctree, 182 | std::vector& meshes, 183 | gaia3d::BoundingBox& bbox, 184 | bool bFixedDepth, 185 | double leafBoxSize, 186 | bool bAllowDuplication); 187 | 188 | void assignObjectsIntoEachCubeInPyramid(gaia3d::SpatialOctreeBox& spatialOctree, 189 | std::vector& meshes, 190 | gaia3d::BoundingBox& bbox, 191 | double leafBoxSize, 192 | bool bAllowDuplication, 193 | bool bBasedOnMesh); 194 | 195 | void makeOcclusionInformation(std::vector& meshes, 196 | gaia3d::VisionOctreeBox& interiorOcclusionOctree, 197 | gaia3d::VisionOctreeBox& exteriorOcclusionOctree, 198 | gaia3d::BoundingBox& interiorBbox, 199 | gaia3d::BoundingBox& exteriorBbox); 200 | 201 | void applyOcclusionInformationOnSpatialOctree(gaia3d::SpatialOctreeBox& spatialOctree, 202 | gaia3d::VisionOctreeBox& interiorOcclusionOctree, 203 | gaia3d::VisionOctreeBox& exteriorOcclusionOctree); 204 | 205 | void normalizeTextures(std::map& textureInfo); 206 | // main processing steps - end 207 | 208 | void calculateBoundingBox(gaia3d::TrianglePolyhedron* mesh); 209 | 210 | void setupPerspectiveViewSetting(gaia3d::BoundingBox& bbox); 211 | 212 | void checkIfEachSurfaceIsExterior(std::vector& surfaces, std::vector& colors); 213 | 214 | void drawSurfacesWithIndexColor(std::vector& surfaces, std::vector& colors); 215 | 216 | void makeDisplayListOfMeshes(std::vector& meshes, std::vector& colors); 217 | 218 | void renderMesh(gaia3d::TrianglePolyhedron* mesh, bool bNormal, bool bTextureCoordinate); 219 | 220 | void makeVisibilityIndices(gaia3d::VisionOctreeBox& octree, std::vector& meshes, 221 | float scanStepX, float scanStepY, float scanStepZ, 222 | gaia3d::VisionOctreeBox* excludedBox); 223 | 224 | void drawAndDetectVisibleColorIndices(std::map& container); 225 | 226 | void extractMatchedReferencesFromOcclusionInfo(gaia3d::VisionOctreeBox* receiver, 227 | gaia3d::VisionOctreeBox& info, 228 | std::vector& meshesToBeCompared); 229 | 230 | void sortTrianglesBySize(std::vector& inputTriangles, 231 | unsigned char sizeLevels, 232 | double* sizeArray, 233 | std::vector& outputTriangles, 234 | unsigned int* sizeIndexMarkers); 235 | 236 | void loadAndBindTextures(std::map& textures, 237 | std::map& textureWidths, 238 | std::map& textureHeights, 239 | std::map& bindingResult); 240 | 241 | void drawMeshesWithTextures(std::vector& meshes, std::map& bindingResult, unsigned int shaderProgram); 242 | 243 | void unbindTextures(std::map& bindingResult); 244 | 245 | unsigned int makeShaders(); 246 | 247 | unsigned int makeShadersForNSM(); 248 | 249 | void deleteShaders(unsigned int programId); 250 | 251 | void makeNetSurfaceMeshes(gaia3d::SpatialOctreeBox& octrees, 252 | std::map& textures, 253 | std::map& textureWidths, 254 | std::map& textureHeights, 255 | std::map& lodUsingOriginalMesh); 256 | 257 | void normalizeMosiacTextures(std::map& mosaicTextures, 258 | std::map& mosaicTextureWidth, 259 | std::map& mosaicTextureHeight); 260 | 261 | void changeXYPlaneCoordinateToRelativeCoordinateToBoundingBoxFootprintCenter(std::vector& meshes, gaia3d::BoundingBox& bbox); 262 | 263 | void dropTrianglesOfSmallSizedEdge(std::vector& meshes, double edgeMinSize); 264 | 265 | void removeDuplicatedVerticesAndOverlappingTriangles(std::vector& meshes, bool bCompareTexCoord, bool bCompareNormal); 266 | 267 | void makeLodTextureUsingOriginalTextureDirectly(unsigned char* originalTexture, int originalWidth, int originalHeight, 268 | std::map& lodMadeOfOriginalMesh, 269 | std::map& netSurfaceTextures, 270 | std::map& netSurfaceTextureWidth, 271 | std::map& netSurfaceTextureHeight); 272 | 273 | void divideOriginalTextureIntoSmallerSize(unsigned char* originalTexture, int originalWidth, int originalHeight, 274 | gaia3d::SpatialOctreeBox& octree, 275 | std::map& results, 276 | std::map& resultWidths, 277 | std::map& resultHeights, 278 | std::map& resultTextureInfo); 279 | 280 | void reuseOriginalMeshForRougherLods(gaia3d::SpatialOctreeBox& octree); 281 | }; 282 | 283 | #endif // _CONVERSIONPROCESSOR_H_ -------------------------------------------------------------------------------- /src/process/NetSurfaceMeshMaker.h: -------------------------------------------------------------------------------- 1 | /** 2 | * NetSurfaceMeshMaker Header 3 | */ 4 | #ifndef _NETSURFACEMESHMAKER_H_ 5 | #define _NETSURFACEMESHMAKER_H_ 6 | #pragma once 7 | 8 | #ifdef _WIN32 9 | #define APIENTRY __stdcall 10 | #endif 11 | 12 | #include 13 | 14 | // confirm that GLAD didn't include windows.h 15 | #ifdef _WINDOWS_ 16 | #error windows.h was included! 17 | #endif 18 | 19 | #include 20 | 21 | #if USE_NATIVE_OSMESA 22 | #define GLFW_EXPOSE_NATIVE_OSMESA 23 | #include 24 | #endif 25 | 26 | #include 27 | #include 28 | 29 | #include "NetSurfaceMeshSetting.h" 30 | #include "SceneControlVariables.h" 31 | #include "../util/GeometryUtility.h" 32 | #include "../geometry/OctreeBox.h" 33 | #include "../geometry/TrianglePolyhedron.h" 34 | 35 | /* 36 | namespace gaia3d 37 | { 38 | class TrianglePolyhedron; 39 | class OctreeBox; 40 | } 41 | 42 | class NetSurfaceMeshSetting; 43 | class SceneControlVariables; 44 | */ 45 | class NetSurfaceMeshMaker 46 | { 47 | public: 48 | NetSurfaceMeshMaker(); 49 | ~NetSurfaceMeshMaker(); 50 | 51 | public: 52 | void makeNetSurfaceMesh(std::vector& octrees, 53 | NetSurfaceMeshSetting* setting, 54 | SceneControlVariables* scv, 55 | unsigned int shaderProgramDepthDetection, 56 | unsigned int shaderProgramTexture, 57 | std::map& bindingResult, 58 | std::map& netSurfaceMeshes, 59 | std::map& netSurfaceTextures, 60 | std::map& netSurfaceTextureWidth, 61 | std::map& netSurfaceTextureHeight); 62 | 63 | void makeNetSurfaceMesh(std::vector& octrees, 64 | NetSurfaceMeshSetting* setting, 65 | std::map& netSurfaceMeshes); 66 | 67 | }; 68 | 69 | #endif // _NETSURFACEMESHMAKER_H_ -------------------------------------------------------------------------------- /src/process/NetSurfaceMeshSetting.h: -------------------------------------------------------------------------------- 1 | /** 2 | * NetSurfaceMeshSetting Header 3 | */ 4 | #ifndef _NETSURFACEMESHSETTING_H_ 5 | #define _NETSURFACEMESHSETTING_H_ 6 | #pragma once 7 | 8 | class NetSurfaceMeshSetting 9 | { 10 | public: 11 | NetSurfaceMeshSetting(); 12 | ~NetSurfaceMeshSetting(); 13 | 14 | public: 15 | unsigned char lod; // lod 16 | float maxAngleChangeOfNormalVectorForAllowingEdgeCollapse; // threshold value of normal vector angle change on edge collapse(for all edge types) (degree) 17 | float maxAngleChangeOfFrontierEdgeForAllowingEdgeCollapse; // threshold value of edge angle change on edge collpase(for only frontier edge) (degree) 18 | float maxAngleDifferenceBetweenNeighborFrontierEdgesForCollapse; // threshold value of angle btw two adjacent frontier edges for collapse (degree) 19 | float maxLengthForAllowingInnerEdgeSkirting;// threshold value for making skirting triangles or not(for inner edge) (meter) 20 | float maxLengthForAllowingFrontierEdgeSkirting; // threshold value for making skirting triangles or not(for frontier edge) (meter) 21 | float netCellSize; // grid size for net (meter) 22 | float subBoxSize; // box edge length by which a target is to be divided into sub boxes (meter) 23 | int netSurfaceMeshTextureWidth; // texture image width for output net surface mesh 24 | int netSurfaceMeshTextureHeight; // texture image height for output net surface mesh 25 | 26 | public: 27 | static NetSurfaceMeshSetting* getNetSurfaceMeshSetting(unsigned char settingIndex, unsigned char lodNumber); 28 | }; 29 | 30 | #endif // _NETSURFACEMESHSETTING_H_ -------------------------------------------------------------------------------- /src/process/ProcessSetting.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the NetSurfaceMeshSetting class 3 | */ 4 | #include "ProcessSetting.h" 5 | 6 | ProcessSetting::ProcessSetting() 7 | { 8 | netSurfaceMeshSettingIndex = 4; // default index to template process setting 9 | 10 | bUseNsm = true; 11 | bExtractExterior = true; // if extract exteriors or not 12 | bOcclusionCulling = false; // if do visibility indexing or not 13 | leafSpatialOctreeSize = 24.0f; // deepest spatial octree edge length 14 | bFlipTextureCoordinateU = false; // if flip texture coordinate u or not 15 | bFlipTextureCoordinateV = false; // if flip texture coordinate v or not 16 | interiorVisibilityIndexingCameraStep = 1.8f; // camera position step for interior visibility indexing 17 | exteriorVisibilityIndexingCameraStep = 20.0f; // camera position step for exterior visibility indexing 18 | interiorVisibilityIndexingOctreeDepth = 2; // visibility octree depth for interior 19 | exteriorVisibilityIndexingOctreeDepth = 1; // visibility octree depth for exterior 20 | bAlignPositionToCenter = false; 21 | meshType = 0; 22 | } 23 | 24 | ProcessSetting::~ProcessSetting() 25 | { 26 | clearNsmSettings(); 27 | } 28 | 29 | void ProcessSetting::fillNsmSettings(unsigned char settingIndex) 30 | { 31 | clearNsmSettings(); 32 | 33 | NetSurfaceMeshSetting* lod2 = NetSurfaceMeshSetting::getNetSurfaceMeshSetting(settingIndex, 2); 34 | nsmSettings[2] = lod2; 35 | NetSurfaceMeshSetting* lod3 = NetSurfaceMeshSetting::getNetSurfaceMeshSetting(settingIndex, 3); 36 | nsmSettings[3] = lod3; 37 | NetSurfaceMeshSetting* lod4 = NetSurfaceMeshSetting::getNetSurfaceMeshSetting(settingIndex, 4); 38 | nsmSettings[4] = lod4; 39 | NetSurfaceMeshSetting* lod5 = NetSurfaceMeshSetting::getNetSurfaceMeshSetting(settingIndex, 5); 40 | nsmSettings[5] = lod5; 41 | } 42 | 43 | void ProcessSetting::clearNsmSettings() 44 | { 45 | std::map::iterator iter = nsmSettings.begin(); 46 | for (; iter != nsmSettings.end(); iter++) 47 | delete iter->second; 48 | nsmSettings.clear(); 49 | } 50 | -------------------------------------------------------------------------------- /src/process/ProcessSetting.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ProcessSetting Header 3 | */ 4 | #ifndef _PROCESSSETTING_H_ 5 | #define _PROCESSSETTING_H_ 6 | #pragma once 7 | 8 | #include 9 | 10 | #include "NetSurfaceMeshSetting.h" 11 | 12 | //class NetSurfaceMeshSetting; 13 | 14 | class ProcessSetting 15 | { 16 | public: 17 | ProcessSetting(); 18 | ~ProcessSetting(); 19 | 20 | public: 21 | unsigned char netSurfaceMeshSettingIndex; // index to template NSM setting 22 | 23 | bool bUseNsm; // if make net surface mesh or not 24 | bool bExtractExterior; // if extract exteriors or not 25 | bool bOcclusionCulling; // if do visibility indexing or not 26 | float leafSpatialOctreeSize; // deepest spatial octree edge length(meter) 27 | bool bFlipTextureCoordinateU; // if flip texture coordinate u or not 28 | bool bFlipTextureCoordinateV; // if flip texture coordinate v or not 29 | float interiorVisibilityIndexingCameraStep; // camera position step for interior visibility indexing(meter) 30 | float exteriorVisibilityIndexingCameraStep; // camera position step for exterior visibility indexing(meter) 31 | unsigned char interiorVisibilityIndexingOctreeDepth; // visibility octree depth for interior 32 | unsigned char exteriorVisibilityIndexingOctreeDepth; // visibility octree depth for exterior 33 | 34 | bool bAlignPositionToCenter; // if positions of result F4D is relative to it's center 35 | int meshType; // type of original mesh 36 | // 0 : semantic mesh, 1 : single(merged) realistic mesh, 2 : splitted realistic mesh 37 | 38 | std::map nsmSettings; // net surface mesh setting for each lod 39 | 40 | void fillNsmSettings(unsigned char settingIndex); 41 | void clearNsmSettings(); 42 | }; 43 | 44 | #endif // _PROCESSSETTING_H_ -------------------------------------------------------------------------------- /src/process/SceneControlVariables.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the SceneControlVariables class 3 | */ 4 | #include "SceneControlVariables.h" 5 | 6 | #include "../geometry/Matrix4.h" 7 | 8 | SceneControlVariables::SceneControlVariables(void) 9 | { 10 | //m_myhDC = 0; 11 | //m_hRC = 0; 12 | m_window = NULL; 13 | m_width = m_height = 0; 14 | this->m_tp_pantalla_action = GESTIO_PANTALLA_CAP; 15 | //m_system_state = SYSTEM_NORMAL; 16 | //m_navigation_mode = NAVIGATION_FIRSTPERSON; 17 | this->m_navigation_mode = NAVIGATION_WORLDMOVE; 18 | //m_tp_render= RENDER_SHADE_WIREFRAME; 19 | this->m_tp_select_and_move = SELECT_AND_MOVE_INDIVIDUALOBJECT; 20 | this->m_tp_geometry_create = NO_CREATE_GEOMETRY; 21 | //m_tp_display_on_screen = DISPLAY_NORMAL; 22 | 23 | this->m_xRot= 0.0; this->m_yRot= 0.0; this->m_zRot= 0.0; 24 | this->m_xRotIni=0.0; this->m_yRotIni=0.0; this->m_zRotIni=0.0; 25 | this->m_xPos=0.0; this->m_yPos=-10.0; this->m_zPos=-20.5; // Original.*** 26 | //m_xPos=0.0; m_yPos=0.0; m_zPos=-16000000.0; // For visualise the globe.*** 27 | this->m_xNextPos=0.0; this->m_yNextPos=0.0; this->m_zNextPos=-60.0; 28 | 29 | this->m_xPosIni=0.0; this->m_yPosIni=0.0; this->m_zPosIni=0.0; 30 | 31 | this->m_xRot_aditional=0.0; this->m_yRot_aditional=0.0; this->m_zRot_aditional=0.0; // Test. delete after test.*** 32 | 33 | //------------------------------------------------------------- 34 | //************************************************************* 35 | gaia3d::Matrix4 mat_xrot, mat_yrot, mat_zrot; 36 | mat_xrot.rotation(this->m_xRot*this->MPI_Div_180, 1.0, 0.0, 0.0); 37 | mat_yrot.rotation(this->m_yRot*this->MPI_Div_180, 0.0, 1.0, 0.0); 38 | mat_zrot.rotation(this->m_zRot*this->MPI_Div_180, 0.0, 0.0, 1.0); 39 | this->mat_rot= (mat_xrot*mat_yrot)*mat_zrot; 40 | //************************************************************* 41 | //------------------------------------------------------------- 42 | this->m_viewing_direction.set(0.0, 0.0, -1.0); 43 | this->m_viewing_direction = this->mat_rot*this->m_viewing_direction; 44 | 45 | //m_frustum= new CKK_Frustum(); 46 | 47 | this->m_Zoom=0.0; this->m_ZoomIni=0.0; 48 | this->m_nRange=1300; 49 | this->m_LButtonDown=false; 50 | this->m_MButtonDown=false; 51 | this->m_RButtonDown=false; 52 | 53 | this->m_xDifPos_Model=0.0; this->m_yDifPos_Model=0.0; this->m_zDifPos_Model=0.0; 54 | //selector=new CSelector(); 55 | 56 | this->m_xAnteriorPos_Model=0.0; 57 | this->m_yAnteriorPos_Model=0.0; 58 | this->m_zAnteriorPos_Model=0.0; 59 | 60 | this->m_xRot_speed=0.0; this->m_yRot_speed=0.0; this->m_zRot_speed=0.0; 61 | this->m_speed=0.0; this->m_lateral_speed=0.0; this->m_vertical_speed=0.0; 62 | this->m_speed_value=0.2; 63 | this->m_key_down=false; 64 | 65 | this->m_perspective_angle=90.0; 66 | this->m_perspective_near=0.01; 67 | this->m_perspective_far=8000000.0; 68 | 69 | this->MPI_Div_180= 3.14159265358979323846/180.0; 70 | } 71 | 72 | 73 | SceneControlVariables::~SceneControlVariables(void) 74 | { 75 | } -------------------------------------------------------------------------------- /src/process/SceneControlVariables.h: -------------------------------------------------------------------------------- 1 | /** 2 | * SceneControlVariables Header 3 | */ 4 | #ifndef _SCENECONTROLVARIABLES_H_ 5 | #define _SCENECONTROLVARIABLES_H_ 6 | #pragma once 7 | 8 | #include 9 | 10 | #include "../geometry/Point3D.h" 11 | #include "../geometry/Matrix4.h" 12 | 13 | enum TYPE_PANTALLA_ACTION 14 | { GESTIO_PANTALLA_CAP, GESTIO_PANTALLA_PAN, GESTIO_PANTALLA_ROT, GESTIO_PANTALLA_ZOOM }; 15 | 16 | enum TYPE_NAVIGATION_MODE 17 | { 18 | NAVIGATION_FIRSTPERSON, NAVIGATION_WORLDMOVE, NAVIGATION_WALKINGMODE 19 | }; 20 | 21 | enum TYPE_PROJECTION 22 | { PROJECTION_ORTHO, PROJECTION_PERSPECTIVE }; 23 | 24 | enum TYPE_GEOMETRY_CREATE 25 | { NO_CREATE_GEOMETRY, CREATE_GEOMETRY_POLYGON, CREATE_EXTRUDE}; 26 | 27 | enum TYPE_SELECT_AND_MOVE 28 | { 29 | SELECT_AND_MOVE_INDIVIDUALOBJECT, SELECT_AND_MOVE_STOREY, SELECT_AND_MOVE_STOREY_STACK 30 | }; 31 | 32 | class SceneControlVariables 33 | { 34 | public: 35 | SceneControlVariables(); 36 | 37 | virtual ~SceneControlVariables(); 38 | 39 | public: 40 | 41 | int m_mouse_x, m_mouse_y; 42 | 43 | int nCount; 44 | 45 | GLFWwindow* m_window; // Window Object 46 | //HGLRC m_hRC; // Permanent Rendering Context 47 | //HDC m_myhDC; // Private GDI Device Context 48 | int m_height; // Stores the height of the View 49 | int m_width; // Stores the width of the view 50 | float m_nRange; 51 | TYPE_PANTALLA_ACTION m_tp_pantalla_action; 52 | 53 | TYPE_NAVIGATION_MODE m_navigation_mode; 54 | TYPE_SELECT_AND_MOVE m_tp_select_and_move; 55 | TYPE_GEOMETRY_CREATE m_tp_geometry_create; 56 | 57 | 58 | double m_xRot, m_yRot, m_zRot, m_xRotIni, m_yRotIni, m_zRotIni; 59 | double m_xPos, m_yPos, m_zPos, m_xPosIni, m_yPosIni, m_zPosIni; 60 | double m_xNextPos, m_yNextPos, m_zNextPos; 61 | double m_Zoom, m_ZoomIni; 62 | 63 | double m_xRot_aditional, m_yRot_aditional, m_zRot_aditional; // Test. delete after test.*** 64 | 65 | bool m_LButtonDown, m_MButtonDown, m_RButtonDown; 66 | //CRect m_Rect; 67 | int CODIFILTRE; 68 | int senCodi[100], selProfund[100], senCodi_aux[100], selProfund_aux[100]; 69 | 70 | float m_xPosLookAt, m_yPosLookAt, m_zPosLookAt; 71 | double m_speed, m_lateral_speed, m_vertical_speed, m_xRot_speed, m_yRot_speed, m_zRot_speed; 72 | double m_speed_value; 73 | bool m_key_down; 74 | double m_perspective_angle, m_perspective_near, m_perspective_far; 75 | 76 | float ambientLight[4]; 77 | float diffuseLight[4]; 78 | float specular[4]; 79 | float lightPos[4]; 80 | float specref[4]; 81 | float ClearColor[4]; 82 | 83 | double m_xDifPos_Model, m_yDifPos_Model, m_zDifPos_Model; 84 | double m_xAnteriorPos_Model, m_yAnteriorPos_Model, m_zAnteriorPos_Model; 85 | double MPI_Div_180; 86 | 87 | TYPE_PROJECTION tp_projection; 88 | gaia3d::Matrix4 mat_rot; 89 | gaia3d::Point3D m_viewing_direction; 90 | }; 91 | 92 | #endif // _SCENECONTROLVARIABLES_H_ -------------------------------------------------------------------------------- /src/reader/AvevaRevReader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * AvevaRevReader Header 3 | */ 4 | #ifndef _AVEVAREVREADER_H_ 5 | #define _AVEVAREVREADER_H_ 6 | #pragma once 7 | 8 | //#ifdef AVEVAREVIEWFORMAT 9 | 10 | #include "Reader.h" 11 | 12 | class AvevaRevReader : public Reader 13 | { 14 | public: 15 | AvevaRevReader(); 16 | virtual ~AvevaRevReader(); 17 | 18 | public: 19 | virtual bool readRawDataFile(std::string& filePath); 20 | 21 | virtual void clear(); 22 | }; 23 | 24 | //#endif 25 | 26 | #endif // _AVEVAREVREADER_H_ 27 | -------------------------------------------------------------------------------- /src/reader/CityGMLReader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * CityGMLReader Header 3 | */ 4 | #ifndef _CITYGMLREADER_H_ 5 | #define _CITYGMLREADER_H_ 6 | #pragma once 7 | 8 | #include "Reader.h" 9 | 10 | class CitygmlReader : public Reader 11 | { 12 | public: 13 | CitygmlReader(); 14 | virtual ~CitygmlReader(); 15 | 16 | public: 17 | virtual bool readRawDataFile(std::string& filePath); 18 | 19 | virtual void clear(); 20 | 21 | }; 22 | 23 | #endif // _CITYGMLREADER_H_ 24 | -------------------------------------------------------------------------------- /src/reader/ClassicFormatReader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ClassicFormatReader Header 3 | */ 4 | #ifndef _CLASSICFORMATREADER_H_ 5 | #define _CLASSICFORMATREADER_H_ 6 | #pragma once 7 | 8 | #include "Reader.h" 9 | 10 | class ClassicFormatReader : public Reader 11 | { 12 | public: 13 | ClassicFormatReader(); 14 | virtual ~ClassicFormatReader(); 15 | 16 | public: 17 | virtual bool readRawDataFile(std::string& filePath); 18 | 19 | virtual void clear(); 20 | 21 | }; 22 | 23 | #endif // _CLASSICFORMATREADER_H_ 24 | -------------------------------------------------------------------------------- /src/reader/IfcLoader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * IfcLoader Header 3 | */ 4 | #ifndef _IFCLOADER_H_ 5 | #define _IFCLOADER_H_ 6 | #pragma once 7 | 8 | #include 9 | 10 | // Abstract Class 11 | class IfcLoader 12 | { 13 | public: 14 | virtual bool loadIfcFile(std::wstring& filePath) = 0; 15 | 16 | virtual void setVertexReductionMode(bool bOn) = 0; 17 | 18 | virtual size_t getPolyhedronCount() = 0; 19 | virtual float* getRepresentativeColor(size_t polyhedronIndex) = 0; 20 | virtual void getGuid(size_t polyhedronIndex, wchar_t buffer[]) = 0; 21 | virtual size_t getVertexCount(size_t polyhedronIndex) = 0; 22 | virtual double* getVertexPositions(size_t polyhedronIndex) = 0; 23 | virtual size_t getSurfaceCount(size_t polyhedronIndex) = 0; 24 | virtual size_t getTrialgleCount(size_t polyhedronIndex, size_t surfaceIndex) = 0; 25 | virtual size_t* getTriangleIndices(size_t polyhedronIndex, size_t surfaceIndex) = 0; 26 | 27 | virtual size_t getStoryCount() = 0; 28 | virtual size_t getStoryDivisionCount(size_t storyIndex) = 0; 29 | virtual size_t getPolyhedronCount(size_t storyIndex, size_t divisionIndex) = 0; 30 | virtual float* getRepresentativeColor(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex) = 0; 31 | virtual void getGuid(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex, wchar_t buffer[]) = 0; 32 | virtual size_t getVertexCount(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex) = 0; 33 | virtual double* getVertexPositions(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex) = 0; 34 | virtual size_t getSurfaceCount(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex) = 0; 35 | virtual size_t getTrialgleCount(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex, size_t surfaceIndex) = 0; 36 | virtual size_t* getTriangleIndices(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex, size_t surfaceIndex) = 0; 37 | 38 | virtual bool loadOnlyPropertiesFromIfc(std::wstring& filePath) = 0; 39 | virtual void setAttributesExtraction(bool bOn) = 0; 40 | virtual std::string getObjectAttributes() = 0; 41 | virtual std::string getProjectAttributes() = 0; // not available now 42 | 43 | #ifdef TMPTEST 44 | virtual size_t getAttributeTypeCount() = 0; 45 | virtual std::string getAttributeType(size_t i) = 0; 46 | #endif 47 | }; 48 | 49 | #endif // _IFCLOADER_H_ -------------------------------------------------------------------------------- /src/reader/IfcReader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * IfcReader Header 3 | */ 4 | #ifndef _IFCREADER_H_ 5 | #define _IFCREADER_H_ 6 | #pragma once 7 | 8 | #include "Reader.h" 9 | 10 | class IfcReader : public Reader 11 | { 12 | public: 13 | IfcReader(); 14 | virtual ~IfcReader(); 15 | 16 | public: 17 | virtual bool readRawDataFile(std::string& filePath); 18 | 19 | virtual void clear(); 20 | }; 21 | 22 | #endif // _IFCREADER_H_ 23 | 24 | -------------------------------------------------------------------------------- /src/reader/IfcppLoader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * IfcppLoader Header 3 | */ 4 | #ifndef _IFCPPLOADER_H_ 5 | #define _IFCPPLOADER_H_ 6 | #pragma once 7 | 8 | #include 9 | 10 | #include "IfcLoader.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | // for geometry structure 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | // for property value 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | // for unit 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include 49 | 50 | #include "../util/StringUtility.h" 51 | 52 | class IfcppLoader : public IfcLoader 53 | { 54 | public: 55 | IfcppLoader(); 56 | virtual ~IfcppLoader(); 57 | 58 | public: 59 | virtual bool loadIfcFile(std::wstring& filePath); 60 | 61 | virtual void setVertexReductionMode(bool bOn); 62 | 63 | virtual size_t getPolyhedronCount(); 64 | virtual float* getRepresentativeColor(size_t polyhedronIndex); 65 | virtual void getGuid(size_t polyhedronIndex, wchar_t buffer[]); 66 | virtual size_t getVertexCount(size_t polyhedronIndex); 67 | virtual double* getVertexPositions(size_t polyhedronIndex); 68 | virtual size_t getSurfaceCount(size_t polyhedronIndex); 69 | virtual size_t getTrialgleCount(size_t polyhedronIndex, size_t surfaceIndex); 70 | virtual size_t* getTriangleIndices(size_t polyhedronIndex, size_t surfaceIndex); 71 | 72 | virtual size_t getStoryCount(); 73 | virtual size_t getStoryDivisionCount(size_t storyIndex); 74 | virtual size_t getPolyhedronCount(size_t storyIndex, size_t divisionIndex); 75 | virtual float* getRepresentativeColor(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex); 76 | virtual void getGuid(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex, wchar_t buffer[]); 77 | virtual size_t getVertexCount(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex); 78 | virtual double* getVertexPositions(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex); 79 | virtual size_t getSurfaceCount(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex); 80 | virtual size_t getTrialgleCount(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex, size_t surfaceIndex); 81 | virtual size_t* getTriangleIndices(size_t storyIndex, size_t divisionIndex, size_t polyhedronIndex, size_t surfaceIndex); 82 | 83 | virtual bool loadOnlyPropertiesFromIfc(std::wstring& filePath); 84 | virtual void setAttributesExtraction(bool bOn); 85 | virtual std::string getObjectAttributes(); 86 | virtual std::string getProjectAttributes(); 87 | 88 | #ifdef TMPTEST 89 | virtual size_t getAttributeTypeCount(); 90 | virtual std::string getAttributeType(size_t i); 91 | std::vector attributeTypes; 92 | std::map attributeMap; 93 | #endif 94 | 95 | private: 96 | 97 | void loadProjectAttributes(); 98 | void loadObjectAttributes(shared_ptr ifcProduct, Json::Value& root); 99 | bool checkIfPropertiesCanBeExtracted(std::string className); 100 | //bool checkIfPropertiesCanBeExtracted(IfcPPEntityEnum ppEnum); 101 | void parsePropertySingleValue(Json::Value& valueObject, shared_ptr value); 102 | 103 | bool bAttributesExtraction; 104 | bool bVertexReduction; 105 | 106 | struct Surface 107 | { 108 | size_t triangleCount; 109 | size_t* triangleIndices; 110 | }; 111 | 112 | struct Polyhedron 113 | { 114 | size_t vertexCount; 115 | double* vertices; 116 | float color[4]; 117 | std::vector surfaces; 118 | std::wstring guid; 119 | }; 120 | 121 | std::vector polyhedrons; 122 | 123 | std::vector>> stories; 124 | 125 | std::vector objectsOutsideStory; 126 | 127 | Json::Value objectPropertyRoot; 128 | Json::Value projectPropertyRoot; 129 | }; 130 | 131 | IfcLoader* createIfcLoader(); 132 | void destroyIfcLoader(IfcLoader* aLoader); 133 | 134 | #endif // _IFCPPLOADER_H_ -------------------------------------------------------------------------------- /src/reader/IndoorGMLReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _INDOORGMLREADER_H_ 4 | #define _INDOORGMLREADER_H_ 5 | 6 | 7 | #include "Reader.h" 8 | 9 | #include "../geometry/TrianglePolyhedron.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | using namespace xercesc; 18 | 19 | class GeometryManager; 20 | 21 | class IndoorGMLReader : public Reader 22 | { 23 | public: 24 | IndoorGMLReader(); 25 | 26 | virtual ~IndoorGMLReader(); 27 | 28 | virtual bool readRawDataFile(std::string& filePath); 29 | 30 | virtual void clear(); 31 | 32 | private: 33 | GeometryManager parseIndoorGeometry(DOMDocument* dom, std::string filePath); 34 | bool readIndoorGML(DOMDocument* dom, std::string filePath, std::map splitFilter, std::vector& container, double& lon, double& lat); 35 | 36 | }; 37 | 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /src/reader/PointCloudReader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * PointCloudReader Header 3 | */ 4 | #ifndef _POINTCLOUDREADER_H_ 5 | #define _POINTCLOUDREADER_H_ 6 | #pragma once 7 | 8 | #include "Reader.h" 9 | 10 | class PointCloudReader : public Reader 11 | { 12 | public: 13 | PointCloudReader(); 14 | ~PointCloudReader(); 15 | 16 | public: 17 | virtual bool readRawDataFile(std::string& filePath); 18 | 19 | virtual void clear(); 20 | 21 | private: 22 | bool readLasFile(std::string& filePath); 23 | bool readTemporaryPointCloudFile(std::string& filePath); 24 | }; 25 | 26 | #endif // _POINTCLOUDREADER_H_ 27 | -------------------------------------------------------------------------------- /src/reader/Reader.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Reader class 3 | */ 4 | #include "Reader.h" 5 | 6 | Reader::Reader() 7 | { 8 | unitScaleFactor = 1.0; 9 | 10 | bHasGeoReferencingInfo = false; 11 | 12 | bCoordinateInfoInjected = false; 13 | 14 | bYAxisUp = false; 15 | 16 | offsetX = offsetY = offsetZ = 0.0; 17 | 18 | bBuildHiararchy = false; 19 | 20 | bAlignToBottomCenter = bAlignToCenter = false; 21 | } 22 | 23 | Reader::~Reader() 24 | { 25 | } 26 | 27 | std::vector& Reader::getDataContainer() 28 | { 29 | return container; 30 | } 31 | 32 | std::map>& Reader::getMultipleDataContainers() 33 | { 34 | return containers; 35 | } 36 | 37 | std::map& Reader::getTextureInfoContainer() 38 | { 39 | return textureContainer; 40 | } 41 | void Reader::setUnitScaleFactor(double factor) 42 | { 43 | unitScaleFactor = factor; 44 | } 45 | 46 | void Reader::TexCoord_Flip_Y() 47 | { 48 | for (int i = 0, count = container.size(); i < count; i++) 49 | { 50 | gaia3d::TrianglePolyhedron *polyhedron = container[i]; 51 | polyhedron->TexCoord_Flip_Y(); 52 | } 53 | } 54 | 55 | std::string Reader::makeProj4String() 56 | { 57 | std::string proj4String; 58 | 59 | if (epsg.empty()) 60 | { 61 | proj4String = std::string("+proj=tmerc +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"); 62 | proj4String += std::string(" +lon_0=") + std::to_string(lonOrigin); 63 | proj4String += std::string(" +lat_0=") + std::to_string(latOrigin); 64 | } 65 | else 66 | { 67 | proj4String = std::string("+init=epsg:") + epsg; 68 | } 69 | 70 | return proj4String; 71 | } -------------------------------------------------------------------------------- /src/reader/Reader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Reader Header 3 | */ 4 | #ifndef _READER_H_ 5 | #define _READER_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "../geometry/TrianglePolyhedron.h" 13 | 14 | class Reader 15 | { 16 | public: 17 | Reader(); 18 | 19 | virtual ~Reader(); 20 | 21 | public: 22 | virtual bool readRawDataFile(std::string& filePath) = 0; 23 | 24 | virtual void clear() = 0; 25 | 26 | virtual std::vector& getDataContainer(); 27 | 28 | virtual std::map>& getMultipleDataContainers(); 29 | 30 | virtual std::map& getTextureInfoContainer(); 31 | 32 | virtual void setUnitScaleFactor(double factor); 33 | 34 | virtual void setOffset(double x, double y, double z) { offsetX = x; offsetY = y; offsetZ = z; } 35 | 36 | virtual void setYAxisUp(bool bUp) { bYAxisUp = bUp; } 37 | 38 | virtual void setBuildHiararchy(bool bBuild) { bBuildHiararchy = bBuild; } 39 | 40 | virtual bool doesHasGeoReferencingInfo() { return bHasGeoReferencingInfo; } 41 | 42 | virtual bool doesHasAdditionalInfo() { return bHasAdditionalInfo; } 43 | 44 | virtual std::map& getAdditionalInfo() { return additionalInfo; } 45 | 46 | virtual void getGeoReferencingInfo(double& lon, double& lat) { lon = refLon; lat = refLat; } 47 | 48 | virtual void injectOringinInfo(double& lon, double& lat) { lonOrigin = lon; latOrigin = lat; bCoordinateInfoInjected = true; } 49 | 50 | virtual void injectSrsInfo(std::string& epsg) { this->epsg = epsg; bCoordinateInfoInjected = true; } 51 | 52 | virtual void alignToBottomCenter(bool bAlign) { bAlignToBottomCenter = bAlign; } 53 | 54 | virtual void alignToCenter(bool bAlign) { bAlignToCenter = bAlign; } 55 | 56 | virtual std::map& getTemporaryFiles() { return temporaryFiles; } 57 | 58 | virtual bool shouldGeometryBeDesroyedOutside() { return (!container.empty() && !containers.empty()); } 59 | 60 | virtual bool shouldRawDataBeConvertedToMuitiFiles() { return !containers.empty(); } 61 | 62 | virtual std::map>& getAncestorsOfEachSubGroup() { return ancestorsOfEachSubGroup; } 63 | 64 | virtual std::map& getSplitFilter() { return splitFilter; } 65 | 66 | void TexCoord_Flip_Y(); 67 | 68 | protected: 69 | std::vector container; 70 | 71 | std::map> containers; 72 | 73 | std::map textureContainer; 74 | 75 | bool bYAxisUp; 76 | 77 | double unitScaleFactor; 78 | 79 | double offsetX, offsetY, offsetZ; 80 | 81 | bool bHasGeoReferencingInfo; 82 | 83 | bool bHasAdditionalInfo; 84 | 85 | double refLon, refLat; 86 | 87 | std::string epsg; 88 | 89 | std::map additionalInfo; 90 | 91 | double lonOrigin, latOrigin; 92 | 93 | bool bCoordinateInfoInjected; 94 | 95 | bool bAlignToBottomCenter; 96 | 97 | bool bAlignToCenter; 98 | 99 | bool bBuildHiararchy; 100 | 101 | std::map> ancestorsOfEachSubGroup; 102 | 103 | std::map splitFilter; 104 | 105 | std::map temporaryFiles; 106 | 107 | std::string makeProj4String(); 108 | }; 109 | 110 | #endif // _READER_H_ 111 | -------------------------------------------------------------------------------- /src/reader/ReaderFactory.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the ReaderFactory class 3 | */ 4 | #include "ReaderFactory.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include "../converter/LogWriter.h" 10 | 11 | #ifdef F4D_FORMAT_SUPPORT_SHIJT 12 | #include "JtReader.h" 13 | #endif 14 | #ifdef F4D_FORMAT_SUPPORT_IFC 15 | #include "IfcReader.h" 16 | #endif 17 | #ifdef F4D_FORMAT_SUPPORT_CLASSIC 18 | #include "ClassicFormatReader.h" 19 | #endif 20 | #ifdef F4D_FORMAT_SUPPORT_CITYGML 21 | #include "CityGMLReader.h" 22 | #endif 23 | #ifdef F4D_FORMAT_SUPPORT_POINTCLOUD 24 | #include "PointCloudReader.h" 25 | #endif 26 | #ifdef F4D_FORMAT_SUPPORT_AVEVAREVIEW 27 | #include "AvevaRevReader.h" 28 | #endif 29 | #ifdef F4D_FORMAT_SUPPORT_INDOORGML 30 | #include "IndoorGMLReader.h" 31 | #endif 32 | 33 | ReaderFactory::ReaderFactory() 34 | { 35 | } 36 | 37 | ReaderFactory::~ReaderFactory() 38 | { 39 | } 40 | 41 | Reader* ReaderFactory::makeReader(std::string& filePath) 42 | { 43 | std::string::size_type dotPosition = filePath.rfind("."); 44 | if(dotPosition == std::string::npos) 45 | { 46 | return NULL; 47 | } 48 | 49 | std::string::size_type fileExtLength = filePath.length() - dotPosition - 1; 50 | 51 | std::string fileExt = filePath.substr(dotPosition + 1, fileExtLength); 52 | 53 | std::transform(fileExt.begin(), fileExt.end(), fileExt.begin(), ::tolower); 54 | 55 | #ifdef F4D_FORMAT_SUPPORT_SHIJT 56 | if(fileExt.compare(std::string("jt")) == 0) 57 | { 58 | return new JtReader; 59 | } 60 | #endif 61 | 62 | #ifdef F4D_FORMAT_SUPPORT_IFC 63 | if (fileExt.compare(std::string("ifc")) == 0) 64 | { 65 | return new IfcReader; 66 | } 67 | #endif 68 | 69 | #ifdef F4D_FORMAT_SUPPORT_CLASSIC 70 | if (fileExt.compare(std::string("obj")) == 0 || 71 | fileExt.compare(std::string("dae")) == 0 || 72 | fileExt.compare(std::string("3ds")) == 0 || 73 | fileExt.compare(std::string("fbx")) == 0) 74 | { 75 | return new ClassicFormatReader; 76 | } 77 | #endif 78 | 79 | #ifdef F4D_FORMAT_SUPPORT_CITYGML 80 | if (fileExt.compare(std::string("gml")) == 0 || 81 | fileExt.compare(std::string("xml")) == 0 || 82 | fileExt.compare(std::string("citygml")) == 0) 83 | { 84 | return new CitygmlReader; 85 | } 86 | #endif 87 | 88 | #ifdef F4D_FORMAT_SUPPORT_POINTCLOUD 89 | if (fileExt.compare(std::string("las")) == 0 || 90 | fileExt.compare(std::string("tpc")) == 0) 91 | { 92 | return new PointCloudReader; 93 | } 94 | #endif 95 | 96 | #ifdef F4D_FORMAT_SUPPORT_AVEVAREVIEW 97 | if (fileExt.compare(std::string("rev")) == 0) 98 | { 99 | return new AvevaRevReader; 100 | } 101 | #endif 102 | 103 | #ifdef F4D_FORMAT_SUPPORT_INDOORGML 104 | if (fileExt.compare(std::string("indoorgml")) == 0) 105 | { 106 | return new IndoorGMLReader; 107 | } 108 | #endif 109 | return NULL; 110 | } 111 | -------------------------------------------------------------------------------- /src/reader/ReaderFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ReaderFactory Header 3 | */ 4 | #ifndef _READERFACTORY_H_ 5 | #define _READERFACTORY_H_ 6 | #pragma once 7 | 8 | #include "Reader.h" 9 | 10 | class ReaderFactory 11 | { 12 | public: 13 | ReaderFactory(); 14 | 15 | virtual ~ReaderFactory(); 16 | 17 | public: 18 | static Reader* makeReader(std::string& filePath); 19 | }; 20 | 21 | #endif // _READERFACTORY_H_ -------------------------------------------------------------------------------- /src/util/GeometryUtility.h: -------------------------------------------------------------------------------- 1 | /** 2 | * GeometryUtility Header 3 | */ 4 | #ifndef _GEOMETRYUTILITY_H_ 5 | #define _GEOMETRYUTILITY_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include // size_t 11 | 12 | #define M_PI 3.14159265358979323846 13 | #define EarthHRadius 6378137.0 14 | #define EarthVRadius 6356751.9566//10375702081371855231 15 | 16 | 17 | namespace gaia3d 18 | { 19 | class LegoBlock; 20 | 21 | class GeometryUtility 22 | { 23 | public: 24 | ///< 점 3개로 이루어진 평면의 normal vector를 계산 25 | static void calculatePlaneNormal(double& x0, double& y0, double& z0, 26 | double& x1, double& y1, double& z1, 27 | double& x2, double& y2, double& z2, 28 | double& nX, double& nY, double& nZ, 29 | bool bNormalize); 30 | 31 | static void crossProduct(double x0, double y0, double z0, 32 | double x1, double y1, double z1, 33 | double& nX, double& nY, double& nZ); 34 | 35 | enum GeomType {POLYHEDRON, TRIANGLE, POINT}; 36 | static bool areTwoCongruentWithEachOther(void* geom1, void* geom2, void* transform, double tolerance, GeomType geomType); 37 | 38 | static double angleBetweenTwoVectors(double x1, double y1, double z1, double x2, double y2, double z2); 39 | 40 | static bool isInsideBox(double x, double y, double z, 41 | double minX, double minY, double minZ, 42 | double maxX, double maxY, double maxZ); 43 | 44 | static bool doesTriangleIntersectWithBox(double& x1, double& y1, double& z1, 45 | double& x2, double& y2, double& z2, 46 | double& x3, double& y3, double& z3, 47 | double& minX, double& minY, double& minZ, 48 | double& maxX, double& maxY, double& maxZ); 49 | 50 | static void wgs84ToAbsolutePosition(double&lon, double& lat, double& alt, double* result); 51 | static void normalAtAbsolutePosition(double& x, double& y, double& z, double* result); 52 | static void transformMatrixAtAbsolutePosition(double& x, double& y, double& z, double* m); 53 | 54 | static void mergeLegoBlocksAlongZAxis(std::vector& legos, bool mustSameColor); 55 | 56 | static void mergeLegoBlocksAlongYAxis(std::vector& legos, bool mustSameColor); 57 | 58 | static void mergeLegoBlocksAlongXAxis(std::vector& legos, bool mustSameColor); 59 | 60 | static bool earCut(double** xs, double** ys, double** zs, std::vector& eachRingPointCount, std::vector>& result, bool bDebug = false); 61 | 62 | static void tessellate(double* xs, double* ys, double* zs, size_t vertexCount, std::vector& polygonIndices, std::vector& indices); 63 | }; 64 | } 65 | 66 | #endif // _GEOMETRYUTILITY_H_ 67 | -------------------------------------------------------------------------------- /src/util/Image2D.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Image2D class 3 | */ 4 | #include "Image2D.h" 5 | 6 | namespace gaia3d 7 | { 8 | Image2D::Image2D() 9 | { 10 | this->m_image = 0; 11 | this->m_dimensions = 4; // default value.*** 12 | } 13 | 14 | Image2D::~Image2D() 15 | { 16 | if (m_image) 17 | delete[] m_image; 18 | } 19 | 20 | void Image2D::Set_Image(unsigned char *image, int width, int height) 21 | { 22 | this->m_image = image; 23 | this->m_imageWidth = width; 24 | this->m_imageHeight = height; 25 | } 26 | 27 | int Image2D::Get_Idx(int col, int row) 28 | { 29 | return row * this->m_imageWidth + col; 30 | } 31 | 32 | unsigned char* Image2D::Get_Color_RGB(int col, int row) 33 | { 34 | unsigned char* colorRGB = new unsigned char[3]; 35 | 36 | int idx = this->Get_Idx(col, row); 37 | colorRGB[0] = this->m_image[idx*this->m_dimensions]; 38 | colorRGB[1] = this->m_image[idx*this->m_dimensions + 1]; 39 | colorRGB[2] = this->m_image[idx*this->m_dimensions + 2]; 40 | 41 | return colorRGB; 42 | } 43 | 44 | unsigned char* Image2D::Get_Color_RGBA(int col, int row) 45 | { 46 | unsigned char* colorRGB = new unsigned char[4]; 47 | 48 | int idx = this->Get_Idx(col, row); 49 | colorRGB[0] = this->m_image[idx*this->m_dimensions]; 50 | colorRGB[1] = this->m_image[idx*this->m_dimensions + 1]; 51 | colorRGB[2] = this->m_image[idx*this->m_dimensions + 2]; 52 | colorRGB[3] = this->m_image[idx*this->m_dimensions + 2]; 53 | 54 | return colorRGB; 55 | } 56 | 57 | void Image2D::Set_Color_RGB(int col, int row, unsigned char *colorRGB) 58 | { 59 | int idx = this->Get_Idx(col, row); 60 | this->m_image[idx*this->m_dimensions] = colorRGB[0]; 61 | this->m_image[idx*this->m_dimensions + 1] = colorRGB[1]; 62 | this->m_image[idx*this->m_dimensions + 2] = colorRGB[2]; 63 | } 64 | 65 | void Image2D::Set_Color_RGBA(int col, int row, unsigned char *colorRGBA) 66 | { 67 | if (col >= this->m_imageWidth) 68 | return; 69 | 70 | if (row >= this->m_imageHeight) 71 | return; 72 | 73 | int idx = this->Get_Idx(col, row); 74 | this->m_image[idx*this->m_dimensions] = colorRGBA[0]; 75 | this->m_image[idx*this->m_dimensions + 1] = colorRGBA[1]; 76 | this->m_image[idx*this->m_dimensions + 2] = colorRGBA[2]; 77 | this->m_image[idx*this->m_dimensions + 3] = colorRGBA[3]; 78 | } 79 | 80 | void Image2D::Set_Color_ARGB(int col, int row, unsigned char *colorRGBA) 81 | { 82 | if (col >= this->m_imageWidth) 83 | return; 84 | 85 | if (row >= this->m_imageHeight) 86 | return; 87 | 88 | int idx = this->Get_Idx(col, row); 89 | this->m_image[idx*this->m_dimensions] = colorRGBA[3]; 90 | this->m_image[idx*this->m_dimensions + 1] = colorRGBA[0]; 91 | this->m_image[idx*this->m_dimensions + 2] = colorRGBA[1]; 92 | this->m_image[idx*this->m_dimensions + 3] = colorRGBA[2]; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/util/Image2D.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Image2D Header 3 | */ 4 | #ifndef _IMAGE2D_H_ 5 | #define _IMAGE2D_H_ 6 | #pragma once 7 | 8 | namespace gaia3d 9 | { 10 | class Image2D 11 | { 12 | public: 13 | 14 | unsigned char* m_image; 15 | int m_imageWidth, m_imageHeight; 16 | int m_dimensions; // 3 for RGB, 4 for RGBA 17 | 18 | Image2D(); 19 | ~Image2D(); 20 | 21 | unsigned char* Get_Color_RGB(int col, int row); 22 | int Get_Idx(int col, int row); 23 | void Set_Color_RGB(int col, int row, unsigned char *colorRGB); 24 | void Set_Color_RGBA(int col, int row, unsigned char *colorRGBA); 25 | void Set_Color_ARGB(int col, int row, unsigned char *colorRGBA); 26 | unsigned char* Get_Color_RGBA(int col, int row); 27 | void Set_Image(unsigned char *image, int width, int height); 28 | }; 29 | } 30 | 31 | #endif // _IMAGE2D_H_ 32 | -------------------------------------------------------------------------------- /src/util/Image2DSplitData.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Image2DSplitData class 3 | */ 4 | #include "Image2DSplitData.h" 5 | 6 | namespace gaia3d 7 | { 8 | Image2DSplitData::Image2DSplitData() 9 | { 10 | m_rectangleImage_original = 0; 11 | m_rectangleImage_splitted = 0; 12 | } 13 | 14 | 15 | Image2DSplitData::~Image2DSplitData() 16 | { 17 | if (m_rectangleImage_original) 18 | delete m_rectangleImage_original; 19 | 20 | if (m_rectangleImage_splitted) 21 | delete m_rectangleImage_splitted; 22 | } 23 | 24 | void Image2DSplitData::Get_Vertices(std::vector &vec_vertices) 25 | { 26 | // this function returns no repeated vertices of the triangles.*** 27 | std::map map_vertices; 28 | size_t trianglesCount = this->m_vec_triangles.size(); 29 | for (size_t i = 0; i < trianglesCount; i++) 30 | { 31 | gaia3d::Triangle *tri = this->m_vec_triangles[i]; 32 | map_vertices[tri->getVertices()[0]] = 1; 33 | map_vertices[tri->getVertices()[1]] = 1; 34 | map_vertices[tri->getVertices()[2]] = 1; 35 | } 36 | 37 | std::map::iterator it; 38 | for (it = map_vertices.begin(); it != map_vertices.end(); it++) 39 | { 40 | vec_vertices.push_back(it->first); 41 | } 42 | } 43 | 44 | bool Image2DSplitData::TEST__AreTexCoordsInside_rectangleOriginal() 45 | { 46 | bool allTrianglesTexCoordsAreInsideOfOriginalRectangle = true; 47 | 48 | double error = 10E-12; 49 | size_t trianglesCount = this->m_vec_triangles.size(); 50 | for (size_t i = 0; i < trianglesCount; i++) 51 | { 52 | gaia3d::Triangle *tri = this->m_vec_triangles[i]; 53 | double *texCoord_0 = tri->getVertices()[0]->textureCoordinate; 54 | double *texCoord_1 = tri->getVertices()[1]->textureCoordinate; 55 | double *texCoord_2 = tri->getVertices()[2]->textureCoordinate; 56 | 57 | if (!this->m_rectangleImage_original->Intersection_withPoint(texCoord_0[0], texCoord_0[1], error)) 58 | return false; 59 | 60 | if (!this->m_rectangleImage_original->Intersection_withPoint(texCoord_1[0], texCoord_1[1], error)) 61 | return false; 62 | 63 | if (!this->m_rectangleImage_original->Intersection_withPoint(texCoord_2[0], texCoord_2[1], error)) 64 | return false; 65 | } 66 | 67 | return allTrianglesTexCoordsAreInsideOfOriginalRectangle; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/util/Image2DSplitData.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Image2DSplitData Header 3 | */ 4 | #ifndef _IMAGE2DSPLITDATA_H_ 5 | #define _IMAGE2DSPLITDATA_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "Rectangle.h" 12 | #include "../geometry/Triangle.h" 13 | #include "../geometry/Vertex.h" 14 | 15 | namespace gaia3d 16 | { 17 | class Image2DSplitData 18 | { 19 | public: 20 | Rectangle *m_rectangleImage_original; // region of the original image.*** 21 | Rectangle *m_rectangleImage_splitted; // the size is equal to "original", only differs in the position in the new image.*** 22 | std::vector m_vec_triangles; 23 | 24 | Image2DSplitData(); 25 | ~Image2DSplitData(); 26 | 27 | void Get_Vertices(std::vector &vec_vertices); 28 | 29 | bool TEST__AreTexCoordsInside_rectangleOriginal(); 30 | }; 31 | } 32 | 33 | #endif // _IMAGE2DSPLITDATA_H_ 34 | -------------------------------------------------------------------------------- /src/util/Image2DUtils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Image2DUtils Header 3 | */ 4 | #ifndef _IMAGE2DUTILS_H_ 5 | #define _IMAGE2DUTILS_H_ 6 | #pragma once 7 | 8 | #include "Image2D.h" 9 | #include "Image2DSplitData.h" 10 | 11 | namespace gaia3d 12 | { 13 | class Image2DUtils 14 | { 15 | public: 16 | 17 | std::vector m_vec_image2DSplitDatas; 18 | 19 | Image2DUtils(); 20 | ~Image2DUtils(); 21 | 22 | int* Get_AreaOnImage_OfNormalizedRectangle(Image2D *image, Rectangle *normalizedRectangle); 23 | 24 | void MULTISPLITTIMAGE_Add_ImageRectangle(Rectangle* imageRectangle, gaia3d::Triangle *triangle); 25 | void MULTISPLITTIMAGE_Delete_Image2DSplitDatas(); 26 | void MULTISPLITTIMAGE_Make_SplittedMosaic(); 27 | bool MULTISPLITTIMAGE_Recombine_ImageRectangles(); 28 | void InsertImage_ARGB(Image2D *image, Rectangle *rectSplitter, Image2D *imageToInsert_RGBA); 29 | void InsertImage_RGBA(Image2D *image, Rectangle *rectSplitter, Image2D *imageToInsert_RGBA); 30 | void Get_Region(Image2D *image, Rectangle *rectSplitter, Image2D *resultSplittedImage_RGBA); 31 | 32 | bool TEST__AllImage2DSplidatas_AreTexCoordsInside_rectangleOriginal(); 33 | 34 | private: 35 | void MULTISPLITTIMAGE_Get_BestPositionMosaic(std::vector &vec_splitDatasMosaic, Image2DSplitData *splitData_toPutInMosaic, double *posX, double *posY); 36 | bool MULTISPLITTIMAGE_IntersectsRectangle(std::vector &vec_rectangles, Rectangle *rectangle); 37 | bool MULTISPLITTIMAGE_TryToRecombine_ImageRectangle(Image2DSplitData *image2dSplitData); 38 | }; 39 | } 40 | 41 | #endif // _IMAGE2DUTILS_H_ 42 | -------------------------------------------------------------------------------- /src/util/Rectangle.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the Image2D class 3 | */ 4 | #include "Rectangle.h" 5 | 6 | namespace gaia3d 7 | { 8 | Rectangle::Rectangle() 9 | { 10 | m_minX = 0.0; 11 | m_maxX = 0.0; 12 | m_minY = 0.0; 13 | m_maxY = 0.0; 14 | } 15 | 16 | 17 | Rectangle::~Rectangle() 18 | { 19 | } 20 | 21 | double Rectangle::Get_Width() 22 | { 23 | return m_maxX - m_minX; 24 | } 25 | 26 | double Rectangle::Get_Height() 27 | { 28 | return m_maxY - m_minY; 29 | } 30 | 31 | double Rectangle::Get_Perimeter() 32 | { 33 | return (this->Get_Width() * 2 + this->Get_Height() * 2); 34 | } 35 | 36 | void Rectangle::Set_Init(double x, double y) 37 | { 38 | // use rectangle as bounding rectangle.*** 39 | m_minX = x; 40 | m_maxX = x; 41 | m_minY = y; 42 | m_maxY = y; 43 | 44 | if (m_minX < 0.0 || m_maxX < 0.0 || m_minY < 0.0 || m_maxY < 0.0) 45 | { 46 | int hola = 0; 47 | } 48 | } 49 | 50 | void Rectangle::Set(double minX, double minY, double maxX, double maxY) 51 | { 52 | // use rectangle as bounding rectangle.*** 53 | m_minX = minX; 54 | m_maxX = maxX; 55 | m_minY = minY; 56 | m_maxY = maxY; 57 | 58 | if (m_minX < 0.0 || m_maxX < 0.0 || m_minY < 0.0 || m_maxY < 0.0) 59 | { 60 | int hola = 0; 61 | } 62 | } 63 | 64 | void Rectangle::Add_Point(double x, double y) 65 | { 66 | // use rectangle as bounding rectangle.*** 67 | if (x < m_minX) 68 | m_minX = x; 69 | else if (x > m_maxX) 70 | m_maxX = x; 71 | 72 | if (y < m_minY) 73 | m_minY = y; 74 | else if (y > m_maxY) 75 | m_maxY = y; 76 | 77 | if (m_minX < 0.0 || m_maxX < 0.0 || m_minY < 0.0 || m_maxY < 0.0) 78 | { 79 | int hola = 0; 80 | } 81 | } 82 | 83 | void Rectangle::Add_Rectangle(Rectangle *rect) 84 | { 85 | // use rectangle as bounding rectangle.*** 86 | if (rect->m_minX < this->m_minX) 87 | this->m_minX = rect->m_minX; 88 | 89 | if (rect->m_maxX > this->m_maxX) 90 | this->m_maxX = rect->m_maxX; 91 | 92 | if (rect->m_minY < this->m_minY) 93 | this->m_minY = rect->m_minY; 94 | 95 | if (rect->m_maxY > this->m_maxY) 96 | this->m_maxY = rect->m_maxY; 97 | 98 | if (m_minX < 0.0 || m_maxX < 0.0 || m_minY < 0.0 || m_maxY < 0.0) 99 | { 100 | int hola = 0; 101 | } 102 | } 103 | 104 | void Rectangle::CopyFrom(Rectangle *rect) 105 | { 106 | this->m_minX = rect->m_minX; 107 | this->m_maxX = rect->m_maxX; 108 | this->m_minY = rect->m_minY; 109 | this->m_maxY = rect->m_maxY; 110 | 111 | if (m_minX < 0.0 || m_maxX < 0.0 || m_minY < 0.0 || m_maxY < 0.0) 112 | { 113 | int hola = 0; 114 | } 115 | } 116 | 117 | bool Rectangle::Intersection_withPoint(double x, double y, double error) 118 | { 119 | bool interscets = true; 120 | 121 | if (x > this->m_maxX + error) 122 | return false; 123 | else if (x < this->m_minX - error) 124 | return false; 125 | else if (y > this->m_maxY + error) 126 | return false; 127 | else if (y < this->m_minY - error) 128 | return false; 129 | 130 | return interscets; 131 | } 132 | 133 | bool Rectangle::Intersection_withRectangle(Rectangle *rect) 134 | { 135 | bool interscets = true; 136 | 137 | if (rect->m_minX > this->m_maxX) 138 | return false; 139 | else if (rect->m_maxX < this->m_minX) 140 | return false; 141 | else if (rect->m_minY > this->m_maxY) 142 | return false; 143 | else if (rect->m_maxY < this->m_minY) 144 | return false; 145 | 146 | return interscets; 147 | } 148 | 149 | bool Rectangle::Intersection_withRectangle(Rectangle *rect, double error) 150 | { 151 | bool interscets = true; 152 | 153 | if (rect->m_minX > this->m_maxX - error) 154 | return false; 155 | else if (rect->m_maxX < this->m_minX + error) 156 | return false; 157 | else if (rect->m_minY > this->m_maxY - error) 158 | return false; 159 | else if (rect->m_maxY < this->m_minY + error) 160 | return false; 161 | 162 | return interscets; 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /src/util/Rectangle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Rectangle Header 3 | */ 4 | #ifndef _RECTANGLE_H_ 5 | #define _RECTANGLE_H_ 6 | #pragma once 7 | 8 | namespace gaia3d 9 | { 10 | class Rectangle 11 | { 12 | public: 13 | 14 | double m_minX, m_maxX, m_minY, m_maxY; 15 | 16 | Rectangle(); 17 | ~Rectangle(); 18 | 19 | void Add_Point(double x, double y); 20 | void Add_Rectangle(Rectangle *rect); 21 | void CopyFrom(Rectangle *rect); 22 | double Get_Height(); 23 | double Get_Width(); 24 | double Get_Perimeter(); 25 | bool Intersection_withPoint(double x, double y, double error); 26 | bool Intersection_withRectangle(Rectangle *rect); 27 | bool Intersection_withRectangle(Rectangle *rect, double error); 28 | void Set(double minX, double minY, double maxX, double maxY); 29 | void Set_Init(double x, double y); 30 | }; 31 | 32 | } 33 | 34 | #endif // _RECTANGLE_H_ 35 | -------------------------------------------------------------------------------- /src/util/StringUtility.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Implementation of the StringUtility class 3 | */ 4 | #include "StringUtility.h" 5 | 6 | ///< 각 나라 언어에 맞는 wide string을 utf8로 변환 7 | std::string gaia3d::StringUtility::convertWideStringToUtf8(const std::wstring& wstr) 8 | { 9 | #ifdef WIN32 10 | static std::locale loc(""); 11 | auto &facet = std::use_facet>(loc); 12 | 13 | return std::wstring_convert::type, wchar_t>(&facet).to_bytes(wstr); 14 | #else 15 | std::string newString(wstr.begin(), wstr.end()); 16 | return newString; 17 | #endif 18 | } 19 | 20 | std::wstring gaia3d::StringUtility::convertUtf8ToWideString(const std::string& str) 21 | { 22 | #ifdef WIN32 23 | static std::locale loc(""); 24 | auto &facet = std::use_facet>(loc); 25 | return std::wstring_convert::type, wchar_t>(&facet).from_bytes(str); 26 | #else 27 | std::wstring newString(str.begin(), str.end()); 28 | return newString; 29 | #endif 30 | } 31 | -------------------------------------------------------------------------------- /src/util/StringUtility.h: -------------------------------------------------------------------------------- 1 | /** 2 | * StringUtility Header 3 | */ 4 | #ifndef _STRINGUTILITY_H_ 5 | #define _STRINGUTILITY_H_ 6 | #pragma once 7 | 8 | #ifdef WIN32 9 | #include 10 | #endif 11 | 12 | #include 13 | 14 | namespace gaia3d 15 | { 16 | class StringUtility 17 | { 18 | public: 19 | static std::string convertWideStringToUtf8(const std::wstring& sourceString); 20 | static std::wstring convertUtf8ToWideString(const std::string& sourceString); 21 | }; 22 | } 23 | 24 | #endif // _STRINGUTILITY_H_ -------------------------------------------------------------------------------- /src/writer/F4DWriter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * F4DWriter Header 3 | */ 4 | #ifndef _F4DWRITER_H_ 5 | #define _F4DWRITER_H_ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | class ConversionProcessor; 13 | 14 | namespace gaia3d 15 | { 16 | class OctreeBox; 17 | class TrianglePolyhedron; 18 | } 19 | 20 | class F4DWriter 21 | { 22 | public: 23 | F4DWriter(ConversionProcessor* conversionResult); 24 | 25 | virtual ~F4DWriter(); 26 | 27 | public: 28 | ConversionProcessor* processor; 29 | 30 | std::string folder; 31 | 32 | std::string version; 33 | 34 | std::string guid; 35 | 36 | int guidLength; 37 | 38 | 39 | public: 40 | void setWriteFolder(std::string folderPath) {folder = folderPath;} 41 | 42 | bool write(); 43 | 44 | bool writeIndexFile(); 45 | 46 | protected: 47 | bool writeMeshes(); 48 | 49 | bool writePoints(); 50 | 51 | bool writeHeader(FILE* f, std::map& textureIndices); 52 | 53 | bool writeVisibilityIndices(FILE* f, gaia3d::OctreeBox* octree); 54 | 55 | bool writeModels(FILE* f, std::vector& models); 56 | 57 | bool writeReferencesAndModels(std::string& referencePath, std::string& modelPath, std::string& lod2Path, std::map& textureIndices); 58 | 59 | bool writeOctreeInfo(gaia3d::OctreeBox* octree, unsigned short dataType, FILE* f); 60 | 61 | void writeColor(unsigned long color, unsigned short type, bool bAlpha, FILE* file); 62 | 63 | void writeTextures(std::string imagePath); 64 | 65 | void writeNetSurfaceMesh(gaia3d::TrianglePolyhedron* mesh, FILE* f); 66 | 67 | void writeNetSurfaceTextures(std::string resultPath); 68 | 69 | void writePointPartition(gaia3d::OctreeBox* octree, std::string& referencePath, bool bShouldCompress); 70 | }; 71 | 72 | #endif // _F4DWRITER_H_ --------------------------------------------------------------------------------