Salome HOME
added support for all type of edges in KindOfShape method
[modules/geom.git] / src / OBJECT / GEOM_VTKTrihedron.cxx
index a57f359d123f965de91f313b420ec78416d468eb..c633accfda85d9963d4308e289d55ba892906e77 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -24,7 +24,6 @@
 //  File   : GEOM_VTKTrihedron.cxx
 //  Author : Sergey LITONIN
 //  Module : SALOME
-//  $Header:
 //
 #include "GEOM_VTKTrihedron.hxx"
 
@@ -52,7 +51,7 @@
 /*
   Class       : GEOM_VTKTrihedron
   Description : Class for displaying axis of trihedron in VTK viewer.
-                Placement of trihedron is chahged with SetPlacement() method
+                Placement of trihedron is changed with SetPlacement() method
 */
 class GEOM_VTKTrihedronAxis : public VTKViewer_Axis
 {
@@ -64,23 +63,23 @@ protected:
 
 public:
 
-                                vtkTypeMacro( GEOM_VTKTrihedronAxis, VTKViewer_Axis );
+                                vtkTypeMacro( GEOM_VTKTrihedronAxis, VTKViewer_Axis )
   static GEOM_VTKTrihedronAxis* New();
 
-  void                          SetAxis( const gp_Ax1& theAxis, const int theRot, vtkFloatingPointType theColor[ 3 ] );
+  void                          SetAxis( const gp_Ax1& theAxis, const int theRot, double theColor[ 3 ] );
   virtual void                  Render( vtkRenderer* theRenderer );
-  virtual void                  SetSize( vtkFloatingPointType theSize );
+  virtual void                  SetSize( double theSize );
   gp_Pnt                        GetOri() const;
-  void                          SetColor( const vtkFloatingPointType theColor[ 3 ] );
+  void                          SetColor( const double theColor[ 3 ] );
 
 private:
 
-  vtkFloatingPointType          myOri[ 3 ];
+  double          myOri[ 3 ];
   vtkMatrix4x4*                 myMatrix;
   vtkTransform*                 myTrsf;
 };
 
-vtkStandardNewMacro( GEOM_VTKTrihedronAxis );
+vtkStandardNewMacro( GEOM_VTKTrihedronAxis )
 
 GEOM_VTKTrihedronAxis::GEOM_VTKTrihedronAxis()
 {
@@ -95,9 +94,9 @@ GEOM_VTKTrihedronAxis::~GEOM_VTKTrihedronAxis()
   myTrsf->Delete();
 }
 
