Fix for a crash in silhouette edge detection. The problem was

reported by macouno.  Thanks!

The crash was caused by a lack of curvature information required
for smooth edges.  Now the curvature information is computed if and
only if there are smooth edges.  This leads to a minor performance
improvement, because in the past the curvature information was
always computed when the Face Smoothness was enabled.

(To be precise, the above description is true when both the Ridges
and Valleys and Suggestive Contours options are disabled.  If they
are enabled, the curvature information is always computed because
it is necessary for the determination of these edge natures.)
This commit is contained in:
Tamito Kajiyama
2011-04-12 22:17:15 +00:00
parent 3df52d4e19
commit 4ee5dcf7ab

View File

@@ -114,7 +114,7 @@ void FEdgeXDetector::preProcessShape(WXShape* iWShape) {
preProcessFace((WXFace*)(*f));
}
if(_faceSmoothness || _computeRidgesAndValleys || _computeSuggestiveContours ) {
if(_computeRidgesAndValleys || _computeSuggestiveContours ) {
vector<WVertex*>& wvertices = iWShape->getVertexList();
for(vector<WVertex*>::iterator wv=wvertices.begin(), wvend=wvertices.end();
wv!=wvend;
@@ -711,6 +711,8 @@ void FEdgeXDetector::ProcessMaterialBoundaryEdge(WXEdge *iEdge)
// Build Smooth edges
/////////////////////
void FEdgeXDetector::buildSmoothEdges(WXShape* iShape){
bool hasSmoothEdges = false;
// Make a last pass to build smooth edges from the previous stored values:
//--------------------------------------------------------------------------
vector<WFace*>& wfaces = iShape->GetFaceList();
@@ -722,7 +724,21 @@ void FEdgeXDetector::buildSmoothEdges(WXShape* iShape){
for(vector<WXFaceLayer*>::iterator wxfl = faceLayers.begin(), wxflend=faceLayers.end();
wxfl!=wxflend;
++wxfl){
(*wxfl)->BuildSmoothEdge();
if ((*wxfl)->BuildSmoothEdge())
hasSmoothEdges = true;
}
}
if (hasSmoothEdges && !_computeRidgesAndValleys && !_computeSuggestiveContours) {
vector<WVertex*>& wvertices = iShape->getVertexList();
for(vector<WVertex*>::iterator wv=wvertices.begin(), wvend=wvertices.end();
wv!=wvend;
++wv){
// Compute curvatures
WXVertex * wxv = dynamic_cast<WXVertex*>(*wv);
computeCurvatures(wxv);
}
_meanK1 /= (real)(_nPoints);
_meanKr /= (real)(_nPoints);
}
}