Page MenuHomePhabricator

bug3198.diff

Authored By
xplanes
Jan 20 2010, 10:54 AM
Size
38 KB
Referenced Files
None
Subscribers
None

bug3198.diff

Index: Modules/MitkExt/Rendering/mitkUnstructuredGridVtkMapper3D.cpp
===================================================================
--- Modules/MitkExt/Rendering/mitkUnstructuredGridVtkMapper3D.cpp (revision 21081)
+++ Modules/MitkExt/Rendering/mitkUnstructuredGridVtkMapper3D.cpp (working copy)
@@ -208,10 +208,10 @@
if ( materialProperty->GetRenderer() == 0 || materialProperty->GetRenderer() == renderer )
{
property->SetColor( materialProperty->GetColor().GetDataPointer() );
- property->SetAmbientColor( materialProperty->GetColor().GetDataPointer() );
- property->SetAmbient( materialProperty->GetColorCoefficient() );
- property->SetDiffuseColor(materialProperty->GetColor().GetDataPointer() );
- property->SetDiffuse( materialProperty->GetColorCoefficient() );
+ property->SetAmbientColor( materialProperty->GetAmbientColor().GetDataPointer() );
+ property->SetAmbient( materialProperty->GetAmbientCoefficient() );
+ property->SetDiffuseColor(materialProperty->GetDiffuseColor().GetDataPointer() );
+ property->SetDiffuse( materialProperty->GetDiffuseCoefficient() );
property->SetSpecularColor( materialProperty->GetSpecularColor().GetDataPointer() );
property->SetSpecular( materialProperty->GetSpecularCoefficient() );
property->SetSpecularPower( materialProperty->GetSpecularPower() );
Index: Core/Code/DataManagement/mitkVtkRepresentationProperty.cpp
===================================================================
--- Core/Code/DataManagement/mitkVtkRepresentationProperty.cpp (revision 21081)
+++ Core/Code/DataManagement/mitkVtkRepresentationProperty.cpp (working copy)
@@ -22,7 +22,7 @@
mitk::VtkRepresentationProperty::VtkRepresentationProperty( )
{
AddRepresentationTypes();
- SetValue( static_cast<IdType>( VTK_SURFACE ) );
+ SetValue( SURFACE );
}
@@ -35,7 +35,7 @@
}
else
{
- SetValue( static_cast<IdType>( VTK_SURFACE ) );
+ SetValue( SURFACE );
}
}
@@ -49,7 +49,7 @@
}
else
{
- SetValue( static_cast<IdType>( VTK_SURFACE ) );
+ SetValue( SURFACE );
}
}
@@ -62,26 +62,33 @@
void mitk::VtkRepresentationProperty::SetRepresentationToPoints()
{
- SetValue( static_cast<IdType>( VTK_POINTS ) );
+ SetValue( POINTS );
}
void mitk::VtkRepresentationProperty::SetRepresentationToWireframe()
{
- SetValue( static_cast<IdType>( VTK_WIREFRAME ) );
+ SetValue( WIREFRAME );
}
void mitk::VtkRepresentationProperty::SetRepresentationToSurface()
{
- SetValue( static_cast<IdType>( VTK_SURFACE ) );
+ SetValue( SURFACE );
+}
+
+
+void mitk::VtkRepresentationProperty::SetRepresentationToWireframeSurface()
+{
+ SetValue( WIRESURF );
}
void mitk::VtkRepresentationProperty::AddRepresentationTypes()
{
- AddEnum( "Points", static_cast<IdType>( VTK_POINTS ) );
- AddEnum( "Wireframe", static_cast<IdType>( VTK_WIREFRAME ) );
- AddEnum( "Surface", static_cast<IdType>( VTK_SURFACE ) );
+ AddEnum( "Points", POINTS );
+ AddEnum( "Wireframe",WIREFRAME );
+ AddEnum( "Surface", SURFACE );
+ AddEnum( "WireframeSurface", WIRESURF );
}
Index: Core/Code/DataManagement/mitkVtkRepresentationProperty.h
===================================================================
--- Core/Code/DataManagement/mitkVtkRepresentationProperty.h (revision 21081)
+++ Core/Code/DataManagement/mitkVtkRepresentationProperty.h (working copy)
@@ -33,6 +33,8 @@
{
public:
+ enum RepresentationType {POINTS = 0, WIREFRAME = 1, SURFACE = 2, WIRESURF = 3};
+
mitkClassMacro( VtkRepresentationProperty, EnumerationProperty );
itkNewMacro(VtkRepresentationProperty);
@@ -61,6 +63,11 @@
* Sets the representation type to VTK_SURFACE.
*/
virtual void SetRepresentationToSurface();
+
+ /**
+ * Sets the representation type to WIRESURF.
+ */
+ virtual void SetRepresentationToWireframeSurface();
protected:
Index: Core/Code/IO/mitkMaterialProperty.cpp
===================================================================
--- Core/Code/IO/mitkMaterialProperty.cpp (revision 21081)
+++ Core/Code/IO/mitkMaterialProperty.cpp (working copy)
@@ -30,7 +30,8 @@
SetDataTreeNode( node );
SetRenderer( renderer );
SetColor( color );
- SetColorCoefficient( GetColorCoefficient() );
+ SetAmbientCoefficient( GetAmbientCoefficient() );
+ SetDiffuseCoefficient( GetDiffuseCoefficient() );
SetSpecularColor( GetSpecularColor() );
SetSpecularCoefficient( GetSpecularCoefficient() );
SetSpecularPower( GetSpecularPower() );
@@ -38,6 +39,7 @@
SetInterpolation( GetInterpolation() );
SetRepresentation( GetRepresentation() );
SetLineWidth( GetLineWidth() );
+ SetPointSize( GetPointSize() );
m_Name = "";
}
@@ -49,7 +51,8 @@
SetDataTreeNode( node );
SetRenderer( renderer );
SetColor( red, green, blue );
- SetColorCoefficient( GetColorCoefficient() );
+ SetAmbientCoefficient( GetAmbientCoefficient() );
+ SetDiffuseCoefficient( GetDiffuseCoefficient() );
SetSpecularColor( GetSpecularColor() );
SetSpecularCoefficient( GetSpecularCoefficient() );
SetSpecularPower( GetSpecularPower() );
@@ -57,6 +60,7 @@
SetInterpolation( GetInterpolation() );
SetRepresentation( GetRepresentation() );
SetLineWidth( GetLineWidth() );
+ SetPointSize( GetPointSize() );
m_Name = "";
}
@@ -70,7 +74,8 @@
SetDataTreeNode( node );
SetRenderer( renderer );
SetColor( red, green, blue );
- SetColorCoefficient( colorCoefficient );
+ SetAmbientCoefficient( colorCoefficient );
+ SetDiffuseCoefficient( colorCoefficient );
SetSpecularColor( GetSpecularColor() );
SetSpecularCoefficient( specularCoefficient );
SetSpecularPower( specularPower );
@@ -78,6 +83,7 @@
SetInterpolation( GetInterpolation() );
SetRepresentation( GetRepresentation() );
SetLineWidth( GetLineWidth() );
+ SetPointSize( GetPointSize() );
m_Name = "";
}
@@ -88,7 +94,8 @@
SetDataTreeNode( node );
SetRenderer( renderer );
SetColor( color );
- SetColorCoefficient( colorCoefficient );
+ SetAmbientCoefficient( colorCoefficient );
+ SetDiffuseCoefficient( colorCoefficient );
SetSpecularColor( GetSpecularColor() );
SetSpecularCoefficient( specularCoefficient );
SetSpecularPower( specularPower );
@@ -96,6 +103,7 @@
SetInterpolation( GetInterpolation() );
SetRepresentation( GetRepresentation() );
SetLineWidth( GetLineWidth() );
+ SetPointSize( GetPointSize() );
}
@@ -105,7 +113,8 @@
SetDataTreeNode( node );
SetRenderer( renderer );
SetColor( GetColor() );
- SetColorCoefficient( GetColorCoefficient() );
+ SetAmbientCoefficient( GetAmbientCoefficient() );
+ SetDiffuseCoefficient( GetDiffuseCoefficient() );
SetSpecularColor( GetSpecularColor() );
SetSpecularCoefficient( GetSpecularCoefficient() );
SetSpecularPower( GetSpecularPower() );
@@ -113,6 +122,7 @@
SetInterpolation( GetInterpolation() );
SetRepresentation( GetRepresentation() );
SetLineWidth( GetLineWidth() );
+ SetPointSize( GetPointSize() );
}
mitk::MaterialProperty::MaterialProperty( const MaterialProperty& property ) : mitk::BaseProperty()
@@ -193,16 +203,69 @@
}
-void mitk::MaterialProperty::SetColorCoefficient( vtkFloatingPointType coefficient )
+void mitk::MaterialProperty::SetAmbientColor( mitk::MaterialProperty::Color color )
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ m_DataTreeNode->SetColor( color.GetRed(), color.GetGreen(), color.GetBlue(), m_Renderer, AMBIENT_COLOR_KEY );
+ }
+ m_AmbientColor = color;
+ Modified();
+}
+
+void mitk::MaterialProperty::SetDiffuseColor( mitk::MaterialProperty::Color color )
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ m_DataTreeNode->SetColor( color.GetRed(), color.GetGreen(), color.GetBlue(), m_Renderer, DIFFUSE_COLOR_KEY );
+ }
+ m_DiffuseColor = color;
+ Modified();
+}
+
+
+void mitk::MaterialProperty::SetAmbientColor( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue )
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ m_DataTreeNode->SetColor( red, green, blue, m_Renderer, AMBIENT_COLOR_KEY );
+ }
+ m_AmbientColor.Set( red, green, blue );
+ Modified();
+}
+
+
+
+void mitk::MaterialProperty::SetDiffuseColor( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue )
{
if ( ForwardToDataTreeNode() )
{
- m_DataTreeNode->SetProperty( COLOR_COEFFICIENT_KEY, mitk::FloatProperty::New( coefficient ), m_Renderer );
+ m_DataTreeNode->SetColor( red, green, blue, m_Renderer, DIFFUSE_COLOR_KEY );
}
- m_ColorCoefficient = coefficient;
+ m_DiffuseColor.Set( red, green, blue );
Modified();
}
+void mitk::MaterialProperty::SetAmbientCoefficient( vtkFloatingPointType coefficient )
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ m_DataTreeNode->SetProperty( AMBIENT_COEFFICIENT_KEY, mitk::FloatProperty::New( coefficient ), m_Renderer );
+ }
+ m_AmbientCoefficient = coefficient;
+ Modified();
+}
+
+
+void mitk::MaterialProperty::SetDiffuseCoefficient( vtkFloatingPointType coefficient )
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ m_DataTreeNode->SetProperty( DIFFUSE_COEFFICIENT_KEY, mitk::FloatProperty::New( coefficient ), m_Renderer );
+ }
+ m_DiffuseCoefficient = coefficient;
+ Modified();
+}
void mitk::MaterialProperty::SetSpecularColor( mitk::MaterialProperty::Color specularColor )
{
if ( ForwardToDataTreeNode() )
@@ -289,6 +352,15 @@
Modified();
}
+void mitk::MaterialProperty::SetPointSize( float pointSize )
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ m_DataTreeNode->SetProperty( POINT_SIZE_KEY, mitk::FloatProperty::New( pointSize ), m_Renderer );
+ }
+ m_PointSize = pointSize;
+ Modified();
+}
mitk::MaterialProperty::Color mitk::MaterialProperty::GetColor() const
{
@@ -307,18 +379,72 @@
}
-vtkFloatingPointType mitk::MaterialProperty::GetColorCoefficient() const
+mitk::MaterialProperty::Color mitk::MaterialProperty::GetAmbientColor() const
{
if ( ForwardToDataTreeNode() )
{
- mitk::FloatProperty * colorCoefficient = dynamic_cast<mitk::FloatProperty*>( m_DataTreeNode->GetProperty( COLOR_COEFFICIENT_KEY, m_Renderer ) );
+ mitk::ColorProperty * colorProperty = dynamic_cast<mitk::ColorProperty*>(
+ m_DataTreeNode->GetProperty( AMBIENT_COLOR_KEY, m_Renderer ) );
+ if ( colorProperty != NULL )
+ {
+ mitk::Color color = colorProperty->GetColor();
+ Color tmpColor;
+ tmpColor.Set( color[ 0 ], color[ 1 ], color[ 2 ] );
+ return tmpColor;
+ }
+ else
+ return m_AmbientColor;
+ }
+ else
+ return m_AmbientColor;
+}
+
+mitk::MaterialProperty::Color mitk::MaterialProperty::GetDiffuseColor() const
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ mitk::ColorProperty * colorProperty = dynamic_cast<mitk::ColorProperty*>( m_DataTreeNode->GetProperty( DIFFUSE_COLOR_KEY, m_Renderer ) );
+ if ( colorProperty != NULL )
+ {
+ mitk::Color color = colorProperty->GetColor();
+ Color tmpColor;
+ tmpColor.Set( color[ 0 ], color[ 1 ], color[ 2 ] );
+ return tmpColor;
+ }
+ else
+ return m_DiffuseColor;
+ }
+ else
+ return m_DiffuseColor;
+}
+
+vtkFloatingPointType mitk::MaterialProperty::GetAmbientCoefficient() const
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ mitk::FloatProperty * colorCoefficient = dynamic_cast<mitk::FloatProperty*>( m_DataTreeNode->GetProperty( AMBIENT_COEFFICIENT_KEY, m_Renderer ) );
if ( colorCoefficient != NULL )
return colorCoefficient->GetValue();
else
- return m_ColorCoefficient;
+ return m_AmbientCoefficient;
}
else
- return m_ColorCoefficient;
+ return m_AmbientCoefficient;
+}
+
+
+vtkFloatingPointType mitk::MaterialProperty::GetDiffuseCoefficient() const
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ mitk::FloatProperty * colorCoefficient = dynamic_cast<mitk::FloatProperty*>( m_DataTreeNode->GetProperty( DIFFUSE_COEFFICIENT_KEY, m_Renderer ) );
+ if ( colorCoefficient != NULL )
+ return colorCoefficient->GetValue();
+ else
+ return m_DiffuseCoefficient;
+ }
+ else
+ return m_DiffuseCoefficient;
}
mitk::MaterialProperty::Color mitk::MaterialProperty::GetSpecularColor() const
@@ -456,6 +582,7 @@
case( Points ) : return VTK_POINTS;
case( Wireframe ) : return VTK_WIREFRAME;
case( Surface ) : return VTK_SURFACE;
+ case ( WireframeSurface ): return VTK_SURFACE;
}
return VTK_SURFACE;
}
@@ -475,6 +602,20 @@
return m_LineWidth;
}
+float mitk::MaterialProperty::GetPointSize() const
+{
+ if ( ForwardToDataTreeNode() )
+ {
+ mitk::FloatProperty * pointSize = dynamic_cast<mitk::FloatProperty*>( m_DataTreeNode->GetProperty( POINT_SIZE_KEY, m_Renderer ));
+ if ( pointSize != NULL )
+ return pointSize->GetValue();
+ else
+ return m_PointSize;
+ }
+ else
+ return m_PointSize;
+}
+
void mitk::MaterialProperty::Initialize( const MaterialProperty& property, const bool& copyDataTreeNode )
{
if ( copyDataTreeNode )
@@ -483,7 +624,10 @@
this->SetRenderer( property.GetRenderer() );
}
this->SetColor( property.GetColor() );
- this->SetColorCoefficient( property.GetColorCoefficient() );
+ this->SetAmbientColor( property.GetAmbientColor() );
+ this->SetDiffuseColor( property.GetDiffuseColor() );
+ this->SetAmbientCoefficient( property.GetAmbientCoefficient() );
+ this->SetDiffuseCoefficient( property.GetDiffuseCoefficient() );
this->SetSpecularColor( property.GetSpecularColor() );
this->SetSpecularCoefficient( property.GetSpecularCoefficient() );
this->SetSpecularPower( property.GetSpecularPower() );
@@ -491,6 +635,7 @@
this->SetInterpolation( property.GetInterpolation() );
this->SetRepresentation( property.GetRepresentation() );
this->SetLineWidth( property.GetLineWidth() );
+ this->SetPointSize( property.GetPointSize() );
this->SetName( property.GetName() );
}
@@ -505,7 +650,10 @@
return ( m_DataTreeNode == other->GetDataTreeNode() &&
m_Renderer == other->GetRenderer() &&
m_Color == other->GetColor() &&
- m_ColorCoefficient == other->GetColorCoefficient() &&
+ m_AmbientColor == other->GetAmbientColor() &&
+ m_DiffuseColor == other->GetDiffuseColor() &&
+ m_AmbientCoefficient == other->GetAmbientCoefficient() &&
+ m_DiffuseCoefficient == other->GetDiffuseCoefficient() &&
m_SpecularColor == other->GetSpecularColor() &&
m_SpecularCoefficient == other->GetSpecularCoefficient() &&
m_SpecularPower == other->GetSpecularPower() &&
@@ -513,7 +661,8 @@
m_Interpolation == other->GetInterpolation() &&
m_Name == other->GetName() &&
m_Representation == other->GetRepresentation() &&
- m_LineWidth == other->GetLineWidth()
+ m_LineWidth == other->GetLineWidth() &&
+ m_PointSize == other->GetPointSize()
);
}
@@ -528,28 +677,36 @@
{
m_DataTreeNode = NULL;
m_Renderer = NULL;
- m_Color.Set( 0.5, 0.5, 0.0 );
- m_ColorCoefficient = 0.5 ;
+ m_Color.Set( 1.0, 1.0, 1.0 );
+ m_AmbientColor.Set( 1.0, 1.0, 1.0 );
+ m_DiffuseColor.Set( 1.0, 1.0, 1.0 );
+ m_AmbientCoefficient = 0.0 ;
+ m_DiffuseCoefficient = 1.0 ;
m_SpecularColor.Set( 1.0, 1.0, 1.0 );
- m_SpecularCoefficient = 0.5;
+ m_SpecularCoefficient = 0.0;
m_SpecularPower = 10.0;
m_Opacity = 1.0 ;
m_Interpolation = Gouraud;
m_Representation = Surface;
m_LineWidth = 1.0;
+ m_PointSize = 1.0;
m_Name = "";
}
void mitk::MaterialProperty::Update()
{
this->SetColor( this->GetColor() );
- this->SetColorCoefficient( this->GetColorCoefficient() );
+ this->SetAmbientColor( this->GetAmbientColor() );
+ this->SetDiffuseColor( this->GetDiffuseColor() );
+ this->SetAmbientCoefficient( this->GetAmbientCoefficient() );
+ this->SetDiffuseCoefficient( this->GetDiffuseCoefficient() );
this->SetSpecularColor( this->GetSpecularColor() );
this->SetSpecularCoefficient( this->GetSpecularCoefficient() );
this->SetSpecularPower( this->GetSpecularPower() );
this->SetOpacity( this->GetOpacity() );
this->SetInterpolation( this->GetInterpolation() );
this->SetRepresentation( this->GetRepresentation() );
+ this->SetPointSize(this->GetPointSize());
}
void mitk::MaterialProperty::PrintSelf ( std::ostream &os ) const
@@ -558,12 +715,16 @@
os << "Renderer: " << GetRenderer() << std::endl;
os << "Name: " << GetName() << std::endl;
os << "Color: " << GetColor() << std::endl;
- os << "ColorCoefficient" << GetColorCoefficient() << std::endl;
+ os << "AmbientColor: " << GetAmbientColor() << std::endl;
+ os << "DiffuseColor: " << GetDiffuseColor() << std::endl;
+ os << "AmbientCoefficient" << GetAmbientCoefficient() << std::endl;
+ os << "DiffuseCoefficient" << GetDiffuseCoefficient() << std::endl;
os << "SpecularColor: " << GetSpecularColor() << std::endl;
os << "SpecularCoefficient: " << GetSpecularCoefficient() << std::endl;
os << "SpecularPower: " << GetSpecularPower() << std::endl;
os << "Opacity: " << GetOpacity() << std::endl;
os << "Line width: " << GetLineWidth() << std::endl;
+ os << "Point Size: " << GetPointSize() << std::endl;
switch ( GetInterpolation() )
{
case ( Flat ) : os << "Interpolation: Flat" << std::endl;
@@ -585,18 +746,25 @@
}
const char* mitk::MaterialProperty::COLOR_KEY = "color";
+const char* mitk::MaterialProperty::AMBIENT_COLOR_KEY = "ambient_color";
+const char* mitk::MaterialProperty::DIFFUSE_COLOR_KEY = "diffuse_color";
const char* mitk::MaterialProperty::SPECULAR_COLOR_KEY = "specular_color";
-const char* mitk::MaterialProperty::COLOR_COEFFICIENT_KEY = "color_coefficient";
+const char* mitk::MaterialProperty::AMBIENT_COEFFICIENT_KEY = "ambient_coefficient";
+const char* mitk::MaterialProperty::DIFFUSE_COEFFICIENT_KEY = "diffuse_coefficient";
const char* mitk::MaterialProperty::SPECULAR_COEFFICIENT_KEY = "specular_coefficient";
const char* mitk::MaterialProperty::SPECULAR_POWER_KEY = "specular_power";
const char* mitk::MaterialProperty::OPACITY_KEY = "opacity";
const char* mitk::MaterialProperty::INTERPOLATION_KEY = "interpolation";
const char* mitk::MaterialProperty::REPRESENTATION_KEY = "representation";
const char* mitk::MaterialProperty::LINE_WIDTH_KEY = "wireframe line width";
+const char* mitk::MaterialProperty::POINT_SIZE_KEY = "point size";
const char* mitk::MaterialProperty::COLOR = "COLOR";
+const char* mitk::MaterialProperty::AMBIENT_COLOR = "AMBIENT_COLOR";
+const char* mitk::MaterialProperty::DIFFUSE_COLOR = "DIFFUSE_COLOR";
const char* mitk::MaterialProperty::SPECULAR_COLOR = "SPECULAR_COLOR";
-const char* mitk::MaterialProperty::COLOR_COEFFICIENT = "COLOR_COEFFICIENT";
+const char* mitk::MaterialProperty::AMBIENT_COEFFICIENT = "AMBIENT_COEFFICIENT";
+const char* mitk::MaterialProperty::DIFFUSE_COEFFICIENT = "DIFFUSE_COEFFICIENT";
const char* mitk::MaterialProperty::SPECULAR_COEFFICIENT = "SPECULAR_COEFFICIENT";
const char* mitk::MaterialProperty::SPECULAR_POWER = "SPECULAR_POWER";
const char* mitk::MaterialProperty::OPACITY = "OPACITY";
Index: Core/Code/IO/mitkMaterialProperty.h
===================================================================
--- Core/Code/IO/mitkMaterialProperty.h (revision 21081)
+++ Core/Code/IO/mitkMaterialProperty.h (working copy)
@@ -59,7 +59,7 @@
enum RepresentationType
{
- Points, Wireframe, Surface
+ Points, Wireframe, Surface, WireframeSurface
};
/**
@@ -233,12 +233,52 @@
*/
virtual void SetColor( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue );
+ /**
+ * Sets the materials color in RGB space. The rgb components have to be
+ * in the range [0..1]
+ * @param color the new color of the material
+ */
+ virtual void SetAmbientColor( Color color );
+
+ /**
+ * Sets the materials color in RGB space. The rgb components have to be
+ * in the range [0..1]
+ * @param color the new color of the material
+ */
+ virtual void SetDiffuseColor( Color color );
+
+ /**
+ * Sets the materials color in RGB space. The rgb components have to be
+ * in the range [0..1]
+ * @param red the red component of the materials color (range [0..1])
+ * @param green the green component of the materials color (range [0..1])
+ * @param blue the blue component of the materials color (range [0..1])
+ */
+ virtual void SetAmbientColor( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue );
+
+
/**
- * Sets a attenuation coefficient for the color. A value of 0 results in
+ * Sets the materials color in RGB space. The rgb components have to be
+ * in the range [0..1]
+ * @param red the red component of the materials color (range [0..1])
+ * @param green the green component of the materials color (range [0..1])
+ * @param blue the blue component of the materials color (range [0..1])
+ */
+ virtual void SetDiffuseColor( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue );
+
+ /**
+ * Sets a attenuation coefficient for the color. A value of 0 results in
* a black object. VAlid range is [0..1]
* @param coefficient the color attenuation coefficient
*/
- virtual void SetColorCoefficient( vtkFloatingPointType coefficient );
+ virtual void SetAmbientCoefficient( vtkFloatingPointType coefficient );
+
+ /**
+ * Sets a attenuation coefficient for the color. A value of 0 results in
+ * a black object. VAlid range is [0..1]
+ * @param coefficient the color attenuation coefficient
+ */
+ virtual void SetDiffuseCoefficient( vtkFloatingPointType coefficient );
/**
* Sets the specular color
@@ -302,15 +342,36 @@
*/
virtual void SetLineWidth( float lineWidth );
+ /**
+ * Set/Get the size of a Point. The size is expressed in screen units. The default is 1.0.
+ */
+ virtual void SetPointSize( float pointSize );
+
/**
* @returns the color of the material
*/
virtual Color GetColor() const;
+
+ /**
+ * @returns the color of the material
+ */
+ virtual Color GetAmbientColor() const;
+
+ /**
+ * @returns the color of the material
+ */
+ virtual Color GetDiffuseColor() const;
+
+ /**
+ * @returns the color coefficient of the material. Range is [0..1]
+ */
+ virtual vtkFloatingPointType GetAmbientCoefficient() const;
+
/**
* @returns the color coefficient of the material. Range is [0..1]
*/
- virtual vtkFloatingPointType GetColorCoefficient() const;
+ virtual vtkFloatingPointType GetDiffuseCoefficient() const;
/**
* @returns the specular color of the material in rgb values, which
@@ -360,6 +421,11 @@
*/
virtual float GetLineWidth() const;
+ /**
+ * @returns the point size used for wireframe rendering as a fraction of screen units
+ */
+ virtual float GetPointSize() const;
+
/**
* Fills the current materials with the properties of the
* given material.
@@ -504,9 +570,15 @@
Color m_Color;
+ Color m_AmbientColor;
+
+ Color m_DiffuseColor;
+
Color m_SpecularColor;
- vtkFloatingPointType m_ColorCoefficient;
+ vtkFloatingPointType m_AmbientCoefficient;
+
+ vtkFloatingPointType m_DiffuseCoefficient;
vtkFloatingPointType m_SpecularCoefficient;
@@ -516,6 +588,8 @@
float m_LineWidth;
+ float m_PointSize;
+
InterpolationType m_Interpolation;
RepresentationType m_Representation;
@@ -524,19 +598,26 @@
mitk::BaseRenderer* m_Renderer;
- static const char* COLOR_KEY;
- static const char* SPECULAR_COLOR_KEY;
- static const char* COLOR_COEFFICIENT_KEY;
+ static const char* COLOR_KEY;
+ static const char* AMBIENT_COLOR_KEY;
+ static const char* DIFFUSE_COLOR_KEY;
+ static const char* SPECULAR_COLOR_KEY;
+ static const char* AMBIENT_COEFFICIENT_KEY;
+ static const char* DIFFUSE_COEFFICIENT_KEY;
static const char* SPECULAR_COEFFICIENT_KEY;
static const char* SPECULAR_POWER_KEY;
static const char* OPACITY_KEY;
static const char* INTERPOLATION_KEY;
static const char* REPRESENTATION_KEY;
static const char* LINE_WIDTH_KEY;
+ static const char* POINT_SIZE_KEY;
- static const char* COLOR;
- static const char* SPECULAR_COLOR;
- static const char* COLOR_COEFFICIENT;
+ static const char* COLOR;
+ static const char* AMBIENT_COLOR;
+ static const char* DIFFUSE_COLOR;
+ static const char* SPECULAR_COLOR;
+ static const char* AMBIENT_COEFFICIENT;
+ static const char* DIFFUSE_COEFFICIENT;
static const char* SPECULAR_COEFFICIENT;
static const char* SPECULAR_POWER;
static const char* OPACITY;
Index: Core/Code/Rendering/mitkGeometry2DDataVtkMapper3D.cpp
===================================================================
--- Core/Code/Rendering/mitkGeometry2DDataVtkMapper3D.cpp (revision 21081)
+++ Core/Code/Rendering/mitkGeometry2DDataVtkMapper3D.cpp (working copy)
@@ -376,8 +376,6 @@
m_SurfaceCreator->SetYResolution(res);
}
- double tubeRadius = 1.0; // Radius of tubular edge surrounding plane
-
// Clip the Geometry2D with the reference geometry bounds (if available)
if ( input->GetGeometry2D()->HasReferenceGeometry() )
{
@@ -403,8 +401,6 @@
m_SurfaceCreatorBoundingBox->ComputeBoundingBox();
m_SurfaceCreator->SetBoundingBox( m_SurfaceCreatorBoundingBox );
-
- tubeRadius = referenceGeometry->GetDiagonalLength() / 450.0;
}
else
{
@@ -413,8 +409,6 @@
if (m_DataStorage.IsNotNull())
{
m_SurfaceCreator->SetBoundingBox(m_DataStorage->ComputeVisibleBoundingBox(NULL, "includeInBoundingBox"));
-
- tubeRadius = sqrt( m_SurfaceCreator->GetBoundingBox()->GetDiagonalLength2() ) / 450.0;
}
}
@@ -535,9 +529,8 @@
if ( extent < extentZ )
extent = extentZ;
-
// Adjust the radius according to extent
- m_EdgeTuber->SetRadius( tubeRadius );
+ m_EdgeTuber->SetRadius( extent / 450.0 );
// Get the plane's color and set the tube properties accordingly
ColorProperty::Pointer colorProperty;
@@ -558,7 +551,28 @@
VtkRepresentationProperty* representationProperty;
this->GetDataTreeNode()->GetProperty(representationProperty, "representation", renderer);
if ( representationProperty != NULL )
- m_BackgroundActor->GetProperty()->SetRepresentation( representationProperty->GetVtkRepresentation() );
+ {
+ mitk::VtkRepresentationProperty::IdType type = representationProperty->GetValueAsId();
+ bool isVolume = false;
+ switch (type) {
+ case mitk::VtkRepresentationProperty::POINTS:
+ m_BackgroundActor->GetProperty()->SetRepresentationToPoints();
+ break;
+ case mitk::VtkRepresentationProperty::WIREFRAME:
+ m_BackgroundActor->GetProperty()->SetRepresentationToWireframe();
+ break;
+ case mitk::VtkRepresentationProperty::SURFACE:
+ m_BackgroundActor->GetProperty()->SetRepresentationToSurface();
+ break;
+ case mitk::VtkRepresentationProperty::WIRESURF:
+ //m_Assembly->RemovePart(m_Actor);
+ //m_Assembly->RemovePart(m_ActorWireframe);
+ //isVolume = true;
+ m_BackgroundActor->GetProperty()->SetRepresentationToSurface();
+ break;
+ }
+ }
+ //m_BackgroundActor->GetProperty()->SetRepresentation( representationProperty->GetVtkRepresentation() );
}
Index: Core/Code/Rendering/mitkSurfaceVtkMapper3D.cpp
===================================================================
--- Core/Code/Rendering/mitkSurfaceVtkMapper3D.cpp (revision 21081)
+++ Core/Code/Rendering/mitkSurfaceVtkMapper3D.cpp (working copy)
@@ -47,7 +47,7 @@
mitk::SurfaceVtkMapper3D::SurfaceVtkMapper3D()
{
- // m_Prop3D = vtkActor::New();
+ // m_Prop3D = vtkAssembly::New();
m_GenerateNormals = false;
}
@@ -59,13 +59,17 @@
void mitk::SurfaceVtkMapper3D::GenerateData(mitk::BaseRenderer* renderer)
{
LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
-// m_Prop3D = ls->m_Actor;
+ //m_Prop3D = ls->m_Assembly;
bool visible = IsVisible(renderer);
if(visible==false)
{
- ls->m_Actor->VisibilityOff();
+ ls->m_Assembly->VisibilityOn();
+
+ ls->m_ActorWireframe->GetProperty()->SetAmbient(1.0);
+ ls->m_ActorWireframe->GetProperty()->SetDiffuse(0.0);
+ ls->m_ActorWireframe->GetProperty()->SetSpecular(0.0);
return;
}
@@ -76,7 +80,7 @@
const TimeSlicedGeometry* inputTimeGeometry = input->GetTimeSlicedGeometry();
if(( inputTimeGeometry == NULL ) || ( inputTimeGeometry->GetTimeSteps() == 0 ) )
{
- ls->m_Actor->VisibilityOff();
+ ls->m_Assembly->VisibilityOff();
return;
}
@@ -95,11 +99,11 @@
timestep = inputTimeGeometry->MSToTimeStep( time );
if( inputTimeGeometry->IsValidTime( timestep ) == false )
{
- ls->m_Actor->VisibilityOff();
+ ls->m_Assembly->VisibilityOff();
return;
}
-// MITK_INFO << "time: "<< time << std::endl;
-// MITK_INFO << "timestep: "<<timestep << std::endl;
+// LOG_INFO << "time: "<< time << std::endl;
+// LOG_INFO << "timestep: "<<timestep << std::endl;
//
// set the input-object at time t for the mapper
@@ -108,7 +112,7 @@
vtkPolyData * polydata = input->GetVtkPolyData( timestep );
if(polydata == NULL)
{
- ls->m_Actor->VisibilityOff();
+ ls->m_Assembly->VisibilityOff();
return;
}
@@ -120,6 +124,7 @@
else
{
ls->m_VtkPolyDataMapper->SetInput( polydata );
+ ls->m_VtkPolyDataMapperWireframe->SetInput( polydata );
}
//
@@ -128,15 +133,16 @@
ApplyProperties(ls->m_Actor, renderer);
if(visible)
- ls->m_Actor->VisibilityOn();
+ ls->m_Assembly->VisibilityOn();
}
void mitk::SurfaceVtkMapper3D::ApplyProperties(vtkActor* /*actor*/, mitk::BaseRenderer* renderer)
{
LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
-// m_Prop3D = ls->m_Actor;
-
+// m_Prop3D = ls->m_Assembly;
+
+ mitk::DataTreeNode::Pointer node = this->GetDataTreeNode();
mitk::MaterialProperty* materialProperty;
//first check render specific property, then the regular one
@@ -156,10 +162,10 @@
{
vtkProperty* property = ls->m_Actor->GetProperty();
//property->SetColor( materialProperty->GetColor().GetDataPointer() );
- property->SetAmbientColor( materialProperty->GetColor().GetDataPointer() );
- property->SetAmbient( materialProperty->GetColorCoefficient() );
- property->SetDiffuseColor(materialProperty->GetColor().GetDataPointer() );
- property->SetDiffuse( materialProperty->GetColorCoefficient() );
+ property->SetAmbientColor( materialProperty->GetAmbientColor().GetDataPointer() );
+ property->SetAmbient( materialProperty->GetAmbientCoefficient() );
+ property->SetDiffuseColor(materialProperty->GetDiffuseColor().GetDataPointer() );
+ property->SetDiffuse( materialProperty->GetDiffuseCoefficient() );
property->SetSpecularColor( materialProperty->GetSpecularColor().GetDataPointer() );
property->SetSpecular( materialProperty->GetSpecularCoefficient() );
property->SetSpecularPower( materialProperty->GetSpecularPower() );
@@ -167,6 +173,10 @@
property->SetInterpolation( materialProperty->GetVtkInterpolation() );
property->SetRepresentation( materialProperty->GetVtkRepresentation() );
property->SetLineWidth( materialProperty->GetLineWidth() );
+ property->SetPointSize( materialProperty->GetPointSize() );
+
+ ls->m_ActorWireframe->GetProperty()->SetOpacity(materialProperty->GetOpacity());
+ ls->m_ActorWireframe->GetProperty()->SetColor( materialProperty->GetColor().GetDataPointer() );
}
else
{
@@ -207,7 +217,47 @@
mitk::VtkRepresentationProperty* representationProperty;
this->GetDataTreeNode()->GetProperty(representationProperty, "representation", renderer);
if ( representationProperty != NULL )
- ls->m_Actor->GetProperty()->SetRepresentation( representationProperty->GetVtkRepresentation() );
+ {
+ mitk::VtkRepresentationProperty::IdType type = representationProperty->GetValueAsId();
+ bool isVolume = false;
+ switch (type) {
+ case mitk::VtkRepresentationProperty::POINTS:
+ ls->m_Assembly->RemovePart(ls->m_Actor);
+ ls->m_Assembly->RemovePart(ls->m_ActorWireframe);
+ ls->m_Assembly->AddPart(ls->m_Actor);
+ ls->m_Actor->GetProperty()->SetRepresentationToPoints();
+ break;
+ case mitk::VtkRepresentationProperty::WIREFRAME:
+ ls->m_Assembly->RemovePart(ls->m_Actor);
+ ls->m_Assembly->RemovePart(ls->m_ActorWireframe);
+ ls->m_Assembly->AddPart(ls->m_Actor);
+ ls->m_Actor->GetProperty()->SetRepresentationToWireframe();
+ break;
+ case mitk::VtkRepresentationProperty::SURFACE:
+ ls->m_Assembly->RemovePart(ls->m_Actor);
+ ls->m_Assembly->RemovePart(ls->m_ActorWireframe);
+ ls->m_Assembly->AddPart(ls->m_Actor);
+ ls->m_Actor->GetProperty()->SetRepresentationToSurface();
+ break;
+ case mitk::VtkRepresentationProperty::WIRESURF:
+ //ls->m_Assembly->AddPart(ls->m_Actor);
+ ls->m_Assembly->RemovePart(ls->m_Actor);
+ ls->m_Assembly->RemovePart(ls->m_ActorWireframe);
+ ls->m_Assembly->AddPart(ls->m_Actor);
+ ls->m_Assembly->AddPart(ls->m_ActorWireframe);
+ ls->m_Actor->GetProperty()->SetRepresentationToSurface();
+ ls->m_ActorWireframe->GetProperty()->SetDiffuseColor(0.0, 0.0, 1.0 );
+ ls->m_ActorWireframe->GetProperty()->SetRepresentationToWireframe();
+ isVolume = true;
+ break;
+ }
+
+ //if (!isVolume) {
+ //m_Assembly->RemovePart(m_Actor);
+ //m_Assembly->RemovePart(m_ActorWireframe);
+ //}
+ }
+ // ls->m_Actor->GetProperty()->SetRepresentation( representationProperty->GetVtkRepresentation() );
mitk::VtkInterpolationProperty* interpolationProperty;
this->GetDataTreeNode()->GetProperty(interpolationProperty, "interpolation", renderer);
@@ -324,13 +374,13 @@
vtkProp *mitk::SurfaceVtkMapper3D::GetVtkProp(mitk::BaseRenderer *renderer)
{
LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
- return ls->m_Actor;
+ return ls->m_Assembly;
}
void mitk::SurfaceVtkMapper3D::CheckForClippingProperty( mitk::BaseRenderer* renderer, mitk::BaseProperty *property )
{
LocalStorage *ls = m_LSH.GetLocalStorage(renderer);
-// m_Prop3D = ls->m_Actor;
+// m_Prop3D = ls->m_Assembly;
ClippingProperty *clippingProperty = dynamic_cast< ClippingProperty * >( property );
Index: Core/Code/Rendering/mitkSurfaceVtkMapper3D.h
===================================================================
--- Core/Code/Rendering/mitkSurfaceVtkMapper3D.h (revision 21081)
+++ Core/Code/Rendering/mitkSurfaceVtkMapper3D.h (working copy)
@@ -25,6 +25,7 @@
#include "mitkBaseRenderer.h"
#include <vtkActor.h>
+#include <vtkAssembly.h>
#include <vtkPainterPolyDataMapper.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolyDataNormals.h>
@@ -133,8 +134,11 @@
{
public:
+ vtkAssembly* m_Assembly;
vtkActor* m_Actor;
+ vtkActor* m_ActorWireframe;
vtkPolyDataMapper *m_VtkPolyDataMapper;
+ vtkPolyDataMapper* m_VtkPolyDataMapperWireframe;
vtkPolyDataNormals *m_VtkPolyDataNormals;
vtkPlaneCollection *m_ClippingPlaneCollection;
@@ -143,19 +147,31 @@
LocalStorage()
{
m_VtkPolyDataMapper = vtkPainterPolyDataMapper::New();
+ m_VtkPolyDataMapperWireframe = vtkPolyDataMapper::New();
m_VtkPolyDataNormals = vtkPolyDataNormals::New();
+ m_Assembly = vtkAssembly::New();
m_Actor = vtkActor::New();
+ m_ActorWireframe = vtkActor::New();
m_ClippingPlaneCollection = vtkPlaneCollection::New();
m_Actor->SetMapper(m_VtkPolyDataMapper);
+ m_ActorWireframe->SetMapper(m_VtkPolyDataMapperWireframe);
+ //m_ActorWireframe->GetProperty()->SetRepresentationToWireframe();
+ m_Assembly->AddPart(m_Actor);
+ m_Assembly->AddPart(m_ActorWireframe);
+
}
~LocalStorage()
{
m_VtkPolyDataMapper->Delete();
+ m_VtkPolyDataMapperWireframe->Delete();
m_VtkPolyDataNormals->Delete();
- m_Actor->Delete();
- m_ClippingPlaneCollection->Delete();
+
+ m_Assembly->Delete();
+ m_Actor->Delete();
+ m_ClippingPlaneCollection->Delete();
+ m_ActorWireframe->Delete();
}
};
Index: Core/Code/Testing/mitkMaterialPropertyTest.cpp
===================================================================
--- Core/Code/Testing/mitkMaterialPropertyTest.cpp (revision 21081)
+++ Core/Code/Testing/mitkMaterialPropertyTest.cpp (working copy)
@@ -105,7 +105,8 @@
MITK_TEST_CONDITION( opacity==myMP->GetOpacity(), "Testing if a Opacity object was set correctly" )
MITK_TEST_CONDITION( specularCoefficient==myMP->GetSpecularCoefficient(), "Testing if a Coefficient object was set correctly" )
MITK_TEST_CONDITION( specularPower==myMP->GetSpecularPower(), "Testing if a SpecularPower object was set correctly" )
- MITK_TEST_CONDITION( colorCoefficient==myMP->GetColorCoefficient(), "Testing if a colorCoefficient object was set correctly" )
+ MITK_TEST_CONDITION( colorCoefficient==myMP->GetAmbientCoefficient(), "Testing if a colorCoefficient object was set correctly" )
+ MITK_TEST_CONDITION( colorCoefficient==myMP->GetDiffuseCoefficient(), "Testing if a colorCoefficient object was set correctly" )
}
void testConstructorColorColorCoefficientSpecularCoefficientSpecularPowerOpacityNodeAndRenderer()
@@ -162,15 +163,26 @@
MITK_TEST_CONDITION(color==myMP->GetColor(),"Testing if a color was set correctly")
}
-void testSetColorCoefficient()
+void testSetAmbientCoefficient()
{
vtkFloatingPointType colorCoefficient = 0;
myMP = mitk::MaterialProperty::New(node, NULL);
- myMP->SetColorCoefficient(colorCoefficient);
- MITK_TEST_CONDITION(colorCoefficient == myMP->GetColorCoefficient(), "Testing if a colorcoefficent was set correctly")
+ myMP->SetAmbientCoefficient(colorCoefficient);
+ MITK_TEST_CONDITION(colorCoefficient == myMP->GetAmbientCoefficient(), "Testing if a colorcoefficent was set correctly")
+
+}
+
+void testSetDiffuseCoefficient()
+{
+
+ vtkFloatingPointType colorCoefficient = 0;
+ myMP = mitk::MaterialProperty::New(node, NULL);
+ myMP->SetDiffuseCoefficient(colorCoefficient);
+ MITK_TEST_CONDITION(colorCoefficient == myMP->GetDiffuseCoefficient(), "Testing if a colorcoefficent was set correctly")
}
+
void testSetSpecularColor()
{
mitk::MaterialProperty::Color color;
@@ -402,7 +414,8 @@
materialPropTest.testAssignable();
materialPropTest.testOperatorAssign();
materialPropTest.testSetColor();
- materialPropTest.testSetColorCoefficient();
+ materialPropTest.testSetAmbientCoefficient();
+ materialPropTest.testSetDiffuseCoefficient();
materialPropTest.testSetSpecularColor();
materialPropTest.testSetSpecularCoefficient();
materialPropTest.testSetSpecularPower();

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
400
Default Alt Text
bug3198.diff (38 KB)

Event Timeline

wireframe+surface, diffuse and ambient colors, point size