// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
// File : SMESH_Gen_i_1.cxx
#include "SMESH_Algo_i.hxx"
#include "SMESH_Group_i.hxx"
+#include "SMESH.hxx"
+
#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
#include "utilities.h"
static int MYDEBUG = 0;
#endif
-// Tags definition ===========================================================
-// Top level
-long Tag_HypothesisRoot = 1; // hypotheses root
-long Tag_AlgorithmsRoot = 2; // algorithms root
-// Mesh/Submesh
-long Tag_RefOnShape = 1; // references to shape
-long Tag_RefOnAppliedHypothesis = 2; // applied hypotheses root
-long Tag_RefOnAppliedAlgorithms = 3; // applied algorithms root
-// Mesh only
-long Tag_SubMeshOnVertex = 4; // sub-meshes roots by type
-long Tag_SubMeshOnEdge = 5; // ...
-long Tag_SubMeshOnWire = 6; // ...
-long Tag_SubMeshOnFace = 7; // ...
-long Tag_SubMeshOnShell = 8; // ...
-long Tag_SubMeshOnSolid = 9; // ...
-long Tag_SubMeshOnCompound = 10; // ...
-long Tag_NodeGroups = 11; // Group roots by type
-long Tag_EdgeGroups = 12; // ...
-long Tag_FaceGroups = 13; // ...
-long Tag_VolumeGroups = 14; // ...
-// ===========================================================================
-
//=============================================================================
/*!
* Get...Tag [ static ]
bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
{
- if(MYDEBUG) MESSAGE("CanPublishInStudy");
+ if(MYDEBUG) MESSAGE("CanPublishInStudy - "<<!CORBA::is_nil(myCurrentStudy));
+ if(CORBA::is_nil(myCurrentStudy))
+ return false;
+
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(theIOR);
if( !aMesh->_is_nil() )
return true;
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
SALOMEDS::SObject_var aReferenceSO;
if ( !theTag ) {
+ // check if the reference to theToObject already exists
+ // and find a free label for the reference object
bool isReferred = false;
+ int tag = 1;
SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator( theSObject );
- for ( ; !isReferred && anIter->More(); anIter->Next() ) {
- if ( anIter->Value()->ReferencedObject( aReferenceSO ) &&
- strcmp( aReferenceSO->GetID(), aToObjSO->GetID() ) == 0 )
- isReferred = true;
+ for ( ; !isReferred && anIter->More(); anIter->Next(), ++tag ) {
+ if ( anIter->Value()->ReferencedObject( aReferenceSO )) {
+ if ( strcmp( aReferenceSO->GetID(), aToObjSO->GetID() ) == 0 )
+ isReferred = true;
+ }
+ else if ( !theTag ) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if ( !anIter->Value()->FindAttribute( anAttr, "AttributeIOR" ))
+ theTag = tag;
+ }
}
- if ( !isReferred ) {
- aReferenceSO = aStudyBuilder->NewObject( theSObject );
- aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
- }
- }
- else {
- if ( !theSObject->FindSubObject( theTag, aReferenceSO ))
- aReferenceSO = aStudyBuilder->NewObjectToTag( theSObject, theTag );
- aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
+ if ( isReferred )
+ return;
+ if ( !theTag )
+ theTag = tag;
}
+ if ( !theSObject->FindSubObject( theTag, aReferenceSO ))
+ aReferenceSO = aStudyBuilder->NewObjectToTag( theSObject, theTag );
+ aStudyBuilder->Addreference( aReferenceSO, aToObjSO );
}
}
else
aTag++;
- aMeshSO = publish (theStudy, theMesh, father, aTag, "ICON_SMESH_TREE_MESH" );
+ aMeshSO = publish (theStudy, theMesh, father, aTag, "ICON_SMESH_TREE_MESH_WARN" );
if ( aMeshSO->_is_nil() )
return aMeshSO._retn();
}
SetName( aRootSO, aRootName );
// Add new submesh to corresponding sub-tree
- aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, "ICON_SMESH_TREE_MESH");
+ aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, "ICON_SMESH_TREE_MESH_WARN");
if ( aSubMeshSO->_is_nil() )
return aSubMeshSO._retn();
}
SALOMEDS::SObject_var aMeshOrSubMesh =
GetMeshOrSubmeshByShape( theStudy, theMesh, theShape );
if ( aMeshOrSubMesh->_is_nil() )
- return false;
+ {
+ // publish submesh
+ TopoDS_Shape aShape = GeomObjectToShape( theShape );
+ SMESH_Mesh_i* mesh_i = objectToServant<SMESH_Mesh_i>( theMesh );
+ if ( !aShape.IsNull() && mesh_i && mesh_i->GetImpl().GetMeshDS() ) {
+ SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS();
+ int shapeID = meshDS->ShapeToIndex( aShape );
+ SMESH::SMESH_subMesh_var aSubMesh = mesh_i->getSubMesh(shapeID);
+ aMeshOrSubMesh = PublishSubMesh( theStudy, theMesh, aSubMesh, theShape );
+ }
+ if ( aMeshOrSubMesh->_is_nil() )
+ return false;
+ }
//Find or Create Applied Hypothesis root
bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( theHyp )->_is_nil();