Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

obj_iv.cc

00001 #include "obj_iv.h"
00002 
00003 // shape nodes
00004 #include <Inventor/nodes/SoLineSet.h>
00005 #include <Inventor/nodes/SoSphere.h>
00006 
00007 // property nodes
00008 //#include <Inventor/nodes/SoBaseColor.h>
00009 #include <Inventor/nodes/SoCoordinate3.h>
00010 //#include <Inventor/nodes/SoMaterial.h>
00011 //#include <Inventor/nodes/SoMaterialBinding.h>
00012 //#include <Inventor/nodes/SoNormal.h>
00013 //#include <Inventor/nodes/SoNormalBinding.h>
00014 
00015 // group nodes
00016 #include <Inventor/nodes/SoSeparator.h>
00017 
00018 
00019 #include <algorithm>
00020 
00021 
00022 
00028 // TODO: handle normals (per-facet), and material properties
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         // need transform node
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 }

Generated on Fri Oct 26 23:38:10 2001 for bicobj-intersection by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001