Wie man eine große Anzahl von Hexaaeder rendert [geschlossen]C++

Programme in C++. Entwicklerforum
Anonymous
 Wie man eine große Anzahl von Hexaaeder rendert [geschlossen]

Post by Anonymous »

Wie rendert man dieses Objekt ...

Was sollte die Rendering -Strategie sein? Vielleicht fahren tausend Schauspieler Zeit nach < /p>

Code: Select all

def open_node_data(self):
# options = QFileDialog.Options()
files, _ = QFileDialog.getOpenFileNames(self, "Select Files", "", "All Files (*);;Text Files (*.txt)")
if len(files) == 2:
self.points, self.uPoints, self.heatmaps = read_Nodes(files[0] if "Node" in files[0] else files[1])
self.cells = read_Triangles(files[0] if "Element" in files[0] else files[1])
num_hex = len(self.cells) // 6
for i in range(num_hex):
hex_faces = self.cells[i * 6:(i + 1) * 6]
self.create_mesh(self.points, hex_faces, color=[0.31, 0.51, 0.9], bounding=False)
< /code>
Lesen Sie alle Punkte und Gesichter des Hexaheders, [url=viewtopic.php?t=13628]teilen[/url] Sie sie in unabhängige Polydaten auf, speichern Sie sie im Schauspieler und fügen Sie sie dann zu vtkassmbly hinzu. Der Zweck davon ist nur, auf die einzelnen Hexaeder -Einheiten zu klicken, wenn die Maus ausgewählt wird, und auf sie zu arbeiten, aber die Interaktion ist zu umständlich < /p>
def create_mesh(self, points, cells, color, bounding=False, num=0):
points_vtk = vtk.vtkPoints()
for point in points:
points_vtk.InsertNextPoint(point)

cells_vtk = vtk.vtkCellArray()
for cell in cells:
cells_vtk.InsertNextCell(4, cell[1:])

polydata = vtk.vtkPolyData()
polydata.SetPoints(points_vtk)
polydata.SetPolys(cells_vtk)

featureEdges = vtk.vtkFeatureEdges()
featureEdges.SetInputData(polydata)
featureEdges.BoundaryEdgesOn()
featureEdges.Update()
boundary = featureEdges.GetOutput()

points_list = []
for i in range(boundary.GetNumberOfPoints()):
p = boundary.GetPoint(i)
points_list.append(p)

pointColors = vtk.vtkUnsignedCharArray()
pointColors.SetNumberOfComponents(3)
pointColors.SetName("PointColors")
numPts = polydata.GetNumberOfPoints()
for i in range(numPts):
pointColors.InsertNextTuple3(color[0]*255,color[1]*255,color[2]*255)
polydata.GetPointData().SetScalars(pointColors)

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(polydata)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(color)
self.interactor_style.register_actor_polydata(actor, polydata)
self.assembly.AddPart(actor)
self.renderer.AddActor(self.assembly)
Ich weiß nicht, was zu tun ist.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post