diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-01-24 03:49:16 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-01-24 03:49:16 (GMT) |
commit | a563c84bcfc36c3c2ab165386df3483b4063768b (patch) | |
tree | ffad918f5eeca657a0bc4a6ed598b4a63b67ca3a /src/export_png.cc | |
parent | 44af912be83d37ff2ef90c084d70b25b358d6d72 (diff) |
move bounding box helper functions to linalg. put bbox code in export_png
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"; } |