Git Product home page Git Product logo

cg3lib's Introduction

cg3lib

Actions Status

Actions Status

DOI

Cg3Lib is a C++ geometry processing library developed by the CG3HCI Group of the University of Cagliari. It is composed of different modules:

  • Core: it provides some basic data structures (Point, BoundingBox...), parsers for saving and loading multiple mesh formats and utilities;
  • Meshes: some Mesh data structures which help to manage easily 3D meshes;
  • Data Structures: some generic (not necessarily geometric) data structures like arrays, trees, graphs;
  • Algorithms: a collection of geometry processing and computetional geometry algorithms;
  • Viewer: a 3D viewer developed with Qt and based on libQGLViewer (http://libqglviewer.com/): it allows to render easily mesh data structures and to create easyly guis (drag&drop with QtCreator);
  • Cgal: a simple interface which allows to use some CGAL functionalities (https://www.cgal.org/);
  • Voro++: a simple 3D Voronoi Data structures computed using the voro++ library (http://math.lbl.gov/voro++/)
  • LibIGL: a simple interface which allows to use some LibIGL functionalities (http://libigl.github.io/libigl/);
  • CinoLib: a simple interface which allows to use some CinoLib functionalities (https://github.com/mlivesu/cinolib);
  • VCGLib: a simple interface which allows to use some VCGLib functionalities (https://github.com/cnr-isti-vclab/vcglib)

All these modules are optional (except of the core module) and the project can be compiled on Windows, MacOS and Linux. The documentation can be found at the following link: https://cg3hci.github.io/index.html.

Installation

MacOS

git clone https://github.com/cg3hci/cg3lib.git
bash cg3lib/install_macos.sh

Ubuntu

git clone https://github.com/cg3hci/cg3lib.git
bash cg3lib/install_ubuntu.sh

Usage

Look at the examples in the "examples" folder inside the repo.

Compiling the examples:

cd cg3lib/examples
qmake
make

Citation

DOI

If you use cg3lib in your research projects, please cite the library using this BibTeX entry:

@software{cg3lib,
  author       = {Alessandro Muntoni and Stefano Nuvoli},
  title        = {{CG3Lib: A C++ geometry processing library}},
  month        = jan,
  year         = 2021,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.4431777}
}

ToDo list

cg3lib's People

Contributors

alemuntoni avatar f-fanni avatar stefanonuvoli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cg3lib's Issues

there are some errors in libigl_booleans

the rest of examples are normal with some warnings. but there are some errors in libigl_booleans.
I think the problem is libigl/include/igl/decimate.h in cg3lib/cg3/libigl is totally different

g++ -c -pipe -fopenmp -isystem /opt/libigl/include/ -std=c++11 -O2 -std=gnu++1y -Wall -Wextra -D_REENTRANT -fPIC -DCGAL_HEADER_ONLY -DCG3_QMAKE -DCG3_CORE_DEFINED -DCG3_WITH_BOOST -DCG3_CGAL_DEFINED -DCGAL_EIGEN3_ENABLED -DCG3_LIBIGL_DEFINED -DCG3_VIEWER_DEFINED -DSOURCE_PATH=/home/zcc2xj/Github/cg3lib/examples/libigl_booleans -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_CORE_LIB -I. -I-I -I/usr/include/eigen3 -I/opt/libigl/include -I../../../cg3lib -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtOpenGL -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtXml -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o booleans_manager.o ../../cg3/viewer/managers/booleans_manager.cpp
g++ -c -pipe -fopenmp -isystem /opt/libigl/include/ -std=c++11 -O2 -std=gnu++1y -Wall -Wextra -D_REENTRANT -fPIC -DCGAL_HEADER_ONLY -DCG3_QMAKE -DCG3_CORE_DEFINED -DCG3_WITH_BOOST -DCG3_CGAL_DEFINED -DCGAL_EIGEN3_ENABLED -DCG3_LIBIGL_DEFINED -DCG3_VIEWER_DEFINED -DSOURCE_PATH=/home/zcc2xj/Github/cg3lib/examples/libigl_booleans -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_CORE_LIB -I. -I-I -I/usr/include/eigen3 -I/opt/libigl/include -I../../../cg3lib -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtOpenGL -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtXml -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o main.o main.cpp
In file included from ../../../cg3lib/cg3/libigl/internal/eigenmesh_libigl_algorithms.h:117,
from ../../../cg3lib/cg3/libigl/booleans.cpp:10,
from ../../../cg3lib/cg3/libigl/booleans.h:58,
from ../../cg3/viewer/managers/booleans_manager.cpp:15:
../../../cg3lib/cg3/libigl/internal/eigenmesh_libigl_algorithms_decimation.cpp: In static member function ‘static cg3::SimpleEigenMesh cg3::libigl::internal::EigenMeshLibIglAlgorithms::decimateMesh(const cg3::SimpleEigenMesh&, int, Eigen::VectorXi&)’:
../../../cg3lib/cg3/libigl/internal/eigenmesh_libigl_algorithms_decimation.cpp:30:18: error: no matching function for call to ‘decimate(const Eigen::Matrix<double, -1, 3, 1, -1, 3>&, const Eigen::Matrix<int, -1, 3, 1, -1, 3>&, int&, Eigen::MatrixXd&, Eigen::MatrixXi&, Eigen::VectorXi&)’
30 | igl::decimate(m.V, m.F, numberDesiredFaces, VV, FF, mapping);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/libigl/include/igl/decimate.h:182,
from ../../../cg3lib/cg3/libigl/internal/eigenmesh_libigl_algorithms_decimation.cpp:10,
from ../../../cg3lib/cg3/libigl/internal/eigenmesh_libigl_algorithms.h:117,
from ../../../cg3lib/cg3/libigl/booleans.cpp:10,
from ../../../cg3lib/cg3/libigl/booleans.h:58,
from ../../cg3/viewer/managers/booleans_manager.cpp:15:
/opt/libigl/include/igl/decimate.cpp:22:17: note: candidate: ‘bool igl::decimate(const MatrixXd&, const MatrixXi&, int, bool, Eigen::MatrixXd&, Eigen::MatrixXi&, Eigen::VectorXi&, Eigen::VectorXi&)’
22 | IGL_INLINE bool igl::decimate(
| ^~~
/opt/libigl/include/igl/decimate.cpp:22:17: note: candidate expects 8 arguments, 6 provided
/opt/libigl/include/igl/decimate.cpp:138:17: note: candidate: ‘bool igl::decimate(const MatrixXd&, const MatrixXi&, const decimate_cost_and_placement_callback&, const decimate_stopping_condition_callback&, const decimate_pre_collapse_callback&, const decimate_post_collapse_callback&, const MatrixXi&, const VectorXi&, const MatrixXi&, const MatrixXi&, Eigen::MatrixXd&, Eigen::MatrixXi&, Eigen::VectorXi&, Eigen::VectorXi&)’

Better Line2 representation

I've noticed you are using the y = mx + q representation for Line2.
This representation does not allow the use of vertical lines.
You did implement a workaround when constructing the line from 2 points
Line2::Line2(const Point2d& p1, const Point2d& p2)
but you did not implement it when creating it from m and a point
Line2::Line2(double m, const Point2d& p).
You are also forced to have multiple branches in Line2::intersection.

I believe that a better representation would be ax + by + c = 0.
The conversion from this to the other representation is given by the equations
m = -a/b and q = -c/b.
Intersections between 2 lines, 1 and 2, are given by the solution of the equation system:

| a1 b1 | * | x | = |-c1|
| a2 b2 |   | y |   |-c2| 

This requires only one branch, when checking if the determinant of the matrix is 0.

With your implementation of y = mx + q you also have weird results with horizontal and vertical lines:
Line( y = 5 ), xValue(2) and xValue(5) throw for division by zero.
Line( x = 5 ), xValue(2) and xValue(5) return 5, yValue(2) and yValue(5) return Infinity

In my opinion the correct results would be:
Line( y = 5 ), xValue(2) returns NaN and xValue(5) returns Infinity.
Line( x = 5 ), xValue(2) returns NaN and xValue(5) returns Infinity.
I believe that correct results are easier to achieve with the ax + by + c = 0 representation, as it handles edge cases better and handles either coordinate in a symmetric way.

The only problem this representation has is that is not unique: all lines of the form kax + kby + kc = 0 are the same line, making comparisons bothersome.
This problem can be solved by normalizing the vector [a b c] on construction.
It is not required to use norm2 (which requires a square root).
Any norm will work fine, and a good candidate would be max(a, b, c).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.