def test_list_of_shapes_to_compound(self): box_shp = get_test_box_shape() sph_shp = get_test_sphere_shape(20.0) result, all_shape_converted = list_of_shapes_to_compound( [box_shp, sph_shp]) self.assertTrue(all_shape_converted) self.assertEqual(get_type_as_string(result), "Compound")
def main(): shp = read_step_file( 'Models/00000000_290a9120f9f249a7a05cfe9c_step_000.step') shape_type = get_type_as_string(shp) t = TopologyFactory(shape_type) shape = t.create_shape_object(shp) shape.parse_shape() with open("model2.json", "w") as f: json.dump(shape.config, f, indent=4)
def DumpTop(self, shape, level=0): """ Print the details of an object from the top down """ brt = BRep_Tool() s = shape.ShapeType() if s == TopAbs_VERTEX: pnt = brt.Pnt(topods_Vertex(shape)) dmp = " " * level dmp += "%s - " % get_type_as_string(shape) dmp += "%.5e %.5e %.5e" % (pnt.X(), pnt.Y(), pnt.Z()) print(dmp) else: dmp = " " * level dmp += get_type_as_string(shape) print(dmp) it = TopoDS_Iterator(shape) while it.More(): shp = it.Value() it.Next() self.DumpTop(shp, level + 1)
def main(): input_folder = "{:08d}".format(int(sys.argv[1])) print(int(sys.argv[1])) filename = [file for file in os.listdir(os.path.join('/adarsh-lab/Aditya/ABCDataset',input_folder)) if os.path.splitext(file)[1] in ['.step', '.stp']][0] filename = os.path.join('/adarsh-lab/Aditya/ABCDataset',input_folder,filename) try: shp = read_step_file(filename) shape_type = get_type_as_string(shp) t = TopologyFactory(shape_type) shape = t.create_shape_object(shp) shape.parse_shape() # seq=(os.path.splitext(filename)[0],"primitive",".json") out_filename = input_folder+'.json' out_filename = os.path.join('/adarsh-lab/Anjana/Points',out_filename) with open(out_filename, "w") as f: json.dump(shape.config, f, indent=4) except KeyError: print("Some Invalid Shape")
def click(value): """ called whenever a shape or edge is clicked """ obj = value.owner.object if self._current_mesh_selection is not None: self._current_mesh_selection.material.color = self._current_selection_material_color if obj is not None: id_clicked = obj.name # the mesh id clicked self._current_mesh_selection = obj self._current_selection_material_color = obj.material.color obj.material.color = self._selection_color # get the shape from this mesh id selected_shape = self._shapes[id_clicked] html_value = "<b>Shape type:</b> %s<br>" % get_type_as_string(selected_shape) html_value += "<b>Shape id:</b> %s<br>" % selected_shape self.html.value = html_value self._current_shape_selection = selected_shape else: self.html.value = "<b>Shape type:</b> None<br><b>Shape id:</b> None" # then execute calbacks for callback in self._select_callbacks: callback(self._current_shape_selection)
def click(self, value): """ called whenever a shape or edge is clicked """ obj = value.owner.object self.clicked_obj = obj if self._current_mesh_selection != obj: if self._current_mesh_selection is not None: self._current_mesh_selection.material.color = self._current_selection_material_color self._current_mesh_selection.material.transparent = False self._current_mesh_selection = None self._current_selection_material_color = None self._shp_properties_button.value = "Compute" self._shp_properties_button.disabled = True self._toggle_shp_visibility_button.disabled = True self._remove_shp_button.disabled = True self._current_shape_selection = None if obj is not None: self._shp_properties_button.disabled = False self._toggle_shp_visibility_button.disabled = False self._remove_shp_button.disabled = False id_clicked = obj.name # the mesh id clicked self._current_mesh_selection = obj self._current_selection_material_color = obj.material.color obj.material.color = self._selection_color # selected part becomes transparent obj.material.transparent = True obj.material.opacity = 0.5 # get the shape from this mesh id selected_shape = self._shapes[id_clicked] html_value = "<b>Shape type:</b> %s<br>" % get_type_as_string( selected_shape) html_value += "<b>Shape id:</b> %s<br>" % id_clicked self.html.value = html_value self._current_shape_selection = selected_shape else: self.html.value = "<b>Shape type:</b> None<br><b>Shape id:</b> None" # then execute calbacks for callback in self._select_callbacks: callback(self._current_shape_selection)
def click(value): """ called whenever a shape or edge is clicked """ obj = value.owner.object if self._current_mesh_selection is not None: self._current_mesh_selection.material.color = self._current_selection_material_color if obj is not None: id_clicked = obj.name # the mesh id clicked self._current_mesh_selection = obj self._current_selection_material_color = obj.material.color obj.material.color = self._selection_color # get the shape from this mesh id selected_shape = self._shapes[id_clicked] html_value = "<b>Shape type:</b> %s<br>" % get_type_as_string(selected_shape) html_value += "<b>Shape id:</b> %s<br>" % selected_shape self.html.value = html_value self._current_shape_selection = selected_shape else: self.html.value = "<b>Shape type:</b> None<br><b>Shape id:</b> None" # then execute calbacks for callback in self._select_callbacks: callback(self._current_shape_selection)
def get_shape(self, shape): return get_type_as_string(shape)
def test_get_type_as_string(self): box_shp = get_test_box_shape() self.assertEqual(get_type_as_string(box_shp), "Solid")