mirror of
https://github.com/microsoft/UVAtlas
synced 2024-11-09 13:50:05 +00:00
Apply patches from cmesser (17391, 17392, 17393)
This commit is contained in:
parent
9b6bd3f91d
commit
2059bb99b8
@ -59,6 +59,12 @@ void CApproximateOneToAll::CutHeapTopData( EdgeWindow &EdgeWindowOut )
|
||||
double b0pie = pWindowLeft->b0 ;
|
||||
double D1 = pWindowRight->dPseuSrcToSrcDistance + SqrtMin0( SquredD2Dist(DVector2(b1pie, 0), pWindowRight->dv2Src) ) ;
|
||||
double D0 = pWindowLeft->dPseuSrcToSrcDistance + SqrtMin0( SquredD2Dist(DVector2(b0pie, 0), pWindowLeft->dv2Src) ) ;
|
||||
|
||||
if (fabs(D1 - D0) < DBL_EPSILON)
|
||||
{
|
||||
continue; // prevent divide-by-zero on very narrow windows
|
||||
}
|
||||
|
||||
double alpha = (b1pie - b0pie) / (D1 - D0) ;
|
||||
double beta = ( SQR(b0pie) - SQR(b1pie) - SQR(D0) + SQR(D1) ) / ( 2*(D1 - D0) ) ;
|
||||
double A = SQR( alpha ) - 1 ;
|
||||
|
@ -664,7 +664,18 @@ HRESULT CIsochartEngine::PartitionByGlobalAvgL2Stretch(
|
||||
CIsochartMesh::ConvertToExternalStretch(
|
||||
fCurrAvgL2SquaredStretch,
|
||||
IsIMTSpecified());
|
||||
|
||||
|
||||
// detect closed surfaces which have not been correctly partitioned.
|
||||
for (size_t i = 0; i < m_finalChartList.size(); ++i)
|
||||
{
|
||||
if (m_finalChartList[i]->GetVertexNumber() > 0
|
||||
&& !m_finalChartList[i]->HasBoundaryVertex())
|
||||
{
|
||||
DPF(0, "UVAtlas Internal error: Closed surface not correctly partitioned" );
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -141,10 +141,24 @@ void CIsochartMesh::Free()
|
||||
DestroyPakingInfoBuffer();
|
||||
DeleteChildren();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//////////////////////Class Public Methods //////////////////
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
// detect whether or not the mesh has boundary vertices
|
||||
bool CIsochartMesh::HasBoundaryVertex() const
|
||||
{
|
||||
for (size_t i = 0; i < m_dwVertNumber; ++i)
|
||||
{
|
||||
if (m_pVerts[i].bIsBoundary)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert external stretch to the internal stretches
|
||||
// See more details in [SSGH01] page 2-3:
|
||||
void CIsochartMesh:: ConvertToInternalCriterion(
|
||||
@ -3443,8 +3457,8 @@ HRESULT CIsochartMesh::CalculateDijkstraPathToVertex(
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
////////////////Calculatel Vertex Improtance methods/////////
|
||||
////////////////////////////////////////////////////////////
|
||||
////////////////Calculate Vertex Importance methods//////////
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// Using Progressive Mesh Algorithm to simplify current chart to get weight of importance
|
||||
|
@ -238,6 +238,7 @@ public:
|
||||
bool IsInitChart() const { return m_bIsInitChart; }
|
||||
bool IsOptimizedL2Stretch() const { return m_bOptimizedL2Stretch; }
|
||||
bool IsIMTSpecified() const { return m_baseInfo.pfIMTArray != 0; }
|
||||
bool HasBoundaryVertex() const;
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
//////////////Basic Data Member Access Methods///////////////
|
||||
|
@ -1169,7 +1169,20 @@ HRESULT CIsochartMesh::ApplyGraphCutByStretch(
|
||||
{
|
||||
CGraphcut graphCut;
|
||||
|
||||
std::unique_ptr<float[]> pfWorkSpace( new (std::nothrow) float[dwLandmarkNumber] );
|
||||
// It is possible for the children to have more landmark vertices than their parents.
|
||||
// This is due to vertices being cloned in CIsochartMesh::CleanNonmanifoldMesh function.
|
||||
// For this allocation simply use the max number of landmark vertices for the size.
|
||||
size_t workspaceSize = dwLandmarkNumber;
|
||||
for(size_t i = 0; i < m_children.size(); ++i)
|
||||
{
|
||||
size_t numChildLandmark = m_children[i]->m_landmarkVerts.size();
|
||||
if (workspaceSize < numChildLandmark)
|
||||
{
|
||||
workspaceSize = numChildLandmark;
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<float[]> pfWorkSpace( new (std::nothrow) float[workspaceSize] );
|
||||
std::unique_ptr<float[]> pfFacesStretchDiff( new (std::nothrow) float[m_dwFaceNumber] );
|
||||
std::unique_ptr<uint32_t []> pdwFaceGraphNodeID(new (std::nothrow) uint32_t[m_dwFaceNumber]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user