当前位置: 首页>>代码示例>>Python>>正文


Python xmldata.MeshWriter类代码示例

本文整理汇总了Python中org.jcae.mesh.xmldata.MeshWriter的典型用法代码示例。如果您正苦于以下问题:Python MeshWriter类的具体用法?Python MeshWriter怎么用?Python MeshWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MeshWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: afront_debug

def afront_debug(afront_path, tmp_dir, mesh, size, point_metric, immutable_groups, afront_stderr=None):
    from org.jcae.mesh.xmldata import Amibe2OFF, AFront2Amibe, AmibeReader, MultiDoubleFileReader

    """ Same as afront but with temporary files to help debugging """
    mesh_dir = os.path.join(tmp_dir, "mesh.amibe")
    if point_metric:
        metric_file = os.path.join(tmp_dir, "metric.bin")
        point_metric.save(metric_file)
        g_id = 1
    MeshWriter.writeObject3D(mesh, mesh_dir, "")
    ar = AmibeReader.Dim3(mesh_dir)
    sm = ar.submeshes[0]
    nodes_file = os.path.join(tmp_dir, "nodes.bin")
    for g in sm.groups:
        if g.numberOfTrias == 0 or g.name in immutable_groups:
            f = open(nodes_file, "ab")
            f.write("\0" * 4)
            f.close()
            continue
        off_fn = tmp_dir + "/" + g.name + ".off"
        m_fn = tmp_dir + "/" + g.name + ".m"
        amibe_fn = tmp_dir + "/" + g.name + ".amibe"
        vtk_fn = tmp_dir + "/" + g.name + ".vtp"
        Amibe2OFF(ar).write(off_fn, g.name)
        cmd = [
            afront_path,
            "-nogui",
            off_fn,
            "-failsafe",
            "false",
            "-resamp_bounds",
            "false",
            "-lf_progress",
            "true",
            "-stop_every",
            "10000",
            "-quiet",
            "true",
            "-outname",
            nodes_file,
            "-idealNumThreads",
            "1",
        ]
        if point_metric:
            cmd.extend(["-target_size", str(point_metric.getSize(g_id)), "-metric_file", metric_file])
            g_id = g_id + 1
        else:
            cmd.extend(["-target_size", str(size)])
        cmd.append("-tri_mesh")
        logstd = sys.stdout if afront_stderr is subprocess.STDOUT else sys.stderr
        logstd.write("meshing %s\n" % g.name)
        logstd.write(" ".join(cmd) + "\n")
        return_code = subprocess.call(cmd, cwd=tmp_dir, stderr=afront_stderr)
        if return_code != 0:
            print "Exit code: " + str(return_code)
    return MultiDoubleFileReader(nodes_file)
开发者ID:jeromerobert,项目名称:jCAE,代码行数:56,代码来源:remesh.py

示例2: afront

def afront(afront_path, tmp_dir, mesh, size, point_metric, immutable_groups,
    afront_stderr = None, custom_options=None):
    from org.jcae.mesh.xmldata import AmibeReader, MultiDoubleFileReader
    """ Run afront and return a MultiDoubleFileReader allowing to read created
    nodes """
    if custom_options is None:
        custom_options = []
    mesh_dir = os.path.join(tmp_dir, "mesh.amibe")
    if isinstance(point_metric, AbstractDistanceMetric):
        metric_file = os.path.join(tmp_dir, "metric.bin")
        point_metric.save(metric_file)
        g_id = 1
    else:
        metric_file = None
    MeshWriter.writeObject3D(mesh, mesh_dir, "")
    ar = AmibeReader.Dim3(mesh_dir)
    sm = ar.submeshes[0]
    nodes_file = os.path.join(tmp_dir, "nodes.bin")
    for g in sm.groups:
        if g.numberOfTrias == 0 or g.name in immutable_groups:
            f = open(nodes_file, 'ab')
            f.write('\0'*4)
            f.close()
            continue
        cmd = [afront_path, '-nogui', ':stdin', '-failsafe','false',
            '-resamp_bounds', 'false', '-lf_progress', 'true',
            '-stop_every', '10000', '-quiet', 'true', '-outname', nodes_file,
            '-idealNumThreads', '1'] + ([] if custom_options is None else custom_options)
        if metric_file:
            cmd.extend(['-target_size', str(point_metric.getSize(g_id)),
                '-metric_file', metric_file])
            g_id = g_id + 1
        else:
            cmd.extend(['-target_size', str(size)])
        cmd.append('-tri_mesh')
        logstd = sys.stdout if afront_stderr is subprocess.STDOUT else sys.stderr
        logstd.write("meshing %s\n" % g.name)
        logstd.write(" ".join(cmd)+"\n")
        try:
            p = subprocess.Popen(cmd, stdin = subprocess.PIPE, cwd = tmp_dir,
                 stderr = afront_stderr)
            sm.readGroup(g, p.stdin.fileno().channel)
            p.stdin.flush()
            return_code = p.wait()
            if return_code != 0:
                print "Exit code: "+str(return_code)
        except OSError:
            print "Cannot run afront"
    if os.path.isfile(nodes_file):
        return MultiDoubleFileReader(nodes_file)
    else:
        return
