allow cancel operation for HACD (it takes minutes to complete, blocking modelers such as Maya when accidently pressed)
used in Dynamica maya plugin (http://dynamica.googlecode.com)
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
bool gCancelRequest=false;
|
||||||
namespace HACD
|
namespace HACD
|
||||||
{
|
{
|
||||||
double HACD::Concavity(ICHull & ch, std::map<long, DPoint> & distPoints)
|
double HACD::Concavity(ICHull & ch, std::map<long, DPoint> & distPoints)
|
||||||
@@ -192,6 +193,11 @@ namespace HACD
|
|||||||
memset(m_normals, 0, sizeof(Vec3<Real>) * m_nPoints);
|
memset(m_normals, 0, sizeof(Vec3<Real>) * m_nPoints);
|
||||||
for(unsigned long f = 0; f < m_nTriangles; f++)
|
for(unsigned long f = 0; f < m_nTriangles; f++)
|
||||||
{
|
{
|
||||||
|
if (m_callBack) (*m_callBack)("+ InitializeDualGraph\n", f, m_nTriangles, 0);
|
||||||
|
|
||||||
|
if (gCancelRequest)
|
||||||
|
return;
|
||||||
|
|
||||||
i = m_triangles[f].X();
|
i = m_triangles[f].X();
|
||||||
j = m_triangles[f].Y();
|
j = m_triangles[f].Y();
|
||||||
k = m_triangles[f].Z();
|
k = m_triangles[f].Z();
|
||||||
@@ -660,6 +666,8 @@ namespace HACD
|
|||||||
|
|
||||||
bool HACD::Compute(bool fullCH, bool exportDistPoints)
|
bool HACD::Compute(bool fullCH, bool exportDistPoints)
|
||||||
{
|
{
|
||||||
|
gCancelRequest = false;
|
||||||
|
|
||||||
if ( !m_points || !m_triangles || !m_nPoints || !m_nTriangles)
|
if ( !m_points || !m_triangles || !m_nPoints || !m_nTriangles)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -691,8 +699,14 @@ namespace HACD
|
|||||||
CreateGraph();
|
CreateGraph();
|
||||||
// Compute the surfaces and perimeters of all the faces
|
// Compute the surfaces and perimeters of all the faces
|
||||||
if (m_callBack) (*m_callBack)("+ Initializing Dual Graph\n", 0.0, 0.0, nV);
|
if (m_callBack) (*m_callBack)("+ Initializing Dual Graph\n", 0.0, 0.0, nV);
|
||||||
|
if (gCancelRequest)
|
||||||
|
return false;
|
||||||
|
|
||||||
InitializeDualGraph();
|
InitializeDualGraph();
|
||||||
if (m_callBack) (*m_callBack)("+ Initializing Priority Queue\n", 0.0, 0.0, nV);
|
if (m_callBack) (*m_callBack)("+ Initializing Priority Queue\n", 0.0, 0.0, nV);
|
||||||
|
if (gCancelRequest)
|
||||||
|
return false;
|
||||||
|
|
||||||
InitializePriorityQueue();
|
InitializePriorityQueue();
|
||||||
// we simplify the graph
|
// we simplify the graph
|
||||||
if (m_callBack) (*m_callBack)("+ Simplification ...\n", 0.0, 0.0, m_nTriangles);
|
if (m_callBack) (*m_callBack)("+ Simplification ...\n", 0.0, 0.0, m_nTriangles);
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace HACD
|
|||||||
{
|
{
|
||||||
return lhs.m_priority>rhs.m_priority;
|
return lhs.m_priority>rhs.m_priority;
|
||||||
}
|
}
|
||||||
typedef void (*CallBackFunction)(const char *, double, double, size_t);
|
typedef bool (*CallBackFunction)(const char *, double, double, size_t);
|
||||||
|
|
||||||
//! Provides an implementation of the Hierarchical Approximate Convex Decomposition (HACD) technique described in "A Simple and Efficient Approach for 3D Mesh Approximate Convex Decomposition" Game Programming Gems 8 - Chapter 2.8, p.202. A short version of the chapter was published in ICIP09 and is available at ftp://ftp.elet.polimi.it/users/Stefano.Tubaro/ICIP_USB_Proceedings_v2/pdfs/0003501.pdf
|
//! Provides an implementation of the Hierarchical Approximate Convex Decomposition (HACD) technique described in "A Simple and Efficient Approach for 3D Mesh Approximate Convex Decomposition" Game Programming Gems 8 - Chapter 2.8, p.202. A short version of the chapter was published in ICIP09 and is available at ftp://ftp.elet.polimi.it/users/Stefano.Tubaro/ICIP_USB_Proceedings_v2/pdfs/0003501.pdf
|
||||||
class HACD
|
class HACD
|
||||||
|
|||||||
Reference in New Issue
Block a user