-void GEOM_VTKTrihedronAxis::SetSize( vtkFloatingPointType theSize )
+void GEOM_VTKTrihedronAxis::SetSize( double theSize )
 {
-  vtkFloatingPointType aPosition[ 3 ] = { myOri[ 0 ] + myDir[ 0 ] * theSize,
+  double aPosition[ 3 ] = { myOri[ 0 ] + myDir[ 0 ] * theSize,
                                           myOri[ 1 ] + myDir[ 1 ] * theSize,
                                           myOri[ 2 ] + myDir[ 2 ] * theSize };
                            
@@ -117,11 +116,15 @@ void GEOM_VTKTrihedronAxis::SetSize( vtkFloatingPointType theSize )
   gp_Mat aRot = aTrsf.VectorialPart();
 
   for ( int i = 1; i <= 3; i++ )
+  {
     for ( int j = 1; j <= 3; j++ )
       myMatrix->SetElement( i - 1, j - 1, aRot( i, j ) );
+  // Set Arrow Position
+  myMatrix->SetElement( i - 1 , 3, aPosition[ i - 1 ] );
+  }
 
   myArrowActor->SetUserMatrix( myMatrix );
-  myArrowActor->SetPosition( aPosition );
     
 #ifdef IPAL21440
   if( vtkCoordinate* aCoord = myLabelActor->GetPositionCoordinate()->GetReferenceCoordinate() )
@@ -151,7 +154,7 @@ gp_Pnt GEOM_VTKTrihedronAxis::GetOri() const
 
 void GEOM_VTKTrihedronAxis::SetAxis( const gp_Ax1& theAxis,
                                      const int     theRot,
-                                     vtkFloatingPointType theColor[ 3 ] )
+                                     double theColor[ 3 ] )
 {
   gp_Pnt aLoc = theAxis.Location();
   gp_Dir aDir = theAxis.Direction();
@@ -164,7 +167,7 @@ void GEOM_VTKTrihedronAxis::SetAxis( const gp_Ax1& theAxis,
   myDir[ 1 ] = aDir.Y();
   myDir[ 2 ] = aDir.Z();
 
-  vtkFloatingPointType aColor[ 3 ] = { 0, 0, 0 };
+  double aColor[ 3 ] = { 0, 0, 0 };
   aColor[ theRot ] = 1;
   if ( theColor[ 0 ] == -1 )
     VTKViewer_Axis::SetColor( aColor[ 0 ], aColor[ 1 ], aColor[ 2 ] );
@@ -182,7 +185,7 @@ void GEOM_VTKTrihedronAxis::SetAxis( const gp_Ax1& theAxis,
 #endif
 }
 
-void GEOM_VTKTrihedronAxis::SetColor( const vtkFloatingPointType theColor[ 3 ] )
+void GEOM_VTKTrihedronAxis::SetColor( const double theColor[ 3 ] )
 {
   VTKViewer_Axis::SetColor( theColor[ 0 ], theColor[ 1 ], theColor[ 2 ] );
 }
@@ -191,10 +194,10 @@ void GEOM_VTKTrihedronAxis::SetColor( const vtkFloatingPointType theColor[ 3 ] )
 /*
   Class       : GEOM_VTKTrihedron
   Description : Class for displaying trihedron of local CS in VTK viewer.
-                Placement of trihedron is chahged with SetPlacement() method
+                Placement of trihedron is changed with SetPlacement() method
 */
 
-vtkStandardNewMacro( GEOM_VTKTrihedron );
+vtkStandardNewMacro( GEOM_VTKTrihedron )
 
 GEOM_VTKTrihedron::GEOM_VTKTrihedron()
 {
@@ -224,7 +227,7 @@ GEOM_VTKTrihedron::~GEOM_VTKTrihedron()
     myMapper->Delete();
 }
 
-void GEOM_VTKTrihedron::SetSize( vtkFloatingPointType theSize )
+void GEOM_VTKTrihedron::SetSize( double theSize )
 {
   mySize = theSize;
   for ( int i = 0; i < 3; i++ )
@@ -251,11 +254,12 @@ void GEOM_VTKTrihedron::SetSize( vtkFloatingPointType theSize )
   aSrcZ->SetPoint2( aEndZ.X(), aEndZ.Y(), aEndZ.Z() );
 
   vtkAppendPolyData* aRes = vtkAppendPolyData::New();
-  aRes->AddInput( aSrcX->GetOutput() );
-  aRes->AddInput( aSrcY->GetOutput() );
-  aRes->AddInput( aSrcZ->GetOutput() );
+  aRes->AddInputConnection( aSrcX->GetOutputPort() );
+  aRes->AddInputConnection( aSrcY->GetOutputPort() );
+  aRes->AddInputConnection( aSrcZ->GetOutputPort() );
   
-  myMapper->SetInput( aRes->GetOutput() );
+  myMapper->SetInputConnection( aRes->GetOutputPort() );
+  aRes->Update();
   SALOME_Actor::SetMapper( myMapper );
 
   aSrcX->Delete();
@@ -359,7 +363,7 @@ void GEOM_VTKTrihedron::Render(vtkRenderer* r, vtkMapper *)
   ( (GEOM_VTKTrihedronAxis*)myAxis[ 2 ] )->Render( r );
 }
 
-void GEOM_VTKTrihedron::SetColor( vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
+void GEOM_VTKTrihedron::SetColor( double r, double g, double b )
 {
   myColor[ 0 ] = r;
   myColor[ 1 ] = g;
@@ -370,7 +374,7 @@ void GEOM_VTKTrihedron::SetColor( vtkFloatingPointType r, vtkFloatingPointType g
   if ( myAxis[ 2 ] ) ( (GEOM_VTKTrihedronAxis*)myAxis[ 2 ] )->SetColor( myColor );
 }
 
-void GEOM_VTKTrihedron::GetColor( vtkFloatingPointType& r, vtkFloatingPointType& g, vtkFloatingPointType& b )
+void GEOM_VTKTrihedron::GetColor( double& r, double& g, double& b )
 {
   r = myColor[ 0 ];
   g = myColor[ 1 ];
@@ -423,9 +427,10 @@ void GEOM_VTKTrihedron::ResetAxesColors()
     SetAxesColors( myDefaultColor, true );
 }
 
-void GEOM_VTKTrihedron::SetAxesColors( vtkFloatingPointType theColor[3], bool theIsDiffuse )
+void GEOM_VTKTrihedron::SetAxesColors( double theColor[3], bool theIsDiffuse )
 {
   myAxis[ 0 ]->SetColor( theColor[0], theIsDiffuse ? 0.0 : theColor[1], theIsDiffuse ? 0.0 : theColor[2] );
   myAxis[ 1 ]->SetColor( theIsDiffuse ? 0.0 : theColor[0], theColor[1], theIsDiffuse ? 0.0 : theColor[2] );
   myAxis[ 2 ]->SetColor( theIsDiffuse ? 0.0 : theColor[0], theIsDiffuse ? 0.0 : theColor[1], theColor[2] );
 }
+