Skip to content

Commit

Permalink
Fix of #281: Crash while importing - cvfPlane.cpp Aborted
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobStoren committed Feb 24, 2015
1 parent 3b914c7 commit 27ce185
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,11 @@ cvf::ref<cvf::DrawableGeo> RivPipeGeometryGenerator::generateExtrudedCylinder(do

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);
}
Expand Down Expand Up @@ -521,11 +525,18 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords()
if (dotProduct > cosMinBendAngle)
{
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();
}
else
{
pipeIntermediateDirection.normalize();
}

double bendRadius = m_bendScalingFactor * m_radius + 1.0e-30;
cvf::Vec3d firstIntermediate = coordB - pipeIntermediateDirection * bendRadius;
Expand Down

0 comments on commit 27ce185

Please sign in to comment.