분류 전체보기

Programming/C#

App.Config 사용하기..

.Net Framework 의 프로젝트에는 App.config 파일을 추가할 수 있다.app.config 파일을 작성하고 build를 수행하면 실행 파일의 경로에 app.config 파일이 그대로 복사가 된다. 프로그램이 실행이 될때에 app.config파일의 내용을 참조하여 runtime 시에 사용할 수 있다. 1. key 값을 설정할 수 있다. 아래와 같이 사용할 있다. 2. Library Probing 참조하는 dll 라이브러리의 경로를 임의의 지정된 폴더에서 probing 하도록 설정을 할 수 있다.

Programming/C#

Abstraction vs Interface Class??

클래스 상속을 위해 부모 클래스를 생성할 때 고려할 수 있는 대상은 3가지가 될 수 있다. 1. standard class 2. abstract class 3. interface class 1번의 경우는 일반 클래스로 자식 클래스에서 override를 수행할 때에 부모 클래스의 함수가 수행 되므로, 특정 자식 클래스에 대한 함수를 따로 구현 할 떄에 이를 compile 단계에서 알수가 없다. 그와 반대로 2,3번의 경우는 위의 상황에 대해 compile 단계에서 에러를 발생한다. 그럼, 어떤 상황을 생각 했을 때에 abstract 와 interface 를 선택할 것인가?? 차이점을 살펴 보자. - abstract 클래스는 구현이 가능한 클래스이나, interface의 경우는 정의만 되어진 클래스이다. -..

Programming/C#

User Setting 파일저장, 로드, 경로 지정

public class MySettings { public int MyNumber { get; set; } public string MyString { get; set; } public void Save() { using (Stream stream = File.Create(SettingsFile)) using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8)) { writer.WriteLine(MyNumber); writer.WriteLine(MyString); } } public static MySettings Load() { if (!File.Exists(SettingsFile)) return DefaultSettings; using (S..

Programming/C#

Is & As & Cast

static void Main(string[] args) { object[] objects = { new M3(), new Hooptie(), }; foreach (M3 obj in objects) { Console.WriteLine(obj); Is(obj); As(obj); Cast(obj); Console.WriteLine("------"); } } private static void Cast(object obj) { try { M3 m3 = (M3)obj; Console.WriteLine("(M3) returned {0}", m3); } catch (InvalidCastException) { Console.WriteLine("InvalidCastException"); } } private stati..

Programming/C#

Abstract & Virtual & Override

Abstract Method (추상 메소드) : base class에서 선언만 된다. : 파생 클래스에서 구현을 해야 한다. : abstract method 가 구현되어 있는 클래스는 abstract 제한자를 설정해야한다. ex) public abstract class MyCalss Virtual Method (가상 메소드) : base class에서 선언 및 구현이 가능하다. : 파생 클래스에서 재정의 할 있도록 되어있다. Virtual Method 사용하는 이유 : Virtual method를 선언하면, vtable이 생성되고, 이를 통해서 함수를 사용할 때 vtable을 참조하여 수행 속도를 향상시킨다. Override 재정의 : virtual, abstract method를 재정의할 때는 over..

Developments/VTK

VTK Texture

namespace vtkTextureTest { class Program { static string VTKDATA = @"D:\Library\vtkdata-5.8.0\"; static void Main(string[] args) { vtkBMPReader bmpRedaer = vtkBMPReader.New(); bmpRedaer.SetFileName(VTKDATA + @"Data\masonry.bmp"); vtkTexture atext = vtkTexture.New(); atext.SetInputConnection(bmpRedaer.GetOutputPort()); atext.InterpolateOn(); /// Create a plane source and actor vtkPlaneSource plan..

Developments/VTK

VTK Assembly

class Program { static vtkRenderer ren; static vtkRenderWindow renWin; static vtkRenderWindowInteractor iren; static void Main(string[] args) { vtkSphereSource sphere = vtkSphereSource.New(); vtkPolyDataMapper sphereMapper = vtkPolyDataMapper.New(); sphereMapper.SetInputConnection(sphere.GetOutputPort()); vtkActor sphereActor = vtkActor.New(); sphereActor .SetMapper( sphereMapper); sphereActor ...

Developments/VTK

VTK Actor & Property

namespace vtkPropTest { class Program { static vtkConeSource cone; static vtkActor anActor; static vtkProperty prop; static vtkRenderer ren; static vtkRenderWindow renWin; static vtkRenderWindowInteractor iren; static vtkPolyDataMapper coneMapper; static void Main(string[] args) { cone = vtkConeSource.New(); cone.SetHeight(3.0); cone.SetRadius(1.0); cone.SetResolution(10); coneMapper = vtkPolyDa..

Developments/VTK

VTK GetActiveCamera 주의점

VTK에서 STL 파일을 로드를 하고 RenderWindow를 Start 하면 모델이 잘 출력된다. 하지만, Render의 GetActiveCamera 함수를 수행하면, 이상하게 모델이 사라지는 문제가 발생하였다. 이는 RenderWindow의 Start 또는 Render 함수를 수행하면, PolyData의 정보를 기반으로 적절한 Camear 를 자동으로 생성한다. 하지만, Render를 하기 전에 GetActiveCamera를 수행하면 기본 값이 만들어지고 그 뒤로 기본 Camera 정보를 이용하여 render를 수행하기 때문에, 모델이 사라지는 것과 같은 현상이 나타난다. GetActiveCamera 를 사용한 후 PolyData 모델이 사라지면 Render를 수행 후 GetActiveCamera를 ..

Developments/VTK

VTK IntPtr 사용법

IntPtr를 이용하여 FocalPoint 얻기 + IntPtr -> Double[] 값 복사하기 double[] ZOOT = new double[3]; int s = Marshal.SizeOf(ZOOT[0]) * ZOOT.Length; System.IntPtr p = Marshal.AllocHGlobal(s); ren1.GetActiveCamera().GetFocalPoint(p); Marshal.Copy(p, ZOOT, 0, ZOOT.Length); double[] ZOOT = new double[3];// (3);// { 100, 100, 100 }; int s = Marshal.SizeOf(ZOOT[0]) * ZOOT.Length; System.IntPtr p = Marshal.AllocHGlob..

RichardBang
'분류 전체보기' 카테고리의 글 목록 (21 Page)