// 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
//
//
//
#include "SMESHDS_Mesh.hxx"
+#include <BRep_Tool.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_Plane.hxx>
+#include <LDOMParser.hxx>
+#include <LDOMString.hxx>
#include <LDOM_Document.hxx>
#include <LDOM_Element.hxx>
#include <LDOM_Node.hxx>
-#include <LDOMString.hxx>
-#include <LDOMParser.hxx>
#include <LDOM_XmlWriter.hxx>
-#include <TCollection_HAsciiString.hxx>
+#include <Precision.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_ListOfReal.hxx>
-#include <TColStd_MapOfInteger.hxx>
#include <TColStd_SequenceOfHAsciiString.hxx>
-#include <TColStd_ListIteratorOfListOfReal.hxx>
-#include <Precision.hxx>
-#include <BRep_Tool.hxx>
-#include <TopoDS_Shape.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_CylindricalSurface.hxx>
-#include <TopExp_Explorer.hxx>
-#include <OSD_Path.hxx>
-#include <OSD_File.hxx>
+#include <TopoDS_Shape.hxx>
using namespace SMESH;
using namespace SMESH::Controls;
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;
}
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 = "";
- 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;
}
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()
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()<<this<<".SetGeom("<<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 );
if ( aLocShape.ShapeType() == TopAbs_FACE )
}
myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType );
- TPythonDump()<<this<<".SetSurface("<<theGeom<<",'"<<theType<<"')";
}
void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
return myElementsOnSurfacePtr->GetTolerance();
}
+void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions )
+{
+ myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions );
+ TPythonDump()<<this<<".SetUseBoundaries( " << theUseBndRestrictions << " )";
+}
+
+CORBA::Boolean BelongToSurface_i::GetUseBoundaries()
+{
+ return myElementsOnSurfacePtr->GetUseBoundaries();
+}
+
+
/*
Class : BelongToPlane_i
Description : Verify whether mesh element lie in pointed Geom planar object
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<<".SetGenSurface("<<theGeom<<","<<theType<<")";
+}
+
+FunctorType BelongToGenSurface_i::GetFunctorType()
+{
+ return FT_BelongToGenSurface;
+}
+
/*
Class : LyingOnGeom_i
Description : Predicate for selection on geometrical support
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 );
myLyingOnGeomPtr->SetGeom( aLocShape );
TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
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 );
}
return anObj._retn();
}
+BelongToGenSurface_ptr FilterManager_i::CreateBelongToGenSurface()
+{
+ SMESH::BelongToGenSurface_i* aServant = new SMESH::BelongToGenSurface_i();
+ SMESH::BelongToGenSurface_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGenSurface()";
+ return anObj._retn();
+}
+
LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
{
SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
const SMDS_Mesh* theMesh,
Controls::Filter::TIdSequence& theSequence )
{
- Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
+ if (thePredicate)
+ Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
}
void
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*
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();
}
case FT_BelongToPlane:
case FT_BelongToCylinder:
+ case FT_BelongToGenSurface:
{
BelongToSurface_i* aPred = dynamic_cast<BelongToSurface_i*>( thePred );
ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement;
long aPrecision = theCriteria[ i ].Precision;
- TPythonDump()<<"aCriteria.append(SMESH.Filter.Criterion("<<
- aCriterion<<","<<aCompare<<","<<aThreshold<<",'"<<aThresholdStr<<"','"<<aThresholdID<<"',"<<
- aUnary<<","<<aBinary<<","<<aTolerance<<","<<aTypeOfElem<<","<<aPrecision<<"))";
+ {
+ TPythonDump pd;
+ pd << "aCriterion = SMESH.Filter.Criterion(" << aCriterion << "," << aCompare
+ << "," << aThreshold << ",'" << aThresholdStr;
+ if (strlen(aThresholdID) > 0)
+ pd << "',salome.ObjectToID(" << aThresholdID
+ << ")," << aUnary << "," << aBinary << "," << aTolerance
+ << "," << aTypeOfElem << "," << aPrecision << ")";
+ else
+ pd << "',''," << aUnary << "," << aBinary << "," << aTolerance
+ << "," << aTypeOfElem << "," << aPrecision << ")";
+ }
SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil();
SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil();
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;
// logical op
aPredicates.push_back( aPredicate );
aBinaries.push_back( aBinary );
+ TPythonDump()<<"aCriteria.append(aCriterion)";
} // end of for
TPythonDump()<<this<<".SetCriteria(aCriteria)";
case FT_BelongToGeom : return "Belong to Geom";
case FT_BelongToPlane : return "Belong to Plane";
case FT_BelongToCylinder: return "Belong to Cylinder";
+ case FT_BelongToGenSurface: return "Belong to Generic Surface";
case FT_LyingOnGeom : return "Lying on Geom";
case FT_BadOrientedVolume: return "Bad Oriented Volume";
case FT_RangeOfIds : return "Range of IDs";
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( "Belong to Generic Surface" ) ) return FT_BelongToGenSurface;
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;