2003-07-10 19:35:03 +06:00
|
|
|
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
|
|
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : SMESH_MeshEditor_i.cxx
|
|
|
|
// Author : Nicolas REJNERI
|
|
|
|
// Module : SMESH
|
2003-05-19 19:54:48 +06:00
|
|
|
// $Header$
|
|
|
|
|
2003-07-10 19:35:03 +06:00
|
|
|
using namespace std;
|
2003-05-19 19:54:48 +06:00
|
|
|
#include "SMESH_MeshEditor_i.hxx"
|
|
|
|
|
|
|
|
#include "SMDS_MeshEdge.hxx"
|
|
|
|
#include "SMDS_MeshFace.hxx"
|
|
|
|
#include "SMDS_MeshVolume.hxx"
|
|
|
|
|
|
|
|
#include "utilities.h"
|
|
|
|
|
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
|
|
|
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
2003-09-04 16:41:22 +06:00
|
|
|
SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESHDS_Mesh* theMesh)
|
|
|
|
{
|
|
|
|
_myMeshDS = theMesh;
|
2003-05-19 19:54:48 +06:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
2003-09-04 16:41:22 +06:00
|
|
|
CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH::
|
|
|
|
long_array & IDsOfElements)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < IDsOfElements.length(); i++)
|
|
|
|
{
|
|
|
|
CORBA::Long index = IDsOfElements[i];
|
2004-06-18 14:34:31 +06:00
|
|
|
const SMDS_MeshElement * elem = _myMeshDS->FindElement(index);
|
|
|
|
// an element may be removed as a result of preceding
|
|
|
|
// loop removal
|
|
|
|
if ( elem )
|
|
|
|
{
|
|
|
|
_myMeshDS->RemoveElement( elem );
|
|
|
|
MESSAGE("Element " << index << " was removed");
|
|
|
|
}
|
2003-09-04 16:41:22 +06:00
|
|
|
}
|
|
|
|
return true;
|
2003-05-19 19:54:48 +06:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
2003-09-04 16:41:22 +06:00
|
|
|
CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::
|
|
|
|
long_array & IDsOfNodes)
|
|
|
|
{
|
|
|
|
// It's nodes' turn to die
|
|
|
|
for (int i = 0; i < IDsOfNodes.length(); i++)
|
|
|
|
{
|
|
|
|
const SMDS_MeshNode * node=_myMeshDS->FindNode(IDsOfNodes[i]);
|
|
|
|
if(node==NULL)
|
|
|
|
{
|
|
|
|
MESSAGE("SMESH_MeshEditor_i::RemoveNodes: Node "<<IDsOfNodes[i]
|
|
|
|
<<" not found");
|
|
|
|
continue;
|
|
|
|
}
|
2003-09-05 16:31:32 +06:00
|
|
|
_myMeshDS->RemoveNode(node);
|
|
|
|
MESSAGE("Node " << IDsOfNodes[i] << " was removed")
|
2003-05-19 19:54:48 +06:00
|
|
|
}
|
2003-09-04 16:41:22 +06:00
|
|
|
return true;
|
2003-05-19 19:54:48 +06:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
2003-09-04 16:41:22 +06:00
|
|
|
CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes)
|
|
|
|
{
|
|
|
|
int NbNodes = IDsOfNodes.length();
|
|
|
|
if (NbNodes == 2)
|
|
|
|
{
|
|
|
|
CORBA::Long index1 = IDsOfNodes[0];
|
|
|
|
CORBA::Long index2 = IDsOfNodes[1];
|
2003-09-05 16:31:32 +06:00
|
|
|
_myMeshDS->AddEdge(_myMeshDS->FindNode(index1), _myMeshDS->FindNode(index2));
|
2003-09-04 16:41:22 +06:00
|
|
|
}
|
|
|
|
return true;
|
2003-05-19 19:54:48 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x,
|
2003-09-04 16:41:22 +06:00
|
|
|
CORBA::Double y, CORBA::Double z)
|
|
|
|
{
|
|
|
|
MESSAGE(" AddNode " << x << " , " << y << " , " << z)
|
|
|
|
int idNode = _myMeshDS->AddNode(x, y, z)->GetID();
|
|
|
|
MESSAGE(" idNode " << idNode) return true;
|
2003-05-19 19:54:48 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
2003-09-04 16:41:22 +06:00
|
|
|
CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes)
|
|
|
|
{
|
|
|
|
int NbNodes = IDsOfNodes.length();
|
2003-09-05 16:31:32 +06:00
|
|
|
const SMDS_MeshNode* nodes[4];
|
|
|
|
for(int i=0;i<NbNodes;i++) nodes[i]=_myMeshDS->FindNode(IDsOfNodes[i]);
|
2003-09-04 16:41:22 +06:00
|
|
|
if (NbNodes == 3)
|
|
|
|
{
|
2003-09-05 16:31:32 +06:00
|
|
|
_myMeshDS->AddFace(nodes[0], nodes[1], nodes[2]);
|
2003-09-04 16:41:22 +06:00
|
|
|
}
|
|
|
|
else if (NbNodes == 4)
|
|
|
|
{
|
2003-09-05 16:31:32 +06:00
|
|
|
_myMeshDS->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]);
|
2003-09-04 16:41:22 +06:00
|
|
|
}
|
|
|
|
return true;
|
2003-05-19 19:54:48 +06:00
|
|
|
};
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
|
2003-09-04 16:41:22 +06:00
|
|
|
CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH::
|
|
|
|
long_array & IDsOfNodes)
|
|
|
|
{
|
|
|
|
int NbNodes = IDsOfNodes.length();
|
2003-09-05 16:31:32 +06:00
|
|
|
const SMDS_MeshNode* n[8];
|
|
|
|
for(int i=0;i<NbNodes;i++) n[i]=_myMeshDS->FindNode(IDsOfNodes[i]);
|
|
|
|
|
|
|
|
switch(NbNodes)
|
2003-09-04 16:41:22 +06:00
|
|
|
{
|
2003-09-05 16:31:32 +06:00
|
|
|
case 4:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3]); break;
|
|
|
|
case 5:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4]); break;
|
|
|
|
case 6:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break;
|
|
|
|
case 8:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break;
|
2003-09-04 16:41:22 +06:00
|
|
|
}
|
|
|
|
return true;
|
2003-05-19 19:54:48 +06:00
|
|
|
};
|