Summary on 4th June

June 4th, 2009

My current objective is to extra skeleton from mesh pieces. It involves the following issues:

  • Mesh Segmentation
  • Boundary Optimization
  • ISO line construction to extra skeleton information

Mesh segmentation, borrow the idea from “Easy Mesh Cut”. However, surface clustering based method has limitation on volume based clustering work. So, I add one more parameter to compute the direction angle between vertex moving direction and use’s drawing intention. The an other problem is the boundary is not smooth and also does not lies in the correct position.

In order to optimize the boundary, I make use of the active contour method. I set the edge angle as the internal energy and the mean value curvature as the external energy.  However, it looks the method do not work properly.

ISO line construction highly depend on the correctness of the optimized boundary. So, I decide to wait until I solve the first two problems.

Thinking about programming in C++

January 14th, 2009

Programming Design:

  • gain a clear understanding of the problem (analysis)
  • identify the key concepts involved in a solution (design)
  • express solution in programming

The key to writing good programs is to design classes sothat each cleanly represents a single concept. often this means that you must focus on questions such as: How are objects of this class created? can objects of this class be copied and/or destroyed? what operations can be applied to such objects?

Research Activities

October 15th, 2008

When I am thinking about the research activities, there are several aspects that I never think carefully. Due to this reason, I made very slow progress on work. From now on, I keep recording all my thinking everyday to make sure that I am alway on the correct direction.

First, set up clear objective. Here the objective does not only indicate what you want to do, but also includes all the features which make your work different from the other’s work. In this case, keep in mind your selling points when thinking solutions on your work.

Second, when read relevant papers, always keep in mind the following four aspects: 1. What is their method? 2. How it works? 3. What is the advantages of their method when compared with your objectives? 4. What is the disadvantages of their method when compared with your objectives?

Last, do not keep focusing on a single issue, try to expand all related issues which are also important to achieve the final objective.

Summary of today

May 6th, 2008

First, I achieved the middle point computation. Today, I improved the pickObject method to select desired region of objects. also, I increased the layer distinguishing function in getAllSelectedNames().

Things to be done tomorrow:

1. convert middle point to bone

2. set up connection relationship with bone point and their neighbors

3. improve the middle point computation — current method still has some drawback on the use of perpendicular plane cutting.

By the way, new issue been remind by Bor, the consideration of possible disconnect two lines should be represented as one line. thus, further refers to shape verification on bone implement plane.

OpenGL: PickObject

May 6th, 2008

做implementation,用到了OpenGL里面的pickObject method。 以前是照葫芦画瓢,不求甚解。现在因为project的需要,今天花了俩小时,终于整明白了。我发现NEHE的tutorial真的是好东西啊。

首先是viewport的使用:

// The Size Of The Viewport. [0] Is <x>, [1] Is <y>, [2] Is <length>, [3] Is <width>
GLint	viewport[4];
// This Sets The Array <viewport> To The Size And Location Of The Screen Relative To The Window
glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(512, buffer);// Tell OpenGL To Use Our Array For Selection
一直不清楚中心点定义后是在哪里使用的,现在终于明白了。
// Puts OpenGL In Selection Mode. Nothing Will Be Drawn.
//Object ID’s and Extents Are Stored In The Buffer.
(void) glRenderMode(GL_SELECT);
glInitNames();// Initializes The Name Stack
glPushName(0);// Push 0 (At Least One Entry) Onto The Stack

glMatrixMode(GL_PROJECTION);// Selects The Projection Matrix
glPushMatrix();	// Push The Projection Matrix
glLoadIdentity();// Resets The Matrix
// This Creates A Matrix That Will Zoom Up To A Small Portion Of The Screen, Where The Mouse Is.
gluPickMatrix((GLdouble) mouse_x, (GLdouble) (viewport[3]-mouse_y), 1.0f, 1.0f, viewport);
这里面 gluPickMatrix(x, y, width, length, viewport).但是上面的代码还是有些不了解。
为什么 上面的参数可以实现zoom的功能呢?需要先记下来再说。

Visual studio: unknown scope 问题

May 6th, 2008

今天写代码的时候遇到了 unknown scope的问题, 由google 得到一下解决办法:

It appears to be a problem with the “VC++ Intellisense Database”
1) Exit the IDE
2) Delete (or rename if paranoid) the file {solution name}.ncb
3) Open IDE
4) Rebuild project — the “VC++ Intellisense Database” will be recreated.

记录下来。

C++ tips

May 6th, 2008

今天我了解到一个以前忽视的问题。 c++中参数初始化和赋值的区别。

一下内容摘自无域暖流的技术博客:http://www.cublog.cn/u/21790/showart_323092.html

