Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions py3dtilers/IfcTiler/IfcTiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def __init__(self):
dest='with_BTH',
action='store_true',
help='Adds a Batch Table Hierarchy when defined')
self.parser.add_argument('--class_filter',
nargs='*',
help='Select IfcType to tile'
)

def get_output_dir(self):
"""
Expand All @@ -30,15 +34,15 @@ def get_output_dir(self):
else:
return self.args.output_dir

def from_ifc(self, grouped_by, with_BTH):
def from_ifc(self, grouped_by, with_BTH, class_filter):
"""
:return: a tileset.
"""
objects = []
for ifc_file in self.files:
print("Reading " + str(ifc_file))
if grouped_by == 'IfcTypeObject':
pre_tileset = IfcObjectsGeom.retrievObjByType(ifc_file, with_BTH)
pre_tileset = IfcObjectsGeom.retrievObjByType(ifc_file, with_BTH, class_filter)
elif grouped_by == 'IfcGroup':
pre_tileset = IfcObjectsGeom.retrievObjByGroup(ifc_file, with_BTH)
elif grouped_by == 'IfcSpace':
Expand All @@ -62,7 +66,7 @@ def main():
ifc_tiler = IfcTiler()
ifc_tiler.parse_command_line()
args = ifc_tiler.args
tileset = ifc_tiler.from_ifc(args.grouped_by, args.with_BTH)
tileset = ifc_tiler.from_ifc(args.grouped_by, args.with_BTH, args.class_filter)

if tileset is not None:
tileset.write_as_json(ifc_tiler.get_output_dir())
Expand Down
33 changes: 16 additions & 17 deletions py3dtilers/IfcTiler/ifcObjectGeom.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def create_batch_table_extension(extension_name, ids, objects):
return None

@staticmethod
def retrievObjByType(path_to_file, with_BTH):
def retrievObjByType(path_to_file, with_BTH,class_filter):
"""
:param path: a path to a directory

Expand All @@ -187,28 +187,27 @@ def retrievObjByType(path_to_file, with_BTH):

buildings = ifc_file.by_type('IfcBuilding')
dictObjByType = dict()
_ = ifc_file.by_type('IfcSlab')
i = 1

for building in buildings:
elements = ifcopenshell.util.element.get_decomposition(building)
nb_element = str(len(elements))
logging.info(nb_element + " elements to parse in building :" + building.GlobalId)
for element in elements:
start_time = time.time()
logging.info(str(i) + " / " + nb_element)
logging.info("Parsing " + element.GlobalId + ", " + element.is_a())
obj = IfcObjectGeom(element, with_BTH=with_BTH)
if obj.hasGeom():
if not (element.is_a() + building.GlobalId in dictObjByType):
dictObjByType[element.is_a() + building.GlobalId] = IfcObjectsGeom()
if obj.material:
obj.material_index = dictObjByType[element.is_a() + building.GlobalId].get_material_index(obj.material)
else:
obj.material_index = 0
dictObjByType[element.is_a() + building.GlobalId].append(obj)
logging.info("--- %s seconds ---" % (time.time() - start_time))
i = i + 1
if(not(class_filter) or element.is_a() in class_filter):
start_time = time.time()
logging.info(str(i) + " / " + nb_element)
logging.info("Parsing " + element.GlobalId + ", " + element.is_a())
obj = IfcObjectGeom(element, with_BTH=with_BTH)
if obj.hasGeom():
if not (element.is_a() + building.GlobalId in dictObjByType):
dictObjByType[element.is_a() + building.GlobalId] = IfcObjectsGeom()
if obj.material:
obj.material_index = dictObjByType[element.is_a() + building.GlobalId].get_material_index(obj.material)
else:
obj.material_index = 0
dictObjByType[element.is_a() + building.GlobalId].append(obj)
logging.info("--- %s seconds ---" % (time.time() - start_time))
i = i + 1
return dictObjByType

@staticmethod
Expand Down