void SinglePoint::run() { DM::System * sys = this->getData("sys"); sys->addNode(x,y,z, DM::View(viewname, DM::NODE, DM::WRITE)); }
void ModernBuilding::run() { std::vector<double> roofColor; roofColor.push_back(0.66); roofColor.push_back(0.66); roofColor.push_back(0.66); std::vector<double> wallColor; wallColor.push_back(196./255.); wallColor.push_back(196./255.); wallColor.push_back(196./255.); std::vector<double> windowColor; windowColor.push_back(0.53); windowColor.push_back(0.81); windowColor.push_back(1); //Get simulation datastream DM::System * city = this->getData("city"); //Create building container DM::Component * building = city->addComponent(new Component(), buildings); //Set building parameters building->addAttribute("type", 1001); building->addAttribute("built_year", buildyear); building->addAttribute("stories", stories); building->addAttribute("stories_below", 0); //cellar counts as story building->addAttribute("stories_height",3 ); building->addAttribute("floor_area", l*b); building->addAttribute("gross_floor_area", l * b * stories); building->addAttribute("V_living", l*b*stories * 3); building->addAttribute("l_bounding", l); building->addAttribute("b_bounding", b); building->addAttribute("h_bounding", stories * 3); building->addAttribute("alpha_bounding", 0); building->addAttribute("alpha_roof", 0); building->addAttribute("cellar_used", 1); building->addAttribute("roof_used", 0); building->addAttribute("T_heating", heatingT); building->addAttribute("T_cooling", 26); //Building Footprint. Orientation matters. Check if the normal vector of the face is in your direction std::vector<DM::Node * > nodes_footprint; DM::Node * n1 = city->addNode(-l/2., -b/2., 0.); DM::Node * n2 = city->addNode( l/2., -b/2., 0.); DM::Node * n3 = city->addNode( l/2., b/2., 0.); DM::Node * n4 = city->addNode(-l/2., b/2., 0.); nodes_footprint.push_back(n1); nodes_footprint.push_back(n2); nodes_footprint.push_back(n3); nodes_footprint.push_back(n4); nodes_footprint.push_back(n1); //To a closed polygon last is first //Overhang DM::Node n1_c (-l/2. - overhang, -b/2. - overhang, 0.); DM::Node n2_c ( l/2. + overhang, -b/2. - overhang, 0.); DM::Node n3_c ( l/2. + overhang, b/2. + overhang, 0.); DM::Node n4_c (-l/2. - overhang, b/2. + overhang, 0.); std::vector<DM::Node> overhang_nodes; overhang_nodes.push_back(n1_c); overhang_nodes.push_back(n2_c); overhang_nodes.push_back(n3_c); overhang_nodes.push_back(n4_c); //Add Footprint DM::Face * footprint = city->addFace(nodes_footprint, footprints); Node n = DM::CGALGeometry::CalculateCentroid(city, footprint); building->addAttribute("centroid_x", n.getX()); building->addAttribute("centroid_y", n.getY()); //Set footprint as floor DM::Face * base_plate = city->addFace(nodes_footprint, geometry); building->getAttribute("Geometry")->addLink(base_plate, "Geometry"); //Define baseplate as cellar base_plate->addAttribute("type", "ceiling_cellar"); //Extrude Footprint for (int story = 0; story < stories; story++) { std::vector<DM::Face*> extruded_faces = TBVectorData::ExtrudeFace(city, geometry, nodes_footprint, 3); //last face in vector is ceiling int unsigned lastID = extruded_faces.size()-1; for (unsigned int i = 0; i < extruded_faces.size(); i++) { DM::Face * f = extruded_faces[i]; //if wall if (i != lastID) { //Add type f->addAttribute("type", "wall_outside"); //Add color f->getAttribute("color")->setDoubleVector(wallColor); //Create Windows every 5m with = 1.5m height = 1.0m std::vector<DM::Face* > windows = LittleGeometryHelpers::CreateHolesInAWall(city, f, w_distance, w_width, w_height, parapet); foreach (DM::Face * w, windows) { city->addComponentToView(w, this->geometry); w->addAttribute("type", "window"); w->getAttribute("color")->setDoubleVector(windowColor); building->getAttribute("Geometry")->addLink(w, "Geometry"); } } //if ceiling else if (story != stories -1){