0

It seems there are some libraries including CGAL to generate meshes from a 2D or 3D model.

Question: In C++ environment, what is the best way to obtain a set of regular nodes to represent an object that is given by a 3d file format such as the STL?

To explain the question, let me provide an example. In a 2D case, a square can be represented by the set of '1's and the empty space can be by the set of '0's.

Is there any C++ library that can deal with this task?

00000000000000
00000111000000
00000111000000
00000111000000
00000000000000

Thank you in advance.

cbuchart
  • 10,847
  • 9
  • 53
  • 93
K.Epf
  • 47
  • 1
  • 11

1 Answers1

0

CGAL it self is already a very good option, if you can match the licenses (many modules are GPL or must pay a fee for proprietary use). This answer shows an example of use.

Another complete library is the Point Clouds Library (PCL) (license compatible with commercial). If your input data is ordered (like the one shown in the question) you can use the pcl::OrganizedFastMesh class. If your data is un-ordered, then a pcl::GreedyProjectionTriangulation may be better.

Finally, if using PCL, you can save your triangle mesh to STL using [pcl::io::savePolygonFileSTL](http://docs.pointclouds.org/1.7.0/group__io.html#ga3223bdca3003262efbd8c475d4ab7cc6].

As a final note, better than trying to find a library that exactly matches your input format, find a library that can generate the result you want and then accommodate your input and output to it through convertors. Of course, if your input doesn't provide the required data, such as normals, then you must either compute it previously or search for another method ;).

Community
  • 1
  • 1
cbuchart
  • 10,847
  • 9
  • 53
  • 93