C++初始化类的成员,不但可以用构造函数(constructor)完成,而且可以用初始化类成员列表来完成。MFC大量用到此方法。例如有些初学者可能不大理解如下代码:
class A
{
public:
int member_var; //成员变量
A();            //构造函数
}
A::A():member_var(0)
{
}
他们觉得这个构造函数的定义应该只能这样写:
A::A()
{
member_var=1;
}
其实两种方法都可。但是有些情况下,只能用第一种,而且通常情况下用第一种也会效率高些。
其实,第一种方法是真正的初始化(initialization),而在构造函数内实现的“=”操作其实是赋值(assign)。这两种方法的一切区别从这儿开始。区别大概如下:
  1. 我们知道普通变量编译器都会默认的替你初始化。他们既能初始化,也能被赋值的,而常量(const)按照其意思只能被初始化,不能赋值。否则与变量就无区别了。所以常量成员(const member)只能用成员初始化列表来完成他们的“初始化”,而不能在构造函数内为他们“赋值”。
  2. 我们知道类的对象的初始化其实就是调用他的构造函数完成,如果没有写构造函数,编译器会为你默认生成一个。如果你自定义了带参数的构造 函数,那么编译器将不生成默认构造函数。这样这个类的对象的初始化必须有参数。如果这样的类的对象来做另外某个类的成员,那么为了初始化这个成员,你必须 为这个类的对象的构造函数传递一个参数。同样,如果你在包含它的这个类的构造函数里用“=”,其实是为这个对象“赋值”而非“初始化”它。所以一个类里的所有构造函数都是有参数的,那么这样的类如果做为别的类的成员变量,你必须显式的初始化它,你也是只能通过成员初始化列表来完成初始化。例如:

class B
{
……
}

class A
{
public:
B member_b;
A();
}
A::A():B(…) //你必须显式初始化它,因为他的所有构造函数
//都是有参数的,之后才能被赋值。
{
B=…; //因为如上所写,已经初始化了,才能被赋值,否则错误。
}

——————————————————————————————————————

初始化顺序:

class test

{

const int a;

std:string str;

object o;

test():str(“df”),o(null),a(0)

{

}

};

黄色的既是初始化列表,他们会在构造函数正式调用前被调用,且他们的初始化顺序并不是根据 初始化列表中出现的顺序,而是他们声明的顺序来初始化。如上:

初始化顺序是:a, str, o;

一般用于初始化 常量类型,静态类型的数据,或者不能独立存在的数据

Work Summary

May 5th, 2008

Today, I roughly achieved the aim to compute the middle point of the mesh. In order to reuse exist code, I rewrite the definition of  Line, change it from struct to class, and combined with two point definition.

Towards the projection part, I get the middle point through the following method:

  • make use of existing method on line drawing, since we get the line, then we get the normal that perpendicular to the two point. then we can get a ring and finally compute the middle point of the two rings. currently, the problem here is, I use the difference between two points to set the normal, however, I should just use X, Y, coordinate information, in order to get real perpendicular plane.
  • rewrite pickObject method to get all the triangles name from given point(x, y) with predefined window size x_window and y_window. there is a problem when I test my method, I cannot get vertices by using the given side windows as well as the predefined point.

So, tomorrow, two tasks should be performed first: change the normal of the plane and verify the problem in pickObject method.

According to the time table, I should finish the whole projection within 5-7 days. Tomorrow, I will verify the projection work based on giving different colors to the selected vertices.

Today’s work summary

May 4th, 2008

Since I give plan on mesh deformation platform implementation. I should carry on my plan for everyday, and make some summary on one day’s work.

Today, I finish my interface design procedure. In this step, I plan to give description to the user on how to use the platform. I optimized the new items on MView and GLMesh. In MView, I create four action: drawBone, selectBones, combineBones, and undoDraw. At the same time, in GLMesh, I also increased four corresponding functions to pass the action into the GLMesh part. Meantime, in GLMesh, I increased four action types to retrieve the signal from MView part.

MView:

1.         drawBoneAct       —– drawBone(bool state)

2.         selectBonesAct     —–  selectBones(bool state)

3.         combineBonesAct —– combineBones(bool state)

4.         undoDrawAct    —-    undoDraw(bool  state);

GLMesh:

1.                  setDraw(bool state) —– DRAW_BONE action.

2.                  setSelectBones(bool state) — SELECT_BONES action

3.                  setCombineBones(bool state) —- COMBINE_BONES action

4.                  setUndo(bool state) —- UNDO_DRAW action

Difference between Vector and List

May 4th, 2008

When doing implementation on my research work, I can not tell too much difference between Vector and List in C++, so I googled the answer from the internet. It seems easy to recognize the difference when you read the tips here.
Lists are double-linked lists, so insertion at either end, or in the middle (providing you know an existing element in the middle) is equally fast. Also, splicing is fast (eg. putting a list into the middle of another) - all that does is re-arrange the end pointers. All of those operations would be slower with vectors, because you would need to copy everything.

eg. Inserting into the middle of a vector of 1000 items would involve moving 500 items up one. Similarly with deleting. In fact, vectors are really only good for insertion and deletion at the end.

For things that require insertion and deletion, but only at *each* end (like a queue) then there is a dequeue (double-ended queue) which is really a collection of vectors. This is more efficient.

However, vectors shine in random access - since they are organised sequentially in memory, whilst this is slow for insertion at anywhere other than the end, you can easily find, say, element 500, you simply index into the vector. Thus, vectors can be sorted, shuffled, and accessed randomly.

When playing with STL - and these other MUD-related ideas - I am asking myself what is the need for each case - random access or fast insertion, and using the container appropriate to the case at hand.

For instance, in the event management code I will post shortly, as I remove events from the queue I am keeping a copy of the auto-repeat ones, for later re-insertion. Now the copy is a temporary copy, and I don’t need to access it in any special way, so I am using a simple vector. However the event queue itself is a priority queue (which I suspect is implemented as a map of queues).

Vectors are designed to auto-grow, with the size - I believe they double in size each time they grow. eg. 2, 4, 8, 16 and so on. So, if you keep adding to them the number of memory allocations is pretty small. However if you know in advance how much they need (even roughly) then you can tell the vector to reserve that amount in advance.