X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Filter_i.cxx;h=06a6e674adbfa94dff3fea956eb0280303c8fa98;hb=ce9cd12e0961ae754db00aced9c3d8b5f672e347;hp=b7c9c8ffb21048307e10863e5863b43484818732;hpb=6263d10065038d0aa8a0447df936293055f9a0fb;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index b7c9c8ffb..06a6e674a 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -34,7 +34,6 @@ #include "SMDS_MeshNode.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_ElemIterator.hxx" -#include "SMDS_VolumeTool.hxx" #include "SMESHDS_Mesh.hxx" @@ -125,7 +124,7 @@ void Controls::BelongToGeom::init() { if (!myMeshDS || myShape.IsNull()) return; - // is subshape of main shape? + // is sub-shape of main shape? TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh(); if (aMainShape.IsNull()) { myIsSubshape = false; @@ -281,7 +280,7 @@ void Controls::LyingOnGeom::init() { if (!myMeshDS || myShape.IsNull()) return; - // is subshape of main shape? + // is sub-shape of main shape? TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh(); if (aMainShape.IsNull()) { myIsSubshape = false; @@ -604,7 +603,11 @@ SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals) std::vector elements; myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements); +#ifdef WIN32 + nbIntervals = CORBA::Short( min( nbEvents.size(), funValues.size() - 1)); +#else nbIntervals = CORBA::Short( std::min( nbEvents.size(), funValues.size() - 1)); +#endif SMESH::Histogram_var histogram = new SMESH::Histogram; if ( nbIntervals > 0 ) { @@ -1429,6 +1432,77 @@ FunctorType FreeNodes_i::GetFunctorType() return SMESH::FT_FreeNodes; } +/* + Class : EqualNodes_i + Description : Predicate for Equal nodes +*/ +EqualNodes_i::EqualNodes_i() +{ + myCoincidentNodesPtr.reset(new Controls::CoincidentNodes()); + myFunctorPtr = myPredicatePtr = myCoincidentNodesPtr; +} + +FunctorType EqualNodes_i::GetFunctorType() +{ + return SMESH::FT_EqualNodes; +} + +void EqualNodes_i::SetTolerance( double tol ) +{ + myCoincidentNodesPtr->SetTolerance( tol ); +} + +double EqualNodes_i::GetTolerance() +{ + return myCoincidentNodesPtr->GetTolerance(); +} + +/* + Class : EqualEdges_i + Description : Predicate for Equal Edges +*/ +EqualEdges_i::EqualEdges_i() +{ + myPredicatePtr.reset(new Controls::CoincidentElements1D()); + myFunctorPtr = myPredicatePtr; +} + +FunctorType EqualEdges_i::GetFunctorType() +{ + return SMESH::FT_EqualEdges; +} + +/* + Class : EqualFaces_i + Description : Predicate for Equal Faces +*/ +EqualFaces_i::EqualFaces_i() +{ + myPredicatePtr.reset(new Controls::CoincidentElements2D()); + myFunctorPtr = myPredicatePtr; +} + +FunctorType EqualFaces_i::GetFunctorType() +{ + return SMESH::FT_EqualFaces; +} + +/* + Class : EqualVolumes_i + Description : Predicate for Equal Volumes +*/ +EqualVolumes_i::EqualVolumes_i() +{ + myPredicatePtr.reset(new Controls::CoincidentElements3D()); + myFunctorPtr = myPredicatePtr; +} + +FunctorType EqualVolumes_i::GetFunctorType() +{ + return SMESH::FT_EqualVolumes; +} + + /* Class : RangeOfIds_i Description : Predicate for Range of Ids. @@ -2082,6 +2156,36 @@ FreeNodes_ptr FilterManager_i::CreateFreeNodes() return anObj._retn(); } +EqualNodes_ptr FilterManager_i::CreateEqualNodes() +{ + SMESH::EqualNodes_i* aServant = new SMESH::EqualNodes_i(); + SMESH::EqualNodes_var anObj = aServant->_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<GetPredicate() ); myPredicate->Register(); + if ( const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh)) + myPredicate->GetPredicate()->SetMesh( aMesh ); TPythonDump()<::iterator i = myWaiters.begin(); @@ -2322,6 +2428,10 @@ SetMesh( SMESH_Mesh_ptr theMesh ) myMesh = SMESH_Mesh::_duplicate( theMesh ); TPythonDump()<GetPredicate()->SetMesh( aMesh ); } SMESH::long_array* @@ -2501,6 +2611,14 @@ static inline bool getCriteria( Predicate_i* thePred, case FT_FreeFaces: case FT_LinearOrQuadratic: case FT_FreeNodes: + case FT_EqualEdges: + case FT_EqualFaces: + case FT_EqualVolumes: + case FT_BadOrientedVolume: + case FT_BareBorderVolume: + case FT_BareBorderFace: + case FT_OverConstrainedVolume: + case FT_OverConstrainedFace: { CORBA::ULong i = theCriteria->length(); theCriteria->length( i + 1 ); @@ -2580,87 +2698,31 @@ static inline bool getCriteria( Predicate_i* thePred, return true; } - case FT_RangeOfIds: - { - RangeOfIds_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = FT_RangeOfIds; - theCriteria[ i ].ThresholdStr = aPred->GetRangeStr(); - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); - - return true; - } - case FT_BadOrientedVolume: - { - BadOrientedVolume_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = FT_BadOrientedVolume; - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); - - return true; - } - case FT_BareBorderVolume: - { - BareBorderVolume_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = FT_BareBorderVolume; - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); - - return true; - } - case FT_BareBorderFace: - { - BareBorderFace_i* aPred = dynamic_cast( thePred ); - - CORBA::ULong i = theCriteria->length(); - theCriteria->length( i + 1 ); - - theCriteria[ i ] = createCriterion(); - - theCriteria[ i ].Type = FT_BareBorderFace; - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); - - return true; - } - case FT_OverConstrainedVolume: + case FT_EqualNodes: { - OverConstrainedVolume_i* aPred = dynamic_cast( thePred ); + EqualNodes_i* aPred = dynamic_cast( thePred ); CORBA::ULong i = theCriteria->length(); theCriteria->length( i + 1 ); theCriteria[ i ] = createCriterion(); - theCriteria[ i ].Type = FT_OverConstrainedVolume; - theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + theCriteria[ i ].Type = FT_EqualNodes; + theCriteria[ i ].Tolerance = aPred->GetTolerance(); return true; } - case FT_OverConstrainedFace: + case FT_RangeOfIds: { - OverConstrainedFace_i* aPred = dynamic_cast( thePred ); + RangeOfIds_i* aPred = dynamic_cast( thePred ); CORBA::ULong i = theCriteria->length(); theCriteria->length( i + 1 ); theCriteria[ i ] = createCriterion(); - theCriteria[ i ].Type = FT_OverConstrainedFace; + theCriteria[ i ].Type = FT_RangeOfIds; + theCriteria[ i ].ThresholdStr = aPred->GetRangeStr(); theCriteria[ i ].TypeOfElement = aPred->GetElementType(); return true; @@ -2864,6 +2926,22 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria case SMESH::FT_FreeNodes: aPredicate = aFilterMgr->CreateFreeNodes(); break; + case SMESH::FT_EqualNodes: + { + SMESH::EqualNodes_ptr pred = aFilterMgr->CreateEqualNodes(); + pred->SetTolerance( aTolerance ); + aPredicate = pred; + break; + } + case SMESH::FT_EqualEdges: + aPredicate = aFilterMgr->CreateEqualEdges(); + break; + case SMESH::FT_EqualFaces: + aPredicate = aFilterMgr->CreateEqualFaces(); + break; + case SMESH::FT_EqualVolumes: + aPredicate = aFilterMgr->CreateEqualVolumes(); + break; case SMESH::FT_BelongToGeom: { SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom(); @@ -3096,6 +3174,8 @@ Predicate_ptr Filter_i::GetPredicate() else { SMESH::Predicate_var anObj = myPredicate->_this(); + // if ( SMESH::Functor_i* fun = SMESH::DownCast( anObj )) + // TPythonDump() << fun << " = " << this << ".GetPredicate()"; return anObj._retn(); } } @@ -3183,8 +3263,12 @@ static inline LDOMString toString( CORBA::Long theType ) case FT_FreeEdges : return "Free edges"; case FT_FreeFaces : return "Free faces"; case FT_FreeNodes : return "Free nodes"; + case FT_EqualNodes : return "Equal nodes"; + case FT_EqualEdges : return "Equal edges"; + 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_LessThan : return "Less than"; @@ -3225,6 +3309,10 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges; else if ( theStr.equals( "Free faces" ) ) return FT_FreeFaces; else if ( theStr.equals( "Free nodes" ) ) return FT_FreeNodes; + else if ( theStr.equals( "Equal nodes" ) ) return FT_EqualNodes; + else if ( theStr.equals( "Equal edges" ) ) return FT_EqualEdges; + else if ( theStr.equals( "Equal faces" ) ) return FT_EqualFaces; + else if ( theStr.equals( "Equal volumes" ) ) return FT_EqualVolumes; else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection; // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D; else if ( theStr.equals( "Length" ) ) return FT_Length; @@ -3768,12 +3856,13 @@ string_array* FilterLibrary_i::GetAllNames() static const char** getFunctNames() { static const char* functName[ SMESH::FT_Undefined + 1 ] = { - // If this line doesn't compile, this means that enum FunctorType has changed and - // it's necessary to update this array accordingly (refer to SMESH_Filter.idl) + // IT's necessary to update this array according to enum FunctorType (SMESH_Filter.idl) + // The order is IMPORTANT !!! "FT_AspectRatio", "FT_AspectRatio3D", "FT_Warping", "FT_MinimumAngle", "FT_Taper", "FT_Skew", "FT_Area", "FT_Volume3D", "FT_MaxElementLength2D", "FT_MaxElementLength3D", "FT_FreeBorders", "FT_FreeEdges", "FT_FreeNodes", - "FT_FreeFaces", "FT_MultiConnection", "FT_MultiConnection2D", "FT_Length", + "FT_FreeFaces","FT_EqualNodes","FT_EqualEdges","FT_EqualFaces","FT_EqualVolumes", + "FT_MultiConnection", "FT_MultiConnection2D", "FT_Length", "FT_Length2D", "FT_BelongToGeom", "FT_BelongToPlane", "FT_BelongToCylinder", "FT_BelongToGenSurface", "FT_LyingOnGeom", "FT_RangeOfIds", "FT_BadOrientedVolume", "FT_BareBorderVolume", "FT_BareBorderFace", "FT_OverConstrainedVolume", @@ -3806,8 +3895,8 @@ SMESH::FunctorType SMESH::StringToFunctorType(const char* str) { std::string name( str + 3 ); // skip "FT_" const char** functNames = getFunctNames(); - int ft = SMESH::FT_Undefined; - for ( ; ft >= 0; --ft ) + int ft = 0; + for ( ; ft < SMESH::FT_Undefined; ++ft ) if ( name == ( functNames[ft] + 3 )) break;