Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Quick and easy spatial localization with octree

License

NotificationsYou must be signed in to change notification settings

LoicMarechal/libOL

Repository files navigation

License: MIT

libOL version 1.82

Quick and easy spatial localization withoctree

Overview

thelibOL first store a mesh made of vertices, edges and triangles in an octree structure with a very small memory footprint.Subsequently, you can perform geometrical queries very quickly on this mesh:

  • retrieve the closest entity from a given set of coordinates
  • build the list of mesh entities than are include in a given bounding box
  • project a vertex on any kind of geometrical entity
  • launch a ray and get the first intersected entity
  • all query operations can be performed in parallel as the library is thread safe

Build

Prerequisites forLinux ormacOS

  • InstallCMake
  • A valid C99 compiler
  • Open a shell window

Prerequisites forWindows

  • You first need to installCMake. Do not forget to choose "add cmake to the path for all users", from the install panel.
  • Then you need a valid C compiler like the freeVisual Studio Community 2019
  • Open the x64 Native Tools Command Prompt for VS (or x86 if you need to build a 32-bit version)

Build commands for all platforms

  • unarchive the ZIP file
  • cd libOL-master
  • mkdir build
  • cd build
  • cmake ..
  • cmake --build . --target install

Optional steps

Optionally, you may download some sample meshes to run the examples:

  • you need to install thelibMeshb from GitHub
  • manually download files from theGit LFS repository:sample files
  • move them into /opt/libOL/sample_meshes/
  • uncompress them withxz -d *.meshb.xz
  • you may now enter /opt/libOL/examples directory and run the various examples

When speed is is more critical than memory, you can compile the library with the-DWITH_FAST_MODE option in order to speed-up queries by 35%, at the cost of 2.5 times the memory footprint.

Usage

It is made of a singleANSI C file and a header file to be compiled and linked alongside the calling program.
It may be used in C or C++ programs.Tested onLinux,macOS, andWindows 7->10.

Here is a basic example that builds an octree from a surface mesh made of vertices (NmbVer vertices stored in VerTab[]) and triangles (NmbTri elements stored in TriTab[]), then searches for the closest triangle from a set of coordinates:

int64_t OctIdx;int     TriIdx;double  dis, crd[3] = {0.2,2.5, -3.1 };// Build an octree from a surface mesh   OctIdx = LolNewOctree(  NmbVer, VerTab[1], VerTab[2],0,NULL,NULL,                           NmbTri, TriTab[1], TriTab[2],0,NULL,NULL,0,NULL,NULL,0,NULL,NULL,0,NULL,NULL,0,NULL,NULL,1,1);// Find the closest triangle from a given point   TriIdx = LolGetNearest(OctIdx, LolTypTri, crd, &dis,0.,NULL,NULL,0);// Print the triangle's index and the distance from the source pointprintf("The closest triangle from (%g %g %g) is: %d, distance = %g\n",          crd[0], crd[1], crd[2], TriIdx, dis);// Free the octreeLolFreeOctree(OctIdx);

About

Quick and easy spatial localization with octree

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp