def topo2topotype(occtopology): """ This function converts the original OCCtopology of the given topology. e.g. an OCCcompound that is originally an OCCface etc. Parameters ---------- occtopology : OCCtopology The OCCtopology to be converted. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex Returns ------- original topology : OCCtopology The original OCCtopology of the input. """ shapetype = occtopology.ShapeType() if shapetype == TopAbs_COMPOUND: #compound orig_topo = topods_Compound(occtopology) if shapetype == TopAbs_COMPSOLID: #compsolid orig_topo = topods_CompSolid(occtopology) if shapetype == TopAbs_SOLID: #solid orig_topo = topods_Solid(occtopology) if shapetype == TopAbs_SHELL: #shell orig_topo = topods_Shell(occtopology) if shapetype == TopAbs_FACE: #face orig_topo = topods_Face(occtopology) if shapetype == TopAbs_WIRE: #wire orig_topo = topods_Wire(occtopology) if shapetype == TopAbs_EDGE: #edge orig_topo = topods_Edge(occtopology) if shapetype == TopAbs_VERTEX: #vertex orig_topo = topods_Vertex(occtopology) return orig_topo
def topo_explorer(occtopo2explore, topotype2find): """ This function explores and fetches the specified topological type from the given OCCtopology. e.g. find a list of OCCfaces in an OCCcompound. Parameters ---------- occtopo2explore : OCCtopology The OCCtopology to be explored. OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex topotype2find : str The string describing the topology to find. The strings can be e.g. "compound", "compsolid", "solid", "shell", "face", "wire", "edge", "vertex". Returns ------- list of topology : list of OCCtopology The list of OCCtopology found in the specified OCCtopology. """ geom_list = [] if topotype2find == "compound": shapetype2find_topABS = TopAbs_COMPOUND if topotype2find == "compsolid": shapetype2find_topABS = TopAbs_COMPSOLID if topotype2find == "solid": shapetype2find_topABS = TopAbs_SOLID if topotype2find == "shell": shapetype2find_topABS = TopAbs_SHELL if topotype2find == "face": shapetype2find_topABS = TopAbs_FACE if topotype2find == "wire": shapetype2find_topABS = TopAbs_WIRE if topotype2find == "edge": shapetype2find_topABS = TopAbs_EDGE if topotype2find == "vertex": shapetype2find_topABS = TopAbs_VERTEX ex = TopExp_Explorer(occtopo2explore, shapetype2find_topABS) while ex.More(): if shapetype2find_topABS == 0: geom = topods_Compound(ex.Current()) if shapetype2find_topABS == 1: geom = topods_CompSolid(ex.Current()) if shapetype2find_topABS == 2: geom = topods_Solid(ex.Current()) if shapetype2find_topABS == 3: geom = topods_Shell(ex.Current()) if shapetype2find_topABS == 4: geom = topods_Face(ex.Current()) if shapetype2find_topABS == 5: geom = topods_Wire(ex.Current()) if shapetype2find_topABS == 6: geom = topods_Edge(ex.Current()) if shapetype2find_topABS == 7: geom = topods_Vertex(ex.Current()) geom_list.append(geom) ex.Next() return geom_list
def test_step_load_shape_correct_stp(self): step_handler = StepHandler() shape = step_handler.load_shape_from_file( 'tests/test_datasets/test_pipe.stp') self.assertEqual(type(topods_Compound(shape)), TopoDS_Compound)
def test_iges_load_shape_correct_igs(self): iges_handler = IgesHandler() shape = iges_handler.load_shape_from_file( 'tests/test_datasets/test_pipe.igs') self.assertEqual(type(topods_Compound(shape)), TopoDS_Compound)