Ejemplo n.º 1
0
def create_mesh(**kwargs):
    mtb = MeshTraitsBuilder.getDefault3D()
    if kwargs.get('recordFile'):
        mtb.addTraceRecord()
    mtb.addNodeSet()
    mesh = Mesh(mtb)
    if kwargs.get('recordFile'):
        mesh.getTrace().setDisabled(True)
    MeshReader.readObject3D(mesh, kwargs['in_dir'])
    return mesh
Ejemplo n.º 2
0
def create_mesh(**kwargs):
    mtb = MeshTraitsBuilder.getDefault3D()
    if kwargs.get('recordFile'):
        mtb.addTraceRecord()
    mtb.addNodeSet()
    mesh = Mesh(mtb)
    if kwargs.get('recordFile'):
        mesh.getTrace().setDisabled(True)
    MeshReader.readObject3D(mesh, kwargs['in_dir'])
    return mesh
Ejemplo n.º 3
0
def remesh(**kwargs):
    """Remesh beams of an existing mesh with a singular analytical metric

    It is necessary to remove J_ and G_ groups for wires.
    """
    # Build background mesh
    try:
        liaison = kwargs["liaison"]
    except KeyError:
        mtb = MeshTraitsBuilder.getDefault3D()
        mtb.addNodeSet()
        mesh = Mesh(mtb)
        MeshReader.readObject3D(mesh, kwargs["in_dir"])
        liaison = MeshLiaison.create(mesh, mtb)
    immutable_groups = list()
    if kwargs["immutable_groups_file"]:
        f = open(kwargs["immutable_groups_file"])
        immutable_groups = f.read().split()
        f.close()
        liaison.mesh.tagGroups(immutable_groups, AbstractHalfEdge.IMMUTABLE)
    liaison = remesh_beams(liaison, kwargs["size"], kwargs["rho"], immutable_groups, kwargs["point_metric_file"])
    # Output
    MeshWriter.writeObject3D(liaison.getMesh(), kwargs["out_dir"], "")
Ejemplo n.º 4
0
import sys

cmd=("report  ", "<dir>", "Print bad triangles in a mesh, sorted by quality.")
parser = OptionParser(usage="amibebatch %s [OPTIONS] %s\n\n%s" % cmd,
	prog="report")
parser.add_option("-c", "--criterion", metavar="CLASS",
                  action="store", type="string", dest="crit",
                  help="criterion (default: MinAngleFace)")
parser.add_option("-n", "--number", metavar="NUMBER",
                  action="store", type="int", dest="number",
                  help="Number of triangles to display (default: 10)")
parser.add_option("-r", "--reverse", action="store_true", dest="reverse",
                  help="Reverse the criteria", default=False)
parser.set_defaults(crit="MinAngleFace", number=10)

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 1:
	parser.print_usage()
	sys.exit(1)

mesh = Mesh(MeshTraitsBuilder())
xmlDir = args[0]
MeshReader.readObject3D(mesh, xmlDir)
qproc = globals()[options.crit]()
for t in QualityProcedure.worstTriangles(qproc, mesh.triangles, options.number,
    options.reverse):
    if "Angle" in options.crit:
        print degrees(qproc.quality(t)), t
    else:
        print qproc.quality(t), t
