2 // File: SMESH_Grid.cxx
3 // Created: Fri Sep 27 15:47:42 2002
4 // Author: Nicolas REJNERI
6 #include "SMESH_Grid.h"
11 #include <vtkObjectFactory.h>
13 SMESH_Grid* SMESH_Grid::New()
15 // First try to create the object from the vtkObjectFactory
16 vtkObject* ret = vtkObjectFactory::CreateInstance("SMESH_Grid");
19 return (SMESH_Grid*)ret;
21 // If the factory was unable to create the object, then create it here.
22 return new SMESH_Grid;
25 void SMESH_Grid::AddNode(int idSMESHDSnode,int idVTKnode)
27 myMapNodeSMDStoVTK.Bind(idSMESHDSnode, idVTKnode);
28 myMapNodeVTKtoSMDS.Bind(idVTKnode, idSMESHDSnode);
30 void SMESH_Grid::AddElement(int idSMESHDSelement, int idVTKelement)
32 myMapElementSMDStoVTK.Bind(idSMESHDSelement, idVTKelement);
33 myMapElementVTKtoSMDS.Bind(idVTKelement, idSMESHDSelement);
36 void SMESH_Grid::SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK)
38 myMapNodeVTKtoSMDS = mapVTK;
40 void SMESH_Grid::SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS)
42 myMapNodeSMDStoVTK = mapSMESHDS;
45 void SMESH_Grid::SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK)
47 myMapElementVTKtoSMDS = mapVTK;
49 void SMESH_Grid::SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS)
51 myMapElementSMDStoVTK = mapSMESHDS;
54 int SMESH_Grid::GetIdVTKNode(int idSMESHDSnode)
56 if ( myMapNodeSMDStoVTK.IsBound( idSMESHDSnode ) )
57 return myMapNodeSMDStoVTK.Find(idSMESHDSnode);
59 MESSAGE("GetIdVTKNode(): SMDS node not found: " << idSMESHDSnode);
63 int SMESH_Grid::GetIdVTKElement(int idSMESHDSelement)
65 if ( myMapElementSMDStoVTK.IsBound( idSMESHDSelement ) )
66 return myMapElementSMDStoVTK.Find(idSMESHDSelement);
68 MESSAGE("GetIdVTKElement(): SMDS element not found: " << idSMESHDSelement);
73 int SMESH_Grid::GetIdSMESHDSNode(int idVTKnode)
75 if ( myMapNodeVTKtoSMDS.IsBound( idVTKnode ) )
76 return myMapNodeVTKtoSMDS.Find(idVTKnode);
78 MESSAGE("GetIdSMESHDSNode(): VTK node not found: " << idVTKnode);
82 int SMESH_Grid::GetIdSMESHDSElement(int idVTKelement)
84 if ( myMapElementVTKtoSMDS.IsBound( idVTKelement ) )
85 return myMapElementVTKtoSMDS.Find(idVTKelement);
87 MESSAGE("GetIdSMESHDSElement(): VTK element not found: " << idVTKelement);
92 void SMESH_Grid::ClearNode()
94 myMapNodeVTKtoSMDS.Clear();
95 myMapNodeSMDStoVTK.Clear();
97 void SMESH_Grid::ClearElement()
99 myMapElementVTKtoSMDS.Clear();
100 myMapElementSMDStoVTK.Clear();
103 void SMESH_Grid::RemoveNode(int id)
105 if ( myMapNodeSMDStoVTK.IsBound( id ) ) {
106 int idVTK = myMapNodeSMDStoVTK.Find(id);
107 myMapNodeSMDStoVTK.UnBind(id);
108 if ( myMapNodeVTKtoSMDS.IsBound( idVTK ) ) {
109 myMapNodeVTKtoSMDS.UnBind(idVTK);
113 void SMESH_Grid::RemoveElement(int id)
115 if ( myMapElementSMDStoVTK.IsBound( id ) ) {
116 int idVTK = myMapElementSMDStoVTK.Find(id);
117 myMapElementSMDStoVTK.UnBind(id);
118 if ( myMapElementVTKtoSMDS.IsBound( idVTK ) ) {
119 myMapElementVTKtoSMDS.UnBind(idVTK);
124 void SMESH_Grid::DeepCopy(vtkDataObject *src)
126 SMESH_Grid* srcGrid = SMESH_Grid::SafeDownCast(src);
128 if (srcGrid != NULL) {
132 vtkUnstructuredGrid::DeepCopy(src);
135 void SMESH_Grid::CopyMaps(SMESH_Grid *srcGrid)
137 this->myMapNodeVTKtoSMDS = srcGrid->myMapNodeVTKtoSMDS;
138 this->myMapNodeSMDStoVTK = srcGrid->myMapNodeSMDStoVTK;
139 this->myMapElementVTKtoSMDS = srcGrid->myMapElementVTKtoSMDS;
140 this->myMapElementSMDStoVTK = srcGrid->myMapElementSMDStoVTK;