1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 // File : SMESH_Filter_i.cxx
25 // Author : Alexey Petrov, OCC
28 #include "SMESH_Filter_i.hxx"
30 #include "SMESH_Gen_i.hxx"
31 #include "SMESH_PythonDump.hxx"
33 #include "SMDS_Mesh.hxx"
34 #include "SMDS_MeshNode.hxx"
35 #include "SMDS_MeshElement.hxx"
36 #include "SMDS_ElemIterator.hxx"
38 #include "SMESHDS_Mesh.hxx"
40 #include <BRep_Tool.hxx>
41 #include <Geom_CylindricalSurface.hxx>
42 #include <Geom_Plane.hxx>
43 #include <LDOMParser.hxx>
44 #include <LDOMString.hxx>
45 #include <LDOM_Document.hxx>
46 #include <LDOM_Element.hxx>
47 #include <LDOM_Node.hxx>
48 #include <LDOM_XmlWriter.hxx>
49 #include <Precision.hxx>
50 #include <TColStd_ListIteratorOfListOfInteger.hxx>
51 #include <TColStd_ListIteratorOfListOfReal.hxx>
52 #include <TColStd_ListOfInteger.hxx>
53 #include <TColStd_ListOfReal.hxx>
54 #include <TColStd_SequenceOfHAsciiString.hxx>
55 #include <TCollection_HAsciiString.hxx>
57 #include <TopExp_Explorer.hxx>
59 #include <TopoDS_Face.hxx>
60 #include <TopoDS_Shape.hxx>
61 #include <TopTools_IndexedMapOfShape.hxx>
63 using namespace SMESH;
64 using namespace SMESH::Controls;
70 GetPredicate( Predicate_ptr thePredicate )
72 return DownCast<Predicate_i*>(thePredicate);
79 Description : Predicate for verifying whether entity belongs to
80 specified geometrical support
83 Controls::BelongToGeom::BelongToGeom()
87 myTolerance(Precision::Confusion())
90 void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
92 myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
96 void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
102 static bool IsSubShape (const TopTools_IndexedMapOfShape& theMap,
103 const TopoDS_Shape& theShape)
105 if (theMap.Contains(theShape)) return true;
107 if (theShape.ShapeType() == TopAbs_COMPOUND ||
108 theShape.ShapeType() == TopAbs_COMPSOLID)
110 TopoDS_Iterator anIt (theShape, Standard_True, Standard_True);
111 for (; anIt.More(); anIt.Next())
113 if (!IsSubShape(theMap, anIt.Value())) {
123 void Controls::BelongToGeom::init()
125 if (!myMeshDS || myShape.IsNull()) return;
127 // is subshape of main shape?
128 TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
129 if (aMainShape.IsNull()) {
130 myIsSubshape = false;
133 TopTools_IndexedMapOfShape aMap;
134 TopExp::MapShapes(aMainShape, aMap);
135 myIsSubshape = IsSubShape(aMap, myShape);
140 myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
141 myElementsOnShapePtr->SetTolerance(myTolerance);
142 myElementsOnShapePtr->SetAllNodes(true); // belong, while false means "lays on"
143 myElementsOnShapePtr->SetMesh(myMeshDS);
144 myElementsOnShapePtr->SetShape(myShape, myType);
148 static bool IsContains( const SMESHDS_Mesh* theMeshDS,
149 const TopoDS_Shape& theShape,
150 const SMDS_MeshElement* theElem,
151 TopAbs_ShapeEnum theFindShapeEnum,
152 TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE )
154 TopExp_Explorer anExp( theShape,theFindShapeEnum,theAvoidShapeEnum );
156 while( anExp.More() )
158 const TopoDS_Shape& aShape = anExp.Current();
159 if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
160 if( aSubMesh->Contains( theElem ) )
168 bool Controls::BelongToGeom::IsSatisfy (long theId)
170 if (myMeshDS == 0 || myShape.IsNull())
175 return myElementsOnShapePtr->IsSatisfy(theId);
179 if (myType == SMDSAbs_Node)
181 if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
183 const SMDS_PositionPtr& aPosition = aNode->GetPosition();
184 SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
185 switch( aTypeOfPosition )
187 case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
188 case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
189 case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
190 case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
196 if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
198 if( myType == SMDSAbs_All )
200 return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
201 IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
202 IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
203 IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
205 else if( myType == anElem->GetType() )
209 case SMDSAbs_Edge : return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE );
210 case SMDSAbs_Face : return IsContains( myMeshDS,myShape,anElem,TopAbs_FACE );
211 case SMDSAbs_Volume: return IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
212 IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
221 void Controls::BelongToGeom::SetType (SMDSAbs_ElementType theType)
227 SMDSAbs_ElementType Controls::BelongToGeom::GetType() const
232 TopoDS_Shape Controls::BelongToGeom::GetShape()
237 const SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() const
242 void Controls::BelongToGeom::SetTolerance (double theTolerance)
244 myTolerance = theTolerance;
249 double Controls::BelongToGeom::GetTolerance()
256 Description : Predicate for verifying whether entiy lying or partially lying on
257 specified geometrical support
260 Controls::LyingOnGeom::LyingOnGeom()
264 myTolerance(Precision::Confusion())
267 void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
269 myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
273 void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
279 void Controls::LyingOnGeom::init()
281 if (!myMeshDS || myShape.IsNull()) return;
283 // is subshape of main shape?
284 TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
285 if (aMainShape.IsNull()) {
286 myIsSubshape = false;
289 TopTools_IndexedMapOfShape aMap;
290 TopExp::MapShapes(aMainShape, aMap);
291 myIsSubshape = IsSubShape(aMap, myShape);
296 myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
297 myElementsOnShapePtr->SetTolerance(myTolerance);
298 myElementsOnShapePtr->SetAllNodes(false); // lays on, while true means "belong"
299 myElementsOnShapePtr->SetMesh(myMeshDS);
300 myElementsOnShapePtr->SetShape(myShape, myType);
304 bool Controls::LyingOnGeom::IsSatisfy( long theId )
306 if ( myMeshDS == 0 || myShape.IsNull() )
311 return myElementsOnShapePtr->IsSatisfy(theId);
315 if( myType == SMDSAbs_Node )
317 if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
319 const SMDS_PositionPtr& aPosition = aNode->GetPosition();
320 SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
321 switch( aTypeOfPosition )
323 case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
324 case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
325 case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
326 case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
332 if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
334 if( myType == SMDSAbs_All )
336 return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
337 Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
338 Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
339 Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
341 else if( myType == anElem->GetType() )
345 case SMDSAbs_Edge : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE );
346 case SMDSAbs_Face : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE );
347 case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
348 Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
357 void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
363 SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
368 TopoDS_Shape Controls::LyingOnGeom::GetShape()
373 const SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() const
378 void Controls::LyingOnGeom::SetTolerance (double theTolerance)
380 myTolerance = theTolerance;
385 double Controls::LyingOnGeom::GetTolerance()
390 bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS,
391 const TopoDS_Shape& theShape,
392 const SMDS_MeshElement* theElem,
393 TopAbs_ShapeEnum theFindShapeEnum,
394 TopAbs_ShapeEnum theAvoidShapeEnum )
396 if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
399 TopTools_IndexedMapOfShape aSubShapes;
400 TopExp::MapShapes( theShape, aSubShapes );
402 for (int i = 1; i <= aSubShapes.Extent(); i++)
404 const TopoDS_Shape& aShape = aSubShapes.FindKey(i);
406 if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
407 if( aSubMesh->Contains( theElem ) )
410 SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
411 while ( aNodeIt->more() )
413 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
414 SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
415 while ( anElemIt->more() )
417 const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
418 if (anElement == theElem)
434 MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
436 SMESH_Mesh_i* anImplPtr = DownCast<SMESH_Mesh_i*>(theMesh);
437 return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
442 toArray( const TColStd_ListOfInteger& aList )
444 SMESH::long_array_var anArray = new SMESH::long_array;
445 anArray->length( aList.Extent() );
446 TColStd_ListIteratorOfListOfInteger anIter( aList );
448 for( ; anIter.More(); anIter.Next() )
449 anArray[ i++ ] = anIter.Value();
451 return anArray._retn();
456 toArray( const TColStd_ListOfReal& aList )
458 SMESH::double_array_var anArray = new SMESH::double_array;
459 anArray->length( aList.Extent() );
460 TColStd_ListIteratorOfListOfReal anIter( aList );
462 for( ; anIter.More(); anIter.Next() )
463 anArray[ i++ ] = anIter.Value();
465 return anArray._retn();
468 static SMESH::Filter::Criterion createCriterion()
470 SMESH::Filter::Criterion aCriterion;
472 aCriterion.Type = FT_Undefined;
473 aCriterion.Compare = FT_Undefined;
474 aCriterion.Threshold = 0;
475 aCriterion.UnaryOp = FT_Undefined;
476 aCriterion.BinaryOp = FT_Undefined;
477 aCriterion.ThresholdStr = "";
478 aCriterion.ThresholdID = "";
479 aCriterion.Tolerance = Precision::Confusion();
480 aCriterion.TypeOfElement = SMESH::ALL;
481 aCriterion.Precision = -1;
486 static TopoDS_Shape getShapeByName( const char* theName )
490 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
491 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
492 if (!CORBA::is_nil(aStudy))
494 SALOMEDS::Study::ListOfSObject_var aList =
495 aStudy->FindObjectByName( theName, "GEOM" );
496 if ( aList->length() > 0 )
498 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() );
499 if ( !aGeomObj->_is_nil() )
501 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
502 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
508 return TopoDS_Shape();
511 static TopoDS_Shape getShapeByID (const char* theID)
513 if (theID != 0 && theID != "") {
514 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
515 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
517 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
518 SALOMEDS::GenericAttribute_var anAttr;
519 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
520 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
521 CORBA::String_var aVal = anIOR->Value();
522 CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal);
523 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
525 if (!aGeomObj->_is_nil()) {
526 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
527 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
533 return TopoDS_Shape();
536 static char* getShapeNameByID (const char* theID)
538 char* aName = (char*)"";
540 if (theID != 0 && theID != "") {
541 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
542 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
544 //SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( theID );
545 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
546 SALOMEDS::GenericAttribute_var anAttr;
547 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeName")) {
548 SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr);
549 aName = aNameAttr->Value();
563 Description : An abstact class for all functors
565 Functor_i::Functor_i():
566 SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
568 //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method
569 //PortableServer::ObjectId_var anObjectId =
570 // SMESH_Gen_i::GetPOA()->activate_object( this );
573 Functor_i::~Functor_i()
575 //TPythonDump()<<this<<".UnRegister()";
578 void Functor_i::SetMesh( SMESH_Mesh_ptr theMesh )
580 myFunctorPtr->SetMesh( MeshPtr2SMDSMesh( theMesh ) );
581 TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
584 ElementType Functor_i::GetElementType()
586 return ( ElementType )myFunctorPtr->GetType();
591 Class : NumericalFunctor_i
592 Description : Base class for numerical functors
594 CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId )
596 return myNumericalFunctorPtr->GetValue( theId );
599 SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals)
601 std::vector<int> nbEvents;
602 std::vector<double> funValues;
603 std::vector<int> elements;
604 myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements);
607 nbIntervals = CORBA::Short( min( nbEvents.size(), funValues.size() - 1));
609 nbIntervals = CORBA::Short( std::min( nbEvents.size(), funValues.size() - 1));
611 SMESH::Histogram_var histogram = new SMESH::Histogram;
612 if ( nbIntervals > 0 )
614 histogram->length( nbIntervals );
615 for ( int i = 0; i < nbIntervals; ++i )
617 HistogramRectangle& rect = histogram[i];
618 rect.nbEvents = nbEvents[i];
619 rect.min = funValues[i];
620 rect.max = funValues[i+1];
623 return histogram._retn();
626 void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision )
628 myNumericalFunctorPtr->SetPrecision( thePrecision );
629 TPythonDump()<<this<<".SetPrecision("<<thePrecision<<")";
632 CORBA::Long NumericalFunctor_i::GetPrecision()
634 return myNumericalFunctorPtr->GetPrecision();
637 Controls::NumericalFunctorPtr NumericalFunctor_i::GetNumericalFunctor()
639 return myNumericalFunctorPtr;
644 Class : SMESH_MinimumAngle
645 Description : Functor for calculation of minimum angle
647 MinimumAngle_i::MinimumAngle_i()
649 myNumericalFunctorPtr.reset( new Controls::MinimumAngle() );
650 myFunctorPtr = myNumericalFunctorPtr;
653 FunctorType MinimumAngle_i::GetFunctorType()
655 return SMESH::FT_MinimumAngle;
661 Description : Functor for calculating aspect ratio
663 AspectRatio_i::AspectRatio_i()
665 myNumericalFunctorPtr.reset( new Controls::AspectRatio() );
666 myFunctorPtr = myNumericalFunctorPtr;
669 FunctorType AspectRatio_i::GetFunctorType()
671 return SMESH::FT_AspectRatio;
676 Class : AspectRatio3D
677 Description : Functor for calculating aspect ratio 3D
679 AspectRatio3D_i::AspectRatio3D_i()
681 myNumericalFunctorPtr.reset( new Controls::AspectRatio3D() );
682 myFunctorPtr = myNumericalFunctorPtr;
685 FunctorType AspectRatio3D_i::GetFunctorType()
687 return SMESH::FT_AspectRatio3D;
693 Description : Functor for calculating warping
695 Warping_i::Warping_i()
697 myNumericalFunctorPtr.reset( new Controls::Warping() );
698 myFunctorPtr = myNumericalFunctorPtr;
701 FunctorType Warping_i::GetFunctorType()
703 return SMESH::FT_Warping;
709 Description : Functor for calculating taper
713 myNumericalFunctorPtr.reset( new Controls::Taper() );
714 myFunctorPtr = myNumericalFunctorPtr;
717 FunctorType Taper_i::GetFunctorType()
719 return SMESH::FT_Taper;
725 Description : Functor for calculating skew in degrees
729 myNumericalFunctorPtr.reset( new Controls::Skew() );
730 myFunctorPtr = myNumericalFunctorPtr;
733 FunctorType Skew_i::GetFunctorType()
735 return SMESH::FT_Skew;
740 Description : Functor for calculating area
744 myNumericalFunctorPtr.reset( new Controls::Area() );
745 myFunctorPtr = myNumericalFunctorPtr;
748 FunctorType Area_i::GetFunctorType()
750 return SMESH::FT_Area;
755 Description : Functor for calculating volume of 3D element
757 Volume3D_i::Volume3D_i()
759 myNumericalFunctorPtr.reset( new Controls::Volume() );
760 myFunctorPtr = myNumericalFunctorPtr;
763 FunctorType Volume3D_i::GetFunctorType()
765 return SMESH::FT_Volume3D;
769 Class : MaxElementLength2D_i
770 Description : Functor for calculating maximum length of 2D element
772 MaxElementLength2D_i::MaxElementLength2D_i()
774 myNumericalFunctorPtr.reset( new Controls::MaxElementLength2D() );
775 myFunctorPtr = myNumericalFunctorPtr;
778 FunctorType MaxElementLength2D_i::GetFunctorType()
780 return SMESH::FT_MaxElementLength2D;
784 Class : MaxElementLength3D_i
785 Description : Functor for calculating maximum length of 3D element
787 MaxElementLength3D_i::MaxElementLength3D_i()
789 myNumericalFunctorPtr.reset( new Controls::MaxElementLength3D() );
790 myFunctorPtr = myNumericalFunctorPtr;
793 FunctorType MaxElementLength3D_i::GetFunctorType()
795 return SMESH::FT_MaxElementLength3D;
800 Description : Functor for calculating length off edge
804 myNumericalFunctorPtr.reset( new Controls::Length() );
805 myFunctorPtr = myNumericalFunctorPtr;
808 FunctorType Length_i::GetFunctorType()
810 return SMESH::FT_Length;
815 Description : Functor for calculating length of edge
817 Length2D_i::Length2D_i()
819 myNumericalFunctorPtr.reset( new Controls::Length2D() );
820 myFunctorPtr = myNumericalFunctorPtr;
823 FunctorType Length2D_i::GetFunctorType()
825 return SMESH::FT_Length2D;
828 SMESH::Length2D::Values* Length2D_i::GetValues()
830 INFOS("Length2D_i::GetValues");
831 SMESH::Controls::Length2D::TValues aValues;
832 (dynamic_cast<SMESH::Controls::Length2D*>(myFunctorPtr.get()))->GetValues( aValues );
834 long i = 0, iEnd = aValues.size();
836 SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd);
837 aResult->length(iEnd);
839 SMESH::Controls::Length2D::TValues::const_iterator anIter;
840 for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
842 const SMESH::Controls::Length2D::Value& aVal = *anIter;
843 SMESH::Length2D::Value &aValue = aResult[ i ];
845 aValue.myLength = aVal.myLength;
846 aValue.myPnt1 = aVal.myPntId[ 0 ];
847 aValue.myPnt2 = aVal.myPntId[ 1 ];
850 INFOS("Length2D_i::GetValuess~");
851 return aResult._retn();
855 Class : MultiConnection_i
856 Description : Functor for calculating number of faces conneted to the edge
858 MultiConnection_i::MultiConnection_i()
860 myNumericalFunctorPtr.reset( new Controls::MultiConnection() );
861 myFunctorPtr = myNumericalFunctorPtr;
864 FunctorType MultiConnection_i::GetFunctorType()
866 return SMESH::FT_MultiConnection;
870 Class : MultiConnection2D_i
871 Description : Functor for calculating number of faces conneted to the edge
873 MultiConnection2D_i::MultiConnection2D_i()
875 myNumericalFunctorPtr.reset( new Controls::MultiConnection2D() );
876 myFunctorPtr = myNumericalFunctorPtr;
879 FunctorType MultiConnection2D_i::GetFunctorType()
881 return SMESH::FT_MultiConnection2D;
884 SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues()
886 INFOS("MultiConnection2D_i::GetValues");
887 SMESH::Controls::MultiConnection2D::MValues aValues;
888 (dynamic_cast<SMESH::Controls::MultiConnection2D*>(myFunctorPtr.get()))->GetValues( aValues );
890 long i = 0, iEnd = aValues.size();
892 SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd);
893 aResult->length(iEnd);
895 SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter;
896 for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
898 const SMESH::Controls::MultiConnection2D::Value& aVal = (*anIter).first;
899 SMESH::MultiConnection2D::Value &aValue = aResult[ i ];
901 aValue.myPnt1 = aVal.myPntId[ 0 ];
902 aValue.myPnt2 = aVal.myPntId[ 1 ];
903 aValue.myNbConnects = (*anIter).second;
906 INFOS("Multiconnection2D_i::GetValuess~");
907 return aResult._retn();
917 Description : Base class for all predicates
919 CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId )
921 return myPredicatePtr->IsSatisfy( theId );
924 Controls::PredicatePtr Predicate_i::GetPredicate()
926 return myPredicatePtr;
930 Class : BadOrientedVolume_i
931 Description : Verify whether a mesh volume is incorrectly oriented from
932 the point of view of MED convention
934 BadOrientedVolume_i::BadOrientedVolume_i()
936 Controls::PredicatePtr control( new Controls::BadOrientedVolume() );
937 myFunctorPtr = myPredicatePtr = control;
940 FunctorType BadOrientedVolume_i::GetFunctorType()
942 return SMESH::FT_BadOrientedVolume;
946 Class : BareBorderVolume_i
947 Description : Verify whether a mesh volume has a free facet without a face on it
949 BareBorderVolume_i::BareBorderVolume_i()
951 Controls::PredicatePtr control( new Controls::BareBorderVolume() );
952 myFunctorPtr = myPredicatePtr = control;
955 FunctorType BareBorderVolume_i::GetFunctorType()
957 return SMESH::FT_BareBorderVolume;
961 Class : BareBorderFace_i
962 Description : Verify whether a mesh face has a free border without an edge on it
964 BareBorderFace_i::BareBorderFace_i()
966 Controls::PredicatePtr control( new Controls::BareBorderFace() );
967 myFunctorPtr = myPredicatePtr = control;
970 FunctorType BareBorderFace_i::GetFunctorType()
972 return SMESH::FT_BareBorderFace;
976 Class : OverConstrainedVolume_i
977 Description : Verify whether a mesh volume has only one facet shared with other volumes
979 OverConstrainedVolume_i::OverConstrainedVolume_i()
981 Controls::PredicatePtr control( new Controls::OverConstrainedVolume() );
982 myFunctorPtr = myPredicatePtr = control;
985 FunctorType OverConstrainedVolume_i::GetFunctorType()
987 return SMESH::FT_OverConstrainedVolume;
991 Class : OverConstrainedFace_i
992 Description : Verify whether a mesh face has only one border shared with other faces
994 OverConstrainedFace_i::OverConstrainedFace_i()
996 Controls::PredicatePtr control( new Controls::OverConstrainedFace() );
997 myFunctorPtr = myPredicatePtr = control;
1000 FunctorType OverConstrainedFace_i::GetFunctorType()
1002 return SMESH::FT_OverConstrainedFace;
1006 Class : BelongToGeom_i
1007 Description : Predicate for selection on geometrical support
1009 BelongToGeom_i::BelongToGeom_i()
1011 myBelongToGeomPtr.reset( new Controls::BelongToGeom() );
1012 myFunctorPtr = myPredicatePtr = myBelongToGeomPtr;
1017 BelongToGeom_i::~BelongToGeom_i()
1023 void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
1025 if ( theGeom->_is_nil() )
1027 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1028 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
1029 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
1030 myBelongToGeomPtr->SetGeom( aLocShape );
1031 TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
1034 void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape )
1036 myBelongToGeomPtr->SetGeom( theShape );
1039 void BelongToGeom_i::SetElementType(ElementType theType){
1040 myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType));
1041 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1044 FunctorType BelongToGeom_i::GetFunctorType()
1046 return SMESH::FT_BelongToGeom;
1049 void BelongToGeom_i::SetShapeName( const char* theName )
1052 myShapeName = strdup( theName );
1053 myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
1054 TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
1057 void BelongToGeom_i::SetShape( const char* theID, const char* theName )
1060 myShapeName = strdup( theName );
1063 myShapeID = strdup( theID );
1067 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
1068 myBelongToGeomPtr->SetGeom( getShapeByID(myShapeID) );
1070 myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
1073 char* BelongToGeom_i::GetShapeName()
1075 return CORBA::string_dup( myShapeName );
1078 char* BelongToGeom_i::GetShapeID()
1080 return CORBA::string_dup( myShapeID );
1083 void BelongToGeom_i::SetTolerance( CORBA::Double theToler )
1085 myBelongToGeomPtr->SetTolerance( theToler );
1086 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1089 CORBA::Double BelongToGeom_i::GetTolerance()
1091 return myBelongToGeomPtr->GetTolerance();
1095 Class : BelongToSurface_i
1096 Description : Predicate for selection on geometrical support
1098 BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceType )
1100 myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() );
1101 myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr;
1104 mySurfaceType = theSurfaceType;
1107 BelongToSurface_i::~BelongToSurface_i()
1113 void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1115 if ( theGeom->_is_nil() )
1117 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1118 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
1119 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
1121 if ( aLocShape.ShapeType() == TopAbs_FACE )
1123 Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aLocShape ) );
1124 if ( !aSurf.IsNull() && aSurf->DynamicType() == mySurfaceType )
1126 myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
1131 myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType );
1134 void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
1137 myShapeName = strdup( theName );
1138 myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
1139 TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
1142 void BelongToSurface_i::SetShape( const char* theID, const char* theName, ElementType theType )
1145 myShapeName = strdup( theName );
1148 myShapeID = strdup( theID );
1152 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
1153 myElementsOnSurfacePtr->SetSurface( getShapeByID(myShapeID), (SMDSAbs_ElementType)theType );
1155 myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
1158 char* BelongToSurface_i::GetShapeName()
1160 return CORBA::string_dup( myShapeName );
1163 char* BelongToSurface_i::GetShapeID()
1165 return CORBA::string_dup( myShapeID );
1168 void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
1170 myElementsOnSurfacePtr->SetTolerance( theToler );
1171 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1174 CORBA::Double BelongToSurface_i::GetTolerance()
1176 return myElementsOnSurfacePtr->GetTolerance();
1179 void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions )
1181 myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions );
1182 TPythonDump()<<this<<".SetUseBoundaries( " << theUseBndRestrictions << " )";
1185 CORBA::Boolean BelongToSurface_i::GetUseBoundaries()
1187 return myElementsOnSurfacePtr->GetUseBoundaries();
1192 Class : BelongToPlane_i
1193 Description : Verify whether mesh element lie in pointed Geom planar object
1196 BelongToPlane_i::BelongToPlane_i()
1197 : BelongToSurface_i( STANDARD_TYPE( Geom_Plane ) )
1201 void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1203 BelongToSurface_i::SetSurface( theGeom, theType );
1204 TPythonDump()<<this<<".SetPlane("<<theGeom<<","<<theType<<")";
1207 FunctorType BelongToPlane_i::GetFunctorType()
1209 return FT_BelongToPlane;
1213 Class : BelongToCylinder_i
1214 Description : Verify whether mesh element lie in pointed Geom planar object
1217 BelongToCylinder_i::BelongToCylinder_i()
1218 : BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
1222 void BelongToCylinder_i::SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1224 BelongToSurface_i::SetSurface( theGeom, theType );
1225 TPythonDump()<<this<<".SetCylinder("<<theGeom<<","<<theType<<")";
1228 FunctorType BelongToCylinder_i::GetFunctorType()
1230 return FT_BelongToCylinder;
1234 Class : BelongToGenSurface_i
1235 Description : Verify whether mesh element lie in pointed Geom planar object
1238 BelongToGenSurface_i::BelongToGenSurface_i()
1239 : BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
1243 void BelongToGenSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1245 if ( theGeom->_is_nil() )
1247 TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom );
1248 if ( !aLocShape.IsNull() && aLocShape.ShapeType() != TopAbs_FACE )
1249 aLocShape.Nullify();
1251 BelongToSurface_i::myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
1252 TPythonDump()<<this<<".SetGenSurface("<<theGeom<<","<<theType<<")";
1255 FunctorType BelongToGenSurface_i::GetFunctorType()
1257 return FT_BelongToGenSurface;
1261 Class : LyingOnGeom_i
1262 Description : Predicate for selection on geometrical support
1264 LyingOnGeom_i::LyingOnGeom_i()
1266 myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
1267 myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
1272 LyingOnGeom_i::~LyingOnGeom_i()
1278 void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
1280 if ( theGeom->_is_nil() )
1282 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1283 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
1284 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
1285 myLyingOnGeomPtr->SetGeom( aLocShape );
1286 TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
1289 void LyingOnGeom_i::SetGeom( const TopoDS_Shape& theShape )
1291 myLyingOnGeomPtr->SetGeom( theShape );
1294 void LyingOnGeom_i::SetElementType(ElementType theType){
1295 myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType));
1296 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1299 FunctorType LyingOnGeom_i::GetFunctorType()
1301 return SMESH::FT_LyingOnGeom;
1304 void LyingOnGeom_i::SetShapeName( const char* theName )
1307 myShapeName = strdup( theName );
1308 myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
1309 TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
1312 void LyingOnGeom_i::SetShape( const char* theID, const char* theName )
1315 myShapeName = strdup( theName );
1318 myShapeID = strdup( theID );
1322 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
1323 myLyingOnGeomPtr->SetGeom( getShapeByID(myShapeID) );
1325 myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
1328 char* LyingOnGeom_i::GetShapeName()
1330 return CORBA::string_dup( myShapeName );
1333 char* LyingOnGeom_i::GetShapeID()
1335 return CORBA::string_dup( myShapeID );
1338 void LyingOnGeom_i::SetTolerance( CORBA::Double theToler )
1340 myLyingOnGeomPtr->SetTolerance( theToler );
1341 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1344 CORBA::Double LyingOnGeom_i::GetTolerance()
1346 return myLyingOnGeomPtr->GetTolerance();
1350 Class : FreeBorders_i
1351 Description : Predicate for free borders
1353 FreeBorders_i::FreeBorders_i()
1355 myPredicatePtr.reset(new Controls::FreeBorders());
1356 myFunctorPtr = myPredicatePtr;
1359 FunctorType FreeBorders_i::GetFunctorType()
1361 return SMESH::FT_FreeBorders;
1366 Description : Predicate for free borders
1368 FreeEdges_i::FreeEdges_i()
1369 : myFreeEdgesPtr( new Controls::FreeEdges() )
1371 myFunctorPtr = myPredicatePtr = myFreeEdgesPtr;
1374 SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders()
1376 INFOS("FreeEdges_i::GetBorders");
1377 SMESH::Controls::FreeEdges::TBorders aBorders;
1378 myFreeEdgesPtr->GetBoreders( aBorders );
1380 long i = 0, iEnd = aBorders.size();
1382 SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders;
1383 aResult->length(iEnd);
1385 SMESH::Controls::FreeEdges::TBorders::const_iterator anIter;
1386 for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ )
1388 const SMESH::Controls::FreeEdges::Border& aBord = *anIter;
1389 SMESH::FreeEdges::Border &aBorder = aResult[ i ];
1391 aBorder.myElemId = aBord.myElemId;
1392 aBorder.myPnt1 = aBord.myPntId[ 0 ];
1393 aBorder.myPnt2 = aBord.myPntId[ 1 ];
1396 INFOS("FreeEdges_i::GetBorders~");
1397 return aResult._retn();
1400 FunctorType FreeEdges_i::GetFunctorType()
1402 return SMESH::FT_FreeEdges;
1407 Description : Predicate for free faces
1409 FreeFaces_i::FreeFaces_i()
1411 myPredicatePtr.reset(new Controls::FreeFaces());
1412 myFunctorPtr = myPredicatePtr;
1415 FunctorType FreeFaces_i::GetFunctorType()
1417 return SMESH::FT_FreeFaces;
1422 Description : Predicate for free nodes
1424 FreeNodes_i::FreeNodes_i()
1426 myPredicatePtr.reset(new Controls::FreeNodes());
1427 myFunctorPtr = myPredicatePtr;
1430 FunctorType FreeNodes_i::GetFunctorType()
1432 return SMESH::FT_FreeNodes;
1436 Class : RangeOfIds_i
1437 Description : Predicate for Range of Ids.
1438 Range may be specified with two ways.
1439 1. Using AddToRange method
1440 2. With SetRangeStr method. Parameter of this method is a string
1441 like as "1,2,3,50-60,63,67,70-"
1444 RangeOfIds_i::RangeOfIds_i()
1446 myRangeOfIdsPtr.reset( new Controls::RangeOfIds() );
1447 myFunctorPtr = myPredicatePtr = myRangeOfIdsPtr;
1450 void RangeOfIds_i::SetRange( const SMESH::long_array& theIds )
1452 CORBA::Long iEnd = theIds.length();
1453 for ( CORBA::Long i = 0; i < iEnd; i++ )
1454 myRangeOfIdsPtr->AddToRange( theIds[ i ] );
1455 TPythonDump()<<this<<".SetRange("<<theIds<<")";
1458 CORBA::Boolean RangeOfIds_i::SetRangeStr( const char* theRange )
1460 TPythonDump()<<this<<".SetRangeStr('"<<theRange<<"')";
1461 return myRangeOfIdsPtr->SetRangeStr(
1462 TCollection_AsciiString( (Standard_CString)theRange ) );
1465 char* RangeOfIds_i::GetRangeStr()
1467 TCollection_AsciiString aStr;
1468 myRangeOfIdsPtr->GetRangeStr( aStr );
1469 return CORBA::string_dup( aStr.ToCString() );
1472 void RangeOfIds_i::SetElementType( ElementType theType )
1474 myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) );
1475 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1478 FunctorType RangeOfIds_i::GetFunctorType()
1480 return SMESH::FT_RangeOfIds;
1484 Class : LinearOrQuadratic_i
1485 Description : Predicate to verify whether a mesh element is linear
1487 LinearOrQuadratic_i::LinearOrQuadratic_i()
1489 myLinearOrQuadraticPtr.reset(new Controls::LinearOrQuadratic());
1490 myFunctorPtr = myPredicatePtr = myLinearOrQuadraticPtr;
1493 void LinearOrQuadratic_i::SetElementType(ElementType theType)
1495 myLinearOrQuadraticPtr->SetType(SMDSAbs_ElementType(theType));
1496 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1499 FunctorType LinearOrQuadratic_i::GetFunctorType()
1501 return SMESH::FT_LinearOrQuadratic;
1505 Class : GroupColor_i
1506 Description : Functor for check color of group to whic mesh element belongs to
1508 GroupColor_i::GroupColor_i()
1510 myGroupColorPtr.reset(new Controls::GroupColor());
1511 myFunctorPtr = myPredicatePtr = myGroupColorPtr;
1514 FunctorType GroupColor_i::GetFunctorType()
1516 return SMESH::FT_GroupColor;
1519 void GroupColor_i::SetColorStr( const char* theColor )
1521 myGroupColorPtr->SetColorStr(
1522 TCollection_AsciiString( (Standard_CString)theColor ) );
1523 TPythonDump()<<this<<".SetColorStr('"<<theColor<<"')";
1526 char* GroupColor_i::GetColorStr()
1528 TCollection_AsciiString aStr;
1529 myGroupColorPtr->GetColorStr( aStr );
1530 return CORBA::string_dup( aStr.ToCString() );
1533 void GroupColor_i::SetElementType(ElementType theType)
1535 myGroupColorPtr->SetType(SMDSAbs_ElementType(theType));
1536 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1540 Class : ElemGeomType_i
1541 Description : Predicate check is element has indicated geometry type
1543 ElemGeomType_i::ElemGeomType_i()
1545 myElemGeomTypePtr.reset(new Controls::ElemGeomType());
1546 myFunctorPtr = myPredicatePtr = myElemGeomTypePtr;
1549 void ElemGeomType_i::SetElementType(ElementType theType)
1551 myElemGeomTypePtr->SetType(SMDSAbs_ElementType(theType));
1552 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1555 void ElemGeomType_i::SetGeometryType(GeometryType theType)
1557 myElemGeomTypePtr->SetGeomType(SMDSAbs_GeometryType(theType));
1558 TPythonDump()<<this<<".SetGeometryType("<<theType<<")";
1561 GeometryType ElemGeomType_i::GetGeometryType() const
1563 return (GeometryType)myElemGeomTypePtr->GetGeomType();
1566 FunctorType ElemGeomType_i::GetFunctorType()
1568 return SMESH::FT_ElemGeomType;
1572 Class : CoplanarFaces_i
1573 Description : Returns true if a mesh face is a coplanar neighbour to a given one
1575 CoplanarFaces_i::CoplanarFaces_i()
1577 myCoplanarFacesPtr.reset(new Controls::CoplanarFaces());
1578 myFunctorPtr = myPredicatePtr = myCoplanarFacesPtr;
1581 void CoplanarFaces_i::SetFace ( CORBA::Long theFaceID )
1583 myCoplanarFacesPtr->SetFace(theFaceID);
1584 TPythonDump()<<this<<".SetFace("<<theFaceID<<")";
1587 void CoplanarFaces_i::SetTolerance( CORBA::Double theToler )
1589 myCoplanarFacesPtr->SetTolerance(theToler);
1590 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1593 CORBA::Long CoplanarFaces_i::GetFace () const
1595 return myCoplanarFacesPtr->GetFace();
1598 char* CoplanarFaces_i::GetFaceAsString () const
1600 TCollection_AsciiString str(Standard_Integer(myCoplanarFacesPtr->GetFace()));
1601 return CORBA::string_dup( str.ToCString() );
1604 CORBA::Double CoplanarFaces_i::GetTolerance() const
1606 return myCoplanarFacesPtr->GetTolerance();
1609 FunctorType CoplanarFaces_i::GetFunctorType()
1611 return SMESH::FT_CoplanarFaces;
1615 Class : Comparator_i
1616 Description : Base class for comparators
1618 Comparator_i::Comparator_i():
1619 myNumericalFunctor( NULL )
1622 Comparator_i::~Comparator_i()
1624 if ( myNumericalFunctor )
1625 myNumericalFunctor->UnRegister();
1628 void Comparator_i::SetMargin( CORBA::Double theValue )
1630 myComparatorPtr->SetMargin( theValue );
1631 TPythonDump()<<this<<".SetMargin("<<theValue<<")";
1634 CORBA::Double Comparator_i::GetMargin()
1636 return myComparatorPtr->GetMargin();
1639 void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
1641 if ( myNumericalFunctor )
1642 myNumericalFunctor->UnRegister();
1644 myNumericalFunctor = DownCast<NumericalFunctor_i*>(theFunct);
1646 if ( myNumericalFunctor )
1648 myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() );
1649 myNumericalFunctor->Register();
1650 TPythonDump()<<this<<".SetNumFunctor("<<myNumericalFunctor<<")";
1654 Controls::ComparatorPtr Comparator_i::GetComparator()
1656 return myComparatorPtr;
1659 NumericalFunctor_i* Comparator_i::GetNumFunctor_i()
1661 return myNumericalFunctor;
1667 Description : Comparator "<"
1669 LessThan_i::LessThan_i()
1671 myComparatorPtr.reset( new Controls::LessThan() );
1672 myFunctorPtr = myPredicatePtr = myComparatorPtr;
1675 FunctorType LessThan_i::GetFunctorType()
1677 return SMESH::FT_LessThan;
1683 Description : Comparator ">"
1685 MoreThan_i::MoreThan_i()
1687 myComparatorPtr.reset( new Controls::MoreThan() );
1688 myFunctorPtr = myPredicatePtr = myComparatorPtr;
1691 FunctorType MoreThan_i::GetFunctorType()
1693 return SMESH::FT_MoreThan;
1699 Description : Comparator "="
1701 EqualTo_i::EqualTo_i()
1702 : myEqualToPtr( new Controls::EqualTo() )
1704 myFunctorPtr = myPredicatePtr = myComparatorPtr = myEqualToPtr;
1707 void EqualTo_i::SetTolerance( CORBA::Double theToler )
1709 myEqualToPtr->SetTolerance( theToler );
1710 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1713 CORBA::Double EqualTo_i::GetTolerance()
1715 return myEqualToPtr->GetTolerance();
1718 FunctorType EqualTo_i::GetFunctorType()
1720 return SMESH::FT_EqualTo;
1724 Class : LogicalNOT_i
1725 Description : Logical NOT predicate
1727 LogicalNOT_i::LogicalNOT_i()
1728 : myPredicate( NULL ),
1729 myLogicalNOTPtr( new Controls::LogicalNOT() )
1731 myFunctorPtr = myPredicatePtr = myLogicalNOTPtr;
1734 LogicalNOT_i::~LogicalNOT_i()
1737 myPredicate->UnRegister();
1740 void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate )
1743 myPredicate->UnRegister();
1745 myPredicate = SMESH::GetPredicate(thePredicate);
1748 myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate());
1749 myPredicate->Register();
1750 TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
1754 FunctorType LogicalNOT_i::GetFunctorType()
1756 return SMESH::FT_LogicalNOT;
1759 Predicate_i* LogicalNOT_i::GetPredicate_i()
1766 Class : LogicalBinary_i
1767 Description : Base class for binary logical predicate
1769 LogicalBinary_i::LogicalBinary_i()
1770 : myPredicate1( NULL ),
1771 myPredicate2( NULL )
1774 LogicalBinary_i::~LogicalBinary_i()
1777 myPredicate1->UnRegister();
1780 myPredicate2->UnRegister();
1783 void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh )
1786 myPredicate1->SetMesh( theMesh );
1789 myPredicate2->SetMesh( theMesh );
1792 void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate )
1795 myPredicate1->UnRegister();
1797 myPredicate1 = SMESH::GetPredicate(thePredicate);
1799 if ( myPredicate1 ){
1800 myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate());
1801 myPredicate1->Register();
1802 TPythonDump()<<this<<".SetPredicate1("<<myPredicate1<<")";
1806 void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate )
1809 myPredicate2->UnRegister();
1811 myPredicate2 = SMESH::GetPredicate(thePredicate);
1813 if ( myPredicate2 ){
1814 myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate());
1815 myPredicate2->Register();
1816 TPythonDump()<<this<<".SetPredicate2("<<myPredicate2<<")";
1820 Controls::LogicalBinaryPtr LogicalBinary_i::GetLogicalBinary()
1822 return myLogicalBinaryPtr;
1825 Predicate_i* LogicalBinary_i::GetPredicate1_i()
1827 return myPredicate1;
1829 Predicate_i* LogicalBinary_i::GetPredicate2_i()
1831 return myPredicate2;
1836 Class : LogicalAND_i
1837 Description : Logical AND
1839 LogicalAND_i::LogicalAND_i()
1841 myLogicalBinaryPtr.reset( new Controls::LogicalAND() );
1842 myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr;
1845 FunctorType LogicalAND_i::GetFunctorType()
1847 return SMESH::FT_LogicalAND;
1853 Description : Logical OR
1855 LogicalOR_i::LogicalOR_i()
1857 myLogicalBinaryPtr.reset( new Controls::LogicalOR() );
1858 myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr;
1861 FunctorType LogicalOR_i::GetFunctorType()
1863 return SMESH::FT_LogicalOR;
1871 FilterManager_i::FilterManager_i()
1872 : SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
1874 //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method
1875 //PortableServer::ObjectId_var anObjectId =
1876 // SMESH_Gen_i::GetPOA()->activate_object( this );
1880 FilterManager_i::~FilterManager_i()
1882 //TPythonDump()<<this<<".UnRegister()";
1886 MinimumAngle_ptr FilterManager_i::CreateMinimumAngle()
1888 SMESH::MinimumAngle_i* aServant = new SMESH::MinimumAngle_i();
1889 SMESH::MinimumAngle_var anObj = aServant->_this();
1890 TPythonDump()<<aServant<<" = "<<this<<".CreateMinimumAngle()";
1891 return anObj._retn();
1895 AspectRatio_ptr FilterManager_i::CreateAspectRatio()
1897 SMESH::AspectRatio_i* aServant = new SMESH::AspectRatio_i();
1898 SMESH::AspectRatio_var anObj = aServant->_this();
1899 TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio()";
1900 return anObj._retn();
1904 AspectRatio3D_ptr FilterManager_i::CreateAspectRatio3D()
1906 SMESH::AspectRatio3D_i* aServant = new SMESH::AspectRatio3D_i();
1907 SMESH::AspectRatio3D_var anObj = aServant->_this();
1908 TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio3D()";
1909 return anObj._retn();
1913 Warping_ptr FilterManager_i::CreateWarping()
1915 SMESH::Warping_i* aServant = new SMESH::Warping_i();
1916 SMESH::Warping_var anObj = aServant->_this();
1917 TPythonDump()<<aServant<<" = "<<this<<".CreateWarping()";
1918 return anObj._retn();
1922 Taper_ptr FilterManager_i::CreateTaper()
1924 SMESH::Taper_i* aServant = new SMESH::Taper_i();
1925 SMESH::Taper_var anObj = aServant->_this();
1926 TPythonDump()<<aServant<<" = "<<this<<".CreateTaper()";
1927 return anObj._retn();
1931 Skew_ptr FilterManager_i::CreateSkew()
1933 SMESH::Skew_i* aServant = new SMESH::Skew_i();
1934 SMESH::Skew_var anObj = aServant->_this();
1935 TPythonDump()<<aServant<<" = "<<this<<".CreateSkew()";
1936 return anObj._retn();
1940 Area_ptr FilterManager_i::CreateArea()
1942 SMESH::Area_i* aServant = new SMESH::Area_i();
1943 SMESH::Area_var anObj = aServant->_this();
1944 TPythonDump()<<aServant<<" = "<<this<<".CreateArea()";
1945 return anObj._retn();
1949 Volume3D_ptr FilterManager_i::CreateVolume3D()
1951 SMESH::Volume3D_i* aServant = new SMESH::Volume3D_i();
1952 SMESH::Volume3D_var anObj = aServant->_this();
1953 TPythonDump()<<aServant<<" = "<<this<<".CreateVolume3D()";
1954 return anObj._retn();
1958 MaxElementLength2D_ptr FilterManager_i::CreateMaxElementLength2D()
1960 SMESH::MaxElementLength2D_i* aServant = new SMESH::MaxElementLength2D_i();
1961 SMESH::MaxElementLength2D_var anObj = aServant->_this();
1962 TPythonDump()<<aServant<<" = "<<this<<".CreateMaxElementLength2D()";
1963 return anObj._retn();
1967 MaxElementLength3D_ptr FilterManager_i::CreateMaxElementLength3D()
1969 SMESH::MaxElementLength3D_i* aServant = new SMESH::MaxElementLength3D_i();
1970 SMESH::MaxElementLength3D_var anObj = aServant->_this();
1971 TPythonDump()<<aServant<<" = "<<this<<".CreateMaxElementLength3D()";
1972 return anObj._retn();
1976 Length_ptr FilterManager_i::CreateLength()
1978 SMESH::Length_i* aServant = new SMESH::Length_i();
1979 SMESH::Length_var anObj = aServant->_this();
1980 TPythonDump()<<aServant<<" = "<<this<<".CreateLength()";
1981 return anObj._retn();
1984 Length2D_ptr FilterManager_i::CreateLength2D()
1986 SMESH::Length2D_i* aServant = new SMESH::Length2D_i();
1987 SMESH::Length2D_var anObj = aServant->_this();
1988 TPythonDump()<<aServant<<" = "<<this<<".CreateLength2D()";
1989 return anObj._retn();
1992 MultiConnection_ptr FilterManager_i::CreateMultiConnection()
1994 SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i();
1995 SMESH::MultiConnection_var anObj = aServant->_this();
1996 TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection()";
1997 return anObj._retn();
2000 MultiConnection2D_ptr FilterManager_i::CreateMultiConnection2D()
2002 SMESH::MultiConnection2D_i* aServant = new SMESH::MultiConnection2D_i();
2003 SMESH::MultiConnection2D_var anObj = aServant->_this();
2004 TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection2D()";
2005 return anObj._retn();
2008 BelongToGeom_ptr FilterManager_i::CreateBelongToGeom()
2010 SMESH::BelongToGeom_i* aServant = new SMESH::BelongToGeom_i();
2011 SMESH::BelongToGeom_var anObj = aServant->_this();
2012 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGeom()";
2013 return anObj._retn();
2016 BelongToPlane_ptr FilterManager_i::CreateBelongToPlane()
2018 SMESH::BelongToPlane_i* aServant = new SMESH::BelongToPlane_i();
2019 SMESH::BelongToPlane_var anObj = aServant->_this();
2020 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToPlane()";
2021 return anObj._retn();
2024 BelongToCylinder_ptr FilterManager_i::CreateBelongToCylinder()
2026 SMESH::BelongToCylinder_i* aServant = new SMESH::BelongToCylinder_i();
2027 SMESH::BelongToCylinder_var anObj = aServant->_this();
2028 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToCylinder()";
2029 return anObj._retn();
2032 BelongToGenSurface_ptr FilterManager_i::CreateBelongToGenSurface()
2034 SMESH::BelongToGenSurface_i* aServant = new SMESH::BelongToGenSurface_i();
2035 SMESH::BelongToGenSurface_var anObj = aServant->_this();
2036 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGenSurface()";
2037 return anObj._retn();
2040 LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
2042 SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
2043 SMESH::LyingOnGeom_var anObj = aServant->_this();
2044 TPythonDump()<<aServant<<" = "<<this<<".CreateLyingOnGeom()";
2045 return anObj._retn();
2048 CoplanarFaces_ptr FilterManager_i::CreateCoplanarFaces()
2050 SMESH::CoplanarFaces_i* aServant = new SMESH::CoplanarFaces_i();
2051 SMESH::CoplanarFaces_var anObj = aServant->_this();
2052 TPythonDump()<<aServant<<" = "<<this<<".CreateCoplanarFaces()";
2053 return anObj._retn();
2056 FreeBorders_ptr FilterManager_i::CreateFreeBorders()
2058 SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
2059 SMESH::FreeBorders_var anObj = aServant->_this();
2060 TPythonDump()<<aServant<<" = "<<this<<".CreateFreeBorders()";
2061 return anObj._retn();
2064 FreeEdges_ptr FilterManager_i::CreateFreeEdges()
2066 SMESH::FreeEdges_i* aServant = new SMESH::FreeEdges_i();
2067 SMESH::FreeEdges_var anObj = aServant->_this();
2068 TPythonDump()<<aServant<<" = "<<this<<".CreateFreeEdges()";
2069 return anObj._retn();
2072 FreeFaces_ptr FilterManager_i::CreateFreeFaces()
2074 SMESH::FreeFaces_i* aServant = new SMESH::FreeFaces_i();
2075 SMESH::FreeFaces_var anObj = aServant->_this();
2076 TPythonDump()<<aServant<<" = "<<this<<".CreateFreeFaces()";
2077 return anObj._retn();
2080 FreeNodes_ptr FilterManager_i::CreateFreeNodes()
2082 SMESH::FreeNodes_i* aServant = new SMESH::FreeNodes_i();
2083 SMESH::FreeNodes_var anObj = aServant->_this();
2084 TPythonDump()<<aServant<<" = "<<this<<".CreateFreeNodes()";
2085 return anObj._retn();
2088 RangeOfIds_ptr FilterManager_i::CreateRangeOfIds()
2090 SMESH::RangeOfIds_i* aServant = new SMESH::RangeOfIds_i();
2091 SMESH::RangeOfIds_var anObj = aServant->_this();
2092 TPythonDump()<<aServant<<" = "<<this<<".CreateRangeOfIds()";
2093 return anObj._retn();
2096 BadOrientedVolume_ptr FilterManager_i::CreateBadOrientedVolume()
2098 SMESH::BadOrientedVolume_i* aServant = new SMESH::BadOrientedVolume_i();
2099 SMESH::BadOrientedVolume_var anObj = aServant->_this();
2100 TPythonDump()<<aServant<<" = "<<this<<".CreateBadOrientedVolume()";
2101 return anObj._retn();
2104 BareBorderVolume_ptr FilterManager_i::CreateBareBorderVolume()
2106 SMESH::BareBorderVolume_i* aServant = new SMESH::BareBorderVolume_i();
2107 SMESH::BareBorderVolume_var anObj = aServant->_this();
2108 TPythonDump()<<aServant<<" = "<<this<<".CreateBareBorderVolume()";
2109 return anObj._retn();
2112 BareBorderFace_ptr FilterManager_i::CreateBareBorderFace()
2114 SMESH::BareBorderFace_i* aServant = new SMESH::BareBorderFace_i();
2115 SMESH::BareBorderFace_var anObj = aServant->_this();
2116 TPythonDump()<<aServant<<" = "<<this<<".CreateBareBorderFace()";
2117 return anObj._retn();
2120 OverConstrainedVolume_ptr FilterManager_i::CreateOverConstrainedVolume()
2122 SMESH::OverConstrainedVolume_i* aServant = new SMESH::OverConstrainedVolume_i();
2123 SMESH::OverConstrainedVolume_var anObj = aServant->_this();
2124 TPythonDump()<<aServant<<" = "<<this<<".CreateOverConstrainedVolume()";
2125 return anObj._retn();
2128 OverConstrainedFace_ptr FilterManager_i::CreateOverConstrainedFace()
2130 SMESH::OverConstrainedFace_i* aServant = new SMESH::OverConstrainedFace_i();
2131 SMESH::OverConstrainedFace_var anObj = aServant->_this();
2132 TPythonDump()<<aServant<<" = "<<this<<".CreateOverConstrainedFace()";
2133 return anObj._retn();
2136 LessThan_ptr FilterManager_i::CreateLessThan()
2138 SMESH::LessThan_i* aServant = new SMESH::LessThan_i();
2139 SMESH::LessThan_var anObj = aServant->_this();
2140 TPythonDump()<<aServant<<" = "<<this<<".CreateLessThan()";
2141 return anObj._retn();
2144 MoreThan_ptr FilterManager_i::CreateMoreThan()
2146 SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
2147 SMESH::MoreThan_var anObj = aServant->_this();
2148 TPythonDump()<<aServant<<" = "<<this<<".CreateMoreThan()";
2149 return anObj._retn();
2152 EqualTo_ptr FilterManager_i::CreateEqualTo()
2154 SMESH::EqualTo_i* aServant = new SMESH::EqualTo_i();
2155 SMESH::EqualTo_var anObj = aServant->_this();
2156 TPythonDump()<<aServant<<" = "<<this<<".CreateEqualTo()";
2157 return anObj._retn();
2160 LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
2162 SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i();
2163 SMESH::LogicalNOT_var anObj = aServant->_this();
2164 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalNOT()";
2165 return anObj._retn();
2168 LogicalAND_ptr FilterManager_i::CreateLogicalAND()
2170 SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i();
2171 SMESH::LogicalAND_var anObj = aServant->_this();
2172 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalAND()";
2173 return anObj._retn();
2176 LogicalOR_ptr FilterManager_i::CreateLogicalOR()
2178 SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i();
2179 SMESH::LogicalOR_var anObj = aServant->_this();
2180 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalOR()";
2181 return anObj._retn();
2184 LinearOrQuadratic_ptr FilterManager_i::CreateLinearOrQuadratic()
2186 SMESH::LinearOrQuadratic_i* aServant = new SMESH::LinearOrQuadratic_i();
2187 SMESH::LinearOrQuadratic_var anObj = aServant->_this();
2188 TPythonDump()<<aServant<<" = "<<this<<".CreateLinearOrQuadratic()";
2189 return anObj._retn();
2192 GroupColor_ptr FilterManager_i::CreateGroupColor()
2194 SMESH::GroupColor_i* aServant = new SMESH::GroupColor_i();
2195 SMESH::GroupColor_var anObj = aServant->_this();
2196 TPythonDump()<<aServant<<" = "<<this<<".CreateGroupColor()";
2197 return anObj._retn();
2200 ElemGeomType_ptr FilterManager_i::CreateElemGeomType()
2202 SMESH::ElemGeomType_i* aServant = new SMESH::ElemGeomType_i();
2203 SMESH::ElemGeomType_var anObj = aServant->_this();
2204 TPythonDump()<<aServant<<" = "<<this<<".CreateElemGeomType()";
2205 return anObj._retn();
2208 Filter_ptr FilterManager_i::CreateFilter()
2210 SMESH::Filter_i* aServant = new SMESH::Filter_i();
2211 SMESH::Filter_var anObj = aServant->_this();
2212 TPythonDump()<<aServant<<" = "<<this<<".CreateFilter()";
2213 return anObj._retn();
2216 FilterLibrary_ptr FilterManager_i::LoadLibrary( const char* aFileName )
2218 SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i( aFileName );
2219 SMESH::FilterLibrary_var anObj = aServant->_this();
2220 TPythonDump()<<aServant<<" = "<<this<<".LoadLibrary('"<<aFileName<<"')";
2221 return anObj._retn();
2224 FilterLibrary_ptr FilterManager_i::CreateLibrary()
2226 SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i();
2227 SMESH::FilterLibrary_var anObj = aServant->_this();
2228 TPythonDump()<<aServant<<" = "<<this<<".CreateLibrary()";
2229 return anObj._retn();
2232 CORBA::Boolean FilterManager_i::DeleteLibrary( const char* aFileName )
2234 TPythonDump()<<this<<".DeleteLibrary("<<aFileName<<")";
2235 return remove( aFileName ) ? false : true;
2238 //=============================================================================
2240 * SMESH_Gen_i::CreateFilterManager
2242 * Create filter manager
2244 //=============================================================================
2246 SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager()
2248 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
2249 SMESH::FilterManager_var anObj = aFilter->_this();
2250 return anObj._retn();
2258 //=======================================================================
2259 // name : Filter_i::Filter_i
2260 // Purpose : Constructor
2261 //=======================================================================
2262 Filter_i::Filter_i()
2263 : myPredicate( NULL )
2266 //=======================================================================
2267 // name : Filter_i::~Filter_i
2268 // Purpose : Destructor
2269 //=======================================================================
2270 Filter_i::~Filter_i()
2273 myPredicate->UnRegister();
2275 if(!CORBA::is_nil(myMesh))
2276 myMesh->UnRegister();
2278 //TPythonDump()<<this<<".UnRegister()";
2281 //=======================================================================
2282 // name : Filter_i::SetPredicate
2283 // Purpose : Set predicate
2284 //=======================================================================
2285 void Filter_i::SetPredicate( Predicate_ptr thePredicate )
2288 myPredicate->UnRegister();
2290 myPredicate = SMESH::GetPredicate(thePredicate);
2294 myFilter.SetPredicate( myPredicate->GetPredicate() );
2295 myPredicate->Register();
2296 if ( const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh))
2297 myPredicate->GetPredicate()->SetMesh( aMesh );
2298 TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
2300 std::list<TPredicateChangeWaiter*>::iterator i = myWaiters.begin();
2301 for ( ; i != myWaiters.end(); ++i )
2302 (*i)->PredicateChanged();
2305 //=======================================================================
2306 // name : Filter_i::GetElementType
2307 // Purpose : Get entity type
2308 //=======================================================================
2309 SMESH::ElementType Filter_i::GetElementType()
2311 return myPredicate != 0 ? myPredicate->GetElementType() : SMESH::ALL;
2314 //=======================================================================
2315 // name : Filter_i::SetMesh
2316 // Purpose : Set mesh
2317 //=======================================================================
2320 SetMesh( SMESH_Mesh_ptr theMesh )
2322 if(!CORBA::is_nil(theMesh))
2323 theMesh->Register();
2325 if(!CORBA::is_nil(myMesh))
2326 myMesh->UnRegister();
2328 myMesh = SMESH_Mesh::_duplicate( theMesh );
2329 TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
2332 if ( const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
2333 myPredicate->GetPredicate()->SetMesh( aMesh );
2340 return GetElementsId(myMesh);
2343 //=======================================================================
2344 // name : Filter_i::GetElementsId
2345 // Purpose : Get ids of entities
2346 //=======================================================================
2349 GetElementsId( Predicate_i* thePredicate,
2350 const SMDS_Mesh* theMesh,
2351 Controls::Filter::TIdSequence& theSequence )
2354 Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
2359 GetElementsId( Predicate_i* thePredicate,
2360 SMESH_Mesh_ptr theMesh,
2361 Controls::Filter::TIdSequence& theSequence )
2364 if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
2365 Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
2370 GetElementsId( SMESH_Mesh_ptr theMesh )
2372 SMESH::long_array_var anArray = new SMESH::long_array;
2373 if(!CORBA::is_nil(theMesh) && myPredicate){
2374 Controls::Filter::TIdSequence aSequence;
2375 GetElementsId(myPredicate,theMesh,aSequence);
2376 long i = 0, iEnd = aSequence.size();
2377 anArray->length( iEnd );
2378 for ( ; i < iEnd; i++ )
2379 anArray[ i ] = aSequence[i];
2381 return anArray._retn();
2384 template<class TElement, class TIterator, class TPredicate>
2385 static void collectMeshInfo(const TIterator& theItr,
2386 TPredicate& thePred,
2387 SMESH::long_array& theRes)
2391 while (theItr->more()) {
2392 const SMDS_MeshElement* anElem = theItr->next();
2393 if ( thePred->IsSatisfy( anElem->GetID() ) )
2394 theRes[ anElem->GetEntityType() ]++;
2398 //=============================================================================
2400 * \brief Returns statistic of mesh elements
2402 //=============================================================================
2403 SMESH::long_array* ::Filter_i::GetMeshInfo()
2405 SMESH::long_array_var aRes = new SMESH::long_array();
2406 aRes->length(SMESH::Entity_Last);
2407 for (int i = SMESH::Entity_Node; i < SMESH::Entity_Last; i++)
2410 if(!CORBA::is_nil(myMesh) && myPredicate) {
2411 const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh);
2412 SMDS_ElemIteratorPtr it;
2413 switch( GetElementType() )
2416 collectMeshInfo<const SMDS_MeshNode*>(aMesh->nodesIterator(),myPredicate,aRes);
2419 collectMeshInfo<const SMDS_MeshElement*>(aMesh->edgesIterator(),myPredicate,aRes);
2422 collectMeshInfo<const SMDS_MeshElement*>(aMesh->facesIterator(),myPredicate,aRes);
2424 case SMDSAbs_Volume:
2425 collectMeshInfo<const SMDS_MeshElement*>(aMesh->volumesIterator(),myPredicate,aRes);
2429 collectMeshInfo<const SMDS_MeshElement*>(aMesh->elementsIterator(),myPredicate,aRes);
2434 return aRes._retn();
2437 //================================================================================
2439 * \brief Return GetElementType() within an array
2440 * Implement SMESH_IDSource interface
2442 //================================================================================
2444 SMESH::array_of_ElementType* Filter_i::GetTypes()
2446 SMESH::array_of_ElementType_var types = new SMESH::array_of_ElementType;
2448 // check if any element passes through the filter
2449 if ( !CORBA::is_nil(myMesh) && myPredicate )
2451 const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(myMesh);
2452 SMDS_ElemIteratorPtr it = aMesh->elementsIterator( SMDSAbs_ElementType( GetElementType() ));
2453 bool satisfies = false;
2454 while ( !satisfies && it->more() )
2455 satisfies = myPredicate->IsSatisfy( it->next()->GetID() );
2458 types[0] = GetElementType();
2461 return types._retn();
2464 //=======================================================================
2465 //function : GetMesh
2466 //purpose : Returns mesh
2467 //=======================================================================
2469 SMESH::SMESH_Mesh_ptr Filter_i::GetMesh()
2471 return SMESH_Mesh::_duplicate( myMesh );
2474 //================================================================================
2476 * \brief Stores an object to be notified on change of predicate
2478 //================================================================================
2480 void Filter_i::AddWaiter( TPredicateChangeWaiter* waiter )
2483 myWaiters.push_back( waiter );
2486 //================================================================================
2488 * \brief Removes an object to be notified on change of predicate
2490 //================================================================================
2492 void Filter_i::RemoveWaiter( TPredicateChangeWaiter* waiter )
2494 myWaiters.remove( waiter );
2497 //=======================================================================
2498 // name : getCriteria
2499 // Purpose : Retrieve criterions from predicate
2500 //=======================================================================
2501 static inline bool getCriteria( Predicate_i* thePred,
2502 SMESH::Filter::Criteria_out theCriteria )
2504 int aFType = thePred->GetFunctorType();
2508 case FT_FreeBorders:
2511 case FT_LinearOrQuadratic:
2514 CORBA::ULong i = theCriteria->length();
2515 theCriteria->length( i + 1 );
2517 theCriteria[ i ] = createCriterion();
2519 theCriteria[ i ].Type = aFType;
2520 theCriteria[ i ].TypeOfElement = thePred->GetElementType();
2523 case FT_BelongToGeom:
2525 BelongToGeom_i* aPred = dynamic_cast<BelongToGeom_i*>( thePred );
2527 CORBA::ULong i = theCriteria->length();
2528 theCriteria->length( i + 1 );
2530 theCriteria[ i ] = createCriterion();
2532 theCriteria[ i ].Type = FT_BelongToGeom;
2533 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2534 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2535 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2536 theCriteria[ i ].Tolerance = aPred->GetTolerance();
2540 case FT_BelongToPlane:
2541 case FT_BelongToCylinder:
2542 case FT_BelongToGenSurface:
2544 BelongToSurface_i* aPred = dynamic_cast<BelongToSurface_i*>( thePred );
2546 CORBA::ULong i = theCriteria->length();
2547 theCriteria->length( i + 1 );
2549 theCriteria[ i ] = createCriterion();
2551 theCriteria[ i ].Type = aFType;
2552 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2553 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2554 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2555 theCriteria[ i ].Tolerance = aPred->GetTolerance();
2559 case FT_LyingOnGeom:
2561 LyingOnGeom_i* aPred = dynamic_cast<LyingOnGeom_i*>( thePred );
2563 CORBA::ULong i = theCriteria->length();
2564 theCriteria->length( i + 1 );
2566 theCriteria[ i ] = createCriterion();
2568 theCriteria[ i ].Type = FT_LyingOnGeom;
2569 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2570 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2571 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2572 theCriteria[ i ].Tolerance = aPred->GetTolerance();
2576 case FT_CoplanarFaces:
2578 CoplanarFaces_i* aPred = dynamic_cast<CoplanarFaces_i*>( thePred );
2580 CORBA::ULong i = theCriteria->length();
2581 theCriteria->length( i + 1 );
2583 theCriteria[ i ] = createCriterion();
2584 CORBA::String_var faceId = aPred->GetFaceAsString();
2586 theCriteria[ i ].Type = FT_CoplanarFaces;
2587 theCriteria[ i ].ThresholdID = faceId;
2588 theCriteria[ i ].Tolerance = aPred->GetTolerance();
2594 RangeOfIds_i* aPred = dynamic_cast<RangeOfIds_i*>( thePred );
2596 CORBA::ULong i = theCriteria->length();
2597 theCriteria->length( i + 1 );
2599 theCriteria[ i ] = createCriterion();
2601 theCriteria[ i ].Type = FT_RangeOfIds;
2602 theCriteria[ i ].ThresholdStr = aPred->GetRangeStr();
2603 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2607 case FT_BadOrientedVolume:
2609 BadOrientedVolume_i* aPred = dynamic_cast<BadOrientedVolume_i*>( thePred );
2611 CORBA::ULong i = theCriteria->length();
2612 theCriteria->length( i + 1 );
2614 theCriteria[ i ] = createCriterion();
2616 theCriteria[ i ].Type = FT_BadOrientedVolume;
2617 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2621 case FT_BareBorderVolume:
2623 BareBorderVolume_i* aPred = dynamic_cast<BareBorderVolume_i*>( thePred );
2625 CORBA::ULong i = theCriteria->length();
2626 theCriteria->length( i + 1 );
2628 theCriteria[ i ] = createCriterion();
2630 theCriteria[ i ].Type = FT_BareBorderVolume;
2631 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2635 case FT_BareBorderFace:
2637 BareBorderFace_i* aPred = dynamic_cast<BareBorderFace_i*>( thePred );
2639 CORBA::ULong i = theCriteria->length();
2640 theCriteria->length( i + 1 );
2642 theCriteria[ i ] = createCriterion();
2644 theCriteria[ i ].Type = FT_BareBorderFace;
2645 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2649 case FT_OverConstrainedVolume:
2651 OverConstrainedVolume_i* aPred = dynamic_cast<OverConstrainedVolume_i*>( thePred );
2653 CORBA::ULong i = theCriteria->length();
2654 theCriteria->length( i + 1 );
2656 theCriteria[ i ] = createCriterion();
2658 theCriteria[ i ].Type = FT_OverConstrainedVolume;
2659 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2663 case FT_OverConstrainedFace:
2665 OverConstrainedFace_i* aPred = dynamic_cast<OverConstrainedFace_i*>( thePred );
2667 CORBA::ULong i = theCriteria->length();
2668 theCriteria->length( i + 1 );
2670 theCriteria[ i ] = createCriterion();
2672 theCriteria[ i ].Type = FT_OverConstrainedFace;
2673 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2681 Comparator_i* aCompar = dynamic_cast<Comparator_i*>( thePred );
2683 CORBA::ULong i = theCriteria->length();
2684 theCriteria->length( i + 1 );
2686 theCriteria[ i ] = createCriterion();
2688 theCriteria[ i ].Type = aCompar->GetNumFunctor_i()->GetFunctorType();
2689 theCriteria[ i ].Compare = aFType;
2690 theCriteria[ i ].Threshold = aCompar->GetMargin();
2691 theCriteria[ i ].TypeOfElement = aCompar->GetElementType();
2693 if ( aFType == FT_EqualTo )
2695 EqualTo_i* aCompar = dynamic_cast<EqualTo_i*>( thePred );
2696 theCriteria[ i ].Tolerance = aCompar->GetTolerance();
2703 Predicate_i* aPred = ( dynamic_cast<LogicalNOT_i*>( thePred ) )->GetPredicate_i();
2704 getCriteria( aPred, theCriteria );
2705 theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT;
2712 Predicate_i* aPred1 = ( dynamic_cast<LogicalBinary_i*>( thePred ) )->GetPredicate1_i();
2713 Predicate_i* aPred2 = ( dynamic_cast<LogicalBinary_i*>( thePred ) )->GetPredicate2_i();
2714 if ( !getCriteria( aPred1, theCriteria ) )
2716 theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType;
2717 return getCriteria( aPred2, theCriteria );
2721 CORBA::ULong i = theCriteria->length();
2722 theCriteria->length( i + 1 );
2724 theCriteria[ i ] = createCriterion();
2726 GroupColor_i* aPred = dynamic_cast<GroupColor_i*>( thePred );
2727 theCriteria[ i ].Type = aFType;
2728 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2729 theCriteria[ i ].ThresholdStr = aPred->GetColorStr();
2733 case FT_ElemGeomType:
2735 CORBA::ULong i = theCriteria->length();
2736 theCriteria->length( i + 1 );
2738 theCriteria[ i ] = createCriterion();
2740 ElemGeomType_i* aPred = dynamic_cast<ElemGeomType_i*>( thePred );
2741 theCriteria[ i ].Type = aFType;
2742 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2743 theCriteria[ i ].Threshold = (double)aPred->GetGeometryType();
2754 //=======================================================================
2755 // name : Filter_i::GetCriteria
2756 // Purpose : Retrieve criterions from predicate
2757 //=======================================================================
2758 CORBA::Boolean Filter_i::GetCriteria( SMESH::Filter::Criteria_out theCriteria )
2760 theCriteria = new SMESH::Filter::Criteria;
2761 return myPredicate != 0 ? getCriteria( myPredicate, theCriteria ) : true;
2764 //=======================================================================
2765 // name : Filter_i::SetCriteria
2766 // Purpose : Create new predicate and set criterions in it
2767 //=======================================================================
2768 CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria )
2770 if ( myPredicate != 0 )
2771 myPredicate->UnRegister();
2773 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
2774 FilterManager_ptr aFilterMgr = aFilter->_this();
2776 // CREATE two lists ( PREDICATES and LOG OP )
2779 TPythonDump()<<"aCriteria = []";
2780 std::list<SMESH::Predicate_ptr> aPredicates;
2781 std::list<int> aBinaries;
2782 for ( int i = 0, n = theCriteria.length(); i < n; i++ )
2784 int aCriterion = theCriteria[ i ].Type;
2785 int aCompare = theCriteria[ i ].Compare;
2786 double aThreshold = theCriteria[ i ].Threshold;
2787 const char* aThresholdStr = theCriteria[ i ].ThresholdStr;
2788 const char* aThresholdID = theCriteria[ i ].ThresholdID;
2789 int aUnary = theCriteria[ i ].UnaryOp;
2790 int aBinary = theCriteria[ i ].BinaryOp;
2791 double aTolerance = theCriteria[ i ].Tolerance;
2792 ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement;
2793 long aPrecision = theCriteria[ i ].Precision;
2797 pd << "aCriterion = SMESH.Filter.Criterion("
2798 << aCriterion << ", "
2800 << aThreshold << ", '"
2801 << aThresholdStr << "', '";
2802 if (aThresholdID) pd << aThresholdID;
2806 << aTolerance << ", "
2807 << aTypeOfElem << ", "
2808 << aPrecision << ")";
2812 SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil();
2813 SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil();
2815 switch ( aCriterion )
2819 case SMESH::FT_MultiConnection:
2820 aFunctor = aFilterMgr->CreateMultiConnection();
2822 case SMESH::FT_MultiConnection2D:
2823 aFunctor = aFilterMgr->CreateMultiConnection2D();
2825 case SMESH::FT_Length:
2826 aFunctor = aFilterMgr->CreateLength();
2828 case SMESH::FT_Length2D:
2829 aFunctor = aFilterMgr->CreateLength2D();
2831 case SMESH::FT_AspectRatio:
2832 aFunctor = aFilterMgr->CreateAspectRatio();
2834 case SMESH::FT_AspectRatio3D:
2835 aFunctor = aFilterMgr->CreateAspectRatio3D();
2837 case SMESH::FT_Warping:
2838 aFunctor = aFilterMgr->CreateWarping();
2840 case SMESH::FT_MinimumAngle:
2841 aFunctor = aFilterMgr->CreateMinimumAngle();
2843 case SMESH::FT_Taper:
2844 aFunctor = aFilterMgr->CreateTaper();
2846 case SMESH::FT_Skew:
2847 aFunctor = aFilterMgr->CreateSkew();
2849 case SMESH::FT_Area:
2850 aFunctor = aFilterMgr->CreateArea();
2852 case SMESH::FT_Volume3D:
2853 aFunctor = aFilterMgr->CreateVolume3D();
2855 case SMESH::FT_MaxElementLength2D:
2856 aFunctor = aFilterMgr->CreateMaxElementLength2D();
2858 case SMESH::FT_MaxElementLength3D:
2859 aFunctor = aFilterMgr->CreateMaxElementLength3D();
2864 case SMESH::FT_FreeBorders:
2865 aPredicate = aFilterMgr->CreateFreeBorders();
2867 case SMESH::FT_FreeEdges:
2868 aPredicate = aFilterMgr->CreateFreeEdges();
2870 case SMESH::FT_FreeFaces:
2871 aPredicate = aFilterMgr->CreateFreeFaces();
2873 case SMESH::FT_FreeNodes:
2874 aPredicate = aFilterMgr->CreateFreeNodes();
2876 case SMESH::FT_BelongToGeom:
2878 SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom();
2879 tmpPred->SetElementType( aTypeOfElem );
2880 tmpPred->SetShape( aThresholdID, aThresholdStr );
2881 tmpPred->SetTolerance( aTolerance );
2882 aPredicate = tmpPred;
2885 case SMESH::FT_BelongToPlane:
2886 case SMESH::FT_BelongToCylinder:
2887 case SMESH::FT_BelongToGenSurface:
2889 SMESH::BelongToSurface_ptr tmpPred;
2890 switch ( aCriterion ) {
2891 case SMESH::FT_BelongToPlane:
2892 tmpPred = aFilterMgr->CreateBelongToPlane(); break;
2893 case SMESH::FT_BelongToCylinder:
2894 tmpPred = aFilterMgr->CreateBelongToCylinder(); break;
2896 tmpPred = aFilterMgr->CreateBelongToGenSurface();
2898 tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem );
2899 tmpPred->SetTolerance( aTolerance );
2900 aPredicate = tmpPred;
2903 case SMESH::FT_LyingOnGeom:
2905 SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
2906 tmpPred->SetElementType( aTypeOfElem );
2907 tmpPred->SetShape( aThresholdID, aThresholdStr );
2908 tmpPred->SetTolerance( aTolerance );
2909 aPredicate = tmpPred;
2912 case SMESH::FT_RangeOfIds:
2914 SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds();
2915 tmpPred->SetRangeStr( aThresholdStr );
2916 tmpPred->SetElementType( aTypeOfElem );
2917 aPredicate = tmpPred;
2920 case SMESH::FT_BadOrientedVolume:
2922 aPredicate = aFilterMgr->CreateBadOrientedVolume();
2925 case SMESH::FT_BareBorderVolume:
2927 aPredicate = aFilterMgr->CreateBareBorderVolume();
2930 case SMESH::FT_BareBorderFace:
2932 aPredicate = aFilterMgr->CreateBareBorderFace();
2935 case SMESH::FT_OverConstrainedVolume:
2937 aPredicate = aFilterMgr->CreateOverConstrainedVolume();
2940 case SMESH::FT_OverConstrainedFace:
2942 aPredicate = aFilterMgr->CreateOverConstrainedFace();
2945 case SMESH::FT_LinearOrQuadratic:
2947 SMESH::LinearOrQuadratic_ptr tmpPred = aFilterMgr->CreateLinearOrQuadratic();
2948 tmpPred->SetElementType( aTypeOfElem );
2949 aPredicate = tmpPred;
2952 case SMESH::FT_GroupColor:
2954 SMESH::GroupColor_ptr tmpPred = aFilterMgr->CreateGroupColor();
2955 tmpPred->SetElementType( aTypeOfElem );
2956 tmpPred->SetColorStr( aThresholdStr );
2957 aPredicate = tmpPred;
2960 case SMESH::FT_ElemGeomType:
2962 SMESH::ElemGeomType_ptr tmpPred = aFilterMgr->CreateElemGeomType();
2963 tmpPred->SetElementType( aTypeOfElem );
2964 tmpPred->SetGeometryType( (GeometryType)(int)(aThreshold + 0.5) );
2965 aPredicate = tmpPred;
2968 case SMESH::FT_CoplanarFaces:
2970 SMESH::CoplanarFaces_ptr tmpPred = aFilterMgr->CreateCoplanarFaces();
2971 tmpPred->SetFace( atol (aThresholdID ));
2972 tmpPred->SetTolerance( aTolerance );
2973 aPredicate = tmpPred;
2982 if ( !aFunctor->_is_nil() && aPredicate->_is_nil() )
2984 SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil();
2986 if ( aCompare == SMESH::FT_LessThan )
2987 aComparator = aFilterMgr->CreateLessThan();
2988 else if ( aCompare == SMESH::FT_MoreThan )
2989 aComparator = aFilterMgr->CreateMoreThan();
2990 else if ( aCompare == SMESH::FT_EqualTo )
2991 aComparator = aFilterMgr->CreateEqualTo();
2995 aComparator->SetNumFunctor( aFunctor );
2996 aComparator->SetMargin( aThreshold );
2998 if ( aCompare == FT_EqualTo )
3000 SMESH::EqualTo_var anEqualTo = SMESH::EqualTo::_narrow( aComparator );
3001 anEqualTo->SetTolerance( aTolerance );
3004 aPredicate = aComparator;
3006 aFunctor->SetPrecision( aPrecision );
3010 if ( aUnary == FT_LogicalNOT )
3012 SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT();
3013 aNotPred->SetPredicate( aPredicate );
3014 aPredicate = aNotPred;
3018 aPredicates.push_back( aPredicate );
3019 aBinaries.push_back( aBinary );
3020 pd <<"aCriteria.append(aCriterion)";
3023 TPythonDump pd; pd<<this<<".SetCriteria(aCriteria)";
3025 // CREATE ONE PREDICATE FROM PREVIOUSLY CREATED MAP
3027 // combine all "AND" operations
3029 std::list<SMESH::Predicate_ptr> aResList;
3031 std::list<SMESH::Predicate_ptr>::iterator aPredIter;
3032 std::list<int>::iterator aBinaryIter;
3034 SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil();
3035 int aPrevBinary = SMESH::FT_Undefined;
3037 for ( aPredIter = aPredicates.begin(), aBinaryIter = aBinaries.begin();
3038 aPredIter != aPredicates.end() && aBinaryIter != aBinaries.end();
3039 ++aPredIter, ++aBinaryIter )
3041 int aCurrBinary = *aBinaryIter;
3043 SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil();
3045 if ( aPrevBinary == SMESH::FT_LogicalAND )
3048 SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND();
3049 aBinaryPred->SetPredicate1( aPrevPredicate );
3050 aBinaryPred->SetPredicate2( *aPredIter );
3051 aCurrPred = aBinaryPred;
3054 aCurrPred = *aPredIter;
3056 if ( aCurrBinary != SMESH::FT_LogicalAND )
3057 aResList.push_back( aCurrPred );
3059 aPrevPredicate = aCurrPred;
3060 aPrevBinary = aCurrBinary;
3063 // combine all "OR" operations
3065 SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil();
3067 if ( aResList.size() == 1 )
3068 aResPredicate = *aResList.begin();
3069 else if ( aResList.size() > 1 )
3071 std::list<SMESH::Predicate_ptr>::iterator anIter = aResList.begin();
3072 aResPredicate = *anIter;
3074 for ( ; anIter != aResList.end(); ++anIter )
3076 SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR();
3077 aBinaryPred->SetPredicate1( aResPredicate );
3078 aBinaryPred->SetPredicate2( *anIter );
3079 aResPredicate = aBinaryPred;
3083 SetPredicate( aResPredicate );
3085 return !aResPredicate->_is_nil();
3088 //=======================================================================
3089 // name : Filter_i::GetPredicate_i
3090 // Purpose : Get implementation of predicate
3091 //=======================================================================
3092 Predicate_i* Filter_i::GetPredicate_i()
3097 //=======================================================================
3098 // name : Filter_i::GetPredicate
3099 // Purpose : Get predicate
3100 //=======================================================================
3101 Predicate_ptr Filter_i::GetPredicate()
3103 if ( myPredicate == 0 )
3104 return SMESH::Predicate::_nil();
3107 SMESH::Predicate_var anObj = myPredicate->_this();
3108 // if ( SMESH::Functor_i* fun = SMESH::DownCast<SMESH::Functor_i*>( anObj ))
3109 // TPythonDump() << fun << " = " << this << ".GetPredicate()";
3110 return anObj._retn();
3118 #define ATTR_TYPE "type"
3119 #define ATTR_COMPARE "compare"
3120 #define ATTR_THRESHOLD "threshold"
3121 #define ATTR_UNARY "unary"
3122 #define ATTR_BINARY "binary"
3123 #define ATTR_THRESHOLD_STR "threshold_str"
3124 #define ATTR_TOLERANCE "tolerance"
3125 #define ATTR_ELEMENT_TYPE "ElementType"
3127 //=======================================================================
3129 // Purpose : Convert bool to LDOMString
3130 //=======================================================================
3131 static inline LDOMString toString( CORBA::Boolean val )
3133 return val ? "logical not" : "";
3136 //=======================================================================
3138 // Purpose : Convert LDOMString to bool
3139 //=======================================================================
3140 static inline bool toBool( const LDOMString& theStr )
3142 return theStr.equals( "logical not" );
3145 //=======================================================================
3147 // Purpose : Convert double to LDOMString
3148 //=======================================================================
3149 static inline LDOMString toString( CORBA::Double val )
3152 sprintf( a, "%e", val );
3153 return LDOMString( a );
3156 //=======================================================================
3158 // Purpose : Convert LDOMString to double
3159 //=======================================================================
3160 static inline double toDouble( const LDOMString& theStr )
3162 return atof( theStr.GetString() );
3165 //=======================================================================
3167 // Purpose : Convert functor type to LDOMString
3168 //=======================================================================
3169 static inline LDOMString toString( CORBA::Long theType )
3173 case FT_AspectRatio : return "Aspect ratio";
3174 case FT_Warping : return "Warping";
3175 case FT_MinimumAngle : return "Minimum angle";
3176 case FT_Taper : return "Taper";
3177 case FT_Skew : return "Skew";
3178 case FT_Area : return "Area";
3179 case FT_Volume3D : return "Volume3D";
3180 case FT_MaxElementLength2D: return "Max element length 2D";
3181 case FT_MaxElementLength3D: return "Max element length 3D";
3182 case FT_BelongToGeom : return "Belong to Geom";
3183 case FT_BelongToPlane : return "Belong to Plane";
3184 case FT_BelongToCylinder: return "Belong to Cylinder";
3185 case FT_BelongToGenSurface: return "Belong to Generic Surface";
3186 case FT_LyingOnGeom : return "Lying on Geom";
3187 case FT_BadOrientedVolume:return "Bad Oriented Volume";
3188 case FT_BareBorderVolume: return "Volumes with bare border";
3189 case FT_BareBorderFace : return "Faces with bare border";
3190 case FT_OverConstrainedVolume: return "Over-constrained Volumes";
3191 case FT_OverConstrainedFace : return "Over-constrained Faces";
3192 case FT_RangeOfIds : return "Range of IDs";
3193 case FT_FreeBorders : return "Free borders";
3194 case FT_FreeEdges : return "Free edges";
3195 case FT_FreeFaces : return "Free faces";
3196 case FT_FreeNodes : return "Free nodes";
3197 case FT_MultiConnection : return "Borders at multi-connections";
3198 case FT_MultiConnection2D: return "Borders at multi-connections 2D";
3199 case FT_Length : return "Length";
3200 case FT_Length2D : return "Length 2D";
3201 case FT_LessThan : return "Less than";
3202 case FT_MoreThan : return "More than";
3203 case FT_EqualTo : return "Equal to";
3204 case FT_LogicalNOT : return "Not";
3205 case FT_LogicalAND : return "And";
3206 case FT_LogicalOR : return "Or";
3207 case FT_GroupColor : return "Color of Group";
3208 case FT_LinearOrQuadratic : return "Linear or Quadratic";
3209 case FT_ElemGeomType : return "Element geomtry type";
3210 case FT_Undefined : return "";
3211 default : return "";
3215 //=======================================================================
3216 // name : toFunctorType
3217 // Purpose : Convert LDOMString to functor type
3218 //=======================================================================
3219 static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
3221 if ( theStr.equals( "Aspect ratio" ) ) return FT_AspectRatio;
3222 else if ( theStr.equals( "Warping" ) ) return FT_Warping;
3223 else if ( theStr.equals( "Minimum angle" ) ) return FT_MinimumAngle;
3224 else if ( theStr.equals( "Taper" ) ) return FT_Taper;
3225 else if ( theStr.equals( "Skew" ) ) return FT_Skew;
3226 else if ( theStr.equals( "Area" ) ) return FT_Area;
3227 else if ( theStr.equals( "Volume3D" ) ) return FT_Volume3D;
3228 else if ( theStr.equals( "Max element length 2D" ) ) return FT_MaxElementLength2D;
3229 else if ( theStr.equals( "Max element length 3D" ) ) return FT_MaxElementLength3D;
3230 else if ( theStr.equals( "Belong to Geom" ) ) return FT_BelongToGeom;
3231 else if ( theStr.equals( "Belong to Plane" ) ) return FT_BelongToPlane;
3232 else if ( theStr.equals( "Belong to Cylinder" ) ) return FT_BelongToCylinder;
3233 else if ( theStr.equals( "Belong to Generic Surface" ) ) return FT_BelongToGenSurface;
3234 else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom;
3235 else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders;
3236 else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges;
3237 else if ( theStr.equals( "Free faces" ) ) return FT_FreeFaces;
3238 else if ( theStr.equals( "Free nodes" ) ) return FT_FreeNodes;
3239 else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection;
3240 // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
3241 else if ( theStr.equals( "Length" ) ) return FT_Length;
3242 // else if ( theStr.equals( "Length2D" ) ) return FT_Length2D;
3243 else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds;
3244 else if ( theStr.equals( "Bad Oriented Volume" ) ) return FT_BadOrientedVolume;
3245 else if ( theStr.equals( "Volumes with bare border" ) ) return FT_BareBorderVolume;
3246 else if ( theStr.equals( "Faces with bare border" ) ) return FT_BareBorderFace;
3247 else if ( theStr.equals( "Over-constrained Volumes" ) ) return FT_OverConstrainedVolume;
3248 else if ( theStr.equals( "Over-constrained Faces" ) ) return FT_OverConstrainedFace;
3249 else if ( theStr.equals( "Less than" ) ) return FT_LessThan;
3250 else if ( theStr.equals( "More than" ) ) return FT_MoreThan;
3251 else if ( theStr.equals( "Equal to" ) ) return FT_EqualTo;
3252 else if ( theStr.equals( "Not" ) ) return FT_LogicalNOT;
3253 else if ( theStr.equals( "And" ) ) return FT_LogicalAND;
3254 else if ( theStr.equals( "Or" ) ) return FT_LogicalOR;
3255 else if ( theStr.equals( "Color of Group" ) ) return FT_GroupColor;
3256 else if ( theStr.equals( "Linear or Quadratic" ) ) return FT_LinearOrQuadratic;
3257 else if ( theStr.equals( "Element geomtry type" ) ) return FT_ElemGeomType;
3258 else if ( theStr.equals( "" ) ) return FT_Undefined;
3259 else return FT_Undefined;
3262 //=======================================================================
3263 // name : toFunctorType
3264 // Purpose : Convert LDOMString to value of ElementType enumeration
3265 //=======================================================================
3266 static inline SMESH::ElementType toElementType( const LDOMString& theStr )
3268 if ( theStr.equals( "NODE" ) ) return SMESH::NODE;
3269 else if ( theStr.equals( "EDGE" ) ) return SMESH::EDGE;
3270 else if ( theStr.equals( "FACE" ) ) return SMESH::FACE;
3271 else if ( theStr.equals( "VOLUME" ) ) return SMESH::VOLUME;
3272 else return SMESH::ALL;
3275 //=======================================================================
3277 // Purpose : Convert ElementType to string
3278 //=======================================================================
3279 static inline LDOMString toString( const SMESH::ElementType theType )
3283 case SMESH::NODE : return "NODE";
3284 case SMESH::EDGE : return "EDGE";
3285 case SMESH::FACE : return "FACE";
3286 case SMESH::VOLUME : return "VOLUME";
3287 case SMESH::ALL : return "ALL";
3288 default : return "";
3292 //=======================================================================
3293 // name : findFilter
3294 // Purpose : Find filter in document
3295 //=======================================================================
3296 static LDOM_Element findFilter( const char* theFilterName,
3297 const LDOM_Document& theDoc,
3298 LDOM_Node* theParent = 0 )
3300 LDOM_Element aRootElement = theDoc.getDocumentElement();
3301 if ( aRootElement.isNull() || !aRootElement.hasChildNodes() )
3302 return LDOM_Element();
3304 for ( LDOM_Node aTypeNode = aRootElement.getFirstChild();
3305 !aTypeNode.isNull(); aTypeNode = aTypeNode.getNextSibling() )
3307 for ( LDOM_Node aFilter = aTypeNode.getFirstChild();
3308 !aFilter.isNull(); aFilter = aFilter.getNextSibling() )
3310 LDOM_Element* anElem = ( LDOM_Element* )&aFilter;
3311 if ( anElem->getTagName().equals( LDOMString( "filter" ) ) &&
3312 anElem->getAttribute( "name" ).equals( LDOMString( theFilterName ) ) )
3314 if ( theParent != 0 )
3315 *theParent = aTypeNode;
3316 return (LDOM_Element&)aFilter;
3320 return LDOM_Element();
3323 //=======================================================================
3324 // name : getSectionName
3325 // Purpose : Get name of section of filters
3326 //=======================================================================
3327 static const char* getSectionName( const ElementType theType )
3331 case SMESH::NODE : return "Filters for nodes";
3332 case SMESH::EDGE : return "Filters for edges";
3333 case SMESH::FACE : return "Filters for faces";
3334 case SMESH::VOLUME : return "Filters for volumes";
3335 case SMESH::ALL : return "Filters for elements";
3336 default : return "";
3340 //=======================================================================
3341 // name : getSection
3342 // Purpose : Create section for filters corresponding to the entity type
3343 //=======================================================================
3344 static LDOM_Node getSection( const ElementType theType,
3345 LDOM_Document& theDoc,
3346 const bool toCreate = false )
3348 LDOM_Element aRootElement = theDoc.getDocumentElement();
3349 if ( aRootElement.isNull() )
3353 bool anExist = false;
3354 const char* aSectionName = getSectionName( theType );
3355 if ( strcmp( aSectionName, "" ) == 0 )
3358 LDOM_NodeList aSections = theDoc.getElementsByTagName( "section" );
3360 for ( int i = 0, n = aSections.getLength(); i < n; i++ )
3362 aNode = aSections.item( i );
3363 LDOM_Element& anItem = ( LDOM_Element& )aNode;
3364 if ( anItem.getAttribute( "name" ).equals( LDOMString( aSectionName ) ) )
3371 // Create new section if necessary
3376 LDOM_Element aNewItem = theDoc.createElement( "section" );
3377 aNewItem.setAttribute( "name", aSectionName );
3378 aRootElement.appendChild( aNewItem );
3388 //=======================================================================
3389 // name : createFilterItem
3390 // Purpose : Create filter item or LDOM document
3391 //=======================================================================
3392 static LDOM_Element createFilterItem( const char* theName,
3393 SMESH::Filter_ptr theFilter,
3394 LDOM_Document& theDoc )
3396 // create new filter in document
3397 LDOM_Element aFilterItem = theDoc.createElement( "filter" );
3398 aFilterItem.setAttribute( "name", theName );
3400 // save filter criterions
3401 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
3403 if ( !theFilter->GetCriteria( aCriteria ) )
3404 return LDOM_Element();
3406 for ( CORBA::ULong i = 0, n = aCriteria->length(); i < n; i++ )
3408 LDOM_Element aCriterionItem = theDoc.createElement( "criterion" );
3410 aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type) );
3411 aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) );
3412 aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) );
3413 aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) );
3414 aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) );
3416 aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr );
3417 aCriterionItem.setAttribute( ATTR_TOLERANCE , toString( aCriteria[ i ].Tolerance ) );
3418 aCriterionItem.setAttribute( ATTR_ELEMENT_TYPE ,
3419 toString( (SMESH::ElementType)aCriteria[ i ].TypeOfElement ) );
3421 aFilterItem.appendChild( aCriterionItem );
3427 //=======================================================================
3428 // name : FilterLibrary_i::FilterLibrary_i
3429 // Purpose : Constructor
3430 //=======================================================================
3431 FilterLibrary_i::FilterLibrary_i( const char* theFileName )
3433 myFileName = strdup( theFileName );
3434 SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i();
3435 myFilterMgr = aFilterMgr->_this();
3439 // Try to use existing library file
3440 bool anExists = false;
3441 if ( !aParser.parse( myFileName ) )
3443 myDoc = aParser.getDocument();
3446 // Create a new XML document if it doesn't exist
3448 myDoc = LDOM_Document::createDocument( LDOMString() );
3450 LDOM_Element aRootElement = myDoc.getDocumentElement();
3451 if ( aRootElement.isNull() )
3453 // If the existing document is empty --> try to create a new one
3455 myDoc = LDOM_Document::createDocument( LDOMString() );
3459 //=======================================================================
3460 // name : FilterLibrary_i::FilterLibrary_i
3461 // Purpose : Constructor
3462 //=======================================================================
3463 FilterLibrary_i::FilterLibrary_i()
3466 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
3467 myFilterMgr = aFilter->_this();
3469 myDoc = LDOM_Document::createDocument( LDOMString() );
3472 FilterLibrary_i::~FilterLibrary_i()
3475 //TPythonDump()<<this<<".UnRegister()";
3478 //=======================================================================
3479 // name : FilterLibrary_i::Copy
3480 // Purpose : Create filter and initialize it with values from library
3481 //=======================================================================
3482 Filter_ptr FilterLibrary_i::Copy( const char* theFilterName )
3484 Filter_ptr aRes = Filter::_nil();
3485 LDOM_Node aFilter = findFilter( theFilterName, myDoc );
3487 if ( aFilter.isNull() )
3490 std::list<SMESH::Filter::Criterion> aCriteria;
3492 for ( LDOM_Node aCritNode = aFilter.getFirstChild();
3493 !aCritNode.isNull() ; aCritNode = aCritNode.getNextSibling() )
3495 LDOM_Element* aCrit = (LDOM_Element*)&aCritNode;
3497 const char* aTypeStr = aCrit->getAttribute( ATTR_TYPE ).GetString();
3498 const char* aCompareStr = aCrit->getAttribute( ATTR_COMPARE ).GetString();
3499 const char* aUnaryStr = aCrit->getAttribute( ATTR_UNARY ).GetString();
3500 const char* aBinaryStr = aCrit->getAttribute( ATTR_BINARY ).GetString();
3501 const char* anElemTypeStr = aCrit->getAttribute( ATTR_ELEMENT_TYPE ).GetString();
3503 SMESH::Filter::Criterion aCriterion = createCriterion();
3505 aCriterion.Type = toFunctorType( aTypeStr );
3506 aCriterion.Compare = toFunctorType( aCompareStr );
3507 aCriterion.UnaryOp = toFunctorType( aUnaryStr );
3508 aCriterion.BinaryOp = toFunctorType( aBinaryStr );
3510 aCriterion.TypeOfElement = toElementType( anElemTypeStr );
3512 LDOMString str = aCrit->getAttribute( ATTR_THRESHOLD );
3514 aCriterion.Threshold = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val )
3515 ? val : atof( str.GetString() );
3517 str = aCrit->getAttribute( ATTR_TOLERANCE );
3518 aCriterion.Tolerance = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val )
3519 ? val : atof( str.GetString() );
3521 str = aCrit->getAttribute( ATTR_THRESHOLD_STR );
3522 if ( str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) )
3525 sprintf( a, "%d", val );
3526 aCriterion.ThresholdStr = strdup( a );
3529 aCriterion.ThresholdStr = str.GetString();
3531 aCriteria.push_back( aCriterion );
3534 SMESH::Filter::Criteria_var aCriteriaVar = new SMESH::Filter::Criteria;
3535 aCriteriaVar->length( aCriteria.size() );
3538 std::list<SMESH::Filter::Criterion>::iterator anIter = aCriteria.begin();
3540 for( ; anIter != aCriteria.end(); ++anIter )
3541 aCriteriaVar[ i++ ] = *anIter;
3543 aRes = myFilterMgr->CreateFilter();
3544 aRes->SetCriteria( aCriteriaVar.inout() );
3546 TPythonDump()<<this<<".Copy('"<<theFilterName<<"')";
3551 //=======================================================================
3552 // name : FilterLibrary_i::SetFileName
3553 // Purpose : Set file name for library
3554 //=======================================================================
3555 void FilterLibrary_i::SetFileName( const char* theFileName )
3558 myFileName = strdup( theFileName );
3559 TPythonDump()<<this<<".SetFileName('"<<theFileName<<"')";
3562 //=======================================================================
3563 // name : FilterLibrary_i::GetFileName
3564 // Purpose : Get file name of library
3565 //=======================================================================
3566 char* FilterLibrary_i::GetFileName()
3568 return CORBA::string_dup( myFileName );
3571 //=======================================================================
3572 // name : FilterLibrary_i::Add
3573 // Purpose : Add new filter to library
3574 //=======================================================================
3575 CORBA::Boolean FilterLibrary_i::Add( const char* theFilterName, Filter_ptr theFilter )
3577 // if filter already in library or entry filter is null do nothing
3578 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc );
3579 if ( !aFilterNode.isNull() || theFilter->_is_nil() )
3582 // get section corresponding to the filter type
3583 ElementType anEntType = theFilter->GetElementType();
3585 LDOM_Node aSection = getSection( anEntType, myDoc, true );
3586 if ( aSection.isNull() )
3589 // create filter item
3590 LDOM_Element aFilterItem = createFilterItem( theFilterName, theFilter, myDoc );
3591 if ( aFilterItem.isNull() )
3595 aSection.appendChild( aFilterItem );
3596 if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
3597 TPythonDump()<<this<<".Add('"<<theFilterName<<"',"<<aFilter<<")";
3602 //=======================================================================
3603 // name : FilterLibrary_i::Add
3604 // Purpose : Add new filter to library
3605 //=======================================================================
3606 CORBA::Boolean FilterLibrary_i::AddEmpty( const char* theFilterName, ElementType theType )
3608 // if filter already in library or entry filter is null do nothing
3609 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc );
3610 if ( !aFilterNode.isNull() )
3613 LDOM_Node aSection = getSection( theType, myDoc, true );
3614 if ( aSection.isNull() )
3617 // create filter item
3618 Filter_var aFilter = myFilterMgr->CreateFilter();
3620 LDOM_Element aFilterItem = createFilterItem( theFilterName, aFilter, myDoc );
3621 if ( aFilterItem.isNull() )
3625 aSection.appendChild( aFilterItem );
3626 TPythonDump()<<this<<".AddEmpty('"<<theFilterName<<"',"<<theType<<")";
3631 //=======================================================================
3632 // name : FilterLibrary_i::Delete
3633 // Purpose : Delete filter from library
3634 //=======================================================================
3635 CORBA::Boolean FilterLibrary_i::Delete ( const char* theFilterName )
3637 LDOM_Node aParentNode;
3638 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc, &aParentNode );
3639 if ( aFilterNode.isNull() || aParentNode.isNull() )
3642 aParentNode.removeChild( aFilterNode );
3643 TPythonDump()<<this<<".Delete('"<<theFilterName<<"')";
3647 //=======================================================================
3648 // name : FilterLibrary_i::Replace
3649 // Purpose : Replace existing filter with entry filter.
3650 // IMPORTANT : If filter does not exist it is not created
3651 //=======================================================================
3652 CORBA::Boolean FilterLibrary_i::Replace( const char* theFilterName,
3653 const char* theNewName,
3654 Filter_ptr theFilter )
3656 LDOM_Element aFilterItem = findFilter( theFilterName, myDoc );
3657 if ( aFilterItem.isNull() || theFilter->_is_nil() )
3660 LDOM_Element aNewItem = createFilterItem( theNewName, theFilter, myDoc );
3661 if ( aNewItem.isNull() )
3665 aFilterItem.ReplaceElement( aNewItem );
3666 if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
3667 TPythonDump()<<this<<".Replace('"<<theFilterName<<"','"<<theNewName<<"',"<<aFilter<<")";
3672 //=======================================================================
3673 // name : FilterLibrary_i::Save
3674 // Purpose : Save library on disk
3675 //=======================================================================
3676 CORBA::Boolean FilterLibrary_i::Save()
3678 if ( myFileName == 0 || strlen( myFileName ) == 0 )
3681 FILE* aOutFile = fopen( myFileName, "wt" );
3685 LDOM_XmlWriter aWriter( aOutFile );
3686 aWriter.SetIndentation( 2 );
3690 TPythonDump()<<this<<".Save()";
3694 //=======================================================================
3695 // name : FilterLibrary_i::SaveAs
3696 // Purpose : Save library on disk
3697 //=======================================================================
3698 CORBA::Boolean FilterLibrary_i::SaveAs( const char* aFileName )
3700 myFileName = strdup ( aFileName );
3701 TPythonDump()<<this<<".SaveAs('"<<aFileName<<"')";
3705 //=======================================================================
3706 // name : FilterLibrary_i::IsPresent
3707 // Purpose : Verify whether filter is in library
3708 //=======================================================================
3709 CORBA::Boolean FilterLibrary_i::IsPresent( const char* theFilterName )
3711 return !findFilter( theFilterName, myDoc ).isNull();
3714 //=======================================================================
3715 // name : FilterLibrary_i::NbFilters
3716 // Purpose : Return amount of filters in library
3717 //=======================================================================
3718 CORBA::Long FilterLibrary_i::NbFilters( ElementType theType )
3720 string_array_var aNames = GetNames( theType );
3721 return aNames->length();
3724 //=======================================================================
3725 // name : FilterLibrary_i::GetNames
3726 // Purpose : Get names of filters from library
3727 //=======================================================================
3728 string_array* FilterLibrary_i::GetNames( ElementType theType )
3730 string_array_var anArray = new string_array;
3731 TColStd_SequenceOfHAsciiString aSeq;
3733 LDOM_Node aSection = getSection( theType, myDoc, false );
3735 if ( !aSection.isNull() )
3737 for ( LDOM_Node aFilter = aSection.getFirstChild();
3738 !aFilter.isNull(); aFilter = aFilter.getNextSibling() )
3740 LDOM_Element& anElem = ( LDOM_Element& )aFilter;
3741 aSeq.Append( new TCollection_HAsciiString(
3742 (Standard_CString)anElem.getAttribute( "name" ).GetString() ) );
3746 anArray->length( aSeq.Length() );
3747 for ( int i = 1, n = aSeq.Length(); i <= n; i++ )
3748 anArray[ i - 1 ] = CORBA::string_dup( aSeq( i )->ToCString() );
3750 return anArray._retn();
3753 //=======================================================================
3754 // name : FilterLibrary_i::GetAllNames
3755 // Purpose : Get names of filters from library
3756 //=======================================================================
3757 string_array* FilterLibrary_i::GetAllNames()
3759 string_array_var aResArray = new string_array;
3760 for ( int type = SMESH::ALL; type <= SMESH::VOLUME; type++ )
3762 SMESH::string_array_var aNames = GetNames( (SMESH::ElementType)type );
3764 int aPrevLength = aResArray->length();
3765 aResArray->length( aPrevLength + aNames->length() );
3766 for ( int i = 0, n = aNames->length(); i < n; i++ )
3767 aResArray[ aPrevLength + i ] = aNames[ i ];
3770 return aResArray._retn();
3773 //================================================================================
3775 * \brief Return an array of strings corresponding to items of enum FunctorType
3777 //================================================================================
3779 static const char** getFunctNames()
3781 static const char* functName[ SMESH::FT_Undefined + 1 ] = {
3782 // If this line doesn't compile, this means that enum FunctorType has changed and
3783 // it's necessary to update this array accordingly (refer to SMESH_Filter.idl)
3784 // The order is IMPORTANT !!!
3785 "FT_AspectRatio", "FT_AspectRatio3D", "FT_Warping", "FT_MinimumAngle",
3786 "FT_Taper", "FT_Skew", "FT_Area", "FT_Volume3D", "FT_MaxElementLength2D",
3787 "FT_MaxElementLength3D", "FT_FreeBorders", "FT_FreeEdges", "FT_FreeNodes",
3788 "FT_FreeFaces", "FT_MultiConnection", "FT_MultiConnection2D", "FT_Length",
3789 "FT_Length2D", "FT_BelongToGeom", "FT_BelongToPlane", "FT_BelongToCylinder",
3790 "FT_BelongToGenSurface", "FT_LyingOnGeom", "FT_RangeOfIds", "FT_BadOrientedVolume",
3791 "FT_BareBorderVolume", "FT_BareBorderFace", "FT_OverConstrainedVolume",
3792 "FT_OverConstrainedFace", "FT_LinearOrQuadratic", "FT_GroupColor", "FT_ElemGeomType",
3793 "FT_CoplanarFaces", "FT_LessThan", "FT_MoreThan", "FT_EqualTo", "FT_LogicalNOT",
3794 "FT_LogicalAND", "FT_LogicalOR", "FT_Undefined" };
3798 //================================================================================
3800 * \brief Return a string corresponding to an item of enum FunctorType
3802 //================================================================================
3804 const char* SMESH::FunctorTypeToString(SMESH::FunctorType ft)
3806 if ( ft < 0 || ft > SMESH::FT_Undefined )
3807 return "FT_Undefined";
3808 return getFunctNames()[ ft ];
3811 //================================================================================
3813 * \brief Converts a string to FunctorType. This is reverse of FunctorTypeToString()
3815 //================================================================================
3817 SMESH::FunctorType SMESH::StringToFunctorType(const char* str)
3819 std::string name( str + 3 ); // skip "FT_"
3820 const char** functNames = getFunctNames();
3822 for ( ; ft < SMESH::FT_Undefined; ++ft )
3823 if ( name == ( functNames[ft] + 3 ))
3826 //ASSERT( strcmp( str, FunctorTypeToString( SMESH::FunctorType( ft ))) == 0 );
3828 return SMESH::FunctorType( ft );