Ejemplo n.º 5
0
(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
	parser.print_usage()
	sys.exit(1)

xmlDir = args[0]
outDir = args[1]
if options.size:
	size = options.size
else:
	size = 1.0

mtb = MeshTraitsBuilder.getDefault3D()
mtb.addNodeList()
mesh = Mesh(mtb)
MeshReader.readObject3D(mesh, xmlDir)

bgroupMap = LinkedHashMap()
#print "beams size: "+str(mesh.getBeams().size())
for i in xrange(mesh.getBeams().size() / 2):
	bId = mesh.getBeamGroup(i)
	listBeamId = bgroupMap.get(bId)
	if listBeamId is None:
		listBeamId = TIntArrayList(100)
		bgroupMap.put(bId, listBeamId)
	listBeamId.add(i)

vertices = ArrayList(mesh.getBeams())
mesh.resetBeams()
mapGroupToListOfPolylines = LinkedHashMap()
Ejemplo n.º 6
0
def clean(**kwargs):
    """Clean a mesh
    """
    # Process coplanarity options
    coplanarity = -2.0
    if kwargs['coplanarityAngle'] > 0:
        coplanarity = cos(kwargs['coplanarityAngle'] * pi / 180.)
    if kwargs['coplanarity']:
        coplanarity = kwargs['coplanarity']

    safe_coplanarity = kwargs['safe_coplanarity']
    if safe_coplanarity is None:
        safe_coplanarity = 0.8
    safe_coplanarity = str(max(coplanarity, safe_coplanarity))

    # Build background mesh
    try:
        liaison = kwargs['liaison']
    except KeyError:
        mtb = MeshTraitsBuilder.getDefault3D()
        if kwargs['recordFile']:
            mtb.addTraceRecord()
        mtb.addNodeSet()
        mesh = Mesh(mtb)
        if kwargs['recordFile']:
            mesh.getTrace().setDisabled(True)

        MeshReader.readObject3D(mesh, kwargs['in_dir'])
        liaison = MeshLiaison.create(mesh, mtb)

    if kwargs['recordFile']:
        liaison.getMesh().getTrace().setDisabled(False)
        liaison.getMesh().getTrace().setLogFile(kwargs['recordFile'])
        liaison.getMesh().getTrace().createMesh("mesh", liaison.getMesh())
    if kwargs['immutable_border']:
        liaison.mesh.tagFreeEdges(AbstractHalfEdge.IMMUTABLE)
    liaison.getMesh().buildRidges(coplanarity)
    if kwargs['preserveGroups']:
        liaison.getMesh().buildGroupBoundaries()

    immutable_groups = []
    if kwargs['immutable_groups_file']:
        f = open(kwargs['immutable_groups_file'])
        immutable_groups = f.read().split()
        f.close()
        liaison.mesh.tagGroups(immutable_groups, AbstractHalfEdge.IMMUTABLE)

    if kwargs['recordFile']:
        cmds = [
            String("assert self.m.checkNoDegeneratedTriangles()"),
            String("assert self.m.checkNoInvertedTriangles()"),
            String("assert self.m.checkVertexLinks()"),
            String("assert self.m.isValid()")
        ]
        liaison.getMesh().getTrace().setHooks(cmds)

    # Swap
    swapOptions = HashMap()
    swapOptions.put("coplanarity", str(safe_coplanarity))
    swapOptions.put("minCosAfterSwap", "0.3")
    SwapEdge(liaison, swapOptions).compute()

    # Improve valence
    valenceOptions = HashMap()
    valenceOptions.put("coplanarity", str(safe_coplanarity))
    valenceOptions.put("checkNormals", "false")
    ImproveVertexValence(liaison, valenceOptions).compute()

    # Smooth
    smoothOptions = HashMap()
    smoothOptions.put("iterations", str(8))
    smoothOptions.put("check", "true")
    smoothOptions.put("boundaries", "true")
    smoothOptions.put("relaxation", str(0.6))
    if (safe_coplanarity >= 0.0):
        smoothOptions.put("coplanarity", str(safe_coplanarity))
    SmoothNodes3DBg(liaison, smoothOptions).compute()

    # Remove Degenerated
    rdOptions = HashMap()
    rdOptions.put("rho", str(kwargs['eratio']))
    RemoveDegeneratedTriangles(liaison, rdOptions).compute()

    # Output
    MeshWriter.writeObject3D(liaison.getMesh(), kwargs['out_dir'], "")
    if kwargs['recordFile']:
        liaison.getMesh().getTrace().finish()
Ejemplo n.º 7
0
    help=
    "minimum dot product of face normals when building feature edges (default 0.95)"
)

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
    parser.print_usage()
    sys.exit(1)

xmlDir = args[0]
outDir = args[1]

mtb = MeshTraitsBuilder.getDefault3D()
mtb.addNodeSet()
mesh = Mesh(mtb)
MeshReader.readObject3D(mesh, xmlDir)
liaison = MeshLiaison.create(mesh, mtb)

if options.coplanarity:
    liaison.getMesh().buildRidges(options.coplanarity)
if options.preserveGroups:
    liaison.getMesh().buildGroupBoundaries()

opts = HashMap()
if options.coplanarity:
    opts.put("coplanarity", str(options.coplanarity))
