diff options
Diffstat (limited to 'src/export_png.cc')
-rw-r--r-- | src/export_png.cc | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/export_png.cc b/src/export_png.cc index 96e30fa..25e99a0 100644 --- a/src/export_png.cc +++ b/src/export_png.cc @@ -3,7 +3,9 @@ #include "OffscreenView.h" #include "CsgInfo.h" #include <stdio.h> - +#include "CGALRenderer.h" +#include "CGAL_renderer.h" +#include "cgal.h" #ifdef ENABLE_CGAL void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output) @@ -14,6 +16,29 @@ void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output) } catch (int error) { fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i.\n", error); } + CGALRenderer cgalRenderer(*root_N); + + BoundingBox bbox; + if (cgalRenderer.polyhedron) { + CGAL::Bbox_3 cgalbbox = cgalRenderer.polyhedron->bbox(); + bbox = BoundingBox(Vector3d(cgalbbox.xmin(), cgalbbox.ymin(), cgalbbox.zmin()), + Vector3d(cgalbbox.xmax(), cgalbbox.ymax(), cgalbbox.zmax())); + } + else if (cgalRenderer.polyset) { + bbox = cgalRenderer.polyset->getBoundingBox(); + } + + Vector3d center = getBoundingCenter(bbox); + double radius = getBoundingRadius(bbox); + + Vector3d cameradir(1, 1, -0.5); + Vector3d camerapos = center - radius*2*cameradir; +/* + csgInfo.glview->setCamera(camerapos, center); + csgInfo.glview->setRenderer(&cgalRenderer); + csgInfo.glview->paintGL(); + csgInfo.glview->save(outfile); +*/ output << "solid OpenSCAD_Model\n"; output << "endsolid OpenSCAD_Model\n"; } |