X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Filter_i.cxx;h=bfb52b21802a22e640e09a1d0ed9d5beb3f3811f;hp=38922a53782d1a5e911b82e815c3ff8faed3b352;hb=79b1ac2b6df9117f16f11d444b1f165d477a1813;hpb=57b43b4d010e2d0a1529d3c131bbb9d416e63258 diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 38922a537..bfb52b218 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -17,7 +17,7 @@ // 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 // // // @@ -37,29 +37,27 @@ #include "SMESHDS_Mesh.hxx" +#include +#include +#include +#include +#include #include #include #include -#include -#include #include -#include +#include #include +#include #include #include -#include #include -#include -#include -#include -#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include +#include using namespace SMESH; using namespace SMESH::Controls; @@ -386,7 +384,7 @@ static TopoDS_Shape getShapeByName( const char* theName ) GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() ); if ( !aGeomObj->_is_nil() ) { - GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine(); + GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine(); TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj ); return aLocShape; } @@ -396,48 +394,49 @@ static TopoDS_Shape getShapeByName( const char* theName ) return TopoDS_Shape(); } -static TopoDS_Shape getShapeByID( const char* theID ) +static TopoDS_Shape getShapeByID (const char* theID) { - if ( theID != 0 && theID!="" ) - { + if (theID != 0 && theID != "") { SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); - if ( aStudy != 0 ) - { - CORBA::Object_var obj = aStudy->ConvertIORToObject(theID); - GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( obj ); + if (aStudy != 0) { + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID); + SALOMEDS::GenericAttribute_var anAttr; + if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aVal = anIOR->Value(); + CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal); + GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj); - if ( !aGeomObj->_is_nil() ) - { - GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine(); + if (!aGeomObj->_is_nil()) { + GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine(); TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj ); return aLocShape; } + } } } return TopoDS_Shape(); } -static char* getShapeNameByID ( const char* theID ) +static char* getShapeNameByID (const char* theID) { char* aName = ""; - if ( theID != 0 && theID!="" ) - { - SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); - if ( aStudy != 0 ) - { - SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( theID ); - SALOMEDS::GenericAttribute_var anAttr; - if ( !aSObj->_is_nil() && aSObj->FindAttribute( anAttr, "AttributeName") ) - { - SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr ); - aName = aNameAttr->Value(); - } - } + if (theID != 0 && theID != "") { + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); + if (aStudy != 0) { + //SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( theID ); + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID); + SALOMEDS::GenericAttribute_var anAttr; + if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeName")) { + SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr); + aName = aNameAttr->Value(); + } } - + } + return aName; } @@ -452,13 +451,14 @@ static char* getShapeNameByID ( const char* theID ) Functor_i::Functor_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) { - PortableServer::ObjectId_var anObjectId = - SMESH_Gen_i::GetPOA()->activate_object( this ); + //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method + //PortableServer::ObjectId_var anObjectId = + // SMESH_Gen_i::GetPOA()->activate_object( this ); } Functor_i::~Functor_i() { - TPythonDump()<_is_nil() ) return; SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine(); + GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine(); TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom ); myBelongToGeomPtr->SetGeom( aLocShape ); TPythonDump()<_is_nil() ) return; SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine(); + GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine(); TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom ); if ( aLocShape.ShapeType() == TopAbs_FACE ) @@ -885,7 +885,6 @@ void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType t } myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType ); - TPythonDump()<GetTolerance(); } +void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions ) +{ + myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions ); + TPythonDump()<GetUseBoundaries(); +} + + /* Class : BelongToPlane_i Description : Verify whether mesh element lie in pointed Geom planar object @@ -975,6 +986,33 @@ FunctorType BelongToCylinder_i::GetFunctorType() return FT_BelongToCylinder; } +/* + Class : BelongToGenSurface_i + Description : Verify whether mesh element lie in pointed Geom planar object +*/ + +BelongToGenSurface_i::BelongToGenSurface_i() +: BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) ) +{ +} + +void BelongToGenSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) +{ + if ( theGeom->_is_nil() ) + return; + TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); + if ( !aLocShape.IsNull() && aLocShape.ShapeType() != TopAbs_FACE ) + aLocShape.Nullify(); + + BelongToSurface_i::myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType ); + TPythonDump()<_is_nil() ) return; SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); - GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine(); + GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine(); TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom ); myLyingOnGeomPtr->SetGeom( aLocShape ); TPythonDump()<activate_object( this ); + //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method + //PortableServer::ObjectId_var anObjectId = + // SMESH_Gen_i::GetPOA()->activate_object( this ); } FilterManager_i::~FilterManager_i() { - TPythonDump()<_this(); + TPythonDump()<Destroy(); - TPythonDump()<GetPredicate(),theSequence); + if (thePredicate) + Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence); } void @@ -1793,8 +1841,9 @@ GetElementsId( Predicate_i* thePredicate, SMESH_Mesh_ptr theMesh, Controls::Filter::TIdSequence& theSequence ) { - if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh)) - Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence); + if (thePredicate) + if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh)) + Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence); } SMESH::long_array* @@ -1802,7 +1851,7 @@ Filter_i:: GetElementsId( SMESH_Mesh_ptr theMesh ) { SMESH::long_array_var anArray = new SMESH::long_array; - if(!CORBA::is_nil(theMesh)){ + if(!CORBA::is_nil(theMesh) && myPredicate){ Controls::Filter::TIdSequence aSequence; GetElementsId(myPredicate,theMesh,aSequence); long i = 0, iEnd = aSequence.size(); @@ -1854,6 +1903,7 @@ static inline bool getCriteria( Predicate_i* thePred, } case FT_BelongToPlane: case FT_BelongToCylinder: + case FT_BelongToGenSurface: { BelongToSurface_i* aPred = dynamic_cast( thePred ); @@ -2006,9 +2056,18 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement; long aPrecision = theCriteria[ i ].Precision; - TPythonDump()<<"aCriteria.append(SMESH.Filter.Criterion("<< - aCriterion<<","< 0) + pd << "',salome.ObjectToID(" << aThresholdID + << ")," << aUnary << "," << aBinary << "," << aTolerance + << "," << aTypeOfElem << "," << aPrecision << ")"; + else + pd << "',''," << aUnary << "," << aBinary << "," << aTolerance + << "," << aTypeOfElem << "," << aPrecision << ")"; + } SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil(); SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil(); @@ -2072,12 +2131,17 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria break; case SMESH::FT_BelongToPlane: case SMESH::FT_BelongToCylinder: + case SMESH::FT_BelongToGenSurface: { SMESH::BelongToSurface_ptr tmpPred; - if ( aCriterion == SMESH::FT_BelongToPlane ) - tmpPred = aFilterMgr->CreateBelongToPlane(); - else - tmpPred = aFilterMgr->CreateBelongToCylinder(); + switch ( aCriterion ) { + case SMESH::FT_BelongToPlane: + tmpPred = aFilterMgr->CreateBelongToPlane(); break; + case SMESH::FT_BelongToCylinder: + tmpPred = aFilterMgr->CreateBelongToCylinder(); break; + default: + tmpPred = aFilterMgr->CreateBelongToGenSurface(); + } tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem ); tmpPred->SetTolerance( aTolerance ); aPredicate = tmpPred; @@ -2148,6 +2212,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria // logical op aPredicates.push_back( aPredicate ); aBinaries.push_back( aBinary ); + TPythonDump()<<"aCriteria.append(aCriterion)"; } // end of for TPythonDump()<