opts.put("checkNormals", str("false"))
ImproveVertexValence(liaison, opts).compute()
MeshWriter.writeObject3D(liaison.getMesh(), outDir, String())
Ejemplo n.º 8
0
    help="record mesh operations in a Python file to replay this scenario")

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
    parser.print_usage()
    sys.exit(1)

xmlDir = args[0]
outDir = args[1]

mtb = MeshTraitsBuilder.getDefault3D()
if options.recordFile:
    mtb.addTraceRecord()
mtb.addNodeSet()
mesh = Mesh(mtb)
if options.recordFile:
    mesh.getTrace().setDisabled(True)
MeshReader.readObject3D(mesh, xmlDir)

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.immutable_border:
    liaison.mesh.tagFreeEdges(AbstractHalfEdge.IMMUTABLE)
liaison.getMesh().buildRidges(0.9)
if options.immutable_border_group:
    liaison.mesh.tagGroupBoundaries(AbstractHalfEdge.IMMUTABLE)
else:
Ejemplo n.º 9
0
if len(args) != 2:
	parser.print_usage()
	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
Ejemplo n.º 10
0
                  dest="coplanarity",
                  help="dot product of face normals to detect feature edges")

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
    parser.print_usage()
    sys.exit(1)

xmlDir = args[0]
outDir = args[1]

# Original mesh will be treated as a background mesh
background_mtb = MeshTraitsBuilder.getDefault3D()
background_mtb.addNodeSet()
background_mesh = Mesh(background_mtb)
MeshReader.readObject3D(background_mesh, xmlDir)
if options.coplanarity:
    background_mesh.buildRidges(options.coplanarity)

# New mesh must not have connectivity
new_mtb = MeshTraitsBuilder()
new_mtb.addTriangleList()
new_mtb.addNodeList()
new_mesh = Mesh(new_mtb)

for point in background_mesh.getNodes():
    new_mesh.add(point)

# Split triangles into 4 new triangles
mapSeenTriangles = {}
Ejemplo n.º 11
0
from java.lang import String

# Python
import sys, os
from optparse import OptionParser

"""
   Extract specified groups from a mesh
"""

cmd=("extract    ", "<inputDir> <outputDir> <groupName> [<groupName>...]", "Extract specified groups")
parser = OptionParser(usage="amibebatch %s [OPTIONS] %s\n\n%s" % cmd,
	prog="extract")

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) < 3:
	parser.print_usage()
	sys.exit(1)

xmlDir = args[0]
outDir = args[1]

s = SubMeshWorker(xmlDir)
groups = args[2:]
extractedDir = s.extractGroups(groups)
m = Mesh()
MeshReader.readObject3D(m, extractedDir)
MeshWriter.writeObject3D(m, outDir, String())

Ejemplo n.º 12
0
# Python
import sys, os
from optparse import OptionParser

"""
   Automatic partitioning of a mesh, based on feature edges
"""

cmd=("partition  ", "<inputDir> <outputDir>", "Automatic partitioning of a mesh, based on feature edges")
parser = OptionParser(usage="amibebatch %s [OPTIONS] %s\n\n%s" % cmd,
	prog="report")
parser.add_option("-c", "--coplanarity", metavar="FLOAT", default=0.95,
                  action="store", type="float", dest="coplanarity",
		  help="minimum dot product of face normals when building feature edges (default 0.95)")

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
	parser.print_usage()
	sys.exit(1)

xmlDir = args[0]
outDir = args[1]

mesh = Mesh()
MeshReader.readObject3D(mesh, xmlDir)
mesh.buildRidges(options.coplanarity)
mesh.buildPartition()
MeshWriter.writeObject3D(mesh, outDir, String())

Ejemplo n.º 13
0
	options.histogram = True
	bounds = [float(i) for i in options.bounds.split(",")]
else:
	bounds = None

qprocFactory = QualityProcedureFactory("org.jcae.mesh.amibe.validation."+options.crit)
qproc = qprocFactory.buildQualityProcedure()
mtb = qproc.getMeshTraitsBuilder()
if options.verboseMesh:
	if not  mtb.hasNodes():
		mtb.addNodeList()
	ttb = mtb.getTriangleTraitsBuilder()
	if not ttb.hasHalfEdge() and not ttb.hasVirtualHalfEdge():
		ttb.addHalfEdge()

