def get_children(children_genotype): res = [0 for _ in children_genotype] for i in range(len(children_genotype)): b = time.time() res[i] = Topo(children_genotype[i]) print('i = {0} and time = {1}'.format(i, time.time() - b)) return res
def get_population(pop_len, geno_len): res = [0 for _ in range(pop_len)] for i in range(pop_len): b = time.time() res[i] = Topo(get_genotypes(geno_len)) print('i = {0} and time = {1}'.format(i, time.time() - b)) return res
def __init__(self, wireA, wireB): self.wireA = wireA self.wireB = wireB self.we_A = WireExplorer(self.wireA) self.we_B = WireExplorer(self.wireB) self.tp_A = Topo(self.wireA) self.tp_B = Topo(self.wireB) self.bt = BRep_Tool() self.vertsA = [v for v in self.we_A.ordered_vertices()] self.vertsB = [v for v in self.we_B.ordered_vertices()] self.edgesA = [v for v in WireExplorer(wireA).ordered_edges()] self.edgesB = [v for v in WireExplorer(wireB).ordered_edges()] self.pntsB = [self.bt.Pnt(v) for v in self.vertsB] self.number_of_vertices = len(self.vertsA) self.index = 0
def test_edges_out_of_scope(self): # check pointers going out of scope face = next(self.topo.faces()) _edges = [] for edg in Topo(face).edges(): _edges.append(edg) for edg in _edges: assert not edg.IsNull()
def analyse(self): """ :return: """ ss = ShapeAnalysis_Shell(self) if ss.HasFreeEdges(): bad_edges = [e for e in Topo(ss.BadEdges()).edges()] return bad_edges
def test_creat_face(self): # create a box b = get_test_box_shape() # take the first edge t = Topo(b) wire = next(t.wires()) my_wire = Wire(wire) assert not my_wire.IsNull() assert my_wire.tolerance == 1e-06
def test_creat_edge(self): # create a box b = get_test_box_shape() # take the first edge t = Topo(b) edge_0 = next(t.edges()) # it's a TopoDS_Edge assert not edge_0.IsNull() # then create an edge my_edge = Edge(edge_0) assert not my_edge.IsNull() assert my_edge.tolerance == 1e-06 assert my_edge.type == 'line' assert my_edge.length() == 30.
def fit_plane_through_face_vertices(_face): """ :param _face: OCC.KBE.face.Face instance :return: Geom_Plane """ from OCC.GeomPlate import GeomPlate_BuildAveragePlane uvs_from_vertices = [ _face.project_vertex(vertex2pnt(i)) for i in Topo(_face).vertices() ] normals = [ gp_Vec(_face.DiffGeom.normal(*uv[0])) for uv in uvs_from_vertices ] points = [i[1] for i in uvs_from_vertices] NORMALS = TColgp_SequenceOfVec() [NORMALS.Append(i) for i in normals] POINTS = to_tcol_(points, TColgp_HArray1OfPnt) pl = GeomPlate_BuildAveragePlane(NORMALS, POINTS).Plane().GetObject() vec = gp_Vec(pl.Location(), _face.GlobalProperties.centre()) pt = (pl.Location().as_vec() + vec).as_pnt() pl.SetLocation(pt) return pl
def Edges(self): return Topo(self, True).edges()
def Wires(self): """ :return: """ return Topo(self, True).wires()
def Faces(self): """ :return: """ return Topo(self, True).faces()
def setUp(self): self.topo = Topo(get_test_box_shape()) assert self.topo
def topo(self): if self._topo is not None: return self._topo else: self._topo = Topo(self) return self._topo
def shells(self): return (Shell(sh) for sh in Topo(self))