1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VISU_ElnoMeshValue.hxx
21 // Author : Alexey PETROV
24 #ifndef VISU_ElnoMeshValue_HeaderFile
25 #define VISU_ElnoMeshValue_HeaderFile
27 #include "VISU_VTKTypeList.hxx"
28 #include <vtkDataSetAttributes.h>
32 \file VISU_ElnoMeshValue.hxx
33 \brief The file contains declarations for the acess to the specific ELNO MED data
38 //---------------------------------------------------------------
39 template< int elno_type >
40 struct TGetElnoNodeData
42 typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray;
43 typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType;
44 TVTKDataArray *myElnoDataArray;
45 vtkIntArray *myElnoDataMapper;
49 //----------------------------------------------------------------------------
50 TGetElnoNodeData( vtkDataArray *theElnoDataArray,
51 vtkDataArray *theElnoDataMapper )
52 : myElnoDataArray( TVTKDataArray::SafeDownCast( theElnoDataArray ) )
53 , myElnoDataMapper( vtkIntArray::SafeDownCast( theElnoDataMapper ) )
57 //----------------------------------------------------------------------------
59 operator () ( vtkIdType theCellId, vtkIdType theLocalPntId )
61 myElnoDataMapper->GetTupleValue( theCellId, myElemInfo );
63 vtkIdType aPos = myElemInfo[ 0 ] + theLocalPntId * myElemInfo[ 1 ];
65 return myElnoDataArray->GetPointer( aPos );
69 //----------------------------------------------------------------------------
73 myElnoDataMapper->GetTupleValue( 0, myElemInfo );
75 return myElemInfo[ 1 ];
80 //----------------------------------------------------------------------------------------------
81 template< int elno_type >
82 struct TSetElnoNodeData
84 typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray;
85 typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType;
87 //----------------------------------------------------------------------------------------------
88 TSetElnoNodeData( vtkIdType theEffectNbComp,
89 vtkIdType theRealNbComp,
90 vtkIdType theNbTuples,
91 const char* theDataArrayName,
92 const char* theMapperArrayName )
93 : myElnoDataArray( TVTKDataArray::New() )
94 , myElnoDataMapper( vtkIntArray::New() )
96 myElnoDataArray->SetNumberOfComponents( theEffectNbComp );
97 myElnoDataArray->SetNumberOfTuples( theNbTuples );
98 myElnoDataArray->SetName( theDataArrayName );
100 myElnoDataMapper->SetNumberOfComponents( 3 );
101 myElnoDataMapper->Allocate( theNbTuples * 3 );
102 myElnoDataMapper->SetName( theMapperArrayName );
105 myElemInfo[ 1 ] = theRealNbComp;
110 //----------------------------------------------------------------------------------------------
113 myElnoDataArray->Delete();
114 myElnoDataMapper->Delete();
118 //----------------------------------------------------------------------------------------------
120 AddNextPointData( TDataType* theDataPtr )
122 vtkIdType aPos = myElemInfo[ 0 ] + myElemInfo[ 2 ] * myElemInfo[ 1 ];
124 TDataType* aDataPtr = myElnoDataArray->GetPointer( aPos );
126 for ( vtkIdType aCompId = 0; aCompId < myElemInfo[ 1 ]; aCompId++ )
127 *aDataPtr++ = *theDataPtr++;
129 return myElemInfo[ 2 ]++;
133 //----------------------------------------------------------------------------------------------
137 myElnoDataMapper->InsertNextTupleValue( myElemInfo );
138 myElemInfo[ 0 ] += myElemInfo[ 2 ] * myElemInfo[ 1 ];
143 //----------------------------------------------------------------------------------------------
145 AddData( vtkDataSetAttributes* theDataSetAttributes )
147 theDataSetAttributes->AddArray( myElnoDataArray );
148 theDataSetAttributes->AddArray( myElnoDataMapper );
152 TVTKDataArray *myElnoDataArray;
153 vtkIntArray *myElnoDataMapper;
158 //---------------------------------------------------------------