PolyData의 위치 및 회전을 제어하기 위해서 Transformfilter 를 사용한다. 우선 적용할 vtkTransform을 이용해 transformation matrix 를 생성한다. 변환할 객체 정보를 vtkTransformPolyDataFilter 에 입력하고 polydata 값을 연결한다. filter를 mapper에 연결하고 최종적으로 actor에 연결하면된다. vtkFloatArray Scalars = vtkFloatArray.New(); Scalars.InsertNextTuple1(1.0); Scalars.InsertNextTuple1(0.0); Scalars.InsertNextTuple1(0.0); Scalars.InsertNextTuple1(1.0); Scalars.InsertNex..
Color range를 표시하는 bar를 사용하는 방법 // 기본 Lut 생성 var lut = vtkLookupTable.New(); lut.Build(); vtkScalarBarActor scalarBar = vtkScalarBarActor.New(); scalarBar.SetLookupTable(lut); // 출력 위치 설정 scalarBar.GetPositionCoordinate().SetCoordinateSystemToNormalizedViewport(); scalarBar.GetPositionCoordinate().SetValue(0.1, 0.1); // 크기 설정 scalarBar.SetWidth(0.8); scalarBar.SetHeight(0.17); // Orient 설정 scalar..
Camera 의 viewport 에 따라서 움직이는 3D text 를 만든다. vtkAxes axes = vtkAxes.New(); axes.SetOrigin(0, 0, 0); vtkPolyDataMapper axesMapper = vtkPolyDataMapper.New(); axesMapper.SetInputConnection(axes.GetOutputPort()); vtkActor axesActor = vtkActor.New(); axesActor.SetMapper(axesMapper); ren1.AddActor(axesActor); vtkVectorText atext = vtkVectorText.New(); atext.SetText("Origin"); vtkPolyDataMapper textMapp..
화면에 Text를 표시하기 위해 적용할 수 있는 두가지 방법별로 설명한다. 1. vtkActor2D 를 사용하는 방법 vtkTextMapper singlineMapper = vtkTextMapper.New(); // 문자열을 mapper 에 입력한다. singlineMapper.SetInput("Single line"); tprop = singlineMapper.GetTextProperty(); tprop.ShallowCopy(commonProp); tprop.SetVerticalJustificationToCentered(); tprop.SetJustificationToCentered(); tprop.SetColor(colors.GetColor3d("Peacock").GetCppThis().Handle)..
vtk에 property 객체에 색상을 적용할 때에 매번 color 값을 입력하지 않고 vtkColors.h 에 정의되어 있는 색상을 사용하기 위해서 vtkNamedColors 를 사용한다. vtkNamedColors 클래스에서 색상 값을 string으로 받아 올 수 있으나, return 값이 vtkColor3d 로 들어온다. vtkColor3d 는 double을 3개를 갖는 tuple 구조이다. .Net에서 쉽게 사용하기 위해서는 아래의 예제와 같이 vtkColor3d의 cpp handle을 바로 property 에 입력할 수 있다. // Method 1 vtkColor3d cc1 = colors.GetColor3d("DimGray"); vtkTextProperty prop = vtkTextProper..
VTK addobserver의 기능을 Activiz.Net을 이용할 때에는 event delegate를 사용하면 쉽게 구현할 수 있다. 다만, event 를 수행하는데 있어서 내부에서 사용하는 객체의 접근에 대한 참조 정보가 에러가 발생하는 경우가 있다. 그럴경우에는 아래와 같은 에러 메시지가 발생한다. 관련 thread 는 다음과 같다. VTK - Users - c# custom interactor exception "could not get registered type - mteIndex='4294967295' " (nabble.com) VTK - Users - c# custom interactor exception "could not get registered type - mteIndex='4294..
VTK에서 STL 파일을 로드를 하고 RenderWindow를 Start 하면 모델이 잘 출력된다. 하지만, Render의 GetActiveCamera 함수를 수행하면, 이상하게 모델이 사라지는 문제가 발생하였다. 이는 RenderWindow의 Start 또는 Render 함수를 수행하면, PolyData의 정보를 기반으로 적절한 Camear 를 자동으로 생성한다. 하지만, Render를 하기 전에 GetActiveCamera를 수행하면 기본 값이 만들어지고 그 뒤로 기본 Camera 정보를 이용하여 render를 수행하기 때문에, 모델이 사라지는 것과 같은 현상이 나타난다. GetActiveCamera 를 사용한 후 PolyData 모델이 사라지면 Render를 수행 후 GetActiveCamera를 ..