-void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName){
- vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
- aWriter->SetFileName(theFileName);
- aWriter->SetInput(theGrid);
- aWriter->Write();
- aWriter->Delete();
-}
-
-
-namespace{
-
- inline const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, int theId){
- if(const SMDS_MeshNode* anElem = theMesh->FindNode(theId)) return anElem;
- EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<<theId);
- }
-
-
- inline const SMDS_MeshElement* FindElement(const SMDS_Mesh* theMesh, int theId){
- if(const SMDS_MeshElement* anElem = theMesh->FindElement(theId)) return anElem;
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot find a SMDS_MeshElement for ID = "<<theId);
- }
-
-
- inline void AddNodesWithID(SMDS_Mesh* theMesh,
- SMESH::log_array_var& theSeq,
- CORBA::Long theId)
- {
- const SMESH::double_array& aCoords = theSeq[theId].coords;
- const SMESH::long_array& anIndexes = theSeq[theId].indexes;
- CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
- if(3*aNbElems != aCoords.length())
- EXCEPTION(runtime_error,"AddNodesWithID - 3*aNbElems != aCoords.length()");
- for(CORBA::Long aCoordId = 0; anElemId < aNbElems; anElemId++, aCoordId+=3){
- SMDS_MeshElement* anElem = theMesh->AddNodeWithID(aCoords[aCoordId],
- aCoords[aCoordId+1],
- aCoords[aCoordId+2],
- anIndexes[anElemId]);
- if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddNodeWithID for ID = "<<anElemId);
- }
- }
-
-
- inline void AddEdgesWithID(SMDS_Mesh* theMesh,
- SMESH::log_array_var& theSeq,
- CORBA::Long theId)
- {
- const SMESH::double_array& aCoords = theSeq[theId].coords;
- const SMESH::long_array& anIndexes = theSeq[theId].indexes;
- CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
- if(3*aNbElems != anIndexes.length())
- EXCEPTION(runtime_error,"AddEdgeWithID - 3*aNbElems != aCoords.length()");
- for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=3){
- SMDS_MeshElement* anElem = theMesh->AddEdgeWithID(anIndexes[anIndexId+1],
- anIndexes[anIndexId+2],
- anIndexes[anIndexId]);
- if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddEdgeWithID for ID = "<<anElemId);
- }
- }
-
-
- inline void AddTriasWithID(SMDS_Mesh* theMesh,
- SMESH::log_array_var& theSeq,
- CORBA::Long theId)
- {
- const SMESH::double_array& aCoords = theSeq[theId].coords;
- const SMESH::long_array& anIndexes = theSeq[theId].indexes;
- CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
- if(4*aNbElems != anIndexes.length())
- EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
- for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=4){
- SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
- anIndexes[anIndexId+2],
- anIndexes[anIndexId+3],
- anIndexes[anIndexId]);
- if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
- }
- }
-
-
- inline void AddQuadsWithID(SMDS_Mesh* theMesh,
- SMESH::log_array_var theSeq,
- CORBA::Long theId)
- {
- const SMESH::double_array& aCoords = theSeq[theId].coords;
- const SMESH::long_array& anIndexes = theSeq[theId].indexes;
- CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
- if(5*aNbElems != anIndexes.length())
- EXCEPTION(runtime_error,"AddEdgeWithID - 4*aNbElems != anIndexes.length()");
- for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
- SMDS_MeshElement* anElem = theMesh->AddFaceWithID(anIndexes[anIndexId+1],
- anIndexes[anIndexId+2],
- anIndexes[anIndexId+3],
- anIndexes[anIndexId+4],
- anIndexes[anIndexId]);
- if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
- }
- }
-
-
- inline void AddTetrasWithID(SMDS_Mesh* theMesh,
- SMESH::log_array_var& theSeq,
- CORBA::Long theId)
- {
- const SMESH::double_array& aCoords = theSeq[theId].coords;
- const SMESH::long_array& anIndexes = theSeq[theId].indexes;
- CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
- if(5*aNbElems != anIndexes.length())
- EXCEPTION(runtime_error,"AddEdgeWithID - 5*aNbElems != anIndexes.length()");
- for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=5){
- SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
- anIndexes[anIndexId+2],
- anIndexes[anIndexId+3],
- anIndexes[anIndexId+4],
- anIndexes[anIndexId]);
- if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
- }
- }
-
-
- inline void AddPiramidsWithID(SMDS_Mesh* theMesh,
- SMESH::log_array_var& theSeq,
- CORBA::Long theId)
- {
- const SMESH::double_array& aCoords = theSeq[theId].coords;
- const SMESH::long_array& anIndexes = theSeq[theId].indexes;
- CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
- if(6*aNbElems != anIndexes.length())
- EXCEPTION(runtime_error,"AddEdgeWithID - 6*aNbElems != anIndexes.length()");
- for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=6){
- SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
- anIndexes[anIndexId+2],
- anIndexes[anIndexId+3],
- anIndexes[anIndexId+4],
- anIndexes[anIndexId+5],
- anIndexes[anIndexId]);
- if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
- }
- }
-
-
- inline void AddPrismsWithID(SMDS_Mesh* theMesh,
- SMESH::log_array_var& theSeq,
- CORBA::Long theId)
- {
- const SMESH::double_array& aCoords = theSeq[theId].coords;
- const SMESH::long_array& anIndexes = theSeq[theId].indexes;
- CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
- if(7*aNbElems != anIndexes.length())
- EXCEPTION(runtime_error,"AddEdgeWithID - 7*aNbElems != anIndexes.length()");
- for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=7){
- SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
- anIndexes[anIndexId+2],
- anIndexes[anIndexId+3],
- anIndexes[anIndexId+4],
- anIndexes[anIndexId+5],
- anIndexes[anIndexId+6],
- anIndexes[anIndexId]);
- if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
- }
- }
-
-
- inline void AddHexasWithID(SMDS_Mesh* theMesh,
- SMESH::log_array_var& theSeq,
- CORBA::Long theId)
- {
- const SMESH::double_array& aCoords = theSeq[theId].coords;
- const SMESH::long_array& anIndexes = theSeq[theId].indexes;
- CORBA::Long anElemId = 0, aNbElems = theSeq[theId].number;
- if(9*aNbElems != anIndexes.length())
- EXCEPTION(runtime_error,"AddEdgeWithID - 9*aNbElems != anIndexes.length()");
- for(CORBA::Long anIndexId = 0; anElemId < aNbElems; anElemId++, anIndexId+=9){
- SMDS_MeshElement* anElem = theMesh->AddVolumeWithID(anIndexes[anIndexId+1],
- anIndexes[anIndexId+2],
- anIndexes[anIndexId+3],
- anIndexes[anIndexId+4],
- anIndexes[anIndexId+5],
- anIndexes[anIndexId+6],
- anIndexes[anIndexId+7],
- anIndexes[anIndexId+8],
- anIndexes[anIndexId]);
- if(!anElem)
- EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId);
- }
- }
-
-
-}