mesh = Mesh(mtb);
MeshReader.readObject3D(mesh, xmlDir)
# Compute mesh quality
if options.verboseMesh:
	nrVertices = 0
	nrNMVertices = 0
	nrEdges = 0
	nrNMEdges = 0
	nrFreeEdges = 0
	nrTriangles = 0
	ot = None
	for t in mesh.getTriangles():
		if not t.isWritable():
			continue
		ot = t.getAbstractHalfEdge(ot)
		nrTriangles += 1
Ejemplo n.º 14
0
    "-i",
    "--no-expect-insert",
    action="store_true",
    dest="no_expect_insert",
    help=
    "Relax swapping conditions when no further point insertion are expected")
(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
    parser.print_usage()
    sys.exit(1)

xmlDir = args[0]
outDir = args[1]

mesh = Mesh()
MeshReader.readObject3D(mesh, xmlDir)
liaison = MeshLiaison(mesh)
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("coplanarity", str(options.coplanarity))
if options.min_quality_factor:
    opts.put("minQualityFactor", str(options.min_quality_factor))
if options.no_expect_insert:
    opts.put("expectInsert", "false")
Ejemplo n.º 15
0
def remesh(**kwargs):
    """
    Remesh an existing mesh with a singular analytical metric
    """
    # Process coplanarity options
    coplanarity = cos(kwargs["coplanarityAngle"] * pi / 180.0)
    if kwargs["coplanarity"]:
        coplanarity = kwargs["coplanarity"]

    safe_coplanarity = kwargs["safe_coplanarity"]
    if safe_coplanarity is None:
        safe_coplanarity = 0.8
    safe_coplanarity = max(coplanarity, safe_coplanarity)

    # Build background mesh
    try:
        liaison = kwargs["liaison"]
    except KeyError:
        mtb = MeshTraitsBuilder.getDefault3D()
        if kwargs["recordFile"]:
            mtb.addTraceRecord()
        mtb.addNodeSet()
        mesh = Mesh(mtb)
        if kwargs["recordFile"]:
            mesh.getTrace().setDisabled(True)

        MeshReader.readObject3D(mesh, kwargs["in_dir"])
        liaison = MeshLiaison.create(mesh, mtb)

    if kwargs["recordFile"]:
        liaison.getMesh().getTrace().setDisabled(False)
        liaison.getMesh().getTrace().setLogFile(kwargs["recordFile"])
        liaison.getMesh().getTrace().createMesh("mesh", liaison.getMesh())
    if kwargs["immutable_border"]:
        liaison.mesh.tagFreeEdges(AbstractHalfEdge.IMMUTABLE)
    liaison.getMesh().buildRidges(coplanarity)
    if kwargs["preserveGroups"]:
        liaison.getMesh().buildGroupBoundaries()

    immutable_groups = []
    if kwargs["immutable_groups_file"]:
        f = open(kwargs["immutable_groups_file"])
        immutable_groups = f.read().split()
        f.close()
        liaison.mesh.tagGroups(immutable_groups, AbstractHalfEdge.IMMUTABLE)

    if kwargs["recordFile"]:
        cmds = [
            String("assert self.m.checkNoDegeneratedTriangles()"),
            String("assert self.m.checkNoInvertedTriangles()"),
            String("assert self.m.checkVertexLinks()"),
            String("assert self.m.isValid()"),
        ]
        liaison.getMesh().getTrace().setHooks(cmds)

    # Decimate
    if kwargs["decimateSize"] or kwargs["decimateTarget"]:
        decimateOptions = HashMap()
        if kwargs["decimateSize"]:
            decimateOptions.put("size", str(kwargs["decimateSize"]))
        elif kwargs["decimateTarget"]:
            decimateOptions.put("maxtriangles", str(kwargs["decimateTarget"]))
        decimateOptions.put("coplanarity", str(safe_coplanarity))
        QEMDecimateHalfEdge(liaison, decimateOptions).compute()
        swapOptions = HashMap()
        swapOptions.put("coplanarity", str(safe_coplanarity))
        SwapEdge(liaison, swapOptions).compute()

    # Metric
    if kwargs["rho"] > 1.0:
        # mixed metric
        metric = SingularMetric(kwargs["sizeinf"], kwargs["point_metric_file"],
                                kwargs["rho"], True)
    else:
        # analytic metric
        metric = SingularMetric(kwargs["sizeinf"], kwargs["point_metric_file"])

    # Remesh Skeleton
    if kwargs["skeleton"]:
        RemeshSkeleton(liaison, 1.66, metric, 0.01).compute()

    # Remesh
    refineOptions = HashMap()
    refineOptions.put("size", str(kwargs["sizeinf"]))
    refineOptions.put("coplanarity", str(safe_coplanarity))
    refineOptions.put("nearLengthRatio", str(kwargs["nearLengthRatio"]))
    refineOptions.put("project", "false")
    if kwargs["allowNearNodes"]:
        refineOptions.put("allowNearNodes", "true")
    refineAlgo = Remesh(liaison, refineOptions)
    refineAlgo.setAnalyticMetric(metric)
    refineAlgo.compute()

    if not kwargs["noclean"]:
        # Swap
        swapOptions = HashMap()
        swapOptions.put("coplanarity", str(safe_coplanarity))
        swapOptions.put("minCosAfterSwap", "0.3")
        SwapEdge(liaison, swapOptions).compute()

        # Improve valence
        valenceOptions = HashMap()
        valenceOptions.put("coplanarity", str(safe_coplanarity))
        valenceOptions.put("checkNormals", "false")
        ImproveVertexValence(liaison, valenceOptions).compute()

        # Smooth
        smoothOptions = HashMap()
        smoothOptions.put("iterations", str(8))
        smoothOptions.put("check", "true")
        smoothOptions.put("boundaries", "true")
        smoothOptions.put("relaxation", str(0.6))
        if safe_coplanarity >= 0.0:
            smoothOptions.put("coplanarity", str(safe_coplanarity))
        SmoothNodes3DBg(liaison, smoothOptions).compute()

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

    # remesh beams
    if kwargs["wire_size"] > 0.0:
        liaison = remesh_beams(
            liaison=liaison,
            size=kwargs["wire_size"],
            rho=kwargs["rho"],
            immutable_groups=immutable_groups,
            point_metric_file=kwargs["wire_metric_file"],
        )

    # Output
    MeshWriter.writeObject3D(liaison.getMesh(), kwargs["out_dir"], "")
    if kwargs["recordFile"]:
        liaison.getMesh().getTrace().finish()
Ejemplo n.º 16
0
def read_mesh(path):
    mtb = MeshTraitsBuilder.getDefault3D()
    mtb.addNodeSet()
    mesh = Mesh(mtb)
    MeshReader.readObject3D(mesh, path)
    return mesh
Ejemplo n.º 17
0
    dest="coplanarity",
    help=
    "dot product of face normals to detect ridges (default: no ridge detection)"
)

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 1:
    parser.print_usage()
    sys.exit(1)

