private void CreateViewportBorder(vtkRenderer renderer, double[] color) { ModelLoaded = false; // points start at upper right and proceed anti-clockwise vtkPoints points = vtkPoints.New(); points.SetNumberOfPoints(4); points.InsertPoint(0, 1, 1, 0); points.InsertPoint(1, 1e-3, 1, 0); points.InsertPoint(2, 1e-3, 1e-3, 0); points.InsertPoint(3, 1, 1e-3, 0); // create cells, and lines vtkCellArray cells = vtkCellArray.New(); cells.Initialize(); vtkPolyLine lines = vtkPolyLine.New(); lines.GetPointIds().SetNumberOfIds(5); for (int i = 0; i < 4; ++i) { lines.GetPointIds().SetId(i, i); } lines.GetPointIds().SetId(4, 0); cells.InsertNextCell(lines); // now make tge polydata and display it vtkPolyData poly = vtkPolyData.New(); poly.Initialize(); poly.SetPoints(points); poly.SetLines(cells); // use normalized viewport coordinates since // they are independent of window size vtkCoordinate coordinate = vtkCoordinate.New(); coordinate.SetCoordinateSystemToNormalizedViewport(); vtkPolyDataMapper2D mapper = vtkPolyDataMapper2D.New(); mapper.SetInput(poly); mapper.SetTransformCoordinate(coordinate); vtkActor2D actor = vtkActor2D.New(); actor.SetMapper(mapper); actor.GetProperty().SetColor(color[0], color[1], color[2]); // line width should be at least 2 to be visible at extremes actor.GetProperty().SetLineWidth((float)2.0); // Line Width renderer.AddViewProp(actor); }
//vtkPoints points = vtkPoints.New(); //points.InsertNextPoint(0.0, 0.0, 0.0); //points.InsertNextPoint(200.0, 0.0, 0.0); //points.InsertNextPoint(200.0, 200.0, 0.0); //points.InsertNextPoint(0.0, 200.0, 0.0); //points.InsertNextPoint(0.0, 0.0, 0.0); //vtkPolygon polygon = vtkPolygon.New(); //polygon.GetPointIds().SetNumberOfIds(5); //for (int i = 0; i < 5; i++) //{ // polygon.GetPointIds().SetId(i, i); //} public vtkActor2D AddMarkerLine(double[] startCoords, double[] endCoords, Color color) { vtkPoints points = vtkPoints.New(); points.InsertNextPoint(startCoords[0], startCoords[1], 0.0); points.InsertNextPoint(endCoords[0], endCoords[1], 0.0); vtkPolyLine line = vtkPolyLine.New(); line.GetPointIds().SetNumberOfIds(2); for (int i = 0; i < 2; i++) { line.GetPointIds().SetId(i, i); } vtkCellArray cellArray = vtkCellArray.New(); cellArray.InsertNextCell(line); vtkPolyData polyData = vtkPolyData.New(); polyData.SetPoints(points); polyData.SetLines(cellArray); vtkPolyDataMapper2D mapper = vtkPolyDataMapper2D.New(); mapper.SetInputData(polyData); vtkActor2D actor = vtkActor2D.New(); actor.SetMapper(mapper); actor.GetProperty().SetOpacity((float)color.A / 255); actor.GetProperty().SetColor((float)color.R / 255, (float)color.G / 255, (float)color.B / 255); _markerLayerRenderer.AddActor(actor); return(actor); }