开发者ID:jeromerobert,项目名称:jCAE,代码行数:52,代码来源:remesh.py

示例3: afront

def afront(afront_path, tmp_dir, mesh, size, point_metric, immutable_groups,
    afront_stderr = None):
    from org.jcae.mesh.xmldata import AmibeReader, MultiDoubleFileReader
    """ Run afront and return a MultiDoubleFileReader allowing to read created
    nodes """
    mesh_dir = os.path.join(tmp_dir, "mesh.amibe")
    if point_metric:
        metric_file = os.path.join(tmp_dir, "metric.bin")
        point_metric.save(metric_file)
        g_id = 1
    MeshWriter.writeObject3D(mesh, mesh_dir, "")
    ar = AmibeReader.Dim3(mesh_dir)
    sm = ar.submeshes[0]
    nodes_file = os.path.join(tmp_dir, "nodes.bin")
    for g in sm.groups:
        if g.numberOfTrias == 0 or g.name in immutable_groups:
            f = open(nodes_file, 'ab')
            f.write('\0'*4)
            f.close()
            continue
        cmd = [afront_path, '-nogui', ':stdin', '-failsafe','false',
            '-resamp_bounds', 'false', '-lf_progress', 'true',
            '-stop_every', '10000', '-quiet', 'true', '-outname', nodes_file]
        if point_metric:
            cmd.extend(['-target_size', str(point_metric.getSize(g_id)),
                '-metric_file', metric_file])
            g_id = g_id + 1
        else:
            cmd.extend(['-target_size', str(size)])
        cmd.append('-tri_mesh')
        sys.stderr.write("meshing %s\n" % g.name)
        sys.stderr.write(" ".join(cmd)+"\n")
        p = subprocess.Popen(cmd, stdin = subprocess.PIPE, cwd = tmp_dir,
             stderr = afront_stderr)
        sm.readGroup(g, p.stdin.fileno().channel)
        p.stdin.flush()
        return_code = p.wait()
        if return_code != 0:
            print "Exit code: "+str(return_code)
    return MultiDoubleFileReader(nodes_file)
开发者ID:mohitgarg27,项目名称:jCAE,代码行数:40,代码来源:remesh.py

示例4: str

if (coplanarity >= 0.0):
    smoothOptions.put("coplanarity", str(coplanarity))
SmoothNodes3DBg(liaison, smoothOptions).compute()

## Remove Degenerated
rdOptions = HashMap()
rdOptions.put("rho", str(options.eratio))
RemoveDegeneratedTriangles(liaison, rdOptions).compute()

## Remesh beams
if options.wire > 0.0:
    polylines = PolylineFactory(liaison.mesh, 135.0, options.wire*0.2)
    liaison.mesh.resetBeams()
    for entry in polylines.entrySet():
        groupId = entry.key
        for polyline in entry.value:
            listM = ArrayList()
            for v in polyline:
                listM.add(EuclidianMetric3D(options.wire))
            if liaison.mesh.getGroupName(groupId) in immutable_groups:
                result = polyline
            else:
                result = RemeshPolyline(liaison.mesh, polyline, listM).compute()
            for i in xrange(result.size() - 1):
                liaison.mesh.addBeam(result.get(i), result.get(i+1), groupId)

## Output
MeshWriter.writeObject3D(liaison.getMesh(), outDir, "")
if options.recordFile:
    liaison.getMesh().getTrace().finish()
开发者ID:alclp,项目名称:jCAE,代码行数:30,代码来源:remeshSingularity.py

示例5: vtkXMLPolyDataReader

	sys.exit(1)

vtpFile = args[0]
outDir = args[1]

Utils.loadVTKLibraries()
reader = vtkXMLPolyDataReader()
reader.SetFileName(vtpFile)
reader.Update()
 
polydata = reader.GetOutput()

mesh = Mesh(MeshTraitsBuilder())
vertices = jarray.zeros(polydata.GetNumberOfPoints(), Vertex)
coord = jarray.zeros(3, "d")
for i in xrange(len(vertices)):
	polydata.GetPoint(i, coord)
	vertices[i] = mesh.createVertex(coord)

indices = Utils.getValues(polydata.GetPolys())
i = 0
while i < len(indices):
	if (indices[i] == 3):
		mesh.add(mesh.createTriangle(
			vertices[indices[i+1]],
			vertices[indices[i+2]],
			vertices[indices[i+3]]))
	i += indices[i] + 1

MeshWriter.writeObject3D(mesh, outDir, String())
开发者ID:GaneshPatil,项目名称:jCAE,代码行数:30,代码来源:vtp2amibe.py

示例6: writeVTK

def writeVTK(liaison):
    global debug_write_counter
    if debug_write_counter:
        MeshWriter.writeObject3D(liaison.mesh, "/tmp/tmp.amibe", "")
        Amibe2VTK("/tmp/tmp.amibe").write("/tmp/m%i.vtp" % (debug_write_counter-1));
        debug_write_counter=debug_write_counter+1
开发者ID:bgarrels,项目名称:jCAE,代码行数:6,代码来源:remesh.py

示例7: __remesh


#.........这里部分代码省略.........
    opts.put("iterations", "2")
    opts.put("size", str(options.size))
    algo = SmoothNodes3DBg(liaison, opts)
    algo.compute()

    #9
    writeVTK(liaison)

    opts.clear()
    opts.put("coplanarity", str(options.coplanarity))
    opts.put("expectInsert", "false" if options.afront_path else "true")
    opts.put("minCosAfterSwap", "0.3")
    algo = SwapEdge(liaison, opts)
    algo.angleQualityRatio = 150
    algo.compute()

    #10
    writeVTK(liaison)
    if not options.afront_path:
        opts.clear()
        opts.put("size", str(options.size))
        algo = Remesh(liaison, opts)
        algo.analyticMetric = point_metric
        algo.compute()

    #11
    writeVTK(liaison)

    opts.clear()
    opts.put("coplanarity", str(options.coplanarity))
    opts.put("size", str(options.size*0.3))
    opts.put("maxlength", str(options.size*sqrt(2)))
    #workaround for a QEMDecimateHalfEdge bug
    opts.put("freezeNonManifold", "true")
    algo = QEMDecimateHalfEdge(liaison, opts)
    if point_metric:
        point_metric.scaling = sqrt(2)
        algo.analyticMetric = point_metric
    algo.compute()

    #12
    writeVTK(liaison)

    opts.clear()
    opts.put("coplanarity", str(options.coplanarity))
    opts.put("expectInsert", "false" if options.afront_path else "true")
    opts.put("minCosAfterSwap", "0.3")
    algo = SwapEdge(liaison, opts)
    algo.angleQualityRatio = 150
    algo.compute()

    #13
    writeVTK(liaison)

    if afront_frozen:
        Vertex.setMutable(afront_frozen, True)

    opts.clear()
    opts.put("checkNormals", "false")
    ImproveVertexValence(liaison, opts).compute()

    #14
    writeVTK(liaison)

    opts.clear()
    opts.put("coplanarity", safe_coplanarity)
    opts.put("iterations", str(8))
    algo = SmoothNodes3DBg(liaison, opts)
    algo.compute()

    #15
    writeVTK(liaison)

    #MeshWriter.writeObject3D(liaison.mesh, outDir, ""
    polylines=PolylineFactory(liaison.mesh, 135.0, options.size*0.2)
    liaison.mesh.resetBeams()
    for entry in polylines.entrySet():
      groupId = entry.key
      for polyline in entry.value:
            listM = ArrayList()
            for v in polyline:
                listM.add(EuclidianMetric3D(options.size))
            #print "Remesh polyline of group "+str(groupId)+"/"+str(polylines.size())+" "+str(polyline.size())+" vertices"
            if liaison.mesh.getGroupName(groupId) in immutable_groups:
                result = polyline
            elif point_metric:
                result = RemeshPolyline(liaison.mesh, polyline, point_metric).compute()
            else:
                result = RemeshPolyline(liaison.mesh, polyline, listM).compute()
            for i in xrange(result.size() - 1):
                liaison.mesh.addBeam(result.get(i), result.get(i+1), groupId)
            #print "  New polyline: "+str(result.size())+" vertices"

    if options.recordFile:
        liaison.getMesh().getTrace().finish()

    if options.post_script:
        execfile(options.post_script)
    if options.out_dir:
        MeshWriter.writeObject3D(liaison.mesh, options.out_dir, "")
