Exemplo n.º 1
0
def Main(cgnsMeshFileName):

	app = App()
	#app.MainLoop()
	#return

	style = vtk.vtkInteractorStyleTrackballCamera()
	Roster.RenderWindow.GetInteractor().SetInteractorStyle(style)

	"""
	picker = vtk.vtkPropPicker()
	picker.AddObserver("EndPickEvent", PickEventCallback)
	Roster.RenderWindow.GetInteractor().SetPicker(picker)
	"""

	axesActor = vtk.vtkAxesActor()
	markerWidget = vtk.vtkOrientationMarkerWidget()
	markerWidget.SetOrientationMarker(axesActor)
	markerWidget.SetInteractor(Roster.RenderWindow.GetInteractor())

	if cgnsMeshFileName != None:
		cgnsf = CGNSFile.CGNSFile(cgnsMeshFileName)
		zones = cgnsf.ReadZones()
		Roster.Zones = zones

		#ren = vtk.vtkRenderer()
		ren = Roster.Renderer

		B = 1
		for zone in zones:

			xyz = cgnsf.ReadZoneCoord(B, zone["Zone"])

			for boco in zone["Bocos"]:
				if Roster.FindPatchByName(boco["Name"]) != None:
					RenamePatch(boco)
				r = CanonizeRange(boco["Range"])
				xyz2 = xyz[:, r[0] - 1:r[3], r[1] - 1:r[4], r[2] - 1:r[5]]
				xyzCoarse = CoarsenPatchMesh(xyz2)
				so = SceneObject(xyzCoarse)
				actors = so.ActorSurface, so.ActorOutline
				actors[0].GetProperty().SetColor(1.0, 1.0, 1.0)
				for actor in actors:
					ren.AddActor(actor)
				#Roster.Patches.append([zone, boco, actors])
				Roster.RegisterPatch(zone, boco, actors)

			if True:
				for c1to1 in zone["1to1s"]:
					if not c1to1.IsPeriodic():
						continue
					if Roster.FindPatchByName(c1to1["Name"]) != None:
						RenamePatch(c1to1)
						"""
						for i in range(2,100):
							candidateName = "%s_%d" % (c1to1["Name"], i)
							if Roster.FindPatchByName(candidateName) == None:
								print "Duplicate patch %s was renamed to %s" % (c1to1["Name"], candidateName)
								c1to1["Name"] = candidateName
								break
						"""
					r = CanonizeRange(c1to1["Range"])
					xyz2 = xyz[:, r[0] - 1:r[3], r[1] - 1:r[4], r[2] - 1:r[5]]
					xyzCoarse = CoarsenPatchMesh(xyz2)
					so = SceneObject(xyzCoarse)
					actors = so.ActorSurface, so.ActorOutline
					actors[0].GetProperty().SetColor(0.0, 0.0, 1.0)
					for actor in actors:
						ren.AddActor(actor)
					Roster.RegisterPatch(zone, c1to1, actors)

			del xyz

	markerWidget.SetEnabled(True)
	markerWidget.InteractiveOn()

	Roster.RosterModified()

	app.MainLoop()