Adjusted according to review comments.

This commit is contained in:
Ruben Thoms 2020-09-30 10:47:46 +02:00 committed by Magne Sjaastad
parent ef4894985a
commit b6cca51593
4 changed files with 25 additions and 24 deletions

View File

@ -426,18 +426,17 @@ std::array<cvf::Vec3f, 7>
shaftStart = evrViz.faceCenter - evrViz.faceNormal / 2.0;
}
// Flip arrow for negative results
// Flip arrow for negative results and if the vector is not aggregated (in which case we do not have any negative
// result)
if ( evrViz.result < 0 && result->vectorView() != RimElementVectorResult::VectorView::AGGREGATED )
{
std::swap( headTop, shaftStart );
}
// float headWidth = 0.05 * evrViz.faceNormal.length();
float headLength = std::min<float>( evrViz.characteristicCellSize / 5.0f, ( headTop - shaftStart ).length() / 2.0 );
float headLength = std::min<float>( evrViz.approximateCellLength / 5.0f, ( headTop - shaftStart ).length() / 2.0 );
// A fixed size is preferred here
cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ).getNormalized() * headLength;
// cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ) * 0.2f;
cvf::Vec3f headBottomDirection1 = evrViz.faceNormal ^ evrViz.faceCenter;
cvf::Vec3f headBottomDirection2 = headBottomDirection1 ^ evrViz.faceNormal;
@ -490,6 +489,10 @@ std::array<uint, 6> RivElementVectorResultPartMgr::createArrowHeadIndices( uint
//--------------------------------------------------------------------------------------------------
double RivElementVectorResultPartMgr::scaleLogarithmically( double value ) const
{
// If values are smaller than one, the logarithm would return
// increasing negative values the smaller the number is. However, small
// numbers shall remain small and not be scaled up. In order to achieve this,
// add 1.0 to small values in order to still obtain small positive numbers after scaling.
if ( value <= 1.0 )
{
value += 1.0;

View File

@ -54,18 +54,18 @@ public:
private:
struct ElementVectorResultVisualization
{
ElementVectorResultVisualization( cvf::Vec3d faceCenter, cvf::Vec3d faceNormal, double result, double characteristicCellSize )
ElementVectorResultVisualization( cvf::Vec3d faceCenter, cvf::Vec3d faceNormal, double result, double approximateCellLength )
: faceCenter( faceCenter )
, faceNormal( faceNormal )
, result( result )
, characteristicCellSize( characteristicCellSize )
, approximateCellLength( approximateCellLength )
{
}
cvf::Vec3f faceCenter;
cvf::Vec3f faceNormal;
double result;
double characteristicCellSize;
double approximateCellLength;
};
private:

View File

@ -277,44 +277,44 @@ void RimElementVectorResult::mappingRange( double& min, double& max ) const
directions = 0;
std::vector<cvf::Vec3d> unitVectors;
for ( size_t fluidIndex = 0; fluidIndex < resVarAddresses.size(); fluidIndex += 3 )
// resVarAddresses contains three directions per fluid, check which of them shall be used.
for ( size_t fluidDirIndex = 0; fluidDirIndex < resVarAddresses.size(); fluidDirIndex += 3 )
{
if ( showVectorI() )
{
if ( fluidIndex == 0 )
// Only increment directions and add to unit vectors once per direction (not per direction for each fluid).
if ( fluidDirIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 1, 0, 0 ) );
unitVectors.push_back( cvf::Vec3d::X_AXIS );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 0 + fluidIndex ) );
cleanedResVarAddresses.push_back( resVarAddresses.at( 0 + fluidDirIndex ) );
}
if ( showVectorJ() )
{
if ( fluidIndex == 0 )
if ( fluidDirIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 0, 1, 0 ) );
unitVectors.push_back( cvf::Vec3d::Y_AXIS );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 1 + fluidIndex ) );
cleanedResVarAddresses.push_back( resVarAddresses.at( 1 + fluidDirIndex ) );
}
if ( showVectorK() )
{
if ( fluidIndex == 0 )
if ( fluidDirIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 0, 0, 1 ) );
unitVectors.push_back( cvf::Vec3d::Z_AXIS );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 2 + fluidIndex ) );
cleanedResVarAddresses.push_back( resVarAddresses.at( 2 + fluidDirIndex ) );
}
}
resVarAddresses = cleanedResVarAddresses;
if ( directions > 0 )
{
std::vector<double> directionsMax;
directionsMax.resize( directions, 0.0 );
std::vector<double> directionsMin;
directionsMin.resize( directions, 0.0 );
std::vector<double> directionsMax( directions, 0.0 );
std::vector<double> directionsMin( directions, 0.0 );
for ( size_t index = 0; index < resVarAddresses.size(); index += directions )
{

View File

@ -31,9 +31,7 @@ Vec3Type GeometryTools::computePolygonCenter( const std::vector<Vec3Type>& polyg
for ( size_t i = 0; i < polygon.size(); i++ )
{
s.x() += polygon[i].x();
s.y() += polygon[i].y();
s.z() += polygon[i].z();
s += polygon[i];
}
s /= polygon.size();
return s;