开发者ID:bgarrels,项目名称:jCAE,代码行数:101,代码来源:remesh.py

示例8: afterSwapHook

	def afterSwapHook(self):
		if self.ridges:
			self.liaison.getMesh().createRidgesGroup("ridges")
		MeshWriter.writeObject3D(self.liaison.getMesh(), "DEBUG"+str(self.cnt), String())
		self.cnt += 1
开发者ID:alclp,项目名称:jCAE,代码行数:5,代码来源:split.py

示例9: __init__

	def __init__(self, liaison, opts, prefix):
		SmoothNodes3DBg.__init__(self, liaison, opts)
		self.prefix = prefix
		self.liaison = liaison
		if self.prefix:
			MeshWriter.writeObject3D(liaison.getOutputMesh(), self.prefix + "0", None)
开发者ID:GaneshPatil,项目名称:jCAE,代码行数:6,代码来源:smooth3dBg.py

示例10: HashMap

	liaison.getMesh().getTrace().setLogFile(options.recordFile)
	liaison.getMesh().getTrace().createMesh("mesh", liaison.getMesh())
if options.immutable_border:
    liaison.mesh.tagFreeEdges(AbstractHalfEdge.IMMUTABLE)
if options.coplanarity:
	liaison.getMesh().buildRidges(options.coplanarity)
if options.preserveGroups:
	liaison.getMesh().buildGroupBoundaries()

opts = HashMap()
opts.put("iterations", str(options.iterations))
opts.put("boundaries", str(options.boundaries))
opts.put("check", str(options.check))
opts.put("size", str(options.size))
opts.put("tolerance", str(options.tolerance))
opts.put("relaxation", str(options.relaxation))
opts.put("refresh", str(options.refresh))
if (options.coplanarity >= 0.0):
	opts.put("coplanarity", str(options.coplanarity))
if options.prefix:
	sm = MySmoothNodes3DBg(liaison, opts, options.prefix)
else:
	sm = SmoothNodes3DBg(liaison, opts)
sm.setProgressBarStatus(10000)
sm.compute()
if options.recordFile:
	liaison.getMesh().getTrace().finish()

MeshWriter.writeObject3D(sm.getOutputMesh(), outDir, String())

开发者ID:GaneshPatil,项目名称:jCAE,代码行数:29,代码来源:smooth3dBg.py

示例11: SwapEdge

SwapEdge(liaison, opts).compute()

writeVTK(liaison)

opts.clear()
opts.put("coplanarity", "0.75")
opts.put("tolerance", "0.6")
opts.put("iterations", str(8))
SmoothNodes3DBg(liaison, opts).compute()

writeVTK(liaison)

#MeshWriter.writeObject3D(liaison.mesh, outDir, ""
polylines=PolylineFactory(liaison.mesh, 135.0, options.size*0.2)
liaison.mesh.resetBeams()
for entry in polylines.entrySet():
  groupId = entry.key
  for polyline in entry.value:
		listM = ArrayList()
		for v in polyline:
			listM.add(EuclidianMetric3D(options.size))
		#print "Remesh polyline of group "+str(groupId)+"/"+str(polylines.size())+" "+str(polyline.size())+" vertices"
		result = RemeshPolyline(liaison.mesh, polyline, listM).compute()
		for i in xrange(result.size() - 1):
			liaison.mesh.addBeam(result.get(i), result.get(i+1), groupId)
		#print "  New polyline: "+str(result.size())+" vertices"

