// get cutting planes
std::vector< bool > isVectorOK( theSegments.size(), true );
+ const double planarCoef = 0.333; // plane height in planar case
for ( size_t iSeg = 0; iSeg < theSegments.size(); ++iSeg )
{
if ( polySeg.myMidProjPoint.Distance( pMid ) < Precision::Confusion() )
{
SMESH_MeshAlgos::FaceNormal( face, const_cast< gp_XYZ& >( polySeg.myVector.XYZ() ));
- polySeg.myMidProjPoint = pMid + polySeg.myVector.XYZ();
+ polySeg.myMidProjPoint = pMid + polySeg.myVector.XYZ() * ( p1 - p2 ).Modulus() * planarCoef;
}
+ else
+ {
+ polySeg.myVector = polySeg.myMidProjPoint.XYZ() - pMid;
+ }
+ }
+ else
+ {
+ polySeg.myVector = plnNorm ^ ( p1 - p2 );
}
}
// return a vector
+ gp_XYZ pMid = 0.5 * ( path.myPoints[0] + path.myPoints.back() );
if ( isVectorOK[ iSeg ])
{
// find the most distance point of a path
double maxDist = 0;
for ( size_t iP = 1; iP < path.myPoints.size(); ++iP )
{
- double dist = theSegments[iSeg].myVector * ( path.myPoints[iP] - path.myPoints[0] );
+ double dist = Abs( theSegments[iSeg].myVector * ( path.myPoints[iP] - path.myPoints[0] ));
if ( dist > maxDist )
{
maxDist = dist;
theSegments[iSeg].myMidProjPoint = path.myPoints[iP];
}
}
+ if ( maxDist < Precision::Confusion() ) // planar case
+ theSegments[iSeg].myMidProjPoint =
+ pMid + theSegments[iSeg].myVector.XYZ().Normalized() * path.myLength * planarCoef;
}
- gp_XYZ pMid = 0.5 * ( path.myPoints[0] + path.myPoints.back() );
theSegments[iSeg].myVector = gp_Vec( pMid, theSegments[iSeg].myMidProjPoint );
}