Fix of #281: Crash while importing - cvfPlane.cpp Aborted

This commit is contained in:
Jacob Støren 2015-02-24 13:34:03 +01:00
parent 3b914c7ac0
commit 27ce1852ca

View File

@ -336,7 +336,11 @@ cvf::ref<cvf::DrawableGeo> RivPipeGeometryGenerator::generateExtrudedCylinder(do
cvf::Vec3d intersectionPlaneNormal = candidateDir + nextDir; cvf::Vec3d intersectionPlaneNormal = candidateDir + nextDir;
// if (intersectionPlaneNormal.lengthSquared() < 1e-10) intersectionPlaneNormal = nextDir; // candidateDir == -nextDir => 180 deg turn if (intersectionPlaneNormal.lengthSquared() < 1e-10) // candidateDir == -nextDir => 180 deg turn
{
CVF_ASSERT(false); // This is never supposed to happen due to what's done in updateFilteredPipeCenterCoords(). So look there for the bug...
intersectionPlaneNormal = nextDir;
}
computeExtrudedCoordsAndNormals(secondCoord, intersectionPlaneNormal, candidateDir, crossSectionNodeCount, &extrudedNodes, &crossSectionVertices, &cylinderSegmentNormals); computeExtrudedCoordsAndNormals(secondCoord, intersectionPlaneNormal, candidateDir, crossSectionNodeCount, &extrudedNodes, &crossSectionVertices, &cylinderSegmentNormals);
} }
@ -521,11 +525,18 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords()
if (dotProduct > cosMinBendAngle) if (dotProduct > cosMinBendAngle)
{ {
bool success = false; bool success = false;
cvf::Vec3d pipeIntermediateDirection = (lastValidDirectionAB + directionBC.getNormalized()).getNormalized(&success);
if (!success) cvf::Vec3d pipeIntermediateDirection = (lastValidDirectionAB + directionBC.getNormalized());
pipeIntermediateDirection.getNormalized(&success);
if (pipeIntermediateDirection.lengthSquared() < squareDistanceTolerance)
{ {
pipeIntermediateDirection = lastValidDirectionAB.perpendicularVector(); pipeIntermediateDirection = lastValidDirectionAB.perpendicularVector();
} }
else
{
pipeIntermediateDirection.normalize();
}
double bendRadius = m_bendScalingFactor * m_radius + 1.0e-30; double bendRadius = m_bendScalingFactor * m_radius + 1.0e-30;
cvf::Vec3d firstIntermediate = coordB - pipeIntermediateDirection * bendRadius; cvf::Vec3d firstIntermediate = coordB - pipeIntermediateDirection * bendRadius;