// // $Id: smt_draw_geometry.cpp,v 1.2 2005/06/30 14:43:48 shfu Exp $ // // File: drawGeometry.cpp // Purpose: Dump program to draw a silicon geometry as seen from the end view. // Only barrel 1 is drawn. The program writes postscript. // Created: 12-NOV-1997 John Hobbs // // $Revision: 1.2 $ // // // Include files #include #include #include #include "silicon_geometry/material/SiMaterialGeometer.hpp" #include "silicon_geometry/base/SiBaseGeometry.hpp" #include "silicon_geometry/utils/StandaloneGeometry.hpp" #include "silicon_geometry/utils/smt_build_material.hpp" #include "geometry_system/components/CartesianCoordinate.hpp" #include #include "silicon_geometry/utils/ToyDraw.hpp" using namespace std; using namespace dgs; //using std::runtime_error; //using std::vector; //using std::string; const double cm_to_points = 28.3; const double scale = 1.5; // 1 cm on picture = 1.5 cm in real life int main(int argc, char **argv) { // Get a pointer to the base geometry, and then get the remaining unused // command line arguments. StandaloneGeometry geomaker(argc,argv); d0_Ref silicon; SiMaterialGeometer* SmtMat=0; try { silicon = geomaker.get_geometry(true); SmtMat = smt_build_material(); } catch(runtime_error mistake) { std::cerr << "Caught error: " << mistake.what() << endl; exit(1); } vector sargv; geomaker.get_modified_args(sargv); // Initialize scale and output unit const double psScale = cm_to_points/scale; std::ostream *psout = &cout; if( sargv.size() == 2 ) psout = new ofstream(sargv[1].c_str()); // Get the trough. It will be drawn on each page... const SiTrough* trough = SmtMat->get_trough_material()->get_Surface(); // Initialize the postscript file and draw a box (for test purposes). draw_init(*psout); // Using each barrel, draw a trivial end view. Include the bulkheads const SiCenter* sic = silicon->get_center(1); if( !sic ) { cerr << "Error getting center(1)" << endl; exit(2); } int nbar = sic->get_barrel_count(); for( int ib=1 ; ib<=nbar ; ib++ ) { draw_newpage(*psout,psScale); const SiBarrel* sib = sic->get_barrel(ib); if( sib ) { Handle sibh = SmtMat->get_bulkhead_material(ib)->get_Surface(); draw_object(*psout,*sibh,ib); //if( trough ) draw_object(*psout,*trough); draw_object(*psout,*sib,ib); draw_endpage(*psout); } } // Finish the postscript file. draw_done(*psout); return(0); }