def triangles_to_xyz_ijk(triangles): triangles = list(triangles) res = Attributize() points = flatten(triangles, depth=1) res.x = list([e[0] for e in points]) res.y = list([e[1] for e in points]) res.z = list([e[2] for e in points]) res.i = list(range(0, 3 * len(triangles), 3)) res.j = list(range(1, 3 * len(triangles), 3)) res.k = list(range(2, 3 * len(triangles), 3)) return res
def proc_libs(self, *libs): packages = [] use_libs = [] libs = flatten(libs) for x in to_list(libs): if isinstance(x, WafBasePkg): packages.append(x) use_libs.append(x.name) elif isinstance(x, WafPkgList): packages.extend(x.tb) use_libs.extend([a.name for a in x.tb]) else: use_libs.append(x) self.register_packages(packages) return use_libs
def get_non_manifold_plot_data(graph_data): pc = graph_data.points faces = vec_pos_to_list(graph_data.faces) res = Attributize() g = graph_data.graph bad_edges = [] for edge in g.edges: if g.get_edge_count(edge.to, edge.from_, False) != 1: bad_edges.append(edge) if len(bad_edges) == 0: return None color = 'r' res.lines = get_polyline_from_edges(bad_edges, pc, color) bad_point_ids = set(flatten([(edge.to, edge.from_) for edge in bad_edges])) res.points = [pc[x] for x in bad_point_ids] res.points_size = 20 res.color = color return res
def remove_objs(self, objs): for obj in flatten([x.objs for x in objs]): obj.parent = None objs.clear()
def build(self): if self.build_done: return self.build_done = 1 if self.basename == None: assert len(self.sources) == 1 self.basename = os.path.splitext(os.path.basename( self.sources[0]))[0] self.name = self.builder.get_target_name(self.basename) tb = Attributize({}) print('GOT DEPS >> ', self.deps) if self.use_global: for x in self.deps[self.typ]: for j in self.builder.build_desc[x]: print(type(j), j.basename, self.name) j.build() print(j.name) self.libs.append(j.name) self.sources = flatten(self.sources, True) self.features = flatten(self.features, True) self.features = self.guess_feature() self.sources = [self.norm_path(x) for x in self.sources] self.deps_list = [ self.builder.normalize_name(x) for x in self.deps_list ] self.libs = [self.builder.normalize_name(x) for x in self.libs] mapper = 'includes export_includes:exports target:name source:sources swig_flags proto_base use:libs features install_path install_from after:deps_list' for x in mapper.split(' '): y = x.split(':') if len(y) == 1: y.append(y[0]) attr = getattr(self, y[1]) if attr is None: continue tb[y[0]] = attr if self.install and not self.install_path: print('INSTALL >>> ', self.features, self.sources) if 'py' in self.features or 'pyembed' in self.features: tb.install_path = opa_waf.PYTHON_INSTALL_DIR print('INSTALL TO ', opa_waf.PYTHON_INSTALL_DIR) else: tb.install_path = '${PREFIX}/lib' tb['install_path'] = tb.install_path if not 'install_from' in tb: tb['install_from'] = self.builder.ctx.path.get_bld() else: before = tb['install_from'] tb['install_from'] = self.builder.ctx.path.get_bld().make_node( before) assert tb[ 'install_from'] is not None, 'before=%s, curpath=%s %s %s' % ( before, self.builder.ctx.path.abspath(), self.sources, self.features) tmp = tb._elem x = self.builder.ctx(**tmp) x.opa_data = self if 0 and self.install: if 'pyembed' in self.features: assert len(self.sources) == 1 modulename = os.path.splitext(os.path.basename( self.sources[0]))[0] filename = os.path.join(os.path.dirname(self.sources[0]), modulename + '.py') from waflib import Build self.builder.ctx.post_mode = Build.POST_LAZY self.builder.ctx.add_group() generated_py = self.builder.ctx.path.find_or_declare(filename) print('GOT FILE >> ', generated_py, filename, self.sources, self.builder.ctx.path.get_bld().abspath()) self.builder.ctx(feature='py', source=generated_py, name='kappa', install_path=tb.install_path, install_from=self.builder.ctx.path.get_bld()) if self.post: self.post(x) if self.clang: wafClang.addHeaders(x, self.headers, self.sources)
def configure(self, ctx): if self.conf_configure: return ctx.load('compiler_cxx') ctx.load('compiler_c') ctx.load('cs') ctx.load('waf_unit_test') configure_asm(ctx) self.conf_configure = True if ctx.options.build == WafBuildType.RELEASE: ctx.env.append_value('CXXFLAGS', ['-O3']) ctx.env.append_value('CFLAGS', ['-O3']) else: ctx.env.append_value('CXXFLAGS', ['-O0', '-g']) ctx.env.append_value('CFLAGS', ['-O0', '-g']) if ctx.options.arch == Target.X86_64: ctx.env.append_value( 'SWIGFLAGS', '-D__x86_64 -D__x86_64__ -Wno-error=stringop-overflow') ctx.env.pincxxshlib_PATTERN = 'lib%s.so' if ctx.options.target_pin: self.pin_mode = True args = [ '-DBIGARRAY_MULTIPLIER=1', '-Werror', '-Wno-unknown-pragmas', '-D__PIN__=1', '-DPIN_CRT=1', '-fno-stack-protector', '-fno-exceptions', '-funwind-tables', '-fasynchronous-unwind-tables', '-fno-rtti', '-DTARGET_LINUX', '-fabi-version=2', '-fomit-frame-pointer', '-fno-strict-aliasing', '-std=c++11', '-nostdinc++', ] if ctx.options.arch == Target.X86: arch_mods = ['ia32', 'x86'] args.extend([ '-DTARGET_IA32', '-DHOST_IA32', ]) else: arch_mods = ['intel64', 'x86_64'] args.extend([ '-DTARGET_IA32E', '-DHOST_IA32E', '-fPIC', ]) dirs = [ 'source/include/pin', 'source/include/pin/gen', 'extras/components/include', 'extras/xed-{}/include/xed'.format(arch_mods[0]), ] sdirs = [ 'extras/stlport/include', 'extras/libstdc++/include', 'extras/crt/include', 'extras/crt/include/arch-{}'.format(arch_mods[1]), 'extras/crt/include/kernel/uapi', 'extras/crt/include/kernel/uapi/asm-x86', ] global pin_shared_args_end global pin_shared_args_begin global pin_link_args kvs = ( ('OPA_PIN_SHARED_ARGS_BEGIN', pin_shared_args_begin), ('OPA_PIN_SHARED_ARGS_END', pin_shared_args_end), ('OPA_PIN_LINK_ARGS', pin_link_args), ) for k, vs in kvs: for v in vs: ctx.env.append_value( k, v.format(pindir=pindir, pinarch=arch_mods[0])) dirs = [opa_paths.PinDir(x) for x in dirs] sdirs = [opa_paths.PinDir(x) for x in sdirs] print(args) ctx.env.append_value('CFLAGS', args) ctx.env.append_value('CXXFLAGS', args) iargs = [] iargs += ['-I' + x for x in dirs] iargs += flatten([['-isystem ' + x] for x in sdirs]) ctx.env.append_value('CFLAGS', iargs) ctx.env.append_value('CXXFLAGS', iargs) #'-I../../../source/include/pin', '-I../../../source/include/pin/gen', '-isystem', '/home/benoit/programmation/tools/pin-3.2-81205-gcc-linux/extras/stlport/include', '-isystem', '/home/benoit/programmation/tools/pin-3.2-81205-gcc-linux/extras/libstdc++/include', '-isystem', '/home/benoit/programmation/tools/pin-3.2-81205-gcc-linux/extras/crt/include', '-isystem', '/home/benoit/programmation/tools/pin-3.2-81205-gcc-linux/extras/crt/include/arch-x86', '-isystem', '/home/benoit/programmation/tools/pin-3.2-81205-gcc-linux/extras/crt/include/kernel/uapi', '-isystem', '/home/benoit/programmation/tools/pin-3.2-81205-gcc-linux/extras/crt/include/kernel/uapi/asm-x86', '-I../../../extras/components/include', '-I../../../extras/xed-ia32/include/xed', '-I../../../source/tools/InstLib' else: ctx.env.append_value('CFLAGS', [ '-fPIC', '-Wreturn-type', ]) ctx.env.append_value('CXXFLAGS', [ '-fPIC', '-std=c++14', '-Wreturn-type', '-Wno-stringop-overflow', '-Wno-unknown-warning-option', '-Wno-attributes', ]) ctx.env.append_value('CFLAGS', ['-Wno-error']) ctx.env.append_value('CXXFLAGS', ['-Wno-error']) ctx.env.append_value('ASFLAGS', ['-D__ASSEMBLY__']) ctx.env.append_value('LINKFLAGS', ['-ldl', '-lm']) if ctx.options.arch == Target.X86: ctx.env.append_value('CXXFLAGS', ['-m32']) ctx.env.append_value('ASFLAGS', ['-m32']) ctx.env.append_value('LINKFLAGS', ['-m32']) ctx.env.append_value('CFLAGS', ['-m32']) ctx.env.PYTHON_INSTALL_DIR = '${PREFIX}/python/opa'
def get_libs(self, *add): lst = list(self._libs) lst.extend(flatten(add)) return lst
def register_packages(self, *packages): self._packages.extend(flatten(packages))
def flatten(self): self.v = flatten(self.v) return self
def stl_to_meshdata(stl_data): vertices = np.array(flatten([x.vx for x in stl_data], depth=1)) faces = np.reshape(range(vertices.shape[0]), (vertices.shape[0] // 3, 3)) return MeshData(vertices=vertices, faces=faces)