xmlDir = args[0]

mtb = MeshTraitsBuilder.getDefault3D()
mtb.addNodeList()
mesh = Mesh(mtb)
MeshReader.readObject3D(mesh, xmlDir)

if options.coplanarity:
    mesh.buildRidges(options.coplanarity)

nrNodes = 0
nrNMNodes = 0
nrNMEdges = 0
nrFreeEdges = 0
nrSharpEdges = 0
nrTriangles = 0
ot = None
for t in mesh.getTriangles():
    if t.hasAttributes(AbstractHalfEdge.OUTER):
        continue
Ejemplo n.º 18
0
cmd = ("partition  ", "<inputDir> <outputDir>",
       "Automatic partitioning of a mesh, based on feature edges")
parser = OptionParser(usage="amibebatch %s [OPTIONS] %s\n\n%s" % cmd,
                      prog="report")
parser.add_option(
    "-c",
    "--coplanarity",
    metavar="FLOAT",
    default=0.95,
    action="store",
    type="float",
    dest="coplanarity",
    help=
    "minimum dot product of face normals when building feature edges (default 0.95)"
)

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
    parser.print_usage()
    sys.exit(1)

xmlDir = args[0]
outDir = args[1]

mesh = Mesh()
MeshReader.readObject3D(mesh, xmlDir)
mesh.buildRidges(options.coplanarity)
mesh.buildPartition()
MeshWriter.writeObject3D(mesh, outDir, String())
Ejemplo n.º 19
0
                  action="store", type="float", dest="coplanarity",
                  help="dot product of face normals to detect feature edges")

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
	parser.print_usage()
	sys.exit(1)

