#include CORBA_SERVER_HEADER(SMESH_Group)
#include CORBA_SERVER_HEADER(SMESH_Filter)
+#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
#include "DriverMED_W_SMESHDS_Mesh.h"
#include "DriverMED_R_SMESHDS_Mesh.h"
errStruct.subShapeID = sm->GetId();
SALOMEDS::SObject_var algoSO = GetAlgoSO( error->myAlgo );
if ( !algoSO->_is_nil() )
- errStruct.algoName = algoSO->GetName();
+ errStruct.algoName = algoSO->GetName();
else
- errStruct.algoName = error->myAlgo->GetName();
+ errStruct.algoName = error->myAlgo->GetName();
+ errStruct.hasBadMesh = !error->myBadElements.empty();
}
}
error_array->length( nbErr );
return error_array._retn();
}
+//
+//================================================================================
+/*!
+ * \brief Return mesh elements preventing computation of a subshape
+ */
+//================================================================================
+
+SMESH::MeshPreviewStruct*
+SMESH_Gen_i::GetBadInputElements( SMESH::SMESH_Mesh_ptr theMesh,
+ CORBA::Short theSubShapeID )
+ throw ( SALOME::SALOME_Exception )
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetBadInputElements()" );
+
+ if ( CORBA::is_nil( theMesh ) )
+ THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference",SALOME::BAD_PARAM );
+
+ SMESH::MeshPreviewStruct_var result = new SMESH::MeshPreviewStruct;
+ try {
+ // mesh servant
+ if ( SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh ))
+ {
+ // mesh implementation
+ ::SMESH_Mesh& mesh = meshServant->GetImpl();
+ // submesh by subshape id
+ if ( SMESH_subMesh * sm = mesh.GetSubMeshContaining( theSubShapeID ))
+ {
+ // compute error
+ SMESH_ComputeErrorPtr error = sm->GetComputeError();
+ if ( error && !error->myBadElements.empty())
+ {
+ typedef map<const SMDS_MeshElement*, int > TNode2LocalIDMap;
+ typedef TNode2LocalIDMap::iterator TNodeLocalID;
+
+ // get nodes of elements and count elements
+ TNode2LocalIDMap mapNode2LocalID;
+ list< TNodeLocalID > connectivity;
+ int i, nbElements = 0, nbConnNodes = 0;
+
+ list<const SMDS_MeshElement*>::iterator elemIt = error->myBadElements.begin();
+ list<const SMDS_MeshElement*>::iterator elemEnd = error->myBadElements.end();
+ for ( ; elemIt != elemEnd; ++elemIt, ++nbElements )
+ {
+ SMDS_ElemIteratorPtr nIt = (*elemIt)->nodesIterator();
+ while ( nIt->more() )
+ connectivity.push_back
+ ( mapNode2LocalID.insert( make_pair( nIt->next(), ++nbConnNodes)).first );
+ }
+ // fill node coords and assign local ids to the nodes
+ int nbNodes = mapNode2LocalID.size();
+ result->nodesXYZ.length( nbNodes );
+ TNodeLocalID node2ID = mapNode2LocalID.begin();
+ for ( i = 0; i < nbNodes; ++i, ++node2ID ) {
+ node2ID->second = i;
+ const SMDS_MeshNode* node = (const SMDS_MeshNode*) node2ID->first;
+ result->nodesXYZ[i].x = node->X();
+ result->nodesXYZ[i].y = node->Y();
+ result->nodesXYZ[i].z = node->Z();
+ }
+ // fill connectivity
+ result->elementConnectivities.length( nbConnNodes );
+ list< TNodeLocalID >::iterator connIt = connectivity.begin();
+ for ( i = 0; i < nbConnNodes; ++i, ++connIt ) {
+ result->elementConnectivities[i] = (*connIt)->second;
+ }
+ // fill element types
+ result->elementTypes.length( nbElements );
+ for ( i = 0, elemIt = error->myBadElements.begin(); i <nbElements; ++i, ++elemIt )
+ {
+ const SMDS_MeshElement* elem = *elemIt;
+ result->elementTypes[i].SMDS_ElementType = (SMESH::ElementType) elem->GetType();
+ result->elementTypes[i].isPoly = elem->IsPoly();
+ result->elementTypes[i].nbNodesInElement = elem->NbNodes();
+ }
+ }
+ }
+ }
+ }
+ catch ( SALOME_Exception& S_ex ) {
+ INFOS( "catch exception "<< S_ex.what() );
+ }
+
+ return result._retn();
+}
+
//================================================================================
/*!
* \brief Returns errors of hypotheses definintion
- * \param theMesh - the mesh
- * \param theSubObject - the main or sub- shape
- * \retval SMESH::algo_error_array* - sequence of errors
+ * \param theMesh - the mesh
+ * \param theSubObject - the main or sub- shape
+ * \retval SMESH::algo_error_array* - sequence of errors
*/
//================================================================================
CORBA::Boolean theMergeNodesAndElements,
CORBA::Double theMergeTolerance)
throw ( SALOME::SALOME_Exception )
+{
+ return ConcatenateCommon(theMeshesArray,
+ theUniteIdenticalGroups,
+ theMergeNodesAndElements,
+ theMergeTolerance,
+ false);
+}
+
+//================================================================================
+/*!
+ * SMESH_Gen_i::ConcatenateWithGroups
+ *
+ * Concatenate the given meshes into one mesh
+ * Create the groups of all elements from initial meshes
+ */
+//================================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_Gen_i::ConcatenateWithGroups(const SMESH::mesh_array& theMeshesArray,
+ CORBA::Boolean theUniteIdenticalGroups,
+ CORBA::Boolean theMergeNodesAndElements,
+ CORBA::Double theMergeTolerance)
+ throw ( SALOME::SALOME_Exception )
+{
+ return ConcatenateCommon(theMeshesArray,
+ theUniteIdenticalGroups,
+ theMergeNodesAndElements,
+ theMergeTolerance,
+ true);
+}
+
+//================================================================================
+/*!
+ * SMESH_Gen_i::ConcatenateCommon
+ *
+ * Concatenate the given meshes into one mesh
+ */
+//================================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_Gen_i::ConcatenateCommon(const SMESH::mesh_array& theMeshesArray,
+ CORBA::Boolean theUniteIdenticalGroups,
+ CORBA::Boolean theMergeNodesAndElements,
+ CORBA::Double theMergeTolerance,
+ CORBA::Boolean theCommonGroups)
+ throw ( SALOME::SALOME_Exception )
{
typedef map<int, int> TIDsMap;
typedef list<SMESH::SMESH_Group_var> TListOfNewGroups;
const SMDS_MeshElement* aNewElem = 0;
int anElemNbNodes = 0;
+ int anNbNodes = 0;
+ int anNbEdges = 0;
+ int anNbFaces = 0;
+ int anNbVolumes = 0;
+
+ SMESH::long_array_var anIDsNodes = new SMESH::long_array();
+ SMESH::long_array_var anIDsEdges = new SMESH::long_array();
+ SMESH::long_array_var anIDsFaces = new SMESH::long_array();
+ SMESH::long_array_var anIDsVolumes = new SMESH::long_array();
+
+ if( theCommonGroups ) {
+ anIDsNodes->length( anInitMeshDS->NbNodes() );
+ anIDsEdges->length( anInitMeshDS->NbEdges() );
+ anIDsFaces->length( anInitMeshDS->NbFaces() );
+ anIDsVolumes->length( anInitMeshDS->NbVolumes() );
+ }
+
for ( int j = 0; itElems->more(); j++) {
anElem = itElems->next();
SMDSAbs_ElementType anElemType = anElem->GetType();
if ( nodesMap.find(aNode->GetID()) == nodesMap.end() ) {
aNewNode = aNewMeshDS->AddNode(aNode->X(), aNode->Y(), aNode->Z());
nodesMap.insert( make_pair(aNode->GetID(), aNewNode->GetID()) );
+ if( theCommonGroups )
+ anIDsNodes[anNbNodes++] = aNewNode->GetID();
}
else
aNewNode = aNewMeshDS->FindNode( nodesMap.find(aNode->GetID())->second );
aNewElem = aNewMeshDS->AddPolyhedralVolume(aNodesArray,
aVolume->GetQuanities());
elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
+ if( theCommonGroups )
+ anIDsVolumes[anNbVolumes++] = aNewElem->GetID();
}
}
else {
anElemType,
anElem->IsPoly());
elemsMap.insert(make_pair(anElem->GetID(), aNewElem->GetID()));
+ if( theCommonGroups ) {
+ if( anElemType == SMDSAbs_Edge )
+ anIDsEdges[anNbEdges++] = aNewElem->GetID();
+ else if( anElemType == SMDSAbs_Face )
+ anIDsFaces[anNbFaces++] = aNewElem->GetID();
+ else if( anElemType == SMDSAbs_Volume )
+ anIDsVolumes[anNbVolumes++] = aNewElem->GetID();
+ }
}
}//elems loop
SMESH::long_array_var anInitIDs = new SMESH::long_array();
SMESH::long_array_var anNewIDs = new SMESH::long_array();
SMESH::SMESH_Group_var aNewGroup;
+
+ SMESH::ElementType aGroupType;
+ CORBA::String_var aGroupName;
+ if ( theCommonGroups ) {
+ for(aGroupType=SMESH::NODE;aGroupType<=SMESH::VOLUME;aGroupType=(SMESH::ElementType)(aGroupType+1)) {
+ string str = "Gr";
+ SALOMEDS::SObject_var aMeshSObj = ObjectToSObject( myCurrentStudy, anInitMesh );
+ if(aMeshSObj)
+ str += aMeshSObj->GetName();
+ str += "_";
+
+ int anLen = 0;
+
+ switch(aGroupType) {
+ case SMESH::NODE:
+ str += "Nodes";
+ anIDsNodes->length(anNbNodes);
+ anLen = anNbNodes;
+ break;
+ case SMESH::EDGE:
+ str += "Edges";
+ anIDsEdges->length(anNbEdges);
+ anLen = anNbEdges;
+ break;
+ case SMESH::FACE:
+ str += "Faces";
+ anIDsFaces->length(anNbFaces);
+ anLen = anNbFaces;
+ break;
+ case SMESH::VOLUME:
+ str += "Volumes";
+ anIDsVolumes->length(anNbVolumes);
+ anLen = anNbVolumes;
+ break;
+ default:
+ break;
+ }
+
+ if(anLen) {
+ aGroupName = str.c_str();
+
+ // add a new group in the mesh
+ aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName);
+
+ switch(aGroupType) {
+ case SMESH::NODE:
+ aNewGroup->Add( anIDsNodes );
+ break;
+ case SMESH::EDGE:
+ aNewGroup->Add( anIDsEdges );
+ break;
+ case SMESH::FACE:
+ aNewGroup->Add( anIDsFaces );
+ break;
+ case SMESH::VOLUME:
+ aNewGroup->Add( anIDsVolumes );
+ break;
+ default:
+ break;
+ }
+
+ aListOfNewGroups.clear();
+ aListOfNewGroups.push_back(aNewGroup);
+ aGroupsMap.insert(make_pair( make_pair(aGroupName, aGroupType), aListOfNewGroups ));
+ }
+ }
+ }
+
+ // check that current group name and type don't have identical ones in union mesh
for (int i = 0; i < aListOfGroups->length(); i++) {
aGroup = aListOfGroups[i];
aListOfNewGroups.clear();
- SMESH::ElementType aGroupType = aGroup->GetType();
- CORBA::String_var aGroupName = aGroup->GetName();
-
+ aGroupType = aGroup->GetType();
+ aGroupName = aGroup->GetName();
+
TGroupsMap::iterator anIter = aGroupsMap.find(make_pair(aGroupName, aGroupType));
// convert a list of IDs
}
// Update Python script
- aPythonDump << aNewMesh << " = " << this << ".Concatenate(";
+ aPythonDump << aNewMesh << " = " << this;
+ if( !theCommonGroups )
+ aPythonDump << ".Concatenate(";
+ else
+ aPythonDump << ".ConcatenateWithGroups(";
aPythonDump << "[";
for ( int i = 0; i < theMeshesArray.length(); i++) {
if (i > 0) aPythonDump << ", ";
}
aPythonDump << "], ";
aPythonDump << theUniteIdenticalGroups << ", "
- << theMergeNodesAndElements << ", "
+ << theMergeNodesAndElements << ", "
<< theMergeTolerance << ")";
return aNewMesh._retn();
// Write data
// ---> create HDF file
- aFile = new HDFfile( filename.ToCString() );
+ aFile = new HDFfile( (char*) filename.ToCString() );
aFile->CreateOnDisk();
// --> iterator for top-level objects
// Read data
// ---> open HDF file
- aFile = new HDFfile( filename.ToCString() );
+ aFile = new HDFfile( (char*) filename.ToCString() );
try {
aFile->OpenOnDisk( HDF_RDONLY );
}