0
我目前正在使用CGAL進行樹生成應用,這是我第一次。CGAL Lib拉伸多邊形
這將是最容易和/或最好的方式做面部擠壓?新點的計算已經完成。
CGAL是一個巨大的庫,所以可能有更好更強大的方法。
請看看當前代碼(考慮註釋):
void TreeGenerator::extrude(Face_handle face, float value)
{
CGAL_precondition(m_mesh.is_valid());
//calculate face normal vector direction
Halfedge_handle halfEdge1 = face->halfedge();
Halfedge_handle halfEdge2 = halfEdge1->next();
Halfedge_handle halfEdge3 = halfEdge2->next();
Halfedge_handle halfEdge4 = halfEdge3->next();
//vectors from v1 to v2 and from v2 to v3 -> vectors lying on the face
Vector3 v1(halfEdge1->vertex()->point(), halfEdge2->vertex()->point());
Vector3 v2(halfEdge2->vertex()->point(), halfEdge3->vertex()->point());
Vector3 normal_vector = cross_product(v1, v2);
//HINT: This can be cpu time consuming -> can we remove the sqrt() ?
normal_vector = (normal_vector/sqrt(normal_vector.squared_length())) * value;
std::cout << "Normal Vector: " << normal_vector << std::endl;
Point point1 = halfEdge1->vertex()->point() + normal_vector;
Point point2 = halfEdge2->vertex()->point() + normal_vector;
Point point3 = halfEdge3->vertex()->point() + normal_vector;
Point point4 = halfEdge4->vertex()->point() + normal_vector;
std::cout << "Point1: " << point1 << std::endl;
std::cout << "Point2: " << point2 << std::endl;
std::cout << "Point3: " << point3 << std::endl;
std::cout << "Point4: " << point4 << std::endl;
//test space -> try to use a Polyhedron_incremnt_builder_3
//http://doc.cgal.org/latest/Polyhedron/classCGAL_1_1Polyhedron__incremental__builder__3.html
//I want to do the extrude code here but what would be the best way?
CGAL_postcondition(m_mesh.is_valid());
}
這將是真棒如果有人能指點正確的方法或者給我一個想法。
THX和再見 達裏安