xmlDir = args[0]
outDir = args[1]

# Original mesh will be treated as a background mesh
background_mtb = MeshTraitsBuilder.getDefault3D()
background_mtb.addNodeSet()
background_mesh = Mesh(background_mtb)
MeshReader.readObject3D(background_mesh, xmlDir)
if options.coplanarity:
	background_mesh.buildRidges(options.coplanarity)

# New mesh must not have connectivity
new_mtb = MeshTraitsBuilder()
new_mtb.addTriangleList()
new_mtb.addNodeList()
new_mesh = Mesh(new_mtb)

for point in background_mesh.getNodes():
	new_mesh.add(point)

# Split triangles into 4 new triangles
mapSeenTriangles = {}
Ejemplo n.º 20
0
if options.tolerance:
	opts.put("size", str(options.tolerance))
elif options.targetTriangles:
	opts.put("maxtriangles", str(options.targetTriangles))
if options.freeEdgesOnly:
	opts.put("freeEdgesOnly", "true");
if options.freeEdgeTol:
	opts.put("freeEdgeTol", str(options.freeEdgeTol))
if options.maxlength:
	opts.put("maxlength", str(options.maxlength))

mtb = MeshTraitsBuilder.getDefault3D()
if options.recordFile:
	mtb.addNodeSet()
	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)
Ejemplo n.º 21
0
(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
	parser.print_usage()
	sys.exit(1)

xmlDir = args[0]
outDir = args[1]
if options.size:
	size = options.size
else:
	size = 1.0

mtb = MeshTraitsBuilder.getDefault3D()
mtb.addNodeList()
mesh = Mesh(mtb)
MeshReader.readObject3D(mesh, xmlDir)

polylines=PolylineFactory(mesh)
mesh.resetBeams()
for entry in polylines.entrySet():
  groupId = entry.key
  for polyline in entry.value:
		listM = ArrayList()
		for v in polyline:
			listM.add(EuclidianMetric3D(size))
		#for v in polyline:
		#	print v
		print "Remesh polyline "+str(numPoly+1)+"/"+str(nrPoly)+" of group "+str(bId)+"/"+str(bgroupMap.size())+" "+str(polyline.size())+" vertices"
		result = RemeshPolyline(mesh, polyline, listM).compute()
		for i in xrange(result.size() - 1):
Ejemplo n.º 22
0
Archivo: refine.py Proyecto: alclp/jCAE
                  help="record mesh operations in a Python file to replay this scenario")

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 2:
	parser.print_usage()
	sys.exit(1)

xmlDir = args[0]
outDir = args[1]

mtb = MeshTraitsBuilder.getDefault3D()
if options.recordFile:
	mtb.addTraceRecord()
mtb.addNodeSet()
mesh = Mesh(mtb)
if options.recordFile:
	mesh.getTrace().setDisabled(True)
MeshReader.readObject3D(mesh, xmlDir)

liaison = MeshLiaison.create(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.immutable_border:
	liaison.mesh.tagFreeEdges(AbstractHalfEdge.IMMUTABLE)
if options.coplanarity:
	liaison.getMesh().buildRidges(options.coplanarity)
if options.preserveGroups:
	liaison.getMesh().buildGroupBoundaries()
Ejemplo n.º 23
0
cmd = ("random  ", "<dir>", "Put random triangles in a given group.")
parser = OptionParser(usage="amibebatch %s [OPTIONS] %s\n\n%s" % cmd,
                      prog="random")
parser.add_option("-r",
                  "--ratio",
                  metavar="FLOAT",
                  default=0.03,
                  action="store",
                  type="float",
                  dest="ratio",
                  help="The ratio of triangles to put in the new group")
parser.add_option("-n",
                  "--name",
                  metavar="STRING",
                  action="store",
                  type="string",
                  dest="group_name",
                  default="random",
                  help="""The name of group to be created.""")

(options, args) = parser.parse_args(args=sys.argv[1:])

if len(args) != 1:
    parser.print_usage()
    sys.exit(1)

mesh = Mesh(MeshTraitsBuilder.getDefault3D())
xmlDir = args[0]
MeshReader.readObject3D(mesh, xmlDir)
RandomizeGroups(options.ratio, options.group_name).compute(mesh, True)
MeshWriter.writeObject3D(mesh, xmlDir, None)