Commit 8743a7b0 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX #53] moved marching cubes algorithm out of GE into common

parent b7be281a
......@@ -27,11 +27,12 @@
#include <vector>
#include <map>
#include "../../common/math/WMatrix.h"
#include "../../common/WProgressCombiner.h"
#include "../WTriangleMesh.h"
#include "marchingCubesCaseTables.h"
#include "../math/WMatrix.h"
#include "../WProgressCombiner.h"
#include "core/graphicsEngine/WTriangleMesh.h"
#include "WMarchingCubesCaseTables.h"
/**
* A point consisting of its coordinates and ID
......
......@@ -22,4 +22,4 @@
//
//---------------------------------------------------------------------------
#include "marchingCubesCaseTables.h"
#include "WMarchingCubesCaseTables.h"
This diff is collapsed.
......@@ -28,10 +28,10 @@
#include <vector>
#include <map>
#include "../../common/math/WMatrix.h"
#include "../../common/WProgressCombiner.h"
#include "../WTriangleMesh.h"
#include "../math/WMatrix.h"
#include "../WProgressCombiner.h"
#include "core/graphicsEngine/WTriangleMesh.h"
/**
* A point consisting of its coordinates and ID
......
......@@ -31,7 +31,7 @@
#include <osg/LightModel>
#include <osg/Geometry>
#include "algorithms/WMarchingLegoAlgorithm.h"
#include "core/common/algorithms/WMarchingLegoAlgorithm.h"
#include "callbacks/WGEFunctorCallback.h"
#include "WGraphicsEngine.h"
......
......@@ -197,23 +197,27 @@ vec4 blueLightBlueColorMap( in float value )
vec4 negative2positive( in float value )
{
float val = value * 2.0 - 1.0;
vec4 zeroColor = vec4( 1.0, 1.0, 1.0, 1.0 );
vec4 negColor = vec4( 1.0, 1.0, 0.0, 1.0 );
vec4 posColor= vec4( 0.0, 1.0, 1.0, 1.0 );
if( val < 0.0 )
{
return ( zeroColor + negColor * val );
}
else if( val >= 0.0 )
{
return ( zeroColor - posColor * val );
}
else
{
return vec4( 0.0, 0.0, 0.0, 1.0 );
}
float valueDescaled = value;
float minV = 0.0;
float scaleV = 1.0;
const vec3 zeroColor = vec3( 1.0, 1.0, 1.0 );
const vec3 negColor = vec3( 1.0, 1.0, 0.0 );
const vec3 posColor= vec3( 0.0, 1.0, 1.0 );
// the descaled value can be in interval [minV,minV+Scale]. But as we want linear scaling where the pos and neg colors are scaled linearly
// agains each other, and we want to handle real negative values correctly. For only positive values, use their interval mid-point.
float isNegative = 1.0 - ( -1.0 * clamp( sign( minV ), -1.0, 0.0 ) ); // this is 1.0 if minV is smaller than zero
float mid = ( 1.0 - isNegative ) * 0.5 * scaleV; // if negative, the mid point always is 0.0
// the width of the interval is its original width/2 if there are no negative values in the dataset
float width = ( isNegative * max( abs( minV ), abs( minV + scaleV ) ) ) + ( ( 1.0 - isNegative ) * mid );
// pos-neg mix factor
float share = ( valueDescaled - mid ) / width;
// use neg color for shares < 0.0 and pos color for the others
return vec4( zeroColor - ( abs( clamp( share, -1.0 , 0.0 ) * negColor ) + ( clamp( share, 0.0 , 1.0 ) * posColor ) ),
1.0 ); // clip zeros is done in colormapping function
}
// TODO(math): Remove this function and replace its calls with bitwise operations as soon as there
......
......@@ -45,8 +45,6 @@
#include "core/dataHandler/WSubject.h"
#include "core/kernel/WKernel.h"
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
#include "WSphericalHarmonicsCoefficientsThread.h"
#include "WMHARDIToSphericalHarmonics.h"
......
......@@ -35,7 +35,7 @@
#include "core/common/WAssert.h"
#include "core/dataHandler/WDataSetScalar.h"
#include "core/graphicsEngine/algorithms/WMarchingLegoAlgorithm.h"
#include "core/common/algorithms/WMarchingLegoAlgorithm.h"
#include "core/graphicsEngine/WROIArbitrary.h"
#include "core/graphicsEngine/WROIBox.h"
#include "core/kernel/WKernel.h"
......
......@@ -33,7 +33,7 @@
#include "core/dataHandler/WDataSetScalar.h"
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
#include "core/common/algorithms/WMarchingCubesAlgorithm.h"
#include "core/graphicsEngine/WTriangleMesh.h"
......
......@@ -42,8 +42,8 @@
#include "core/common/WThreadedFunction.h"
#include "core/common/WStringUtils.h"
#include "core/dataHandler/WDataSetScalar.h"
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
#include "core/graphicsEngine/algorithms/WMarchingLegoAlgorithm.h"
#include "core/common/algorithms/WMarchingCubesAlgorithm.h"
#include "core/common/algorithms/WMarchingLegoAlgorithm.h"
#include "core/graphicsEngine/WGEGroupNode.h"
#include "core/graphicsEngine/WGEUtils.h"
#include "core/graphicsEngine/WROI.h"
......
......@@ -37,7 +37,7 @@
#include "core/common/WStringUtils.h"
#include "core/common/WPathHelper.h"
#include "core/common/WPropertyHelper.h"
#include "core/graphicsEngine/algorithms/WMarchingLegoAlgorithm.h"
#include "core/common/algorithms/WMarchingLegoAlgorithm.h"
#include "core/graphicsEngine/WGEColormapping.h"
#include "core/graphicsEngine/WGEUtils.h"
#include "core/kernel/WKernel.h"
......
......@@ -46,8 +46,8 @@
#include "core/common/WProgress.h"
#include "core/dataHandler/WDataHandler.h"
#include "core/dataHandler/WSubject.h"
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
#include "core/graphicsEngine/algorithms/WMarchingLegoAlgorithm.h"
#include "core/common/algorithms/WMarchingCubesAlgorithm.h"
#include "core/common/algorithms/WMarchingLegoAlgorithm.h"
#include "core/graphicsEngine/callbacks/WGEFunctorCallback.h"
#include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
......
......@@ -53,7 +53,6 @@
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
#include "core/kernel/WKernel.h"
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
#include "WSurface.h"
#include "WMSplineSurface.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment