-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// 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
#include "SMDS_MeshNode.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_ElemIterator.hxx"
+#include "SMDS_VolumeTool.hxx"
#include "SMESHDS_Mesh.hxx"
Functor_i::~Functor_i()
{
- //TPythonDump()<<this<<".Destroy()";
+ //TPythonDump()<<this<<".UnRegister()";
}
void Functor_i::SetMesh( SMESH_Mesh_ptr theMesh )
return myNumericalFunctorPtr->GetValue( theId );
}
+SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals)
+{
+ std::vector<int> nbEvents;
+ std::vector<double> funValues;
+ std::vector<int> elements;
+ myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements);
+
+ 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 );
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
{
INFOS("Length2D_i::GetValues");
SMESH::Controls::Length2D::TValues aValues;
- myLength2DPtr->GetValues( aValues );
+ (dynamic_cast<SMESH::Controls::Length2D*>(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++ )
{
INFOS("MultiConnection2D_i::GetValues");
SMESH::Controls::MultiConnection2D::MValues aValues;
- myMulticonnection2DPtr->GetValues( aValues );
-
+ (dynamic_cast<SMESH::Controls::MultiConnection2D*>(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++ )
return SMESH::FT_BadOrientedVolume;
}
+/*
+ Class : BareBorderVolume_i
+ Description : Verify whether a mesh volume has a free facet without a face on it
+*/
+BareBorderVolume_i::BareBorderVolume_i()
+{
+ Controls::PredicatePtr control( new Controls::BareBorderVolume() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType BareBorderVolume_i::GetFunctorType()
+{
+ return SMESH::FT_BareBorderVolume;
+}
+
+/*
+ Class : BareBorderFace_i
+ Description : Verify whether a mesh face has a free border without an edge on it
+*/
+BareBorderFace_i::BareBorderFace_i()
+{
+ Controls::PredicatePtr control( new Controls::BareBorderFace() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType BareBorderFace_i::GetFunctorType()
+{
+ return SMESH::FT_BareBorderFace;
+}
+
+/*
+ Class : OverConstrainedVolume_i
+ Description : Verify whether a mesh volume has only one facet shared with other volumes
+*/
+OverConstrainedVolume_i::OverConstrainedVolume_i()
+{
+ Controls::PredicatePtr control( new Controls::OverConstrainedVolume() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType OverConstrainedVolume_i::GetFunctorType()
+{
+ return SMESH::FT_OverConstrainedVolume;
+}
+
+/*
+ Class : OverConstrainedFace_i
+ Description : Verify whether a mesh face has only one border shared with other faces
+*/
+OverConstrainedFace_i::OverConstrainedFace_i()
+{
+ Controls::PredicatePtr control( new Controls::OverConstrainedFace() );
+ myFunctorPtr = myPredicatePtr = control;
+};
+
+FunctorType OverConstrainedFace_i::GetFunctorType()
+{
+ return SMESH::FT_OverConstrainedFace;
+}
+
/*
Class : BelongToGeom_i
Description : Predicate for selection on geometrical support
GeometryType ElemGeomType_i::GetGeometryType() const
{
- return (GeometryType)myElemGeomTypePtr->GetGeomType();;
+ return (GeometryType)myElemGeomTypePtr->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()<<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
Description : Base class for comparators
Comparator_i::~Comparator_i()
{
if ( myNumericalFunctor )
- myNumericalFunctor->Destroy();
+ myNumericalFunctor->UnRegister();
}
void Comparator_i::SetMargin( CORBA::Double theValue )
void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
{
if ( myNumericalFunctor )
- myNumericalFunctor->Destroy();
+ myNumericalFunctor->UnRegister();
myNumericalFunctor = DownCast<NumericalFunctor_i*>(theFunct);
LogicalNOT_i::~LogicalNOT_i()
{
if ( myPredicate )
- myPredicate->Destroy();
+ myPredicate->UnRegister();
}
void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate )
{
if ( myPredicate )
- myPredicate->Destroy();
+ myPredicate->UnRegister();
myPredicate = SMESH::GetPredicate(thePredicate);
LogicalBinary_i::~LogicalBinary_i()
{
if ( myPredicate1 )
- myPredicate1->Destroy();
+ myPredicate1->UnRegister();
if ( myPredicate2 )
- myPredicate2->Destroy();
+ myPredicate2->UnRegister();
}
void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh )
void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate )
{
if ( myPredicate1 )
- myPredicate1->Destroy();
+ myPredicate1->UnRegister();
myPredicate1 = SMESH::GetPredicate(thePredicate);
void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate )
{
if ( myPredicate2 )
- myPredicate2->Destroy();
+ myPredicate2->UnRegister();
myPredicate2 = SMESH::GetPredicate(thePredicate);
FilterManager_i::~FilterManager_i()
{
- //TPythonDump()<<this<<".Destroy()";
+ //TPythonDump()<<this<<".UnRegister()";
}
}
+MaxElementLength2D_ptr FilterManager_i::CreateMaxElementLength2D()
+{
+ SMESH::MaxElementLength2D_i* aServant = new SMESH::MaxElementLength2D_i();
+ SMESH::MaxElementLength2D_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateMaxElementLength2D()";
+ return anObj._retn();
+}
+
+
+MaxElementLength3D_ptr FilterManager_i::CreateMaxElementLength3D()
+{
+ SMESH::MaxElementLength3D_i* aServant = new SMESH::MaxElementLength3D_i();
+ SMESH::MaxElementLength3D_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateMaxElementLength3D()";
+ return anObj._retn();
+}
+
+
Length_ptr FilterManager_i::CreateLength()
{
SMESH::Length_i* aServant = new SMESH::Length_i();
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()
{
SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
return anObj._retn();
}
+BareBorderVolume_ptr FilterManager_i::CreateBareBorderVolume()
+{
+ SMESH::BareBorderVolume_i* aServant = new SMESH::BareBorderVolume_i();
+ SMESH::BareBorderVolume_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateBareBorderVolume()";
+ return anObj._retn();
+}
+
+BareBorderFace_ptr FilterManager_i::CreateBareBorderFace()
+{
+ SMESH::BareBorderFace_i* aServant = new SMESH::BareBorderFace_i();
+ SMESH::BareBorderFace_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateBareBorderFace()";
+ return anObj._retn();
+}
+
+OverConstrainedVolume_ptr FilterManager_i::CreateOverConstrainedVolume()
+{
+ SMESH::OverConstrainedVolume_i* aServant = new SMESH::OverConstrainedVolume_i();
+ SMESH::OverConstrainedVolume_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateOverConstrainedVolume()";
+ return anObj._retn();
+}
+
+OverConstrainedFace_ptr FilterManager_i::CreateOverConstrainedFace()
+{
+ SMESH::OverConstrainedFace_i* aServant = new SMESH::OverConstrainedFace_i();
+ SMESH::OverConstrainedFace_var anObj = aServant->_this();
+ TPythonDump()<<aServant<<" = "<<this<<".CreateOverConstrainedFace()";
+ return anObj._retn();
+}
+
LessThan_ptr FilterManager_i::CreateLessThan()
{
SMESH::LessThan_i* aServant = new SMESH::LessThan_i();
Filter_i::~Filter_i()
{
if ( myPredicate )
- myPredicate->Destroy();
+ myPredicate->UnRegister();
if(!CORBA::is_nil(myMesh))
- myMesh->Destroy();
+ myMesh->UnRegister();
- //TPythonDump()<<this<<".Destroy()";
+ //TPythonDump()<<this<<".UnRegister()";
}
//=======================================================================
void Filter_i::SetPredicate( Predicate_ptr thePredicate )
{
if ( myPredicate )
- myPredicate->Destroy();
+ myPredicate->UnRegister();
myPredicate = SMESH::GetPredicate(thePredicate);
theMesh->Register();
if(!CORBA::is_nil(myMesh))
- myMesh->Destroy();
+ myMesh->UnRegister();
myMesh = SMESH_Mesh::_duplicate( theMesh );
TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
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
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
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;
}
case FT_RangeOfIds:
theCriteria[ i ].Type = FT_BadOrientedVolume;
theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+ return true;
+ }
+ case FT_BareBorderVolume:
+ {
+ BareBorderVolume_i* aPred = dynamic_cast<BareBorderVolume_i*>( thePred );
+
+ CORBA::ULong i = theCriteria->length();
+ theCriteria->length( i + 1 );
+
+ theCriteria[ i ] = createCriterion();
+
+ theCriteria[ i ].Type = FT_BareBorderVolume;
+ theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+
+ return true;
+ }
+ case FT_BareBorderFace:
+ {
+ BareBorderFace_i* aPred = dynamic_cast<BareBorderFace_i*>( thePred );
+
+ CORBA::ULong i = theCriteria->length();
+ theCriteria->length( i + 1 );
+
+ theCriteria[ i ] = createCriterion();
+
+ theCriteria[ i ].Type = FT_BareBorderFace;
+ theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+
+ return true;
+ }
+ case FT_OverConstrainedVolume:
+ {
+ OverConstrainedVolume_i* aPred = dynamic_cast<OverConstrainedVolume_i*>( thePred );
+
+ CORBA::ULong i = theCriteria->length();
+ theCriteria->length( i + 1 );
+
+ theCriteria[ i ] = createCriterion();
+
+ theCriteria[ i ].Type = FT_OverConstrainedVolume;
+ theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+
+ return true;
+ }
+ case FT_OverConstrainedFace:
+ {
+ OverConstrainedFace_i* aPred = dynamic_cast<OverConstrainedFace_i*>( thePred );
+
+ CORBA::ULong i = theCriteria->length();
+ theCriteria->length( i + 1 );
+
+ theCriteria[ i ] = createCriterion();
+
+ theCriteria[ i ].Type = FT_OverConstrainedFace;
+ theCriteria[ i ].TypeOfElement = aPred->GetElementType();
+
return true;
}
case FT_LessThan:
CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria )
{
if ( myPredicate != 0 )
- myPredicate->Destroy();
+ myPredicate->UnRegister();
SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
FilterManager_ptr aFilterMgr = aFilter->_this();
case SMESH::FT_Volume3D:
aFunctor = aFilterMgr->CreateVolume3D();
break;
+ case SMESH::FT_MaxElementLength2D:
+ aFunctor = aFilterMgr->CreateMaxElementLength2D();
+ break;
+ case SMESH::FT_MaxElementLength3D:
+ aFunctor = aFilterMgr->CreateMaxElementLength3D();
+ break;
// Predicates
aPredicate = aFilterMgr->CreateBadOrientedVolume();
}
break;
+ case SMESH::FT_BareBorderVolume:
+ {
+ aPredicate = aFilterMgr->CreateBareBorderVolume();
+ }
+ break;
+ case SMESH::FT_BareBorderFace:
+ {
+ aPredicate = aFilterMgr->CreateBareBorderFace();
+ }
+ break;
+ case SMESH::FT_OverConstrainedVolume:
+ {
+ aPredicate = aFilterMgr->CreateOverConstrainedVolume();
+ }
+ break;
+ case SMESH::FT_OverConstrainedFace:
+ {
+ aPredicate = aFilterMgr->CreateOverConstrainedFace();
+ }
+ break;
case SMESH::FT_LinearOrQuadratic:
{
SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic();
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;
case FT_Skew : return "Skew";
case FT_Area : return "Area";
case FT_Volume3D : return "Volume3D";
+ case FT_MaxElementLength2D: return "Max element length 2D";
+ case FT_MaxElementLength3D: return "Max element length 3D";
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_BadOrientedVolume:return "Bad Oriented Volume";
+ case FT_BareBorderVolume: return "Volumes with bare border";
+ case FT_BareBorderFace : return "Faces with bare border";
+ case FT_OverConstrainedVolume: return "Over-constrained Volumes";
+ case FT_OverConstrainedFace : return "Over-constrained Faces";
case FT_RangeOfIds : return "Range of IDs";
case FT_FreeBorders : return "Free borders";
case FT_FreeEdges : return "Free edges";
else if ( theStr.equals( "Skew" ) ) return FT_Skew;
else if ( theStr.equals( "Area" ) ) return FT_Area;
else if ( theStr.equals( "Volume3D" ) ) return FT_Volume3D;
+ else if ( theStr.equals( "Max element length 2D" ) ) return FT_MaxElementLength2D;
+ else if ( theStr.equals( "Max element length 3D" ) ) return FT_MaxElementLength3D;
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( "Length2D" ) ) return FT_Length2D;
else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds;
else if ( theStr.equals( "Bad Oriented Volume" ) ) return FT_BadOrientedVolume;
+ else if ( theStr.equals( "Volumes with bare border" ) ) return FT_BareBorderVolume;
+ else if ( theStr.equals( "Faces with bare border" ) ) return FT_BareBorderFace;
+ else if ( theStr.equals( "Over-constrained Volumes" ) ) return FT_OverConstrainedVolume;
+ else if ( theStr.equals( "Over-constrained Faces" ) ) return FT_OverConstrainedFace;
else if ( theStr.equals( "Less than" ) ) return FT_LessThan;
else if ( theStr.equals( "More than" ) ) return FT_MoreThan;
else if ( theStr.equals( "Equal to" ) ) return FT_EqualTo;
FilterLibrary_i::~FilterLibrary_i()
{
delete myFileName;
- //TPythonDump()<<this<<".Destroy()";
+ //TPythonDump()<<this<<".UnRegister()";
}
//=======================================================================