def execute(self, pycitygml_reader, nrmlised_parm_list): parm_list = self.map_nrmlise_parms_2_parms(nrmlised_parm_list) citygml_writer = pycitygml.Writer() gml_landuses = pycitygml_reader.get_landuses() gml_bldg_list = pycitygml_reader.get_buildings() bcnt = 0 for gml_landuse in gml_landuses: #echeck which buildings are on this plot gml_bldg_on_luse = gml3dmodel.buildings_on_landuse( gml_landuse, gml_bldg_list, pycitygml_reader) #check which buildings should this parameter be applied to eligibility_bldg_list, non_eligible_bldg_list = self.eligibility_test( gml_bldg_on_luse, pycitygml_reader) n_eligibility_bldgs = len(eligibility_bldg_list) #get the parameters for this landuse plot parms_4_luse = parm_list[bcnt:bcnt + n_eligibility_bldgs] #change the bldgs height bcnt = 0 for eligible_gml_bldg in eligibility_bldg_list: #get the height parm for the bldg height_parm = parms_4_luse[bcnt] #extract the bldg solid bldg_solid = gml3dmodel.get_building_occsolid( eligible_gml_bldg, pycitygml_reader) #change the height of each bldg according to the parameter height, nstorey, storey_height = gml3dmodel.get_building_height_storey( eligible_gml_bldg, pycitygml_reader) bldg_bounding_footprint = gml3dmodel.get_building_bounding_footprint( bldg_solid) midpt = py3dmodel.calculate.face_midpt(bldg_bounding_footprint) height_ratio = float(height_parm) / height scaled_bldg = py3dmodel.modify.uniform_scale( bldg_solid, 1, 1, height_ratio, midpt) new_bldg_occsolid = py3dmodel.fetch.geom_explorer( scaled_bldg, "solid")[0] new_height, new_n_storey = gml3dmodel.calculate_bldg_height_n_nstorey( new_bldg_occsolid, storey_height) gml3dmodel.update_gml_building(eligible_gml_bldg, new_bldg_occsolid, pycitygml_reader, citygml_writer, new_height=new_height, new_nstorey=new_n_storey) bcnt += 1 non_bldg_cityobjs = pycitygml_reader.get_non_xtype_cityobject( "bldg:Building") gml3dmodel.write_citygml(non_bldg_cityobjs, citygml_writer) gml3dmodel.write_non_eligible_bldgs(non_eligible_bldg_list, citygml_writer) citymodel_node = citygml_writer.citymodelnode reader = pycitygml.Reader() reader.load_citymodel_node(citymodel_node) return reader
def generate_design_variant(self, parameters, dv_citygml_filepath): """ This function defines generates a design alternative based on all the appended parameter objects. Parameters ---------- parameters : list of ints/floats The normalised parameters to be mapped to the real parameters defined, the parameters will be used to generate a design alternative. dv_citygml_filepath : str The file path of the CityGML file to write the generated design alternative. """ if self.nparameters == None: self.define_nparameters() parm_obj_dict_list = self.parm_obj_dict_list citygml_reader = self.citygml for parm_obj_dict in parm_obj_dict_list: parm_obj = parm_obj_dict["parameter_object"] parm_cnt = parm_obj_dict["parameter_count"] parm_object_parms = parameters[parm_cnt[0]:parm_cnt[1]] print parm_obj citygml_reader = parm_obj.execute(citygml_reader, parm_object_parms) citygml_writer = pycitygml.Writer() citygml_writer.citymodel_node = citygml_reader.citymodel_node citygml_writer.write(dv_citygml_filepath) #===================================================================================================================================================
def execute_template_rule(self, citygml_filepath, tolerance = 1e-02): template_rule_obj_list = self.template_rule_obj_list occshape_attribs_obj_list = self.occshp_attribs_obj_list pycitygml_writer = pycitygml.Writer() for template_rule_obj in template_rule_obj_list: print template_rule_obj template_rule_obj.identify(occshape_attribs_obj_list, pycitygml_writer) pycitygml_writer.write(citygml_filepath)
def execute_template_rule(self, citygml_filepath): """ This function executes the template rule and convert the geometry to semantic models. Parameters ---------- citygml_filepath : str The file path of the resultant CityGML file. """ template_rule_obj_list = self.template_rule_obj_list occshape_attribs_obj_list = self.occshp_attribs_obj_list pycitygml_writer = pycitygml.Writer() for template_rule_obj in template_rule_obj_list: print template_rule_obj template_rule_obj.identify(occshape_attribs_obj_list, pycitygml_writer) pycitygml_writer.write(citygml_filepath)
def generate_design_variant(self, parameters, dv_citygml_filepath): if self.nparameters == None: self.define_nparameters() parm_obj_dict_list = self.parm_obj_dict_list citygml_reader = self.citygml for parm_obj_dict in parm_obj_dict_list: parm_obj = parm_obj_dict["parameter_object"] parm_cnt = parm_obj_dict["parameter_count"] parm_object_parms = parameters[parm_cnt[0]:parm_cnt[1]] citygml_reader = parm_obj.execute(citygml_reader, parm_object_parms) citygml_writer = pycitygml.Writer() citygml_writer.citymodelnode = citygml_reader.citymodelnode citygml_writer.write(dv_citygml_filepath) #===================================================================================================================================================
def execute(self, pycitygml_reader, nrmlised_parm_list): citygml_writer = pycitygml.Writer() gml_landuses = pycitygml_reader.get_landuses() gml_bldg_list = pycitygml_reader.get_buildings() bcnt = 0 for gml_landuse in gml_landuses: #echeck which buildings are on this plot gml_bldg_on_luse = gml3dmodel.buildings_on_landuse( gml_landuse, gml_bldg_list, pycitygml_reader) #check which buildings should this parameter be applied to eligibility_bldg_list, non_eligible_bldg_list = self.eligibility_test( gml_bldg_on_luse, pycitygml_reader) n_eligibility_bldgs = len(eligibility_bldg_list) #grid the plot luse_occface = gml3dmodel.gml_landuse_2_occface( gml_landuse, pycitygml_reader) pypt_list, grid_faces = gml3dmodel.landuse_2_grid( luse_occface, self.xdim, self.ydim) npypt_list = len(pypt_list) self.define_int_range(0, npypt_list - 1, 1) #get the parameters for this landuse plot nrmlised_parms_4_luse = nrmlised_parm_list[bcnt:bcnt + n_eligibility_bldgs] parms_4_luse = self.map_nrmlise_parms_2_parms( nrmlised_parms_4_luse) bldg_occsolid_list = [] #get all the occsolid of the buildings for eligible_gml_bldg in eligibility_bldg_list: bldg_occsolid = gml3dmodel.get_building_occsolid( eligible_gml_bldg, pycitygml_reader) bldg_occsolid_list.append(bldg_occsolid) non_bldg_occsolid_list = [] for non_eligible_gml_bldg in non_eligible_bldg_list: non_bldg_occsolid = gml3dmodel.get_building_occsolid( non_eligible_gml_bldg, pycitygml_reader) non_bldg_occsolid_list.append(non_bldg_occsolid) posed_bldg_occsolid_list = gml3dmodel.rearrange_building_position( bldg_occsolid_list, pypt_list, luse_occface, parms_4_luse, other_occsolids=non_bldg_occsolid_list, clash_detection=self.clash_detection, boundary_detection=self.boundary_detection) for up_cnt in range(n_eligibility_bldgs): gml_bldg = eligibility_bldg_list[up_cnt] new_building_solid = posed_bldg_occsolid_list[up_cnt] gml3dmodel.update_gml_building(gml_bldg, new_building_solid, pycitygml_reader, citygml_writer) bcnt += n_eligibility_bldgs non_bldg_cityobjs = pycitygml_reader.get_non_xtype_cityobject( "bldg:Building") gml3dmodel.write_citygml(non_bldg_cityobjs, citygml_writer) gml3dmodel.write_non_eligible_bldgs(non_eligible_bldg_list, citygml_writer) citymodel_node = citygml_writer.citymodelnode reader = pycitygml.Reader() reader.load_citymodel_node(citymodel_node) return reader
def execute(self, pycitygml_reader, nrmlised_parm_list): parm_list = self.map_nrmlise_parms_2_parms(nrmlised_parm_list) citygml_writer = pycitygml.Writer() gml_landuses = pycitygml_reader.get_landuses() gml_bldg_list = pycitygml_reader.get_buildings() bcnt = 0 for gml_landuse in gml_landuses: #echeck which buildings are on this plot gml_bldg_on_luse = gml3dmodel.buildings_on_landuse( gml_landuse, gml_bldg_list, pycitygml_reader) #check which buildings should this parameter be applied to eligibility_bldg_list, non_eligible_bldg_list = self.eligibility_test( gml_bldg_on_luse, pycitygml_reader) n_eligibility_bldgs = len(eligibility_bldg_list) #get the parameters for this landuse plot parms_4_luse = parm_list[bcnt:bcnt + n_eligibility_bldgs] luse_occface = gml3dmodel.gml_landuse_2_occface( gml_landuse, pycitygml_reader) #get all the bldg_occsolid roting_bldg_occsolid_list = [] for gml_bldg in eligibility_bldg_list: bldg_occsolid = gml3dmodel.get_building_occsolid( gml_bldg, pycitygml_reader) roting_bldg_occsolid_list.append(bldg_occsolid) non_roting_bldg_occsolid_list = [] for non_gml_bldg in non_eligible_bldg_list: non_bldg_occsolid = gml3dmodel.get_building_occsolid( non_gml_bldg, pycitygml_reader) non_roting_bldg_occsolid_list.append(non_bldg_occsolid) #rotate the buildings for cnt in range(n_eligibility_bldgs): eligible_gml_bldg = eligibility_bldg_list[cnt] rot_angle = parms_4_luse[cnt] rot_bldg_occsolid = gml3dmodel.rotate_bldg( eligible_gml_bldg, rot_angle, pycitygml_reader) roting_bldg_occsolid_list2 = roting_bldg_occsolid_list[:] del roting_bldg_occsolid_list2[cnt] roting_bldg_occsolid_list2.extend( non_roting_bldg_occsolid_list) if self.clash_detection == True and self.boundary_detection == False: clash_detected = gml3dmodel.detect_clash( rot_bldg_occsolid, roting_bldg_occsolid_list2) if not clash_detected: #there is no clash roting_bldg_occsolid_list[cnt] = rot_bldg_occsolid elif self.boundary_detection == True and self.clash_detection == False: is_in_boundary = gml3dmodel.detect_in_boundary( rot_bldg_occsolid, luse_occface) if is_in_boundary: #it is within the boundary roting_bldg_occsolid_list[cnt] = rot_bldg_occsolid elif self.boundary_detection == True and self.clash_detection == True: clash_detected = gml3dmodel.detect_clash( rot_bldg_occsolid, roting_bldg_occsolid_list2) is_in_boundary = gml3dmodel.detect_in_boundary( rot_bldg_occsolid, luse_occface) if not clash_detected and is_in_boundary: roting_bldg_occsolid_list[cnt] = rot_bldg_occsolid elif self.clash_detection == False and self.boundary_detection == False: roting_bldg_occsolid_list[cnt] = rot_bldg_occsolid for up_cnt in range(n_eligibility_bldgs): gml_bldg = eligibility_bldg_list[up_cnt] new_building_solid = roting_bldg_occsolid_list[up_cnt] gml3dmodel.update_gml_building(gml_bldg, new_building_solid, pycitygml_reader, citygml_writer) bcnt += n_eligibility_bldgs non_bldg_cityobjs = pycitygml_reader.get_non_xtype_cityobject( "bldg:Building") gml3dmodel.write_citygml(non_bldg_cityobjs, citygml_writer) gml3dmodel.write_non_eligible_bldgs(non_eligible_bldg_list, citygml_writer) citymodel_node = citygml_writer.citymodelnode reader = pycitygml.Reader() reader.load_citymodel_node(citymodel_node) return reader
def execute(self, pycitygml_reader, nrmlised_parm_list): parm_list = self.map_nrmlise_parms_2_parms(nrmlised_parm_list) citygml_writer = pycitygml.Writer() gml_landuses = pycitygml_reader.get_landuses() gml_bldg_list = pycitygml_reader.get_buildings() bcnt = 0 for gml_landuse in gml_landuses: #echeck which buildings are on this plot gml_bldg_on_luse = gml3dmodel.buildings_on_landuse( gml_landuse, gml_bldg_list, pycitygml_reader) #check which buildings should this parameter be applied to eligibility_bldg_list, non_eligible_bldg_list = self.eligibility_test( gml_bldg_on_luse, pycitygml_reader) n_eligibility_bldgs = len(eligibility_bldg_list) #calculate the total landuse floor area luse_flr_area = 0 for eligible_gml_bldg in eligibility_bldg_list: height, nstorey, storey_height = gml3dmodel.get_building_height_storey( eligible_gml_bldg, pycitygml_reader) bldg_flr_area, flrplates = gml3dmodel.get_bulding_floor_area( eligible_gml_bldg, nstorey, storey_height, pycitygml_reader) luse_flr_area += bldg_flr_area #get the parameters for this landuse plot parms_4_luse = parm_list[bcnt:bcnt + n_eligibility_bldgs] total_prop = float(sum(parms_4_luse)) #redistribute the flr area new_bldg_flr_area_list = [] for parm in parms_4_luse: new_bldg_flr_area = float(parm) / total_prop * luse_flr_area new_bldg_flr_area_list.append(new_bldg_flr_area) #reconstuct the buildings according to the new distribuition for cnt in range(n_eligibility_bldgs): gml_bldg = eligibility_bldg_list[cnt] bldg_occsolid = gml3dmodel.get_building_occsolid( gml_bldg, pycitygml_reader) height, nstorey, storey_height = gml3dmodel.get_building_height_storey( gml_bldg, pycitygml_reader) new_bldg_flr_area = new_bldg_flr_area_list[cnt] new_building_solid = gml3dmodel.construct_building_through_floorplates( bldg_occsolid, new_bldg_flr_area, storey_height) new_height, new_n_storey = gml3dmodel.calculate_bldg_height_n_nstorey( new_building_solid, storey_height) gml3dmodel.update_gml_building(gml_bldg, new_building_solid, pycitygml_reader, citygml_writer, new_height=new_height, new_nstorey=new_n_storey) bcnt += n_eligibility_bldgs non_bldg_cityobjs = pycitygml_reader.get_non_xtype_cityobject( "bldg:Building") gml3dmodel.write_citygml(non_bldg_cityobjs, citygml_writer) gml3dmodel.write_non_eligible_bldgs(non_eligible_bldg_list, citygml_writer) citymodel_node = citygml_writer.citymodelnode reader = pycitygml.Reader() reader.load_citymodel_node(citymodel_node) return reader