static public vtkAlgorithmOutput genFrustumCone(double total_dis, double end_radius, double distance, bool is_reverse) { vtkConeSource cone = vtkConeSource.New(); cone.SetHeight(total_dis * 1.2); cone.SetRadius(end_radius * 1.2); cone.SetCenter(0, 0, total_dis * 0.4); cone.SetResolution(80); cone.SetDirection(0, 0, 1); cone.Update(); vtkPlane plane = vtkPlane.New(); plane.SetOrigin(0, 0, 0); plane.SetNormal(0, 0, 1); vtkClipPolyData clipPolyData = vtkClipPolyData.New(); clipPolyData.SetInputConnection(cone.GetOutputPort()); clipPolyData.SetClipFunction(plane); clipPolyData.GenerateClippedOutputOn(); clipPolyData.Update(); vtkPlane plane2 = vtkPlane.New(); plane2.SetOrigin(0, 0, distance); plane2.SetNormal(0, 0, -1); vtkClipPolyData clipPolyData2 = vtkClipPolyData.New(); clipPolyData2.SetInputConnection(clipPolyData.GetOutputPort()); clipPolyData2.SetClipFunction(plane2); clipPolyData2.GenerateClippedOutputOn(); clipPolyData2.Update(); if (is_reverse) { vtkTransform transform = vtkTransform.New(); transform.RotateWXYZ(180, 0, 1, 0); transform.Translate(0, 0, -distance); vtkTransformPolyDataFilter transFilter = vtkTransformPolyDataFilter.New(); transFilter.SetInputConnection(clipPolyData2.GetOutputPort()); transFilter.SetTransform(transform); //use vtkTransform (or maybe vtkLinearTransform) transFilter.Update(); return(transFilter.GetOutputPort()); } return(clipPolyData2.GetOutputPort()); }
/// <summary> /// Update Boundary Condition actor (arrows) in Viewport /// </summary> public void Update_Arrows(Dictionary <int, Node> NodeLib, double scale, int Step, bool ClipMode) { vtkPoints PointsX = vtkPoints.New(); vtkPoints PointsY = vtkPoints.New(); vtkPoints PointsZ = vtkPoints.New(); // Create Cone Sources for X, Y and Z direction vtkConeSource ConeSourceX = vtkConeSource.New(); vtkConeSource ConeSourceY = vtkConeSource.New(); vtkConeSource ConeSourceZ = vtkConeSource.New(); ConeSourceX.SetAngle(15); ConeSourceX.SetHeight(scale); ConeSourceX.SetRadius(scale / 4); ConeSourceX.SetResolution(12); ConeSourceX.SetDirection(1, 0, 0); ConeSourceY.SetAngle(15); ConeSourceY.SetHeight(scale); ConeSourceY.SetRadius(scale / 4); ConeSourceY.SetResolution(12); ConeSourceY.SetDirection(0, 1, 0); ConeSourceZ.SetAngle(15); ConeSourceZ.SetHeight(scale); ConeSourceZ.SetRadius(scale / 4); ConeSourceZ.SetResolution(12); ConeSourceZ.SetDirection(0, 0, 1); // Create Points foreach (int i in NodalValues.Keys) { double X = NodeLib[i].X + NodeLib[i].GetDisp(Step, 0); double Y = NodeLib[i].Y + NodeLib[i].GetDisp(Step, 1); double Z = NodeLib[i].Z + NodeLib[i].GetDisp(Step, 2); if (NodalValues[i].Get(0, 0) != 0) { PointsX.InsertNextPoint(X - scale / 2, Y, Z); } if (NodalValues[i].Get(1, 0) != 0) { PointsY.InsertNextPoint(X, Y - scale / 2, Z); } if (NodalValues[i].Get(2, 0) != 0) { PointsZ.InsertNextPoint(X, Y, Z - scale / 2); } } // Set Points to PolyData vtkPolyData PolyX = vtkPolyData.New(); PolyX.SetPoints(PointsX); vtkPolyData PolyY = vtkPolyData.New(); PolyY.SetPoints(PointsY); vtkPolyData PolyZ = vtkPolyData.New(); PolyZ.SetPoints(PointsZ); // Create Glyphs 3D GlyphX = vtkGlyph3D.New(); GlyphY = vtkGlyph3D.New(); GlyphZ = vtkGlyph3D.New(); GlyphX.SetSourceConnection(ConeSourceX.GetOutputPort()); GlyphX.SetInput(PolyX); GlyphX.Update(); GlyphY.SetSourceConnection(ConeSourceY.GetOutputPort()); GlyphY.SetInput(PolyY); GlyphY.Update(); GlyphZ.SetSourceConnection(ConeSourceZ.GetOutputPort()); GlyphZ.SetInput(PolyZ); GlyphZ.Update(); // Set Mapper based on Clip Mode if (ClipMode == true) { // Add Clippers to Mapper ClipperX.SetInputConnection(GlyphX.GetOutputPort()); ClipperX.Update(); MapperX.SetInputConnection(ClipperX.GetOutputPort()); MapperX.Update(); ClipperY.SetInputConnection(GlyphY.GetOutputPort()); ClipperY.Update(); MapperY.SetInputConnection(ClipperY.GetOutputPort()); MapperY.Update(); ClipperZ.SetInputConnection(GlyphZ.GetOutputPort()); ClipperZ.Update(); MapperZ.SetInputConnection(ClipperZ.GetOutputPort()); MapperZ.Update(); } else { // Add Glyphs to Mapper MapperX.SetInputConnection(GlyphX.GetOutputPort()); MapperY.SetInputConnection(GlyphY.GetOutputPort()); MapperZ.SetInputConnection(GlyphZ.GetOutputPort()); MapperX.Update(); MapperY.Update(); MapperZ.Update(); } // Update Actor color ActorX.GetProperty().SetColor( GetColor()[0] / 255.0, GetColor()[1] / 255.0, GetColor()[2] / 255.0); ActorY.GetProperty().SetColor( GetColor()[0] / 255.0, GetColor()[1] / 255.0, GetColor()[2] / 255.0); ActorZ.GetProperty().SetColor( GetColor()[0] / 255.0, GetColor()[1] / 255.0, GetColor()[2] / 255.0); }