summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-09-01 15:02:50 (GMT)
committerMarius Kintel <marius@kintel.net>2011-09-01 15:02:50 (GMT)
commitfee63ab7aec661ea3fe5890e79df752f1af10690 (patch)
tree92273d738a809fbd0e282ec91d03eb6fc62ff33e
parent24d81b5732c178998f640e86b336196272f31bc5 (diff)
added bbox calculation
-rw-r--r--tests/cgalpngtest.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc
index e864090..2680752 100644
--- a/tests/cgalpngtest.cc
+++ b/tests/cgalpngtest.cc
@@ -36,7 +36,9 @@
#include "CGAL_Nef_polyhedron.h"
#include "CGALEvaluator.h"
#include "PolySetCGALEvaluator.h"
-#include "CGALRenderer.h"
+#include "cgalrenderer.h"
+#include "CGAL_renderer.h"
+#include "cgal.h"
#include "OffscreenView.h"
#include <QApplication>
@@ -182,16 +184,6 @@ int main(int argc, char **argv)
QDir::setCurrent(original_path.absolutePath());
csgInfo.glview = new OffscreenView(512,512);
-// FIXME: Get bbox from CGAL mesh BoundingBox bbox = csgInfo.root_chain->getBoundingBox();
- BoundingBox bbox;
-
- Vector3d center = (bbox.min() + bbox.max()) / 2;
- double radius = (bbox.max() - bbox.min()).norm() / 2;
-
-
- Vector3d cameradir(1, 1, -0.5);
- Vector3d camerapos = center - radius*1.5*cameradir;
- csgInfo.glview->setCamera(camerapos, center);
glewInit();
#ifdef DEBUG
@@ -213,6 +205,22 @@ int main(int argc, char **argv)
#endif
CGALRenderer cgalRenderer(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()));
+ }
+ Vector3d center = (bbox.min() + bbox.max()) / 2;
+ double radius = (bbox.max() - bbox.min()).norm() / 2;
+
+
+ Vector3d cameradir(1, 1, -0.5);
+ Vector3d camerapos = center - radius*1.5*cameradir;
+ csgInfo.glview->setCamera(camerapos, center);
+
+
csgInfo.glview->setRenderer(&cgalRenderer);
csgInfo.glview->paintGL();
csgInfo.glview->save("/dev/stdout");
contact: Jan Huwald // Impressum