X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Filter_i.cxx;h=d2a7ae648d7b2510cbef06115cb41d1a3276743c;hb=d8f644ca3d4ce62f2ef41d4aacb52f5bb1221df3;hp=38922a53782d1a5e911b82e815c3ff8faed3b352;hpb=57b43b4d010e2d0a1529d3c131bbb9d416e63258;p=modules%2Fsmesh.git diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 38922a537..d2a7ae648 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -1,6 +1,6 @@ -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or @@ -17,15 +17,14 @@ // 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 // + +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses // File : SMESH_Filter_i.cxx // Author : Alexey Petrov, OCC // Module : SMESH - - +// #include "SMESH_Filter_i.hxx" #include "SMESH_Gen_i.hxx" @@ -34,32 +33,32 @@ #include "SMDS_Mesh.hxx" #include "SMDS_MeshNode.hxx" #include "SMDS_MeshElement.hxx" +#include "SMDS_ElemIterator.hxx" #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 +#include using namespace SMESH; using namespace SMESH::Controls; @@ -77,23 +76,73 @@ namespace SMESH /* Class : BelongToGeom - Description : Predicate for verifying whether entiy belong to + Description : Predicate for verifying whether entity belongs to specified geometrical support */ Controls::BelongToGeom::BelongToGeom() -: myMeshDS(NULL), - myType(SMDSAbs_All) + : myMeshDS(NULL), + myType(SMDSAbs_All), + myIsSubshape(false), + myTolerance(Precision::Confusion()) {} void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh ) { myMeshDS = dynamic_cast(theMesh); + init(); } void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape ) { myShape = theShape; + init(); +} + +static bool IsSubShape (const TopTools_IndexedMapOfShape& theMap, + const TopoDS_Shape& theShape) +{ + if (theMap.Contains(theShape)) return true; + + if (theShape.ShapeType() == TopAbs_COMPOUND || + theShape.ShapeType() == TopAbs_COMPSOLID) + { + TopoDS_Iterator anIt (theShape, Standard_True, Standard_True); + for (; anIt.More(); anIt.Next()) + { + if (!IsSubShape(theMap, anIt.Value())) { + return false; + } + } + return true; + } + + return false; +} + +void Controls::BelongToGeom::init() +{ + if (!myMeshDS || myShape.IsNull()) return; + + // is subshape of main shape? + TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh(); + if (aMainShape.IsNull()) { + myIsSubshape = false; + } + else { + TopTools_IndexedMapOfShape aMap; + TopExp::MapShapes(aMainShape, aMap); + myIsSubshape = IsSubShape(aMap, myShape); + } + + if (!myIsSubshape) + { + myElementsOnShapePtr.reset(new Controls::ElementsOnShape()); + myElementsOnShapePtr->SetTolerance(myTolerance); + myElementsOnShapePtr->SetAllNodes(true); // belong, while false means "lays on" + myElementsOnShapePtr->SetMesh(myMeshDS); + myElementsOnShapePtr->SetShape(myShape, myType); + } } static bool IsContains( const SMESHDS_Mesh* theMeshDS, @@ -116,12 +165,18 @@ static bool IsContains( const SMESHDS_Mesh* theMeshDS, return false; } -bool Controls::BelongToGeom::IsSatisfy( long theId ) +bool Controls::BelongToGeom::IsSatisfy (long theId) { - if ( myMeshDS == 0 || myShape.IsNull() ) + if (myMeshDS == 0 || myShape.IsNull()) return false; - if( myType == SMDSAbs_Node ) + if (!myIsSubshape) + { + return myElementsOnShapePtr->IsSatisfy(theId); + } + + // Case of submesh + if (myType == SMDSAbs_Node) { if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) ) { @@ -163,9 +218,10 @@ bool Controls::BelongToGeom::IsSatisfy( long theId ) return false; } -void Controls::BelongToGeom::SetType( SMDSAbs_ElementType theType ) +void Controls::BelongToGeom::SetType (SMDSAbs_ElementType theType) { myType = theType; + init(); } SMDSAbs_ElementType Controls::BelongToGeom::GetType() const @@ -178,13 +234,23 @@ TopoDS_Shape Controls::BelongToGeom::GetShape() return myShape; } -const SMESHDS_Mesh* -Controls::BelongToGeom:: -GetMeshDS() const +const SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() const { return myMeshDS; } +void Controls::BelongToGeom::SetTolerance (double theTolerance) +{ + myTolerance = theTolerance; + if (!myIsSubshape) + init(); +} + +double Controls::BelongToGeom::GetTolerance() +{ + return myTolerance; +} + /* Class : LyingOnGeom Description : Predicate for verifying whether entiy lying or partially lying on @@ -192,18 +258,47 @@ GetMeshDS() const */ Controls::LyingOnGeom::LyingOnGeom() -: myMeshDS(NULL), - myType(SMDSAbs_All) + : myMeshDS(NULL), + myType(SMDSAbs_All), + myIsSubshape(false), + myTolerance(Precision::Confusion()) {} void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh ) { myMeshDS = dynamic_cast(theMesh); + init(); } void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape ) { myShape = theShape; + init(); +} + +void Controls::LyingOnGeom::init() +{ + if (!myMeshDS || myShape.IsNull()) return; + + // is subshape of main shape? + TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh(); + if (aMainShape.IsNull()) { + myIsSubshape = false; + } + else { + TopTools_IndexedMapOfShape aMap; + TopExp::MapShapes(aMainShape, aMap); + myIsSubshape = IsSubShape(aMap, myShape); + } + + if (!myIsSubshape) + { + myElementsOnShapePtr.reset(new Controls::ElementsOnShape()); + myElementsOnShapePtr->SetTolerance(myTolerance); + myElementsOnShapePtr->SetAllNodes(false); // lays on, while true means "belong" + myElementsOnShapePtr->SetMesh(myMeshDS); + myElementsOnShapePtr->SetShape(myShape, myType); + } } bool Controls::LyingOnGeom::IsSatisfy( long theId ) @@ -211,6 +306,12 @@ bool Controls::LyingOnGeom::IsSatisfy( long theId ) if ( myMeshDS == 0 || myShape.IsNull() ) return false; + if (!myIsSubshape) + { + return myElementsOnShapePtr->IsSatisfy(theId); + } + + // Case of submesh if( myType == SMDSAbs_Node ) { if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) ) @@ -256,6 +357,7 @@ bool Controls::LyingOnGeom::IsSatisfy( long theId ) void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType ) { myType = theType; + init(); } SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const @@ -268,13 +370,23 @@ TopoDS_Shape Controls::LyingOnGeom::GetShape() return myShape; } -const SMESHDS_Mesh* -Controls::LyingOnGeom:: -GetMeshDS() const +const SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() const { return myMeshDS; } +void Controls::LyingOnGeom::SetTolerance (double theTolerance) +{ + myTolerance = theTolerance; + if (!myIsSubshape) + init(); +} + +double Controls::LyingOnGeom::GetTolerance() +{ + return myTolerance; +} + bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS, const TopoDS_Shape& theShape, const SMDS_MeshElement* theElem, @@ -386,7 +498,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 +508,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 = ""; + char* aName = (char*)""; - 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 +565,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()<GetValue( theId ); } +SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals) +{ + std::vector nbEvents; + std::vector funValues; + myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues); + + nbIntervals = CORBA::Short( std::min( nbEvents.size(), funValues.size() - 1)); + SMESH::Histogram_var histogram = new SMESH::Histogram; + if ( nbIntervals > 0 ) + { + histogram->length( nbIntervals ); + for ( int i = 0; i < nbIntervals; ++i ) + { + HistogramRectangle& rect = histogram[i]; + rect.nbEvents = nbEvents[i]; + rect.min = funValues[i]; + rect.max = funValues[i+1]; + } + } + return histogram._retn(); +} + void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision ) { myNumericalFunctorPtr->SetPrecision( thePrecision ); @@ -624,6 +760,36 @@ FunctorType Volume3D_i::GetFunctorType() return SMESH::FT_Volume3D; } +/* + Class : MaxElementLength2D_i + Description : Functor for calculating maximum length of 2D element +*/ +MaxElementLength2D_i::MaxElementLength2D_i() +{ + myNumericalFunctorPtr.reset( new Controls::MaxElementLength2D() ); + myFunctorPtr = myNumericalFunctorPtr; +} + +FunctorType MaxElementLength2D_i::GetFunctorType() +{ + return SMESH::FT_MaxElementLength2D; +} + +/* + Class : MaxElementLength3D_i + Description : Functor for calculating maximum length of 3D element +*/ +MaxElementLength3D_i::MaxElementLength3D_i() +{ + myNumericalFunctorPtr.reset( new Controls::MaxElementLength3D() ); + myFunctorPtr = myNumericalFunctorPtr; +} + +FunctorType MaxElementLength3D_i::GetFunctorType() +{ + return SMESH::FT_MaxElementLength3D; +} + /* Class : Length_i Description : Functor for calculating length off edge @@ -658,11 +824,12 @@ SMESH::Length2D::Values* Length2D_i::GetValues() { INFOS("Length2D_i::GetValues"); SMESH::Controls::Length2D::TValues aValues; - myLength2DPtr->GetValues( aValues ); + (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); long i = 0, iEnd = aValues.size(); SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd); + aResult->length(iEnd); SMESH::Controls::Length2D::TValues::const_iterator anIter; for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ ) @@ -713,11 +880,12 @@ SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues() { INFOS("MultiConnection2D_i::GetValues"); SMESH::Controls::MultiConnection2D::MValues aValues; - myMulticonnection2DPtr->GetValues( aValues ); - + (dynamic_cast(myFunctorPtr.get()))->GetValues( aValues ); + long i = 0, iEnd = aValues.size(); 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++ ) @@ -792,7 +960,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_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()<SetTolerance( theToler ); + TPythonDump()<GetTolerance(); +} + /* Class : BelongToSurface_i Description : Predicate for selection on geometrical support @@ -871,7 +1050,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 ) @@ -885,7 +1064,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 +1165,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()<SetTolerance( theToler ); + TPythonDump()<GetTolerance(); +} + /* Class : FreeBorders_i Description : Predicate for free borders @@ -1109,6 +1337,36 @@ FunctorType FreeEdges_i::GetFunctorType() return SMESH::FT_FreeEdges; } +/* + Class : FreeFaces_i + Description : Predicate for free faces +*/ +FreeFaces_i::FreeFaces_i() +{ + myPredicatePtr.reset(new Controls::FreeFaces()); + myFunctorPtr = myPredicatePtr; +} + +FunctorType FreeFaces_i::GetFunctorType() +{ + return SMESH::FT_FreeFaces; +} + +/* + Class : FreeNodes_i + Description : Predicate for free nodes +*/ +FreeNodes_i::FreeNodes_i() +{ + myPredicatePtr.reset(new Controls::FreeNodes()); + myFunctorPtr = myPredicatePtr; +} + +FunctorType FreeNodes_i::GetFunctorType() +{ + return SMESH::FT_FreeNodes; +} + /* Class : RangeOfIds_i Description : Predicate for Range of Ids. @@ -1157,6 +1415,137 @@ FunctorType RangeOfIds_i::GetFunctorType() return SMESH::FT_RangeOfIds; } +/* + Class : LinearOrQuadratic_i + Description : Predicate to verify whether a mesh element is linear +*/ +LinearOrQuadratic_i::LinearOrQuadratic_i() +{ + myLinearOrQuadraticPtr.reset(new Controls::LinearOrQuadratic()); + myFunctorPtr = myPredicatePtr = myLinearOrQuadraticPtr; +} + +void LinearOrQuadratic_i::SetElementType(ElementType theType) +{ + myLinearOrQuadraticPtr->SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetColorStr( + TCollection_AsciiString( (Standard_CString)theColor ) ); + TPythonDump()<GetColorStr( aStr ); + return CORBA::string_dup( aStr.ToCString() ); +} + +void GroupColor_i::SetElementType(ElementType theType) +{ + myGroupColorPtr->SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetType(SMDSAbs_ElementType(theType)); + TPythonDump()<SetGeomType(SMDSAbs_GeometryType(theType)); + TPythonDump()<GetGeomType(); +} + +FunctorType ElemGeomType_i::GetFunctorType() +{ + return SMESH::FT_ElemGeomType; +} + +/* + Class : CoplanarFaces_i + Description : Returns true if a mesh face is a coplanar neighbour to a given one +*/ +CoplanarFaces_i::CoplanarFaces_i() +{ + myCoplanarFacesPtr.reset(new Controls::CoplanarFaces()); + myFunctorPtr = myPredicatePtr = myCoplanarFacesPtr; +} + +void CoplanarFaces_i::SetFace ( CORBA::Long theFaceID ) +{ + myCoplanarFacesPtr->SetFace(theFaceID); + TPythonDump()<SetTolerance(theToler); + TPythonDump()<GetFace(); +} + +char* CoplanarFaces_i::GetFaceAsString () const +{ + TCollection_AsciiString str(Standard_Integer(myCoplanarFacesPtr->GetFace())); + return CORBA::string_dup( str.ToCString() ); +} + +CORBA::Double CoplanarFaces_i::GetTolerance() const +{ + return myCoplanarFacesPtr->GetTolerance(); +} + +FunctorType CoplanarFaces_i::GetFunctorType() +{ + return SMESH::FT_CoplanarFaces; +} + /* Class : Comparator_i Description : Base class for comparators @@ -1417,14 +1806,15 @@ FunctorType LogicalOR_i::GetFunctorType() FilterManager_i::FilterManager_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 ); } FilterManager_i::~FilterManager_i() { - TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); + TPythonDump()<_this(); - TPythonDump()<Destroy(); - TPythonDump()<Destroy(); - myMesh = theMesh; + myMesh = SMESH_Mesh::_duplicate( theMesh ); TPythonDump()<GetPredicate(),theSequence); + if (thePredicate) + Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence); } void @@ -1793,8 +2254,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 +2264,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(); @@ -1813,6 +2275,85 @@ GetElementsId( SMESH_Mesh_ptr theMesh ) return anArray._retn(); } +template +static void collectMeshInfo(const TIterator& theItr, + TPredicate& thePred, + SMESH::long_array& theRes) +{ + if (!theItr) + return; + while (theItr->more()) { + const SMDS_MeshElement* anElem = theItr->next(); + if ( thePred->IsSatisfy( anElem->GetID() ) ) + theRes[ anElem->GetEntityType() ]++; + } +} + +//============================================================================= +/*! + * \brief Returns statistic of mesh elements + */ +//============================================================================= +SMESH::long_array* ::Filter_i::GetMeshInfo() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + aRes->length(SMESH::Entity_Last); + for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++) + aRes[i] = 0; + + if(!CORBA::is_nil(myMesh) && myPredicate) { + const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh); + SMDS_ElemIteratorPtr it; + switch( GetElementType() ) + { + case SMDSAbs_Node: + collectMeshInfo(aMesh->nodesIterator(),myPredicate,aRes); + break; + case SMDSAbs_Edge: + collectMeshInfo(aMesh->edgesIterator(),myPredicate,aRes); + break; + case SMDSAbs_Face: + collectMeshInfo(aMesh->facesIterator(),myPredicate,aRes); + break; + case SMDSAbs_Volume: + collectMeshInfo(aMesh->volumesIterator(),myPredicate,aRes); + break; + case SMDSAbs_All: + default: + collectMeshInfo(aMesh->elementsIterator(),myPredicate,aRes); + break; + } + } + + + return aRes._retn(); +} + +//================================================================================ +/*! + * \brief Return GetElementType() within an array + * Implement SMESH_IDSource interface + */ +//================================================================================ + +SMESH::array_of_ElementType* Filter_i::GetTypes() +{ + SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType; + types->length( 1 ); + types[0] = GetElementType(); + return types._retn(); +} + +//======================================================================= +//function : GetMesh +//purpose : Returns mesh +//======================================================================= + +SMESH::SMESH_Mesh_ptr Filter_i::GetMesh() +{ + return SMESH_Mesh::_duplicate( myMesh ); +} + //======================================================================= // name : getCriteria // Purpose : Retrieve criterions from predicate @@ -1826,6 +2367,9 @@ static inline bool getCriteria( Predicate_i* thePred, { case FT_FreeBorders: case FT_FreeEdges: + case FT_FreeFaces: + case FT_LinearOrQuadratic: + case FT_FreeNodes: { CORBA::ULong i = theCriteria->length(); theCriteria->length( i + 1 ); @@ -1849,11 +2393,13 @@ static inline bool getCriteria( Predicate_i* thePred, theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); theCriteria[ i ].ThresholdID = aPred->GetShapeID(); theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + theCriteria[ i ].Tolerance = aPred->GetTolerance(); return true; } case FT_BelongToPlane: case FT_BelongToCylinder: + case FT_BelongToGenSurface: { BelongToSurface_i* aPred = dynamic_cast( thePred ); @@ -1883,6 +2429,23 @@ static inline bool getCriteria( Predicate_i* thePred, theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); theCriteria[ i ].ThresholdID = aPred->GetShapeID(); theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + theCriteria[ i ].Tolerance = aPred->GetTolerance(); + + return true; + } + case FT_CoplanarFaces: + { + CoplanarFaces_i* aPred = dynamic_cast( thePred ); + + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + CORBA::String_var faceId = aPred->GetFaceAsString(); + + theCriteria[ i ].Type = FT_CoplanarFaces; + theCriteria[ i ].ThresholdID = faceId; + theCriteria[ i ].Tolerance = aPred->GetTolerance(); return true; } @@ -1957,6 +2520,33 @@ static inline bool getCriteria( Predicate_i* thePred, theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType; return getCriteria( aPred2, theCriteria ); } + case FT_GroupColor: + { + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + GroupColor_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].Type = aFType; + theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + theCriteria[ i ].ThresholdStr = aPred->GetColorStr(); + + return true; + } + case FT_ElemGeomType: + { + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + ElemGeomType_i* aPred = dynamic_cast( thePred ); + theCriteria[ i ].Type = aFType; + theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + theCriteria[ i ].Threshold = (double)aPred->GetGeometryType(); + return true; + } case FT_Undefined: return false; @@ -2006,9 +2596,19 @@ 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<<","<CreateVolume3D(); break; + case SMESH::FT_MaxElementLength2D: + aFunctor = aFilterMgr->CreateMaxElementLength2D(); + break; + case SMESH::FT_MaxElementLength3D: + aFunctor = aFilterMgr->CreateMaxElementLength3D(); + break; // Predicates @@ -2062,22 +2668,34 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria case SMESH::FT_FreeEdges: aPredicate = aFilterMgr->CreateFreeEdges(); break; + case SMESH::FT_FreeFaces: + aPredicate = aFilterMgr->CreateFreeFaces(); + break; + case SMESH::FT_FreeNodes: + aPredicate = aFilterMgr->CreateFreeNodes(); + break; case SMESH::FT_BelongToGeom: { SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom(); tmpPred->SetElementType( aTypeOfElem ); tmpPred->SetShape( aThresholdID, aThresholdStr ); + tmpPred->SetTolerance( aTolerance ); 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(); + 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; @@ -2087,7 +2705,8 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria { SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom(); tmpPred->SetElementType( aTypeOfElem ); - tmpPred->SetShape( aThresholdID, aThresholdStr ); + tmpPred->SetShape( aThresholdID, aThresholdStr ); + tmpPred->SetTolerance( aTolerance ); aPredicate = tmpPred; } break; @@ -2104,6 +2723,37 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria aPredicate = aFilterMgr->CreateBadOrientedVolume(); } break; + case SMESH::FT_LinearOrQuadratic: + { + SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic(); + tmpPred->SetElementType( aTypeOfElem ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_GroupColor: + { + SMESH::GroupColor_ptr tmpPred = aFilterMgr->CreateGroupColor(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetColorStr( aThresholdStr ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_ElemGeomType: + { + SMESH::ElemGeomType_ptr tmpPred = aFilterMgr->CreateElemGeomType(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetGeometryType( (GeometryType)(int)(aThreshold + 0.5) ); + aPredicate = tmpPred; + break; + } + case SMESH::FT_CoplanarFaces: + { + SMESH::CoplanarFaces_ptr tmpPred = aFilterMgr->CreateCoplanarFaces(); + tmpPred->SetFace( atol (aThresholdID )); + tmpPred->SetTolerance( aTolerance ); + aPredicate = tmpPred; + break; + } default: continue; @@ -2148,6 +2798,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()<