1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : VISU_ElnoMeshValue.hxx
23 // Author : Alexey PETROV
26 #ifndef VISU_ElnoMeshValue_HeaderFile
27 #define VISU_ElnoMeshValue_HeaderFile
29 #include "VISU_VTKTypeList.hxx"
30 #include <vtkDataSetAttributes.h>
34 \file VISU_ElnoMeshValue.hxx
35 \brief The file contains declarations for the acess to the specific ELNO MED data
40 //---------------------------------------------------------------
41 template< int elno_type >
42 struct TGetElnoNodeData
44 typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray;
45 typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType;
46 TVTKDataArray *myElnoDataArray;
47 vtkIntArray *myElnoDataMapper;
51 //----------------------------------------------------------------------------
52 TGetElnoNodeData( vtkDataArray *theElnoDataArray,
53 vtkDataArray *theElnoDataMapper )
54 : myElnoDataArray( TVTKDataArray::SafeDownCast( theElnoDataArray ) )
55 , myElnoDataMapper( vtkIntArray::SafeDownCast( theElnoDataMapper ) )
59 //----------------------------------------------------------------------------
61 operator () ( vtkIdType theCellId, vtkIdType theLocalPntId )
63 myElnoDataMapper->GetTupleValue( theCellId, myElemInfo );
65 vtkIdType aPos = myElemInfo[ 0 ] + theLocalPntId * myElemInfo[ 1 ];
67 return myElnoDataArray->GetPointer( aPos );
71 //----------------------------------------------------------------------------
75 myElnoDataMapper->GetTupleValue( 0, myElemInfo );
77 return myElemInfo[ 1 ];
82 //----------------------------------------------------------------------------------------------
83 template< int elno_type >
84 struct TSetElnoNodeData
86 typedef typename TL::TEnum2VTKArrayType< elno_type >::TResult TVTKDataArray;
87 typedef typename TL::TEnum2VTKBasicType< elno_type >::TResult TDataType;
89 //----------------------------------------------------------------------------------------------
90 TSetElnoNodeData( vtkIdType theEffectNbComp,
91 vtkIdType theRealNbComp,
92 vtkIdType theNbTuples,
93 const char* theDataArrayName,
94 const char* theMapperArrayName )
95 : myElnoDataArray( TVTKDataArray::New() )
96 , myElnoDataMapper( vtkIntArray::New() )
98 myElnoDataArray->SetNumberOfComponents( theEffectNbComp );
99 myElnoDataArray->SetNumberOfTuples( theNbTuples );
100 myElnoDataArray->SetName( theDataArrayName );
102 myElnoDataMapper->SetNumberOfComponents( 3 );
103 myElnoDataMapper->Allocate( theNbTuples * 3 );
104 myElnoDataMapper->SetName( theMapperArrayName );
107 myElemInfo[ 1 ] = theRealNbComp;
112 //----------------------------------------------------------------------------------------------
115 myElnoDataArray->Delete();
116 myElnoDataMapper->Delete();
120 //----------------------------------------------------------------------------------------------
122 AddNextPointData( TDataType* theDataPtr )
124 vtkIdType aPos = myElemInfo[ 0 ] + myElemInfo[ 2 ] * myElemInfo[ 1 ];
126 TDataType* aDataPtr = myElnoDataArray->GetPointer( aPos );
128 for ( vtkIdType aCompId = 0; aCompId < myElemInfo[ 1 ]; aCompId++ )
129 *aDataPtr++ = *theDataPtr++;
131 return myElemInfo[ 2 ]++;
135 //----------------------------------------------------------------------------------------------
139 myElnoDataMapper->InsertNextTupleValue( myElemInfo );
140 myElemInfo[ 0 ] += myElemInfo[ 2 ] * myElemInfo[ 1 ];
145 //----------------------------------------------------------------------------------------------
147 AddData( vtkDataSetAttributes* theDataSetAttributes )
149 theDataSetAttributes->AddArray( myElnoDataArray );
150 theDataSetAttributes->AddArray( myElnoDataMapper );
154 TVTKDataArray *myElnoDataArray;
155 vtkIntArray *myElnoDataMapper;
160 //---------------------------------------------------------------