+ SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd);
+ aResult->length(iEnd);
+
+ SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter;
+ for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
+ {
+ const SMESH::Controls::MultiConnection2D::Value& aVal = (*anIter).first;
+ SMESH::MultiConnection2D::Value &aValue = aResult[ i ];
+
+ aValue.myPnt1 = aVal.myPntId[ 0 ];
+ aValue.myPnt2 = aVal.myPntId[ 1 ];
+ aValue.myNbConnects = (*anIter).second;
+ }
+
+ return aResult._retn();
+}
+
+/*
+ PREDICATES
+*/
+
+
+/*
+ Class : Predicate_i
+ Description : Base class for all predicates
+*/
+CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId )
+{
+ return myPredicatePtr->IsSatisfy( theId );
+}
+
+CORBA::Long Predicate_i::NbSatisfying( SMESH::SMESH_IDSource_ptr obj )
+{
+ SMESH::SMESH_Mesh_var meshVar = obj->GetMesh();
+ const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( meshVar );
+ if ( !meshDS )
+ return 0;
+ myPredicatePtr->SetMesh( meshDS );
+
+ SMDSAbs_ElementType elemType = SMDSAbs_ElementType( GetElementType() );
+
+ int nb = 0;
+ SMDS_ElemIteratorPtr elemIt =
+ SMESH::DownCast<SMESH_Mesh_i*>( meshVar )->GetElements( obj, GetElementType() );
+ if ( elemIt )
+ while ( elemIt->more() )
+ {
+ const SMDS_MeshElement* e = elemIt->next();
+ if ( e && e->GetType() == elemType )
+ nb += myPredicatePtr->IsSatisfy( e->GetID() );
+ }
+ return nb;
+}
+
+Controls::PredicatePtr Predicate_i::GetPredicate()
+{
+ return myPredicatePtr;
+}
+
+/*
+ Class : BadOrientedVolume_i
+ Description : Verify whether a mesh volume is incorrectly oriented from
+ the point of view of MED convention
+*/
+BadOrientedVolume_i::BadOrientedVolume_i()
+{
+ Controls::PredicatePtr control( new Controls::BadOrientedVolume() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType BadOrientedVolume_i::GetFunctorType()
+{
+ return SMESH::FT_BadOrientedVolume;
+}
+
+/*
+ Class : BareBorderVolume_i
+ Description : Verify whether a mesh volume has a free facet without a face on it
+*/
+BareBorderVolume_i::BareBorderVolume_i()
+{
+ Controls::PredicatePtr control( new Controls::BareBorderVolume() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType BareBorderVolume_i::GetFunctorType()
+{
+ return SMESH::FT_BareBorderVolume;
+}
+
+/*
+ Class : BareBorderFace_i
+ Description : Verify whether a mesh face has a free border without an edge on it
+*/
+BareBorderFace_i::BareBorderFace_i()
+{
+ Controls::PredicatePtr control( new Controls::BareBorderFace() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType BareBorderFace_i::GetFunctorType()
+{
+ return SMESH::FT_BareBorderFace;
+}
+
+/*
+ Class : OverConstrainedVolume_i
+ Description : Verify whether a mesh volume has only one facet shared with other volumes
+*/
+OverConstrainedVolume_i::OverConstrainedVolume_i()
+{
+ Controls::PredicatePtr control( new Controls::OverConstrainedVolume() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType OverConstrainedVolume_i::GetFunctorType()
+{
+ return SMESH::FT_OverConstrainedVolume;
+}
+
+/*
+ Class : OverConstrainedFace_i
+ Description : Verify whether a mesh face has only one border shared with other faces
+*/
+OverConstrainedFace_i::OverConstrainedFace_i()
+{
+ Controls::PredicatePtr control( new Controls::OverConstrainedFace() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType OverConstrainedFace_i::GetFunctorType()
+{
+ return SMESH::FT_OverConstrainedFace;
+}
+
+/*
+ Class : BelongToMeshGroup_i
+ Description : Verify whether a mesh element is included into a mesh group
+*/
+BelongToMeshGroup_i::BelongToMeshGroup_i()
+{
+ myBelongToMeshGroup = Controls::BelongToMeshGroupPtr( new Controls::BelongToMeshGroup() );
+ myFunctorPtr = myPredicatePtr = myBelongToMeshGroup;
+}
+
+BelongToMeshGroup_i::~BelongToMeshGroup_i()
+{
+ SetGroup( SMESH::SMESH_GroupBase::_nil() );
+}
+
+void BelongToMeshGroup_i::SetGroup( SMESH::SMESH_GroupBase_ptr theGroup )
+{
+ if ( myGroup->_is_equivalent( theGroup ))
+ return;
+
+ if ( ! myGroup->_is_nil() )
+ myGroup->UnRegister();
+
+ myGroup = SMESH_GroupBase::_duplicate( theGroup );
+
+ myBelongToMeshGroup->SetGroup( 0 );
+ if ( SMESH_GroupBase_i* gr_i = SMESH::DownCast< SMESH_GroupBase_i* >( myGroup ))
+ {
+ myBelongToMeshGroup->SetGroup( gr_i->GetGroupDS() );
+ myGroup->Register();
+ }
+}
+
+void BelongToMeshGroup_i::SetGroupID( const char* theID ) // IOR or StoreName
+{
+ myID = theID;
+ if ( strncmp( "IOR:", myID.c_str(), 4 ) == 0 ) // transient mode, no GUI
+ {
+ CORBA::Object_var obj = SMESH_Gen_i::GetORB()->string_to_object( myID.c_str() );
+ SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
+ }
+ else if ( strncmp( "0:", myID.c_str(), 2 ) == 0 ) // transient mode + GUI
+ {
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::Study_var aStudy = aSMESHGen->GetCurrentStudy();
+ if ( !aStudy->_is_nil() ) {
+ SALOMEDS::SObject_wrap aSObj = aStudy->FindObjectID( myID.c_str() );
+ if ( !aSObj->_is_nil() ) {
+ CORBA::Object_var obj = aSObj->GetObject();
+ SetGroup( SMESH::SMESH_GroupBase::_narrow( obj ));
+ }
+ }
+ }
+ else if ( !myID.empty() ) // persistent mode
+ {
+ myBelongToMeshGroup->SetStoreName( myID );
+ }
+}
+
+std::string BelongToMeshGroup_i::GetGroupID()
+{
+ if ( myGroup->_is_nil() )
+ SMESH::SMESH_GroupBase_var( GetGroup() );
+
+ if ( !myGroup->_is_nil() )
+ myID = SMESH_Gen_i::GetORB()->object_to_string( myGroup );
+
+ return myID;
+}
+
+SMESH::SMESH_GroupBase_ptr BelongToMeshGroup_i::GetGroup()
+{
+ if ( myGroup->_is_nil() && myBelongToMeshGroup->GetGroup() )
+ {
+ // search for a group in a current study
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ if ( StudyContext* sc = aSMESHGen->GetCurrentStudyContext() )
+ {
+ int id = 1;
+ std::string ior;
+ while (true)
+ {
+ ior = sc->getIORbyId( id++ );
+ if ( ior.empty() ) break;
+ CORBA::Object_var obj = aSMESHGen->GetORB()->string_to_object( ior.c_str() );
+ if ( SMESH_GroupBase_i* g_i = SMESH::DownCast<SMESH_GroupBase_i*>( obj ))
+ if ( g_i->GetGroupDS() == myBelongToMeshGroup->GetGroup() )
+ {
+ SetGroup( g_i->_this() );
+ break;
+ }
+ }
+ }
+ }
+ return SMESH::SMESH_GroupBase::_duplicate( myGroup );
+}
+
+FunctorType BelongToMeshGroup_i::GetFunctorType()
+{
+ return SMESH::FT_BelongToMeshGroup;
+}
+
+/*
+ Class : BelongToGeom_i
+ Description : Predicate for selection on geometrical support
+*/
+BelongToGeom_i::BelongToGeom_i()
+{
+ myBelongToGeomPtr.reset( new Controls::BelongToGeom() );
+ myFunctorPtr = myPredicatePtr = myBelongToGeomPtr;
+ myShapeName = 0;
+ myShapeID = 0;
+}
+
+BelongToGeom_i::~BelongToGeom_i()
+{
+ CORBA::string_free( myShapeName );
+ CORBA::string_free( myShapeID );
+}
+
+void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
+{
+ if ( theGeom->_is_nil() )
+ return;
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
+ TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
+ myBelongToGeomPtr->SetGeom( aLocShape );
+ TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
+}
+
+void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape )
+{
+ myBelongToGeomPtr->SetGeom( theShape );
+}
+
+void BelongToGeom_i::SetElementType(ElementType theType)
+{
+ myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType));
+ TPythonDump()<<this<<".SetElementType("<<theType<<")";
+}
+
+FunctorType BelongToGeom_i::GetFunctorType()
+{
+ return SMESH::FT_BelongToGeom;
+}
+
+void BelongToGeom_i::SetShapeName( const char* theName )
+{
+ CORBA::string_free( myShapeName );
+ myShapeName = CORBA::string_dup( theName );
+ myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
+ TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
+}
+
+void BelongToGeom_i::SetShape( const char* theID, const char* theName )
+{
+ CORBA::string_free( myShapeName );
+ CORBA::string_free( myShapeID );
+ myShapeName = CORBA::string_dup( theName );
+ myShapeID = CORBA::string_dup( theID );
+ bool hasName = ( theName && theName[0] );
+ bool hasID = ( theID && theID[0] );
+
+ TopoDS_Shape S;
+ if ( hasName && hasID )
+ {
+ S = getShapeByID( myShapeID );
+ if ( S.IsNull() )
+ S = getShapeByName( myShapeName );
+ }
+ else
+ {
+ S = hasID ? getShapeByID( myShapeID ) : getShapeByName( myShapeName );
+ }
+ myBelongToGeomPtr->SetGeom( S );
+}
+
+char* BelongToGeom_i::GetShapeName()
+{
+ return CORBA::string_dup( myShapeName );
+}
+
+char* BelongToGeom_i::GetShapeID()
+{
+ return CORBA::string_dup( myShapeID );
+}
+
+void BelongToGeom_i::SetTolerance( CORBA::Double theToler )
+{
+ myBelongToGeomPtr->SetTolerance( theToler );
+ TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
+}
+
+CORBA::Double BelongToGeom_i::GetTolerance()
+{
+ return myBelongToGeomPtr->GetTolerance();
+}
+
+/*
+ Class : BelongToSurface_i
+ Description : Predicate for selection on geometrical support
+*/
+BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceType )
+{
+ myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() );
+ myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr;
+ myShapeName = 0;
+ myShapeID = 0;
+ mySurfaceType = theSurfaceType;
+}
+
+BelongToSurface_i::~BelongToSurface_i()
+{
+ CORBA::string_free( myShapeName );
+ CORBA::string_free( myShapeID );
+}
+
+void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
+{
+ if ( theGeom->_is_nil() )
+ return;
+ SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
+ GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
+ TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
+
+ if ( aLocShape.ShapeType() == TopAbs_FACE )
+ {
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aLocShape ) );
+ if ( !aSurf.IsNull() && aSurf->DynamicType() == mySurfaceType )
+ {
+ myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
+ return;
+ }
+ }
+
+ myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType );
+}
+
+void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
+{
+ CORBA::string_free( myShapeName );
+ myShapeName = CORBA::string_dup( theName );
+ myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
+ TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
+}
+
+void BelongToSurface_i::SetShape( const char* theID, const char* theName, ElementType theType )
+{
+ CORBA::string_free( myShapeName );
+ CORBA::string_free( myShapeID );
+ myShapeName = CORBA::string_dup( theName );
+ myShapeID = CORBA::string_dup( theID );
+ bool hasName = ( theName && theName[0] );
+ bool hasID = ( theID && theID[0] );
+
+ TopoDS_Shape S;
+ if ( hasName && hasID )
+ {
+ S = getShapeByID( myShapeID );
+ if ( S.IsNull() )
+ S = getShapeByName( myShapeName );
+ }
+ else
+ {
+ S = hasID ? getShapeByID( myShapeID ) : getShapeByName( myShapeName );
+ }
+ myElementsOnSurfacePtr->SetSurface( S, (SMDSAbs_ElementType)theType );
+}
+
+char* BelongToSurface_i::GetShapeName()
+{
+ return CORBA::string_dup( myShapeName );
+}
+
+char* BelongToSurface_i::GetShapeID()
+{
+ return CORBA::string_dup( myShapeID );
+}
+
+void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
+{
+ myElementsOnSurfacePtr->SetTolerance( theToler );
+ TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
+}
+
+CORBA::Double BelongToSurface_i::GetTolerance()
+{
+ return myElementsOnSurfacePtr->GetTolerance();
+}
+
+void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions )
+{
+ myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions );
+ TPythonDump()<<this<<".SetUseBoundaries( " << theUseBndRestrictions << " )";
+}
+
+CORBA::Boolean BelongToSurface_i::GetUseBoundaries()
+{
+ return myElementsOnSurfacePtr->GetUseBoundaries();
+}
+
+
+/*
+ Class : BelongToPlane_i
+ Description : Verify whether mesh element lie in pointed Geom planar object
+*/