0020833: EDF 1361 SMESH : Graphical Selection of the boundary faces in one clic

+    FT_CoplanarFaces,
This commit is contained in:
eap 2010-10-14 11:08:06 +00:00
parent 263a1ad899
commit c9fbd2bbf8
8 changed files with 359 additions and 99 deletions

View File

@ -65,6 +65,7 @@ module SMESH
FT_LinearOrQuadratic, FT_LinearOrQuadratic,
FT_GroupColor, FT_GroupColor,
FT_ElemGeomType, FT_ElemGeomType,
FT_CoplanarFaces,
FT_LessThan, FT_LessThan,
FT_MoreThan, FT_MoreThan,
FT_EqualTo, FT_EqualTo,
@ -346,6 +347,16 @@ module SMESH
void SetGeometryType( in GeometryType theType ); void SetGeometryType( in GeometryType theType );
}; };
/*!
* Functor "Coplanar faces"
* Returns true if a mesh face is a coplanar neighbour to a given one. It checks
* if normal of a face has angle with the threshold face less than a tolerance.
*/
interface CoplanarFaces : Predicate{
void SetFace ( in long theFaceID );
void SetTolerance( in double theToler );
};
/*! /*!
* Filter * Filter
*/ */
@ -360,13 +371,13 @@ module SMESH
* BinaryOp - binary logical operation FT_LogicalAND, FT_LogicalOR or * BinaryOp - binary logical operation FT_LogicalAND, FT_LogicalOR or
* (FT_Undefined must be for the last criterion) * (FT_Undefined must be for the last criterion)
* ThresholdStr - Threshold value defined as string. Used for: * ThresholdStr - Threshold value defined as string. Used for:
* 1. Diaposon of identifiers. Example: "1,2,3,5-10,12,27-29" * 1. Diapason of identifiers. Example: "1,2,3,5-10,12,27-29"
* 2. BelongToGeom predicate for storing name of shape * 2. BelongToGeom predicate for storing name of shape
* 3. GroupColor predicate for storing group color "0.2;0;0.5" * 3. GroupColor predicate for storing group color "0.2;0;0.5"
* ThresholdID - One more threshold value defined as string. Used for: * ThresholdID - One more threshold value defined as string. Used for:
* 1. BelongToGeom predicate for storing id of shape * 1. BelongToGeom predicate for storing id of shape
* Tolerance - Tolerance is used for comparators (EqualTo comparision) and for * Tolerance - Tolerance is used for comparators (EqualTo comparision) and for
* "Belong to plane" and "Belong to cylinder" predicates * "Belong to plane", "Belong to cylinder" etc predicates
* TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only) * TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only)
* Precision - Precision of numerical functors * Precision - Precision of numerical functors
*/ */
@ -477,6 +488,7 @@ module SMESH
GroupColor CreateGroupColor(); GroupColor CreateGroupColor();
ElemGeomType CreateElemGeomType(); ElemGeomType CreateElemGeomType();
CoplanarFaces CreateCoplanarFaces();
/*! /*!
* Create comparators ( predicates ) * Create comparators ( predicates )

View File

@ -70,6 +70,12 @@
*/ */
namespace{ namespace{
inline gp_XYZ gpXYZ(const SMDS_MeshNode* aNode )
{
return gp_XYZ(aNode->X(), aNode->Y(), aNode->Z() );
}
inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 )
{ {
gp_Vec v1( P1 - P2 ), v2( P3 - P2 ); gp_Vec v1( P1 - P2 ), v2( P3 - P2 );
@ -171,6 +177,26 @@ namespace{
return aResult; return aResult;
} }
gp_XYZ getNormale( const SMDS_MeshFace* theFace, bool* ok=0 )
{
int aNbNode = theFace->NbNodes();
gp_XYZ q1 = gpXYZ( theFace->GetNode(1)) - gpXYZ( theFace->GetNode(0));
gp_XYZ q2 = gpXYZ( theFace->GetNode(2)) - gpXYZ( theFace->GetNode(0));
gp_XYZ n = q1 ^ q2;
if ( aNbNode > 3 ) {
gp_XYZ q3 = gpXYZ( theFace->GetNode(3)) - gpXYZ( theFace->GetNode(0));
n += q2 ^ q3;
}
double len = n.Modulus();
bool zeroLen = ( len <= numeric_limits<double>::min());
if ( !zeroLen )
n /= len;
if (ok) *ok = !zeroLen;
return n;
}
} }
@ -178,8 +204,8 @@ namespace{
using namespace SMESH::Controls; using namespace SMESH::Controls;
/* /*
FUNCTORS * FUNCTORS
*/ */
/* /*
Class : NumericalFunctor Class : NumericalFunctor
@ -2002,13 +2028,71 @@ SMDSAbs_GeometryType ElemGeomType::GetGeomType() const
return myGeomType; return myGeomType;
} }
//================================================================================
/*!
* \brief Class CoplanarFaces
*/
//================================================================================
CoplanarFaces::CoplanarFaces()
: myMesh(0), myFaceID(0), myToler(0)
{
}
bool CoplanarFaces::IsSatisfy( long theElementId )
{
if ( myCoplanarIDs.empty() )
{
// Build a set of coplanar face ids
if ( !myMesh || !myFaceID || !myToler )
return false;
const SMDS_MeshElement* face = myMesh->FindElement( myFaceID );
if ( !face || face->GetType() != SMDSAbs_Face )
return false;
bool normOK;
gp_Vec myNorm = getNormale( static_cast<const SMDS_MeshFace*>(face), &normOK );
if (!normOK)
return false;
const double radianTol = myToler * PI180;
typedef SMDS_StdIterator< const SMDS_MeshElement*, SMDS_ElemIteratorPtr > TFaceIt;
std::set<const SMDS_MeshElement*> checkedFaces, checkedNodes;
std::list<const SMDS_MeshElement*> faceQueue( 1, face );
while ( !faceQueue.empty() )
{
face = faceQueue.front();
if ( checkedFaces.insert( face ).second )
{
gp_Vec norm = getNormale( static_cast<const SMDS_MeshFace*>(face), &normOK );
if (!normOK || myNorm.Angle( norm ) <= radianTol)
{
myCoplanarIDs.insert( face->GetID() );
std::set<const SMDS_MeshElement*> neighborFaces;
for ( int i = 0; i < face->NbCornerNodes(); ++i )
{
const SMDS_MeshNode* n = face->GetNode( i );
if ( checkedNodes.insert( n ).second )
neighborFaces.insert( TFaceIt( n->GetInverseElementIterator(SMDSAbs_Face)),
TFaceIt());
}
faceQueue.insert( faceQueue.end(), neighborFaces.begin(), neighborFaces.end() );
}
}
faceQueue.pop_front();
}
}
return myCoplanarIDs.count( theElementId );
}
/* /*
Class : RangeOfIds *Class : RangeOfIds
Description : Predicate for Range of Ids. *Description : Predicate for Range of Ids.
Range may be specified with two ways. * Range may be specified with two ways.
1. Using AddToRange method * 1. Using AddToRange method
2. With SetRangeStr method. Parameter of this method is a string * 2. With SetRangeStr method. Parameter of this method is a string
like as "1,2,3,50-60,63,67,70-" * like as "1,2,3,50-60,63,67,70-"
*/ */
//======================================================================= //=======================================================================
@ -2638,32 +2722,6 @@ static void getLinks( const SMDS_MeshFace* theFace,
} }
} }
static gp_XYZ getNormale( const SMDS_MeshFace* theFace )
{
gp_XYZ n;
int aNbNode = theFace->NbNodes();
TColgp_Array1OfXYZ anArrOfXYZ(1,4);
SMDS_ElemIteratorPtr aNodeItr = theFace->nodesIterator();
int i = 1;
for ( ; aNodeItr->more() && i <= 4; i++ ) {
SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next();
anArrOfXYZ.SetValue(i, gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) );
}
gp_XYZ q1 = anArrOfXYZ.Value(2) - anArrOfXYZ.Value(1);
gp_XYZ q2 = anArrOfXYZ.Value(3) - anArrOfXYZ.Value(1);
n = q1 ^ q2;
if ( aNbNode > 3 ) {
gp_XYZ q3 = anArrOfXYZ.Value(4) - anArrOfXYZ.Value(1);
n += q2 ^ q3;
}
double len = n.Modulus();
if ( len > 0 )
n /= len;
return n;
}
bool ManifoldPart::findConnected bool ManifoldPart::findConnected
( const ManifoldPart::TDataMapFacePtrInt& theAllFacePtrInt, ( const ManifoldPart::TDataMapFacePtrInt& theAllFacePtrInt,
SMDS_MeshFace* theStartFace, SMDS_MeshFace* theStartFace,

View File

@ -784,6 +784,31 @@ namespace SMESH{
}; };
typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr; typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
/*
Class : CoplanarFaces
Description : Predicate to check angle between faces
*/
class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
{
public:
CoplanarFaces();
void SetFace( long theID ) { myFaceID = theID; }
long GetFace() const { return myFaceID; }
void SetTolerance (const double theToler) { myToler = theToler; }
double GetTolerance () const { return myToler; }
virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
virtual bool IsSatisfy( long theElementId );
private:
const SMDS_Mesh* myMesh;
long myFaceID;
double myToler;
std::set< long > myCoplanarIDs;
};
typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
/* /*
FILTER FILTER
*/ */

View File

@ -968,13 +968,16 @@ bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType)
QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(i, 2)); QtxColorButton* clrBtn = qobject_cast<QtxColorButton*>(aTable->cellWidget(i, 2));
if (clrBtn && !clrBtn->color().isValid()) if (clrBtn && !clrBtn->color().isValid())
errMsg = tr( "GROUPCOLOR_ERROR" ); errMsg = tr( "GROUPCOLOR_ERROR" );
} else if (aCriterion == SMESH::FT_RangeOfIds || }
else if (aCriterion == SMESH::FT_RangeOfIds ||
aCriterion == SMESH::FT_BelongToGeom || aCriterion == SMESH::FT_BelongToGeom ||
aCriterion == SMESH::FT_BelongToPlane || aCriterion == SMESH::FT_BelongToPlane ||
aCriterion == SMESH::FT_BelongToCylinder || aCriterion == SMESH::FT_BelongToCylinder ||
aCriterion == SMESH::FT_BelongToGenSurface || aCriterion == SMESH::FT_BelongToGenSurface ||
aCriterion == SMESH::FT_ElemGeomType || aCriterion == SMESH::FT_ElemGeomType ||
aCriterion == SMESH::FT_LyingOnGeom) { aCriterion == SMESH::FT_CoplanarFaces ||
aCriterion == SMESH::FT_LyingOnGeom)
{
if (aTable->text(i, 2).isEmpty()) if (aTable->text(i, 2).isEmpty())
errMsg = tr( "ERROR" ); errMsg = tr( "ERROR" );
} }
@ -1088,12 +1091,14 @@ void SMESHGUI_FilterTable::GetCriterion (const int theRow,
} }
else if ( aCriterionType == SMESH::FT_ElemGeomType ) else if ( aCriterionType == SMESH::FT_ElemGeomType )
theCriterion.Threshold = (double)((ComboItem*)aTable->item(theRow, 2))->value(); theCriterion.Threshold = (double)((ComboItem*)aTable->item(theRow, 2))->value();
else if ( aCriterionType == SMESH::FT_CoplanarFaces )
theCriterion.ThresholdID = aTable->text(theRow, 2).toLatin1().constData();
else if ( aCriterionType != SMESH::FT_RangeOfIds && else if ( aCriterionType != SMESH::FT_RangeOfIds &&
aCriterionType != SMESH::FT_BelongToGeom && aCriterionType != SMESH::FT_BelongToGeom &&
aCriterionType != SMESH::FT_BelongToPlane && aCriterionType != SMESH::FT_BelongToPlane &&
aCriterionType != SMESH::FT_BelongToCylinder && aCriterionType != SMESH::FT_BelongToCylinder &&
aCriterionType != SMESH::FT_BelongToGenSurface && aCriterionType != SMESH::FT_BelongToGenSurface &&
aCriterionType != SMESH::FT_LyingOnGeom) aCriterionType != SMESH::FT_LyingOnGeom )
{ {
theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->value(); theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->value();
theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble(); theCriterion.Threshold = aTable->item(theRow, 2)->text().toDouble();
@ -1159,19 +1164,26 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow,
ComboItem* typeBox = (ComboItem*)aTable->item(theRow, 2); ComboItem* typeBox = (ComboItem*)aTable->item(theRow, 2);
typeBox->setValue( (int)(theCriterion.Threshold + 0.5) ); typeBox->setValue( (int)(theCriterion.Threshold + 0.5) );
} }
else if (theCriterion.Type == SMESH::FT_CoplanarFaces )
{
aTable->item( theRow, 2 )->setText( QString( theCriterion.ThresholdID ) );
}
else if (theCriterion.Type != SMESH::FT_RangeOfIds && else if (theCriterion.Type != SMESH::FT_RangeOfIds &&
theCriterion.Type != SMESH::FT_BelongToGeom && theCriterion.Type != SMESH::FT_BelongToGeom &&
theCriterion.Type != SMESH::FT_BelongToPlane && theCriterion.Type != SMESH::FT_BelongToPlane &&
theCriterion.Type != SMESH::FT_BelongToCylinder && theCriterion.Type != SMESH::FT_BelongToCylinder &&
theCriterion.Type != SMESH::FT_BelongToGenSurface && theCriterion.Type != SMESH::FT_BelongToGenSurface &&
theCriterion.Type != SMESH::FT_LyingOnGeom && theCriterion.Type != SMESH::FT_LyingOnGeom &&
theCriterion.Type != SMESH::FT_CoplanarFaces &&
theCriterion.Type != SMESH::FT_FreeBorders && theCriterion.Type != SMESH::FT_FreeBorders &&
theCriterion.Type != SMESH::FT_FreeEdges && theCriterion.Type != SMESH::FT_FreeEdges &&
theCriterion.Type != SMESH::FT_FreeNodes && theCriterion.Type != SMESH::FT_FreeNodes &&
theCriterion.Type != SMESH::FT_FreeFaces && theCriterion.Type != SMESH::FT_FreeFaces &&
theCriterion.Type != SMESH::FT_BadOrientedVolume && theCriterion.Type != SMESH::FT_BadOrientedVolume &&
theCriterion.Type != SMESH::FT_LinearOrQuadratic) theCriterion.Type != SMESH::FT_LinearOrQuadratic)
{
aTable->item( theRow, 2 )->setText(QString("%1").arg(theCriterion.Threshold, 0, 'g', 15)); aTable->item( theRow, 2 )->setText(QString("%1").arg(theCriterion.Threshold, 0, 'g', 15));
}
else else
{ {
aTable->item( theRow, 2 )->setText(QString(theCriterion.ThresholdStr)); aTable->item( theRow, 2 )->setText(QString(theCriterion.ThresholdStr));
@ -1184,7 +1196,8 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow,
theCriterion.Type == SMESH::FT_BelongToCylinder || theCriterion.Type == SMESH::FT_BelongToCylinder ||
theCriterion.Type == SMESH::FT_BelongToGenSurface || theCriterion.Type == SMESH::FT_BelongToGenSurface ||
theCriterion.Type == SMESH::FT_BelongToGeom || theCriterion.Type == SMESH::FT_BelongToGeom ||
theCriterion.Type == SMESH::FT_LyingOnGeom) theCriterion.Type == SMESH::FT_LyingOnGeom ||
theCriterion.Type == SMESH::FT_CoplanarFaces)
{ {
QTableWidgetItem* anItem = aTable->item(theRow, 0); QTableWidgetItem* anItem = aTable->item(theRow, 0);
if (!myAddWidgets.contains(anItem)) if (!myAddWidgets.contains(anItem))
@ -1324,11 +1337,13 @@ void SMESHGUI_FilterTable::updateAdditionalWidget()
ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0)); ComboItem* anItem = ((ComboItem*)aTable->item(aRow, 0));
int aCriterion = GetCriterionType(aRow); int aCriterion = GetCriterionType(aRow);
bool toEnable = ((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo && bool toEnable = ((((ComboItem*)aTable->item(aRow, 1))->value() == SMESH::FT_EqualTo &&
aCriterion != SMESH::FT_RangeOfIds && aCriterion != SMESH::FT_RangeOfIds &&
aCriterion != SMESH::FT_FreeEdges && aCriterion != SMESH::FT_FreeEdges &&
aCriterion != SMESH::FT_FreeFaces && aCriterion != SMESH::FT_FreeFaces &&
aCriterion != SMESH::FT_BadOrientedVolume; aCriterion != SMESH::FT_BadOrientedVolume)
||
aCriterion == SMESH::FT_CoplanarFaces);
if (!myAddWidgets.contains(anItem)) if (!myAddWidgets.contains(anItem))
{ {
@ -1352,6 +1367,7 @@ const char* SMESHGUI_FilterTable::getPrecision( const int aType )
case SMESH::FT_Warping: case SMESH::FT_Warping:
case SMESH::FT_MinimumAngle: case SMESH::FT_MinimumAngle:
case SMESH::FT_Skew: case SMESH::FT_Skew:
case SMESH::FT_CoplanarFaces:
retval = "angle_precision"; break; retval = "angle_precision"; break;
case SMESH::FT_Area: case SMESH::FT_Area:
retval = "area_precision"; break; retval = "area_precision"; break;
@ -1466,7 +1482,7 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
bool isComboItem = false; bool isComboItem = false;
if (aTableItem) { if (aTableItem) {
int aTableType = aTable->item(row, 2)->type(); int aTableType = aTable->item(row, 2)->type();
isComboItem = aTableType == aComboType ? true : false; isComboItem = ( aTableType == aComboType );
} }
if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) || if ( (aCriterionType != SMESH::FT_GroupColor && clrBtn) ||
@ -1500,14 +1516,16 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
aTable->blockSignals( isSignalsBlocked ); aTable->blockSignals( isSignalsBlocked );
} }
if (aType == SMESH::NODE && aCriterionType == SMESH::FT_FreeNodes || if ((aType == SMESH::NODE && aCriterionType == SMESH::FT_FreeNodes ) ||
aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders || (aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders ) ||
aType == SMESH::FACE && (aCriterionType == SMESH::FT_FreeEdges || (aType == SMESH::FACE && (aCriterionType == SMESH::FT_FreeEdges ||
aCriterionType == SMESH::FT_FreeFaces) || aCriterionType == SMESH::FT_FreeFaces)) ||
aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume || (aType == SMESH::VOLUME && aCriterionType == SMESH::FT_BadOrientedVolume) ||
aCriterionType == SMESH::FT_LinearOrQuadratic || aCriterionType == SMESH::FT_LinearOrQuadratic ||
aCriterionType == SMESH::FT_GroupColor || aCriterionType == SMESH::FT_GroupColor ||
aCriterionType == SMESH::FT_ElemGeomType) aCriterionType == SMESH::FT_ElemGeomType ||
aCriterionType == SMESH::FT_CoplanarFaces
)
{ {
bool isSignalsBlocked = aTable->signalsBlocked(); bool isSignalsBlocked = aTable->signalsBlocked();
aTable->blockSignals( true ); aTable->blockSignals( true );
@ -1516,7 +1534,8 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con
aCompareItem->clear(); aCompareItem->clear();
aTable->setEditable(false, row, 1); aTable->setEditable(false, row, 1);
aTable->setEditable(aCriterionType == SMESH::FT_GroupColor || aTable->setEditable(aCriterionType == SMESH::FT_GroupColor ||
aCriterionType == SMESH::FT_ElemGeomType, row, 2); aCriterionType == SMESH::FT_ElemGeomType ||
aCriterionType == SMESH::FT_CoplanarFaces, row, 2);
aTable->blockSignals( isSignalsBlocked ); aTable->blockSignals( isSignalsBlocked );
} }
else if (aCriterionType == SMESH::FT_RangeOfIds || else if (aCriterionType == SMESH::FT_RangeOfIds ||
@ -1789,6 +1808,7 @@ const QMap<int, QString>& SMESHGUI_FilterTable::getCriteria (const int theType)
aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR"); aCriteria[ SMESH::FT_LinearOrQuadratic ] = tr("LINEAR");
aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR"); aCriteria[ SMESH::FT_GroupColor ] = tr("GROUP_COLOR");
aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE"); aCriteria[ SMESH::FT_ElemGeomType ] = tr("GEOM_TYPE");
aCriteria[ SMESH::FT_CoplanarFaces ] = tr("COPLANAR_FACES");
} }
return aCriteria; return aCriteria;
} }
@ -2638,7 +2658,8 @@ bool SMESHGUI_FilterDlg::isValid() const
aType == SMESH::FT_BelongToPlane || aType == SMESH::FT_BelongToPlane ||
aType == SMESH::FT_BelongToCylinder || aType == SMESH::FT_BelongToCylinder ||
aType == SMESH::FT_BelongToGenSurface || aType == SMESH::FT_BelongToGenSurface ||
aType == SMESH::FT_LyingOnGeom) { aType == SMESH::FT_LyingOnGeom)
{
QString aName; QString aName;
myTable->GetThreshold(i, aName); myTable->GetThreshold(i, aName);
@ -2687,6 +2708,29 @@ bool SMESHGUI_FilterDlg::isValid() const
} }
} }
} }
else if (aType == SMESH::FT_CoplanarFaces)
{
QString faceID;
myTable->GetThreshold(i, faceID);
if ( faceID.isEmpty() )
{
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr("FACE_ID_NOT_SELECTED"));
return false;
}
if ( myMesh->_is_nil() )
{
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr("MESH_IS_NOT_SELECTED"));
return false;
}
if ( myMesh->GetElementType( faceID.toLong(), /*iselem=*/true) != SMESH::FACE )
{
SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr("NOT_FACE_ID").arg(faceID));
return false;
}
}
} }
return true; return true;
@ -2705,7 +2749,7 @@ void SMESHGUI_FilterDlg::SetSourceWg (QWidget* theWg,
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_FilterDlg::SetGroupIds // name : SMESHGUI_FilterDlg::SetMesh
// Purpose : Set mesh // Purpose : Set mesh
//======================================================================= //=======================================================================
void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_var theMesh) void SMESHGUI_FilterDlg::SetMesh (SMESH::SMESH_Mesh_var theMesh)
@ -3067,11 +3111,21 @@ void SMESHGUI_FilterDlg::onSelectionDone()
QList<int> types; QList<int> types;
types << SMESH::FT_BelongToGeom << SMESH::FT_BelongToPlane types << SMESH::FT_BelongToGeom << SMESH::FT_BelongToPlane
<< SMESH::FT_BelongToCylinder << SMESH::FT_BelongToGenSurface << SMESH::FT_BelongToCylinder << SMESH::FT_BelongToGenSurface
<< SMESH::FT_LyingOnGeom; << SMESH::FT_LyingOnGeom << SMESH::FT_CoplanarFaces;
if (aList.Extent() != 1 || !myTable->CurrentCell(aRow, aCol) || if (aList.Extent() != 1 || !myTable->CurrentCell(aRow, aCol) ||
!types.contains(myTable->GetCriterionType(aRow))) !types.contains(myTable->GetCriterionType(aRow)))
return; return;
if ( myTable->GetCriterionType(aRow) == SMESH::FT_CoplanarFaces )
{
QString aString;
int nbElems = SMESH::GetNameOfSelectedElements(mySelector,//myViewWindow->GetSelector(),
aList.First(), aString);
if (nbElems == 1)
myTable->SetThreshold(aRow, aString);
}
else
{
Handle(SALOME_InteractiveObject) anIO = aList.First(); Handle(SALOME_InteractiveObject) anIO = aList.First();
GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO); GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
if (!anObj->_is_nil()) if (!anObj->_is_nil())
@ -3080,6 +3134,7 @@ void SMESHGUI_FilterDlg::onSelectionDone()
//myTable->SetID( aRow, GEOMBase::GetIORFromObject(anObj)); //myTable->SetID( aRow, GEOMBase::GetIORFromObject(anObj));
myTable->SetID(aRow, anIO->getEntry()); myTable->SetID(aRow, anIO->getEntry());
} }
}
} }
@ -3110,9 +3165,9 @@ void SMESHGUI_FilterDlg::updateSelection()
if (mySelectionMgr == 0) if (mySelectionMgr == 0)
return; return;
TColStd_MapOfInteger allTypes; // TColStd_MapOfInteger allTypes;
for( int i=0; i<10; i++ ) // for( int i=0; i<10; i++ )
allTypes.Add( i ); // allTypes.Add( i );
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() ); SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
if( !aStudy ) if( !aStudy )
return; return;
@ -3128,8 +3183,8 @@ void SMESHGUI_FilterDlg::updateSelection()
aCriterionType == SMESH::FT_BelongToPlane || aCriterionType == SMESH::FT_BelongToPlane ||
aCriterionType == SMESH::FT_BelongToCylinder || aCriterionType == SMESH::FT_BelongToCylinder ||
aCriterionType == SMESH::FT_BelongToGenSurface || aCriterionType == SMESH::FT_BelongToGenSurface ||
aCriterionType == SMESH::FT_LyingOnGeom)) { aCriterionType == SMESH::FT_LyingOnGeom))
{
if (aCriterionType == SMESH::FT_BelongToGeom || if (aCriterionType == SMESH::FT_BelongToGeom ||
aCriterionType == SMESH::FT_BelongToGenSurface || aCriterionType == SMESH::FT_BelongToGenSurface ||
aCriterionType == SMESH::FT_LyingOnGeom) { aCriterionType == SMESH::FT_LyingOnGeom) {
@ -3144,7 +3199,9 @@ void SMESHGUI_FilterDlg::updateSelection()
} }
myIsSelectionChanged = true; myIsSelectionChanged = true;
} else { }
else
{
if (myIsSelectionChanged) { if (myIsSelectionChanged) {
mySelectionMgr->installFilter( new GEOM_TypeFilter( aStudy, -1 ) ); // This filter deactivates selection mySelectionMgr->installFilter( new GEOM_TypeFilter( aStudy, -1 ) ); // This filter deactivates selection
} }

View File

@ -3932,6 +3932,16 @@ Please select a face and try again</translation>
<source>SHAPE_IS_NOT_A_PLANE</source> <source>SHAPE_IS_NOT_A_PLANE</source>
<translation>&quot;%1&quot; is not a plane <translation>&quot;%1&quot; is not a plane
Please select a plane and try again</translation> Please select a plane and try again</translation>
</message>
<message>
<source>FACE_ID_NOT_SELECTED</source>
<translation>Mesh face is not selected
Please specify it and try again</translation>
</message>
<message>
<source>NOT_FACE_ID</source>
<translation>&quot;%1&quot; is not an ID of a mesh face.
Please select a face and try again</translation>
</message> </message>
<message> <message>
<source>SOURCE</source> <source>SOURCE</source>
@ -4140,6 +4150,10 @@ Please check input data and try again</translation>
<source>COMPARE</source> <source>COMPARE</source>
<translation>Compare</translation> <translation>Compare</translation>
</message> </message>
<message>
<source>COPLANAR_FACES</source>
<translation>Coplanar faces</translation>
</message>
<message> <message>
<source>COPY_FROM</source> <source>COPY_FROM</source>
<translation>Copy from...</translation> <translation>Copy from...</translation>

View File

@ -287,6 +287,7 @@ namespace SMESH
case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break; case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break;
case FT_BelongToGenSurface:myStream<<"aBelongToGenSurface";break; case FT_BelongToGenSurface:myStream<<"aBelongToGenSurface";break;
case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break; case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break;
case FT_CoplanarFaces: myStream<< "aCoplanarFaces"; break;
case FT_RangeOfIds: myStream<< "aRangeOfIds"; break; case FT_RangeOfIds: myStream<< "aRangeOfIds"; break;
case FT_BadOrientedVolume:myStream<< "aBadOrientedVolume";break; case FT_BadOrientedVolume:myStream<< "aBadOrientedVolume";break;
case FT_LinearOrQuadratic:myStream<< "aLinearOrQuadratic";break; case FT_LinearOrQuadratic:myStream<< "aLinearOrQuadratic";break;

View File

@ -1443,7 +1443,7 @@ void ElemGeomType_i::SetGeometryType(GeometryType theType)
GeometryType ElemGeomType_i::GetGeometryType() const GeometryType ElemGeomType_i::GetGeometryType() const
{ {
return (GeometryType)myElemGeomTypePtr->GetGeomType();; return (GeometryType)myElemGeomTypePtr->GetGeomType();
} }
FunctorType ElemGeomType_i::GetFunctorType() FunctorType ElemGeomType_i::GetFunctorType()
@ -1451,6 +1451,49 @@ FunctorType ElemGeomType_i::GetFunctorType()
return SMESH::FT_ElemGeomType; 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()<<this<<".SetFace("<<theFaceID<<")";
}
void CoplanarFaces_i::SetTolerance( CORBA::Double theToler )
{
myCoplanarFacesPtr->SetTolerance(theToler);
TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
}
CORBA::Long CoplanarFaces_i::GetFace () const
{
return myCoplanarFacesPtr->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 Class : Comparator_i
Description : Base class for comparators Description : Base class for comparators
@ -1867,6 +1910,14 @@ LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
return anObj._retn(); return anObj._retn();
} }
CoplanarFaces_ptr FilterManager_i::CreateCoplanarFaces()
{
SMESH::CoplanarFaces_i* aServant = new SMESH::CoplanarFaces_i();
SMESH::CoplanarFaces_var anObj = aServant->_this();
TPythonDump()<<aServant<<" = "<<this<<".CreateCoplanarFaces()";
return anObj._retn();
}
FreeBorders_ptr FilterManager_i::CreateFreeBorders() FreeBorders_ptr FilterManager_i::CreateFreeBorders()
{ {
SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i(); SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
@ -2300,6 +2351,22 @@ static inline bool getCriteria( Predicate_i* thePred,
theCriteria[ i ].TypeOfElement = aPred->GetElementType(); theCriteria[ i ].TypeOfElement = aPred->GetElementType();
theCriteria[ i ].Tolerance = aPred->GetTolerance(); theCriteria[ i ].Tolerance = aPred->GetTolerance();
return true;
}
case FT_CoplanarFaces:
{
CoplanarFaces_i* aPred = dynamic_cast<CoplanarFaces_i*>( 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; return true;
} }
case FT_RangeOfIds: case FT_RangeOfIds:
@ -2593,6 +2660,14 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
aPredicate = tmpPred; aPredicate = tmpPred;
break; break;
} }
case SMESH::FT_CoplanarFaces:
{
SMESH::CoplanarFaces_ptr tmpPred = aFilterMgr->CreateCoplanarFaces();
tmpPred->SetFace( atol (aThresholdID ));
tmpPred->SetTolerance( aTolerance );
aPredicate = tmpPred;
break;
}
default: default:
continue; continue;

