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=98ae207dec57ab53a1f73e58128b6a82c681138d;hp=b53448c3f399299ad43ee3fcf447e2b448d69861;hb=7e350caa2f1f4cbb2f3d948558c2710d73e76136;hpb=8ad9cef463885b9649315044884cb6c13cbf31b1 diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index b53448c3f..98ae207de 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; @@ -363,6 +361,7 @@ static SMESH::Filter::Criterion createCriterion() aCriterion.UnaryOp = FT_Undefined; aCriterion.BinaryOp = FT_Undefined; aCriterion.ThresholdStr = ""; + aCriterion.ThresholdID = ""; aCriterion.Tolerance = Precision::Confusion(); aCriterion.TypeOfElement = SMESH::ALL; aCriterion.Precision = -1; @@ -385,7 +384,32 @@ 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; + } + } + } + } + return TopoDS_Shape(); +} + +static TopoDS_Shape getShapeByID (const char* theID) +{ + 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->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_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine(); TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj ); return aLocShape; } @@ -395,7 +419,26 @@ static TopoDS_Shape getShapeByName( const char* theName ) return TopoDS_Shape(); } +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::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; +} /* FUNCTORS @@ -414,7 +457,7 @@ Functor_i::Functor_i(): 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()<SetGeom( getShapeByID(myShapeID) ); + else + myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) ); +} + char* BelongToGeom_i::GetShapeName() { return CORBA::string_dup( myShapeName ); } +char* BelongToGeom_i::GetShapeID() +{ + return CORBA::string_dup( myShapeID ); +} + /* Class : BelongToSurface_i Description : Predicate for selection on geometrical support @@ -774,12 +855,14 @@ BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceTyp myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() ); myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr; myShapeName = 0; + myShapeID = 0; mySurfaceType = theSurfaceType; } BelongToSurface_i::~BelongToSurface_i() { delete myShapeName; + delete myShapeID; } void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) @@ -787,7 +870,7 @@ void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType t if ( theGeom->_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 ) @@ -801,7 +884,6 @@ void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType t } myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType ); - TPythonDump()<SetSurface( getShapeByID(myShapeID), (SMDSAbs_ElementType)theType ); + else + myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (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 ); @@ -828,6 +931,18 @@ CORBA::Double BelongToSurface_i::GetTolerance() return myElementsOnSurfacePtr->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 @@ -870,6 +985,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()<SetGeom( getShapeByID(myShapeID) ); + else + myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) ); +} + char* LyingOnGeom_i::GetShapeName() { return CORBA::string_dup( myShapeName ); } +char* LyingOnGeom_i::GetShapeID() +{ + return CORBA::string_dup( myShapeID ); +} + /* Class : FreeBorders_i Description : Predicate for free borders @@ -958,7 +1123,8 @@ SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders() long i = 0, iEnd = aBorders.size(); - SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders(iEnd); + SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders; + aResult->length(iEnd); SMESH::Controls::FreeEdges::TBorders::const_iterator anIter; for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ ) @@ -1295,7 +1461,7 @@ FilterManager_i::FilterManager_i() FilterManager_i::~FilterManager_i() { - TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<Destroy(); - TPythonDump()<GetShapeName(); + theCriteria[ i ].ThresholdID = aPred->GetShapeID(); theCriteria[ i ].TypeOfElement = aPred->GetElementType(); return true; } case FT_BelongToPlane: case FT_BelongToCylinder: + case FT_BelongToGenSurface: { BelongToSurface_i* aPred = dynamic_cast( thePred ); @@ -1725,6 +1910,7 @@ static inline bool getCriteria( Predicate_i* thePred, theCriteria[ i ].Type = aFType; theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); + theCriteria[ i ].ThresholdID = aPred->GetShapeID(); theCriteria[ i ].TypeOfElement = aPred->GetElementType(); theCriteria[ i ].Tolerance = aPred->GetTolerance(); @@ -1741,6 +1927,7 @@ static inline bool getCriteria( Predicate_i* thePred, theCriteria[ i ].Type = FT_LyingOnGeom; theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); + theCriteria[ i ].ThresholdID = aPred->GetShapeID(); theCriteria[ i ].TypeOfElement = aPred->GetElementType(); return true; @@ -1857,16 +2044,26 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria int aCriterion = theCriteria[ i ].Type; int aCompare = theCriteria[ i ].Compare; double aThreshold = theCriteria[ i ].Threshold; + const char* aThresholdStr = theCriteria[ i ].ThresholdStr; + const char* aThresholdID = theCriteria[ i ].ThresholdID; int aUnary = theCriteria[ i ].UnaryOp; int aBinary = theCriteria[ i ].BinaryOp; double aTolerance = theCriteria[ i ].Tolerance; - const char* aThresholdStr = theCriteria[ i ].ThresholdStr; 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(); @@ -1908,6 +2105,9 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria case SMESH::FT_Area: aFunctor = aFilterMgr->CreateArea(); break; + case SMESH::FT_Volume3D: + aFunctor = aFilterMgr->CreateVolume3D(); + break; // Predicates @@ -1921,19 +2121,24 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria { SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom(); tmpPred->SetElementType( aTypeOfElem ); - tmpPred->SetShapeName( aThresholdStr ); + tmpPred->SetShape( aThresholdID, aThresholdStr ); aPredicate = tmpPred; } 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(); - tmpPred->SetShapeName( aThresholdStr, aTypeOfElem ); + 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; } @@ -1942,7 +2147,7 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria { SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom(); tmpPred->SetElementType( aTypeOfElem ); - tmpPred->SetShapeName( aThresholdStr ); + tmpPred->SetShape( aThresholdID, aThresholdStr ); aPredicate = tmpPred; } break; @@ -2003,6 +2208,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()<length(); i < n; i++ ) { LDOM_Element aCriterionItem = theDoc.createElement( "criterion" ); - - aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type ) ); - aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) ); - aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) ); - aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) ); - aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) ); + + aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type) ); + aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) ); + aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) ); + aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) ); + aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) ); aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr ); aCriterionItem.setAttribute( ATTR_TOLERANCE , toString( aCriteria[ i ].Tolerance ) ); @@ -2429,7 +2639,7 @@ FilterLibrary_i::FilterLibrary_i() FilterLibrary_i::~FilterLibrary_i() { delete myFileName; - TPythonDump()<