if options.recordFile:
	liaison.getMesh().getTrace().finish()
MeshWriter.writeObject3D(liaison.mesh, outDir, "")
开发者ID:iee,项目名称:jCAE,代码行数:30,代码来源:remesh.py

示例12: postProcessIteration

	def postProcessIteration(self, mesh, counter, *args):
		if self.prefix:
			MeshWriter.writeObject3D(mesh, self.prefix + str(counter), None);
开发者ID:GaneshPatil,项目名称:jCAE,代码行数:3,代码来源:smooth3d.py

示例13: Mesh

	mtb.addTraceRecord()
mesh = Mesh(mtb)
if options.recordFile:
	mesh.getTrace().setDisabled(True)
MeshReader.readObject3D(mesh, xmlDir)
assert mesh.isValid()

liaison = MeshLiaison(mesh, mtb)
if options.recordFile:
	liaison.getMesh().getTrace().setDisabled(False)
	liaison.getMesh().getTrace().setLogFile(options.recordFile)
	liaison.getMesh().getTrace().createMesh("mesh", liaison.getMesh())
if options.coplanarity:
	liaison.getMesh().buildRidges(options.coplanarity)
if options.immutable_border:
    liaison.mesh.tagFreeEdges(AbstractHalfEdge.IMMUTABLE)

if options.immutable_border_group:
    liaison.mesh.tagGroupBoundaries(AbstractHalfEdge.IMMUTABLE)
else:
    if options.preserveGroups:
	liaison.getMesh().buildGroupBoundaries()
    
cons = Class.forName("org.jcae.mesh.amibe.algos3d."+options.algorithm).getConstructor([ MeshLiaison, Map ])
cons.newInstance([ liaison, opts ]).compute()

if options.recordFile:
	liaison.getMesh().getTrace().finish()
MeshWriter.writeObject3D(liaison.getMesh(), outDir, String())

开发者ID:GaneshPatil,项目名称:jCAE,代码行数:29,代码来源:decimate.py

示例14: postProcessIteration

	def postProcessIteration(self, liaison, counter, *args):
		if self.prefix:
			MeshWriter.writeObject3D(liaison.getOutputMesh(), self.prefix + str(counter+1), None)
开发者ID:GaneshPatil,项目名称:jCAE,代码行数:3,代码来源:smooth3dBg.py

示例15: ArrayList

			# New polyline
			polyline = ArrayList()
			listOfPolylines.add(polyline)
			polyline.add(vertices.get(2*b))
		lastVertex = vertices.get(2*b+1)
		polyline.add(lastVertex)
	#print "Group "+str(bId)+" contains "+str(listOfPolylines.size())+" polylines and "+str(listBeamId.size()+1)+" vertices"
	mapGroupToListOfPolylines.put(bId, listOfPolylines)

for bId in bgroupMap.keySet():
	listBeamId = bgroupMap.get(bId)
	listOfPolylines = mapGroupToListOfPolylines.get(bId)
	nrPoly = listOfPolylines.size()
	for numPoly in xrange(nrPoly):
		polyline = listOfPolylines.get(numPoly)
		if options.point_metric_file:
			met = DistanceMetric(options.size, options.point_metric_file)
		elif setAnalytic:
			met = RemeshMetric()
		else:
			met = ArrayList()
			for v in polyline:
				met.add(EuclidianMetric3D(options.size))
		#print "Remesh polyline "+str(numPoly+1)+"/"+str(nrPoly)+" of group "+str(bId)+"/"+str(bgroupMap.size())+" "+str(polyline.size())+" vertices"
		result = RemeshPolyline(newMesh, polyline, met).compute()
		for i in xrange(result.size() - 1):
			newMesh.addBeam(result.get(i), result.get(i+1), bId)
		#print "  New polyline: "+str(result.size())+" vertices"

MeshWriter.writeObject3D(newMesh, outDir, "")
开发者ID:alclp,项目名称:jCAE,代码行数:30,代码来源:refine.py


注:本文中的org.jcae.mesh.xmldata.MeshWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。