View File

@ -622,6 +622,26 @@ namespace SMESH
Controls::ElemGeomTypePtr myElemGeomTypePtr; Controls::ElemGeomTypePtr myElemGeomTypePtr;
}; };
/*
Class : CoplanarFaces_i
Description : Returns true if a mesh face is a coplanar neighbour to a given one
*/
class SMESH_I_EXPORT CoplanarFaces_i: public virtual POA_SMESH::CoplanarFaces,
public virtual Predicate_i
{
public:
CoplanarFaces_i();
FunctorType GetFunctorType();
void SetFace ( CORBA::Long theFaceID );
void SetTolerance( CORBA::Double theToler );
char* GetFaceAsString () const;
CORBA::Long GetFace () const;
CORBA::Double GetTolerance () const;
private:
Controls::CoplanarFacesPtr myCoplanarFacesPtr;
};
/* /*
Class : Comparator_i Class : Comparator_i
Description : Base class for comparators Description : Base class for comparators
@ -908,13 +928,11 @@ namespace SMESH
FreeFaces_ptr CreateFreeFaces(); FreeFaces_ptr CreateFreeFaces();
RangeOfIds_ptr CreateRangeOfIds(); RangeOfIds_ptr CreateRangeOfIds();
BadOrientedVolume_ptr CreateBadOrientedVolume(); BadOrientedVolume_ptr CreateBadOrientedVolume();
LinearOrQuadratic_ptr CreateLinearOrQuadratic(); LinearOrQuadratic_ptr CreateLinearOrQuadratic();
GroupColor_ptr CreateGroupColor(); GroupColor_ptr CreateGroupColor();
ElemGeomType_ptr CreateElemGeomType(); ElemGeomType_ptr CreateElemGeomType();
CoplanarFaces_ptr CreateCoplanarFaces();
LessThan_ptr CreateLessThan(); LessThan_ptr CreateLessThan();
MoreThan_ptr CreateMoreThan(); MoreThan_ptr CreateMoreThan();