PAL7221 (DEVELOPMENT : Improve filter which find elements on Shape).

Add "LyingOnGeom" filter.
This commit is contained in:
mzn 2005-01-17 13:35:49 +00:00
parent 0677cc99fe
commit 157b19ec7f
5 changed files with 318 additions and 29 deletions

View File

@ -60,6 +60,7 @@ module SMESH
FT_BelongToGeom,
FT_BelongToPlane,
FT_BelongToCylinder,
FT_LyingOnGeom,
FT_RangeOfIds,
FT_LessThan,
FT_MoreThan,
@ -180,6 +181,19 @@ module SMESH
void SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType );
};
/*!
* Logical functor (predicate) "Lying On Geometry".
* Verify whether mesh element or node lying or partially lying on the pointed Geom Object
*/
interface LyingOnGeom: Predicate
{
void SetGeom( in GEOM::GEOM_Object theGeom );
void SetElementType( in ElementType theType );
void SetShapeName( in string theName );
string GetShapeName();
};
/*!
* Logical functor (predicate) "Free borders".
* Verify whether 1D mesh element is free ( i.e. connected to one face only )
@ -362,6 +376,8 @@ module SMESH
BelongToPlane CreateBelongToPlane();
BelongToCylinder CreateBelongToCylinder();
LyingOnGeom CreateLyingOnGeom();
FreeBorders CreateFreeBorders();
FreeEdges CreateFreeEdges();

View File

@ -658,7 +658,8 @@ bool SMESHGUI_FilterTable::IsValid( const bool theMess, const int theEntityType
if ( aCriterion == FT_RangeOfIds ||
aCriterion == FT_BelongToGeom ||
aCriterion == FT_BelongToPlane ||
aCriterion == FT_BelongToCylinder )
aCriterion == FT_BelongToCylinder ||
aCriterion == FT_LyingOnGeom)
{
if ( aTable->text( i, 2 ).isEmpty() )
{
@ -772,7 +773,8 @@ void SMESHGUI_FilterTable::GetCriterion( const int theRow,
if ( aCriterionType != FT_RangeOfIds &&
aCriterionType != FT_BelongToGeom &&
aCriterionType != FT_BelongToPlane &&
aCriterionType != FT_BelongToCylinder )
aCriterionType != FT_BelongToCylinder &&
aCriterionType != FT_LyingOnGeom)
{
theCriterion.Compare = ( (ComboItem*)aTable->item( theRow, 1 ) )->GetValue();
theCriterion.Threshold = aTable->item( theRow, 2 )->text().toDouble();
@ -817,7 +819,8 @@ void SMESHGUI_FilterTable::SetCriterion( const int theRow,
if ( theCriterion.Type != FT_RangeOfIds &&
theCriterion.Type != FT_BelongToGeom &&
theCriterion.Type != FT_BelongToPlane &&
theCriterion.Type != FT_BelongToCylinder )
theCriterion.Type != FT_BelongToCylinder &&
theCriterion.Type != FT_LyingOnGeom)
aTable->setText( theRow, 2, QString( "%1" ).arg( theCriterion.Threshold, 0, 'g', 15 ) );
else
aTable->setText( theRow, 2, QString( theCriterion.ThresholdStr ) );
@ -968,6 +971,7 @@ void SMESHGUI_FilterTable::updateAdditionalWidget()
ComboItem* anItem = ( (ComboItem*)aTable->item( aRow, 0 ) );
bool toEnable = ( (ComboItem*)aTable->item( aRow, 1 ) )->GetValue() == FT_EqualTo &&
GetCriterionType( aRow ) != FT_BelongToGeom &&
GetCriterionType( aRow ) != FT_LyingOnGeom &&
GetCriterionType( aRow ) != FT_RangeOfIds &&
GetCriterionType( aRow ) != FT_FreeEdges;
if ( !myAddWidgets.contains( anItem ) )
@ -1050,7 +1054,8 @@ void SMESHGUI_FilterTable::onCriterionChanged( const int row, const int col, con
else if ( aCriterionType == SMESH::FT_RangeOfIds ||
aCriterionType == SMESH::FT_BelongToGeom ||
aCriterionType == SMESH::FT_BelongToPlane ||
aCriterionType == SMESH::FT_BelongToCylinder )
aCriterionType == SMESH::FT_BelongToCylinder ||
aCriterionType == SMESH::FT_LyingOnGeom)
{
QMap<int, QString> aMap;
aMap[ FT_EqualTo ] = tr( "EQUAL_TO" );
@ -1242,6 +1247,7 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" );
aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
}
return aCriteria;
}
@ -1257,6 +1263,7 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" );
aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
}
return aCriteria;
}
@ -1276,6 +1283,7 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" );
aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" );
aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
aCriteria[ SMESH::FT_Length2D ] = tr( "LENGTH2D" );
aCriteria[ SMESH::FT_MultiConnection2D] = tr( "MULTI2D_BORDERS" );
}
@ -1289,6 +1297,7 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria( const int theType )
aCriteria[ SMESH::FT_AspectRatio3D] = tr( "ASPECT_RATIO_3D" );
aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" );
aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" );
aCriteria[ SMESH::FT_LyingOnGeom ] = tr( "LYING_ON_GEOM" );
}
return aCriteria;
}
@ -2002,7 +2011,8 @@ bool SMESHGUI_FilterDlg::isValid() const
int aType = myTable->GetCriterionType( i );
if ( aType == FT_BelongToGeom ||
aType == FT_BelongToPlane ||
aType == FT_BelongToCylinder )
aType == FT_BelongToCylinder ||
aType == FT_LyingOnGeom)
{
QString aName;
myTable->GetThreshold( i, aName );
@ -2421,7 +2431,8 @@ void SMESHGUI_FilterDlg::onSelectionDone()
!myTable->CurrentCell( aRow, aCol ) ||
myTable->GetCriterionType( aRow ) != FT_BelongToGeom &&
myTable->GetCriterionType( aRow ) != FT_BelongToPlane &&
myTable->GetCriterionType( aRow ) != FT_BelongToCylinder)
myTable->GetCriterionType( aRow ) != FT_BelongToCylinder &&
myTable->GetCriterionType( aRow ) != FT_LyingOnGeom )
return;
Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject() ;
@ -2464,9 +2475,10 @@ void SMESHGUI_FilterDlg::updateSelection()
if ( myTable->CurrentCell( aRow, aCol ) &&
( myTable->GetCriterionType( aRow ) == FT_BelongToGeom ||
myTable->GetCriterionType( aRow ) == FT_BelongToPlane ||
myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ) )
myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ||
myTable->GetCriterionType( aRow ) == FT_LyingOnGeom) )
{
if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom )
if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom || myTable->GetCriterionType( aRow ) == FT_LyingOnGeom )
mySelection->AddFilter( new SALOME_TypeFilter( "GEOM" ) );
else if ( myTable->GetCriterionType( aRow ) == FT_BelongToPlane )
mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Plane ) );

View File

@ -1048,6 +1048,9 @@ msgstr "Belong to Plane"
msgid "SMESHGUI_FilterTable::BELONG_TO_CYLINDER"
msgstr "Belong to Cylinder"
msgid "SMESHGUI_FilterTable::LYING_ON_GEOM"
msgstr "Lying on Geom"
# -------------- SMESHGUI_FilterDlg --------------
msgid "SMESHGUI_FilterDlg::TLT"
msgstr "Selection filter"

View File

@ -171,6 +171,143 @@ SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS()
return myMeshDS;
}
/*
Class : LyingOnGeom
Description : Predicate for verifying whether entiy lying or partially lying on
specified geometrical support
*/
Controls::LyingOnGeom::LyingOnGeom()
: myMeshDS(NULL),
myType(SMDSAbs_All)
{}
void Controls::LyingOnGeom::SetMesh( SMDS_Mesh* theMesh )
{
myMeshDS = dynamic_cast<SMESHDS_Mesh*>(theMesh);
}
void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
{
myShape = theShape;
}
bool Controls::LyingOnGeom::IsSatisfy( long theId )
{
if ( myMeshDS == 0 || myShape.IsNull() )
return false;
if( myType == SMDSAbs_Node )
{
if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
{
const SMDS_PositionPtr& aPosition = aNode->GetPosition();
SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
switch( aTypeOfPosition )
{
case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
}
}
}
else
{
if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
{
if( myType == SMDSAbs_All )
{
return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
}
else if( myType == anElem->GetType() )
{
switch( myType )
{
case SMDSAbs_Edge : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE );
case SMDSAbs_Face : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE );
case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
}
}
}
}
return false;
}
void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
{
myType = theType;
}
SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
{
return myType;
}
TopoDS_Shape Controls::LyingOnGeom::GetShape()
{
return myShape;
}
SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS()
{
return myMeshDS;
}
bool Controls::LyingOnGeom::Contains( SMESHDS_Mesh* theMeshDS,
const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum,
TopAbs_ShapeEnum theAvoidShapeEnum )
{
if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
return true;
if ( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( theShape ) )
{
SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
while ( aNodeIt->more() )
{
const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
while ( anElemIt->more() )
{
const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
if (anElement == theElem)
return true;
}
}
}
TopExp_Explorer anExp( theShape,TopAbs_VERTEX,theAvoidShapeEnum );
while( anExp.More() )
{
const TopoDS_Shape& aShape = anExp.Current();
if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
while ( aNodeIt->more() )
{
const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
while ( anElemIt->more() )
{
const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
if (anElement == theElem)
return true;
}
}
}
anExp.Next();
}
return false;
}
/*
AUXILIARY METHODS
@ -696,7 +833,57 @@ FunctorType BelongToCylinder_i::GetFunctorType()
return FT_BelongToCylinder;
}
/*
Class : LyingOnGeom_i
Description : Predicate for selection on geometrical support
*/
LyingOnGeom_i::LyingOnGeom_i()
{
myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
myShapeName = 0;
}
LyingOnGeom_i::~LyingOnGeom_i()
{
delete myShapeName;
}
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_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
myLyingOnGeomPtr->SetGeom( aLocShape );
}
void LyingOnGeom_i::SetGeom( const TopoDS_Shape& theShape )
{
myLyingOnGeomPtr->SetGeom( theShape );
}
void LyingOnGeom_i::SetElementType(ElementType theType){
myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType));
}
FunctorType LyingOnGeom_i::GetFunctorType()
{
return SMESH::FT_LyingOnGeom;
}
void LyingOnGeom_i::SetShapeName( const char* theName )
{
delete myShapeName;
myShapeName = strdup( theName );
myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
}
char* LyingOnGeom_i::GetShapeName()
{
return CORBA::string_dup( myShapeName );
}
/*
Class : FreeBorders_i
@ -1160,6 +1347,13 @@ BelongToCylinder_ptr FilterManager_i::CreateBelongToCylinder()
return anObj._retn();
}
LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
{
SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
SMESH::LyingOnGeom_var anObj = aServant->_this();
return anObj._retn();
}
FreeBorders_ptr FilterManager_i::CreateFreeBorders()
{
SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
@ -1400,6 +1594,21 @@ static inline bool getCriteria( Predicate_i* thePred,
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
theCriteria[ i ].Tolerance = aPred->GetTolerance();
return true;
}
case FT_LyingOnGeom:
{
LyingOnGeom_i* aPred = dynamic_cast<LyingOnGeom_i*>( thePred );
CORBA::ULong i = theCriteria->length();
theCriteria->length( i + 1 );
theCriteria[ i ] = createCriterion();
theCriteria[ i ].Type = FT_LyingOnGeom;
theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
return true;
}
case FT_RangeOfIds:
@ -1576,6 +1785,14 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
aPredicate = tmpPred;
}
break;
case SMESH::FT_LyingOnGeom:
{
SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
tmpPred->SetElementType( aTypeOfElem );
tmpPred->SetShapeName( aThresholdStr );
aPredicate = tmpPred;
}
break;
case SMESH::FT_RangeOfIds:
{
SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds();
@ -1786,6 +2003,7 @@ static inline LDOMString toString( const long theType )
case FT_BelongToGeom : return "Belong to Geom";
case FT_BelongToPlane : return "Belong to Plane";
case FT_BelongToCylinder: return "Belong to Cylinder";
case FT_LyingOnGeom : return "Lying on Geom";
case FT_RangeOfIds : return "Range of IDs";
case FT_FreeBorders : return "Free borders";
case FT_FreeEdges : return "Free edges";
@ -1819,6 +2037,7 @@ static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
else if ( theStr.equals( "Belong to Geom" ) ) return FT_BelongToGeom;
else if ( theStr.equals( "Belong to Plane" ) ) return FT_BelongToPlane;
else if ( theStr.equals( "Belong to Cylinder" ) ) return FT_BelongToCylinder;
else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom;
else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders;
else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges;
else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection;
@ -2334,23 +2553,3 @@ string_array* FilterLibrary_i::GetAllNames()
return aResArray._retn();
}

View File

@ -72,6 +72,39 @@ private:
SMDSAbs_ElementType myType;
};
typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
/*
Class : LyingOnGeom
Description : Predicate for verifying whether entiy lying or partially lying on
specified geometrical support
*/
class LyingOnGeom: public virtual Predicate
{
public:
LyingOnGeom();
virtual void SetMesh( SMDS_Mesh* theMesh );
virtual void SetGeom( const TopoDS_Shape& theShape );
virtual bool IsSatisfy( long theElementId );
virtual void SetType( SMDSAbs_ElementType theType );
virtual SMDSAbs_ElementType GetType() const;
TopoDS_Shape GetShape();
SMESHDS_Mesh* GetMeshDS();
virtual bool Contains( SMESHDS_Mesh* theMeshDS,
const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum,
TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
private:
TopoDS_Shape myShape;
SMESHDS_Mesh* myMeshDS;
SMDSAbs_ElementType myType;
};
typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
}
/*
@ -359,6 +392,30 @@ public:
FunctorType GetFunctorType();
};
/*
Class : LyingOnGeom_i
Description : Predicate for selection on geometrical support(lying or partially lying)
*/
class LyingOnGeom_i: public virtual POA_SMESH::LyingOnGeom,
public virtual Predicate_i
{
public:
LyingOnGeom_i();
virtual ~LyingOnGeom_i();
void SetGeom( GEOM::GEOM_Object_ptr theGeom );
void SetElementType( ElementType theType );
FunctorType GetFunctorType();
void SetGeom( const TopoDS_Shape& theShape );
void SetShapeName( const char* theName );
char* GetShapeName();
protected:
Controls::LyingOnGeomPtr myLyingOnGeomPtr;
char* myShapeName;
};
/*
Class : FreeBorders_i
@ -642,6 +699,8 @@ public:
BelongToPlane_ptr CreateBelongToPlane();
BelongToCylinder_ptr CreateBelongToCylinder();
LyingOnGeom_ptr CreateLyingOnGeom();
FreeBorders_ptr CreateFreeBorders();
FreeEdges_ptr CreateFreeEdges();