Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Extrude Facet

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Extrude Facet


Chronological Thread 
  • From: Darian <>
  • To:
  • Subject: Re: [cgal-discuss] Extrude Facet
  • Date: Wed, 2 Mar 2016 06:17:24 -0800 (PST)
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=SoftFail ; spf=None
  • Ironport-phdr: 9a23:cNxVzhUDrPmgVUEdJr9eNIF9tr7V8LGtZVwlr6E/grcLSJyIuqrYZhCHt8tkgFKBZ4jH8fUM07OQ6PC/HzNaqsjc+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq8KVPF8D2mf1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu2pN5g/GLdXBTBjP2Eu79DwrjHCSxGO7z0SSDY4iB1NViTM9hDzWN+lviL8t+d5niCcIcn3S785Qxyt6q5qTFnjjyJRZG1xy33elsEl1PETmxmmvREqm4M=

Hello,

is there a nice solution already? I tried to get the 8 vertices and split
new vertices in between. But sometimes its not working.

And I actually don't understand the extrude Code in the git you posted (I
know its a old discussion :-))

Would be nice if you have better solutions?

My current code:

void extrude(Face_handle face, float value)
{
CGAL_precondition( m_mesh.is_valid());

Halfedge_handle startEdge = face->halfedge();

//get the 4 edges_top
Halfedge_handle e1_top = startEdge->next()->next()->next();
Halfedge_handle e2_top = startEdge;
Halfedge_handle e3_top = startEdge->next();
Halfedge_handle e4_top = startEdge->next()->next();

//get the 4 edges_bottom
Halfedge_handle e1_bottom = startEdge->opposite()->next();
Halfedge_handle e2_bottom = startEdge->next()->opposite()->next();
Halfedge_handle e3_bottom =
startEdge->next()->next()->opposite()->next();
Halfedge_handle e4_bottom =
startEdge->next()->next()->next()->opposite()->next();

Halfedge_handle e1_new = m_mesh.split_edge(e1_bottom);
Halfedge_handle e2_new = m_mesh.split_edge(e2_bottom);
Halfedge_handle e3_new = m_mesh.split_edge(e3_bottom);
Halfedge_handle e4_new = m_mesh.split_edge(e4_bottom);

//direction vector from bottom to the high
Vector3 dir1 = (e1_top->vertex()->point() -
e1_bottom->vertex()->point());
Vector3 dir2 = (e2_top->vertex()->point() -
e2_bottom->vertex()->point());
Vector3 dir3 = (e3_top->vertex()->point() -
e3_bottom->vertex()->point());
Vector3 dir4 = (e4_top->vertex()->point() -
e4_bottom->vertex()->point());

dir1 = (dir1 / sqrt(dir1.squared_length())) * value;
dir2 = (dir2 / sqrt(dir2.squared_length())) * value;
dir3 = (dir3 / sqrt(dir3.squared_length())) * value;
dir4 = (dir4 / sqrt(dir4.squared_length())) * value;

//calculate new positions for the new generated points
Point point1 = Point(e1_top->vertex()->point()[0] + dir1[0],
e1_top->vertex()->point()[1] + dir1[1], e1_top->vertex()->point()[2] +
dir1[2]);
Point point2 = Point(e2_top->vertex()->point()[0] + dir2[0],
e2_top->vertex()->point()[1] + dir2[1], e2_top->vertex()->point()[2] +
dir2[2]);
Point point3 = Point(e3_top->vertex()->point()[0] + dir3[0],
e3_top->vertex()->point()[1] + dir3[1], e3_top->vertex()->point()[2] +
dir3[2]);
Point point4 = Point(e4_top->vertex()->point()[0] + dir4[0],
e4_top->vertex()->point()[1] + dir4[1], e4_top->vertex()->point()[2] +
dir4[2]);


//set positions for the new generated points
e1_new->vertex()->point() = e1_top->vertex()->point();
e2_new->vertex()->point() = e2_top->vertex()->point();
e3_new->vertex()->point() = e3_top->vertex()->point();
e4_new->vertex()->point() = e4_top->vertex()->point();

e1_top->vertex()->point() = point1;
e2_top->vertex()->point() = point2;
e3_top->vertex()->point() = point3;
e4_top->vertex()->point() = point4;

m_mesh.split_facet(e1_new, e2_bottom->opposite());
m_mesh.split_facet(e2_new, e3_bottom->opposite());
m_mesh.split_facet(e3_new, e4_bottom->opposite());
m_mesh.split_facet(e4_new, e1_bottom->opposite());

CGAL_postcondition( m_mesh.is_valid());
}

thx and bye
Darian



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Extrude-Facet-tp2276104p4661660.html
Sent from the cgal-discuss mailing list archive at Nabble.com.


  • Re: [cgal-discuss] Extrude Facet, Darian, 03/02/2016

Archive powered by MHonArc 2.6.18.

Top of Page