// ---------------------------------------------------------------------- void RectangleTopologyTask:: run( shawn::SimulationController& sc ) throw( std::runtime_error ) { double x1 = sc.environment().required_double_param("x1"); double x2 = sc.environment().required_double_param("x2"); double y1 = sc.environment().required_double_param("y1"); double y2 = sc.environment().required_double_param("y2"); std::string n = sc.environment().optional_string_param("name",""); if( x1 > x2 ) throw std::runtime_error("rectangle has negative X size"); if( y1 > y2 ) throw std::runtime_error("rectangle has negative Y size"); topology_keeper_w(sc).add( new RectangleTopology(Box(Vec(x1,y1,0.0), Vec(x2,y2,0.0)), n) ); }
// ---------------------------------------------------------------------- void XMLPolygonTopologyTask:: run( shawn::SimulationController& sc ) throw( std::runtime_error ) { std::string f = sc.environment().required_string_param("file"); std::string n = sc.environment().required_string_param("name"); bool create_outer = sc.environment().optional_bool_param("xml_create_outer_hull", false) || sc.environment().optional_bool_param("create_outer_hull", false); bool fix_non_simple_polygons = sc.environment().optional_bool_param("fix_non_simple_polygons", false); XMLPolygonTopology* p = new XMLPolygonTopology; p->set_name(n); p->read(sc, f, create_outer, fix_non_simple_polygons); topology_keeper_w(sc).add(p); }
// ---------------------------------------------------------------------- void CuboidTopologyTask:: run( shawn::SimulationController& sc ) throw( std::runtime_error ) { double x1 = sc.environment().required_double_param("x1"); double x2 = sc.environment().required_double_param("x2"); double y1 = sc.environment().required_double_param("y1"); double y2 = sc.environment().required_double_param("y2"); double z1 = sc.environment().required_double_param("z1"); double z2 = sc.environment().required_double_param("z2"); std::string n = sc.environment().optional_string_param("name",""); if( x1 > x2 ) throw std::runtime_error("cuboid has negative X size"); if( y1 > y2 ) throw std::runtime_error("cuboid has negative Y size"); if( z1 > z2 ) throw std::runtime_error("cuboid has negative Z size"); topology_keeper_w(sc).add( new CuboidTopology(Box(Vec(x1,y1,z1), Vec(x2,y2,z2)), n) ); }