00001 #include "obj_iv.h"
00002
00003
00004 #include <Inventor/nodes/SoLineSet.h>
00005 #include <Inventor/nodes/SoSphere.h>
00006
00007
00008
00009 #include <Inventor/nodes/SoCoordinate3.h>
00010
00011
00012
00013
00014
00015
00016 #include <Inventor/nodes/SoSeparator.h>
00017
00018
00019 #include <algorithm>
00020
00021
00022
00028
00029 SoNode* obj_to_iv( const CGAL::Object& obj )
00030 {
00031 SoSeparator* root = new SoSeparator;
00032
00033 CGAL::Point_3<Exact_rep> p;
00034 CGAL::Segment_3<Exact_rep> s;
00035
00036 if ( assign(p,obj) ) {
00037
00038 SoSphere* sphere = new SoSphere;
00039 root->addChild(sphere);
00040 } else if ( assign(s,obj) ) {
00041 SoCoordinate3* coord = new SoCoordinate3;
00042 coord->point.setNum(2);
00043 coord->point.set1Value( 0, CGAL::to_double(s.source().x()),
00044 CGAL::to_double(s.source().y()),
00045 CGAL::to_double(s.source().z()) );
00046 coord->point.set1Value( 1, CGAL::to_double(s.target().x()),
00047 CGAL::to_double(s.target().y()),
00048 CGAL::to_double(s.target().z()) );
00049 root->addChild(coord);
00050
00051 SoLineSet* lines = new SoLineSet;
00052 lines->numVertices.set1Value(0,2);
00053 root->addChild(lines);
00054 } else {
00055 std::cerr << "Yikes!" << std::endl;
00056 }
00057
00058 return root;
00059 }