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=ae97ce1c664fd6f444e9127a111055f543ae2a02;hp=a255fa53f7cec411d9cabc24a5a40e94c1dbc68c;hb=e85e13ee2a8e2484050471ff8e4dea298abe481a;hpb=bd7477efc255f965c479d88d1be1ee3dbf4aa760 diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index a255fa53f..ae97ce1c6 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes // File : SMESH_Filter_i.cxx // Author : Alexey Petrov, OCC // Module : SMESH @@ -40,8 +40,6 @@ #include #include -#include - #include #include #include @@ -139,6 +137,8 @@ static TopoDS_Shape getShapeByName( const char* theName ) { SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); SALOMEDS::Study::ListOfSObject_var aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "GEOM" ); + if ( aList->length() == 0 ) + aList = SMESH_Gen_i::getStudyServant()->FindObjectByName( theName, "SHAPERSTUDY" ); if ( aList->length() > 0 ) { CORBA::Object_var anObj = aList[ 0 ]->GetObject(); @@ -183,7 +183,7 @@ static TopoDS_Shape getShapeByID (const char* theID) /* Class : Functor_i - Description : An abstact class for all functors + Description : An abstract class for all functors */ Functor_i::Functor_i(): SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) @@ -219,6 +219,11 @@ CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId ) return myNumericalFunctorPtr->GetValue( theId ); } +CORBA::Boolean NumericalFunctor_i::IsApplicable( CORBA::Long theElementId ) +{ + return myNumericalFunctorPtr->IsApplicable( theElementId ); +} + SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals, CORBA::Boolean isLogarithmic) { std::vector nbEvents; @@ -523,6 +528,61 @@ SMESH::Length2D::Values* Length2D_i::GetValues() return aResult._retn(); } + +/* + Class : Length3D_i + Description : Functor for calculating length of edge +*/ +Length3D_i::Length3D_i() +{ + myNumericalFunctorPtr.reset( new Controls::Length3D() ); + myFunctorPtr = myNumericalFunctorPtr; +} + +FunctorType Length3D_i::GetFunctorType() +{ + return SMESH::FT_Length3D; +} + +// SMESH::Length3D::Values* Length3D_i::GetValues() +// { +// SMESH::Controls::Length3D::TValues aValues; +// (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); + +// long i = 0, iEnd = aValues.size(); + +// SMESH::Length3D::Values_var aResult = new SMESH::Length3D::Values(iEnd); +// aResult->length(iEnd); + +// SMESH::Controls::Length3D::TValues::const_iterator anIter; +// for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ ) +// { +// const SMESH::Controls::Length3D::Value& aVal = *anIter; +// SMESH::Length3D::Value &aValue = aResult[ i ]; + +// aValue.myLength = aVal.myLength; +// aValue.myPnt1 = aVal.myPntId[ 0 ]; +// aValue.myPnt2 = aVal.myPntId[ 1 ]; +// } + +// return aResult._retn(); +// } + +/* + Class : Deflection2D_i + Description : Functor for calculating distance between a face and geometry +*/ +Deflection2D_i::Deflection2D_i() +{ + myNumericalFunctorPtr.reset( new Controls::Deflection2D() ); + myFunctorPtr = myNumericalFunctorPtr; +} + +FunctorType Deflection2D_i::GetFunctorType() +{ + return SMESH::FT_Deflection2D; +} + /* Class : MultiConnection_i Description : Functor for calculating number of faces conneted to the edge @@ -845,9 +905,7 @@ 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 ); + TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); myBelongToGeomPtr->SetGeom( aLocShape ); TPythonDump()<_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 ); + TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); if ( aLocShape.ShapeType() == TopAbs_FACE ) { @@ -1115,9 +1171,7 @@ void LyingOnGeom_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 ); + TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom ); myLyingOnGeomPtr->SetGeom( aLocShape ); TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()< 0 && myPredicate ) + { + SMESH_Mesh_ptr mesh = theParts[0]->GetMesh(); + mesh->Load(); + const SMDS_Mesh* meshDS = MeshPtr2SMDSMesh( mesh ); + Controls::Filter::TIdSequence totalSequence; + for ( CORBA::ULong i = 0; i < theParts.length(); ++i ) + { + if ( SMESH::Filter_i* filter = SMESH::DownCast( theParts[i] )) + filter->SetMesh( mesh ); + SMDS_ElemIteratorPtr iter = SMESH_Mesh_i::GetElements( theParts[i], GetElementType() ); + if ( iter && meshDS ) + { + Controls::Filter::TIdSequence sequence; + Controls::Filter::GetElementsId( meshDS, myPredicate->GetPredicate(), sequence, iter ); + totalSequence.insert( totalSequence.end(), sequence.begin(), sequence.end() ); + } + } + array->length( totalSequence.size() ); + for ( size_t i = 0; i < totalSequence.size(); ++i ) + array[ i ] = totalSequence[ i ]; + } + return array._retn(); +} + //============================================================================= /*! * \brief Returns number of mesh elements per each \a EntityType @@ -2937,6 +3037,12 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria case SMESH::FT_Length2D: aFunctor = aFilterMgr->CreateLength2D(); break; + case SMESH::FT_Length3D: + aFunctor = aFilterMgr->CreateLength3D(); + break; + case SMESH::FT_Deflection2D: + aFunctor = aFilterMgr->CreateDeflection2D(); + break; case SMESH::FT_AspectRatio: aFunctor = aFilterMgr->CreateAspectRatio(); break; @@ -3432,9 +3538,11 @@ static inline LDOMString toString( CORBA::Long theType ) case FT_EqualFaces : return "Equal faces"; case FT_EqualVolumes : return "Equal volumes"; case FT_MultiConnection : return "Borders at multi-connections"; - case FT_MultiConnection2D :return "Borders at multi-connections 2D"; + case FT_MultiConnection2D : return "Borders at multi-connections 2D"; case FT_Length : return "Length"; case FT_Length2D : return "Length 2D"; + case FT_Length3D : return "Length 3D"; + case FT_Deflection2D : return "Deflection 2D"; case FT_LessThan : return "Less than"; case FT_MoreThan : return "More than"; case FT_EqualTo : return "Equal to"; @@ -3443,7 +3551,7 @@ static inline LDOMString toString( CORBA::Long theType ) case FT_LogicalOR : return "Or"; case FT_GroupColor : return "Color of Group"; case FT_LinearOrQuadratic : return "Linear or Quadratic"; - case FT_ElemGeomType : return "Element geomtry type"; + case FT_ElemGeomType : return "Element geometry type"; case FT_EntityType : return "Entity type"; case FT_Undefined : return ""; default : return ""; @@ -3483,6 +3591,8 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D; else if ( theStr.equals( "Length" ) ) return FT_Length; // else if ( theStr.equals( "Length2D" ) ) return FT_Length2D; + // else if ( theStr.equals( "Length3D" ) ) return FT_Length3D; + else if ( theStr.equals( "Deflection" ) ) return FT_Deflection2D; else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds; else if ( theStr.equals( "Bad Oriented Volume" ) ) return FT_BadOrientedVolume; else if ( theStr.equals( "Volumes with bare border" ) ) return FT_BareBorderVolume; @@ -3497,7 +3607,7 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) else if ( theStr.equals( "Or" ) ) return FT_LogicalOR; else if ( theStr.equals( "Color of Group" ) ) return FT_GroupColor; else if ( theStr.equals( "Linear or Quadratic" ) ) return FT_LinearOrQuadratic; - else if ( theStr.equals( "Element geomtry type" ) ) return FT_ElemGeomType; + else if ( theStr.equals( "Element geometry type" ) ) return FT_ElemGeomType; else if ( theStr.equals( "Entity type" ) ) return FT_EntityType; else if ( theStr.equals( "" ) ) return FT_Undefined; else return FT_Undefined; @@ -3922,16 +4032,6 @@ CORBA::Boolean FilterLibrary_i::Save() if ( myFileName == 0 || strlen( myFileName ) == 0 ) return false; -#if OCC_VERSION_MAJOR < 7 - FILE* aOutFile = fopen( myFileName, "wt" ); - if ( !aOutFile ) - return false; - - LDOM_XmlWriter aWriter( aOutFile ); - aWriter.SetIndentation( 2 ); - aWriter << myDoc; - fclose( aOutFile ); -#else std::filebuf fb; fb.open( myFileName, std::ios::out ); @@ -3941,7 +4041,6 @@ CORBA::Boolean FilterLibrary_i::Save() aWriter.SetIndentation( 2 ); aWriter.Write( os, myDoc ); fb.close(); -#endif TPythonDump()<