From: eap Date: Wed, 27 Dec 2006 08:30:03 +0000 (+0000) Subject: Add BelongToGenSurface predicate X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1b151a4568db40e23b9c8e65f6346a26a8468de7;p=modules%2Fsmesh.git Add BelongToGenSurface predicate --- diff --git a/idl/SMESH_Filter.idl b/idl/SMESH_Filter.idl index 5018b0781..fcb5a9936 100644 --- a/idl/SMESH_Filter.idl +++ b/idl/SMESH_Filter.idl @@ -55,6 +55,7 @@ module SMESH FT_BelongToGeom, FT_BelongToPlane, FT_BelongToCylinder, + FT_BelongToGenSurface, FT_LyingOnGeom, FT_RangeOfIds, FT_BadOrientedVolume, @@ -158,22 +159,28 @@ module SMESH /*! * Logical functor (predicate) "Belong To Surface". - * Base interface for "belong to plane" and "belong to cylinder interfaces" + * Base interface for "belong to plane" and "belong to cylinder" + * and "Belong To Generic Surface" interfaces */ interface BelongToSurface: Predicate { - void SetTolerance( in double theToler ); - double GetTolerance(); - void SetShapeName( in string theName, in ElementType theType ); - void SetShape( in string theID, in string theName, in ElementType theType ); - string GetShapeName(); - string GetShapeID(); + void SetTolerance( in double theToler ); + double GetTolerance(); + void SetShapeName( in string theName, in ElementType theType ); + void SetShape( in string theID, in string theName, in ElementType theType ); + string GetShapeName(); + string GetShapeID(); + /*! + * Limit surface extent to bounding box of boundaries (edges) + * in surface parametric space. Boundaries are ignored by default + */ + void SetUseBoundaries( in boolean theUseBndRestrictions ); + boolean GetUseBoundaries(); }; - /*! * Logical functor (predicate) "Belong To Plane". - * Verify whether mesh element lie in pointed Geom planar object + * Verify whether mesh element lie on pointed Geom planar object */ interface BelongToPlane: BelongToSurface { @@ -181,14 +188,23 @@ module SMESH }; /*! - * Logical functor (predicate) "Belong To Culinder". - * Verify whether mesh element lie in pointed Geom cylindrical object + * Logical functor (predicate) "Belong To Cylinder". + * Verify whether mesh element lie on pointed Geom cylindrical object */ interface BelongToCylinder: BelongToSurface { void SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType ); }; + /*! + * Logical functor (predicate) "Belong To Generic Surface". + * Verify whether mesh element lie in pointed Geom cylindrical object + */ + interface BelongToGenSurface: BelongToSurface + { + void SetSurface( 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 @@ -391,6 +407,7 @@ module SMESH BelongToGeom CreateBelongToGeom(); BelongToPlane CreateBelongToPlane(); BelongToCylinder CreateBelongToCylinder(); + BelongToGenSurface CreateBelongToGenSurface(); LyingOnGeom CreateLyingOnGeom(); diff --git a/src/Controls/Makefile.in b/src/Controls/Makefile.in index 3416e9751..35d3a6b10 100644 --- a/src/Controls/Makefile.in +++ b/src/Controls/Makefile.in @@ -45,8 +45,8 @@ BIN_SRC = CPPFLAGS+=$(OCC_INCLUDES) $(BOOST_CPPFLAGS) $(KERNEL_CXXFLAGS) -LDFLAGS+=$(OCC_KERNEL_LIBS) $(KERNEL_LDFLAGS) -lOpUtil -lSMDS -lTKBRep -lTKG3d +LDFLAGS+=$(OCC_KERNEL_LIBS) $(KERNEL_LDFLAGS) -lOpUtil -lSMDS -lTKBRep -lTKG3d -lTKGeomAlgo -LDFLAGSFORBIN += -lSMDS $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSALOMEBasics $(OCC_KERNEL_LIBS) -lTKBRep -lTKG3d +LDFLAGSFORBIN += -lSMDS $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSALOMEBasics $(OCC_KERNEL_LIBS) -lTKBRep -lTKG3d -lTKGeomAlgo @CONCLUDE@ diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 8b27024a6..9ef5d00f5 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -21,25 +21,27 @@ #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 "SMDS_Mesh.hxx" #include "SMDS_Iterator.hxx" @@ -2527,6 +2529,7 @@ ElementsOnSurface::ElementsOnSurface() myType = SMDSAbs_All; mySurf.Nullify(); myToler = Precision::Confusion(); + myUseBoundaries = false; } ElementsOnSurface::~ElementsOnSurface() @@ -2539,7 +2542,6 @@ void ElementsOnSurface::SetMesh( const SMDS_Mesh* theMesh ) if ( myMesh == theMesh ) return; myMesh = theMesh; - myIds.Clear(); process(); } @@ -2555,8 +2557,14 @@ void ElementsOnSurface::SetTolerance( const double theToler ) { myToler = theToler; } double ElementsOnSurface::GetTolerance() const +{ return myToler; } + +void ElementsOnSurface::SetUseBoundaries( bool theUse ) { - return myToler; + bool diff = ( myUseBoundaries != theUse ); + myUseBoundaries = theUse; + if ( diff ) + SetSurface( mySurf, myType ); } void ElementsOnSurface::SetSurface( const TopoDS_Shape& theShape, @@ -2565,12 +2573,17 @@ void ElementsOnSurface::SetSurface( const TopoDS_Shape& theShape, myType = theType; mySurf.Nullify(); if ( theShape.IsNull() || theShape.ShapeType() != TopAbs_FACE ) - { - mySurf.Nullify(); return; - } - TopoDS_Face aFace = TopoDS::Face( theShape ); - mySurf = BRep_Tool::Surface( aFace ); + mySurf = TopoDS::Face( theShape ); + BRepAdaptor_Surface SA( mySurf, myUseBoundaries ); + Standard_Real + u1 = SA.FirstUParameter(), + u2 = SA.LastUParameter(), + v1 = SA.FirstVParameter(), + v2 = SA.LastVParameter(); + Handle(Geom_Surface) surf = BRep_Tool::Surface( mySurf ); + myProjector.Init( surf, u1,u2, v1,v2 ); + process(); } void ElementsOnSurface::process() @@ -2584,6 +2597,7 @@ void ElementsOnSurface::process() if ( myType == SMDSAbs_Face || myType == SMDSAbs_All ) { + myIds.ReSize( myMesh->NbFaces() ); SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); for(; anIter->more(); ) process( anIter->next() ); @@ -2591,6 +2605,7 @@ void ElementsOnSurface::process() if ( myType == SMDSAbs_Edge || myType == SMDSAbs_All ) { + myIds.ReSize( myMesh->NbEdges() ); SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); for(; anIter->more(); ) process( anIter->next() ); @@ -2598,6 +2613,7 @@ void ElementsOnSurface::process() if ( myType == SMDSAbs_Node ) { + myIds.ReSize( myMesh->NbNodes() ); SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator(); for(; anIter->more(); ) process( anIter->next() ); @@ -2621,32 +2637,34 @@ void ElementsOnSurface::process( const SMDS_MeshElement* theElemPtr ) myIds.Add( theElemPtr->GetID() ); } -bool ElementsOnSurface::isOnSurface( const SMDS_MeshNode* theNode ) const +bool ElementsOnSurface::isOnSurface( const SMDS_MeshNode* theNode ) { if ( mySurf.IsNull() ) return false; gp_Pnt aPnt( theNode->X(), theNode->Y(), theNode->Z() ); - double aToler2 = myToler * myToler; - if ( mySurf->IsKind(STANDARD_TYPE(Geom_Plane))) - { - gp_Pln aPln = Handle(Geom_Plane)::DownCast(mySurf)->Pln(); - if ( aPln.SquareDistance( aPnt ) > aToler2 ) - return false; - } - else if ( mySurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) - { - gp_Cylinder aCyl = Handle(Geom_CylindricalSurface)::DownCast(mySurf)->Cylinder(); - double aRad = aCyl.Radius(); - gp_Ax3 anAxis = aCyl.Position(); - gp_XYZ aLoc = aCyl.Location().XYZ(); - double aXDist = anAxis.XDirection().XYZ() * ( aPnt.XYZ() - aLoc ); - double aYDist = anAxis.YDirection().XYZ() * ( aPnt.XYZ() - aLoc ); - if ( fabs(aXDist*aXDist + aYDist*aYDist - aRad*aRad) > aToler2 ) - return false; - } - else - return false; - - return true; + // double aToler2 = myToler * myToler; +// if ( mySurf->IsKind(STANDARD_TYPE(Geom_Plane))) +// { +// gp_Pln aPln = Handle(Geom_Plane)::DownCast(mySurf)->Pln(); +// if ( aPln.SquareDistance( aPnt ) > aToler2 ) +// return false; +// } +// else if ( mySurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) +// { +// gp_Cylinder aCyl = Handle(Geom_CylindricalSurface)::DownCast(mySurf)->Cylinder(); +// double aRad = aCyl.Radius(); +// gp_Ax3 anAxis = aCyl.Position(); +// gp_XYZ aLoc = aCyl.Location().XYZ(); +// double aXDist = anAxis.XDirection().XYZ() * ( aPnt.XYZ() - aLoc ); +// double aYDist = anAxis.YDirection().XYZ() * ( aPnt.XYZ() - aLoc ); +// if ( fabs(aXDist*aXDist + aYDist*aYDist - aRad*aRad) > aToler2 ) +// return false; +// } +// else +// return false; + myProjector.Perform( aPnt ); + bool isOn = ( myProjector.IsDone() && myProjector.LowerDistance() <= myToler ); + + return isOn; } diff --git a/src/Controls/SMESH_ControlsDef.hxx b/src/Controls/SMESH_ControlsDef.hxx index 32cd281f5..da707d9cb 100644 --- a/src/Controls/SMESH_ControlsDef.hxx +++ b/src/Controls/SMESH_ControlsDef.hxx @@ -25,10 +25,12 @@ #include #include #include -#include +//#include +#include #include #include #include +#include #include "SMDSAbs_ElementType.hxx" #include "SMDS_MeshNode.hxx" @@ -44,7 +46,7 @@ class SMESHDS_Mesh; class SMESHDS_SubMesh; class gp_Pnt; -class TopoDS_Shape; +//class TopoDS_Shape; namespace SMESH{ @@ -612,18 +614,23 @@ namespace SMESH{ double GetTolerance() const; void SetSurface( const TopoDS_Shape& theShape, const SMDSAbs_ElementType theType ); + void SetUseBoundaries( bool theUse ); + bool GetUseBoundaries() const { return myUseBoundaries; } private: void process(); void process( const SMDS_MeshElement* theElem ); - bool isOnSurface( const SMDS_MeshNode* theNode ) const; + bool isOnSurface( const SMDS_MeshNode* theNode ); private: const SMDS_Mesh* myMesh; TColStd_MapOfInteger myIds; SMDSAbs_ElementType myType; - Handle(Geom_Surface) mySurf; + //Handle(Geom_Surface) mySurf; + TopoDS_Face mySurf; double myToler; + bool myUseBoundaries; + GeomAPI_ProjectPointOnSurf myProjector; }; typedef boost::shared_ptr ElementsOnSurfacePtr; diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index b4b23b381..aa644b333 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -676,6 +676,7 @@ bool SMESHGUI_FilterTable::IsValid (const bool theMess, const int theEntityType) aCriterion == FT_BelongToGeom || aCriterion == FT_BelongToPlane || aCriterion == FT_BelongToCylinder || + aCriterion == FT_BelongToGenSurface || aCriterion == FT_LyingOnGeom) { if (aTable->text(i, 2).isEmpty()) { if (theMess) @@ -786,6 +787,7 @@ void SMESHGUI_FilterTable::GetCriterion (const int theRow, aCriterionType != FT_BelongToGeom && aCriterionType != FT_BelongToPlane && aCriterionType != FT_BelongToCylinder && + aCriterionType != FT_BelongToGenSurface && aCriterionType != FT_LyingOnGeom) { theCriterion.Compare = ((ComboItem*)aTable->item(theRow, 1))->GetValue(); @@ -836,6 +838,7 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow, theCriterion.Type != FT_BelongToGeom && theCriterion.Type != FT_BelongToPlane && theCriterion.Type != FT_BelongToCylinder && + theCriterion.Type != FT_BelongToGenSurface && theCriterion.Type != FT_LyingOnGeom && theCriterion.Type != FT_FreeBorders && theCriterion.Type != FT_FreeEdges && @@ -850,7 +853,8 @@ void SMESHGUI_FilterTable::SetCriterion (const int theRow, if (theCriterion.Compare == FT_EqualTo || theCriterion.Type == FT_BelongToPlane || - theCriterion.Type == FT_BelongToCylinder) + theCriterion.Type == FT_BelongToCylinder || + theCriterion.Type == FT_BelongToGenSurface) { QTableItem* anItem = aTable->item(theRow, 0); if (!myAddWidgets.contains(anItem)) @@ -1081,6 +1085,7 @@ void SMESHGUI_FilterTable::onCriterionChanged (const int row, const int col, con aCriterionType == SMESH::FT_BelongToGeom || aCriterionType == SMESH::FT_BelongToPlane || aCriterionType == SMESH::FT_BelongToCylinder || + aCriterionType == SMESH::FT_BelongToGenSurface || aCriterionType == SMESH::FT_LyingOnGeom) { QMap aMap; @@ -1275,6 +1280,7 @@ const QMap& 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_BelongToGenSurface]= tr("BELONG_TO_GENSURFACE"); aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); } return aCriteria; @@ -1291,6 +1297,7 @@ const QMap& 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_BelongToGenSurface]= tr("BELONG_TO_GENSURFACE"); aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); } return aCriteria; @@ -1311,6 +1318,7 @@ const QMap& 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_BelongToGenSurface]= tr("BELONG_TO_GENSURFACE"); aCriteria[ SMESH::FT_LyingOnGeom ] = tr("LYING_ON_GEOM"); aCriteria[ SMESH::FT_Length2D ] = tr("LENGTH2D"); aCriteria[ SMESH::FT_MultiConnection2D] = tr("MULTI2D_BORDERS"); @@ -2106,6 +2114,7 @@ bool SMESHGUI_FilterDlg::isValid() const if (aType == FT_BelongToGeom || aType == FT_BelongToPlane || aType == FT_BelongToCylinder || + aType == FT_BelongToGenSurface || aType == FT_LyingOnGeom) { QString aName; myTable->GetThreshold(i, aName); @@ -2118,7 +2127,9 @@ bool SMESHGUI_FilterDlg::isValid() const return false; } - if (aType == FT_BelongToCylinder || aType == FT_BelongToPlane) { + if (aType == FT_BelongToCylinder || + aType == FT_BelongToPlane || + aType == FT_BelongToGenSurface ) { CORBA::Object_var anObject = SMESH::SObjectToObject(aList[ 0 ]); //GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aList[ 0 ]->GetObject()); GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObject); @@ -2514,6 +2525,7 @@ void SMESHGUI_FilterDlg::onSelectionDone() myTable->GetCriterionType(aRow) != FT_BelongToGeom && myTable->GetCriterionType(aRow) != FT_BelongToPlane && myTable->GetCriterionType(aRow) != FT_BelongToCylinder && + myTable->GetCriterionType(aRow) != FT_BelongToGenSurface && myTable->GetCriterionType(aRow) != FT_LyingOnGeom) return; @@ -2569,9 +2581,11 @@ void SMESHGUI_FilterDlg::updateSelection() (myTable->GetCriterionType(aRow) == FT_BelongToGeom || myTable->GetCriterionType(aRow) == FT_BelongToPlane || myTable->GetCriterionType(aRow) == FT_BelongToCylinder || + myTable->GetCriterionType(aRow) == FT_BelongToGenSurface || myTable->GetCriterionType(aRow) == FT_LyingOnGeom)) { if (myTable->GetCriterionType(aRow) == FT_BelongToGeom || + myTable->GetCriterionType(aRow) == FT_BelongToGenSurface || myTable->GetCriterionType(aRow) == FT_LyingOnGeom) { mySelectionMgr->installFilter(new GEOM_SelectionFilter( aStudy, true )); diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po index 9d51ef2c4..bad4eaeeb 100644 --- a/src/SMESHGUI/SMESH_msg_en.po +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -23,7 +23,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"PO-Revision-Date: 2006-01-13 13:50+0300\n" +"PO-Revision-Date: 2006-12-18 10:07+0300\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" @@ -1139,6 +1139,9 @@ msgstr "Belong to Plane" msgid "SMESHGUI_FilterTable::BELONG_TO_CYLINDER" msgstr "Belong to Cylinder" +msgid "SMESHGUI_FilterTable::BELONG_TO_GENSURFACE" +msgstr "Belong to Surface" + msgid "SMESHGUI_FilterTable::LYING_ON_GEOM" msgstr "Lying on Geom" diff --git a/src/SMESH_I/SMESH_DumpPython.cxx b/src/SMESH_I/SMESH_DumpPython.cxx index e0ecf8fcd..e1079ebc7 100644 --- a/src/SMESH_I/SMESH_DumpPython.cxx +++ b/src/SMESH_I/SMESH_DumpPython.cxx @@ -231,6 +231,7 @@ namespace SMESH case FT_BelongToGeom: myStream<< "aBelongToGeom"; break; case FT_BelongToPlane: myStream<< "aBelongToPlane"; break; case FT_BelongToCylinder: myStream<< "aBelongToCylinder"; break; + case FT_BelongToGenSurface:myStream<<"aBelongToGenSurface";break; case FT_LyingOnGeom: myStream<< "aLyingOnGeom"; break; case FT_RangeOfIds: myStream<< "aRangeOfIds"; break; case FT_BadOrientedVolume:myStream<< "aBadOrientedVolume";break; diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 917732d62..fbd399f71 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -885,7 +885,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 +986,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()<_this(); + TPythonDump()<( thePred ); @@ -2006,7 +2053,7 @@ 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("<< + TPythonDump()<<"aCriterion = SMESH.Filter.Criterion("<< aCriterion<<","<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; @@ -2148,6 +2200,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()<