1 // Copyright (C) 2007-2008 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
22 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
23 // File : SMESH_Filter_i.cxx
24 // Author : Alexey Petrov, OCC
27 #include "SMESH_Filter_i.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include "SMESH_PythonDump.hxx"
32 #include "SMDS_Mesh.hxx"
33 #include "SMDS_MeshNode.hxx"
34 #include "SMDS_MeshElement.hxx"
36 #include "SMESHDS_Mesh.hxx"
38 #include <BRep_Tool.hxx>
39 #include <Geom_CylindricalSurface.hxx>
40 #include <Geom_Plane.hxx>
41 #include <LDOMParser.hxx>
42 #include <LDOMString.hxx>
43 #include <LDOM_Document.hxx>
44 #include <LDOM_Element.hxx>
45 #include <LDOM_Node.hxx>
46 #include <LDOM_XmlWriter.hxx>
47 #include <Precision.hxx>
48 #include <TColStd_ListIteratorOfListOfInteger.hxx>
49 #include <TColStd_ListIteratorOfListOfReal.hxx>
50 #include <TColStd_ListOfInteger.hxx>
51 #include <TColStd_ListOfReal.hxx>
52 #include <TColStd_SequenceOfHAsciiString.hxx>
53 #include <TCollection_HAsciiString.hxx>
55 #include <TopExp_Explorer.hxx>
57 #include <TopoDS_Face.hxx>
58 #include <TopoDS_Shape.hxx>
59 #include <TopTools_IndexedMapOfShape.hxx>
61 using namespace SMESH;
62 using namespace SMESH::Controls;
68 GetPredicate( Predicate_ptr thePredicate )
70 return DownCast<Predicate_i*>(thePredicate);
77 Description : Predicate for verifying whether entity belongs to
78 specified geometrical support
81 Controls::BelongToGeom::BelongToGeom()
85 myTolerance(Precision::Confusion())
88 void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
90 myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
94 void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
100 static bool IsSubShape (const TopTools_IndexedMapOfShape& theMap,
101 const TopoDS_Shape& theShape)
103 if (theMap.Contains(theShape)) return true;
105 if (theShape.ShapeType() == TopAbs_COMPOUND ||
106 theShape.ShapeType() == TopAbs_COMPSOLID)
108 TopoDS_Iterator anIt (theShape, Standard_True, Standard_True);
109 for (; anIt.More(); anIt.Next())
111 if (!IsSubShape(theMap, anIt.Value())) {
121 void Controls::BelongToGeom::init()
123 if (!myMeshDS || myShape.IsNull()) return;
125 // is subshape of main shape?
126 TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
127 if (aMainShape.IsNull()) {
128 myIsSubshape = false;
131 TopTools_IndexedMapOfShape aMap;
132 TopExp::MapShapes(aMainShape, aMap);
133 myIsSubshape = IsSubShape(aMap, myShape);
138 myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
139 myElementsOnShapePtr->SetTolerance(myTolerance);
140 myElementsOnShapePtr->SetAllNodes(true); // belong, while false means "lays on"
141 myElementsOnShapePtr->SetMesh(myMeshDS);
142 myElementsOnShapePtr->SetShape(myShape, myType);
146 static bool IsContains( const SMESHDS_Mesh* theMeshDS,
147 const TopoDS_Shape& theShape,
148 const SMDS_MeshElement* theElem,
149 TopAbs_ShapeEnum theFindShapeEnum,
150 TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE )
152 TopExp_Explorer anExp( theShape,theFindShapeEnum,theAvoidShapeEnum );
154 while( anExp.More() )
156 const TopoDS_Shape& aShape = anExp.Current();
157 if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
158 if( aSubMesh->Contains( theElem ) )
166 bool Controls::BelongToGeom::IsSatisfy (long theId)
168 if (myMeshDS == 0 || myShape.IsNull())
173 return myElementsOnShapePtr->IsSatisfy(theId);
177 if (myType == SMDSAbs_Node)
179 if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
181 const SMDS_PositionPtr& aPosition = aNode->GetPosition();
182 SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
183 switch( aTypeOfPosition )
185 case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
186 case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
187 case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
188 case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
194 if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
196 if( myType == SMDSAbs_All )
198 return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
199 IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
200 IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
201 IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
203 else if( myType == anElem->GetType() )
207 case SMDSAbs_Edge : return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE );
208 case SMDSAbs_Face : return IsContains( myMeshDS,myShape,anElem,TopAbs_FACE );
209 case SMDSAbs_Volume: return IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
210 IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
219 void Controls::BelongToGeom::SetType (SMDSAbs_ElementType theType)
225 SMDSAbs_ElementType Controls::BelongToGeom::GetType() const
230 TopoDS_Shape Controls::BelongToGeom::GetShape()
235 const SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() const
240 void Controls::BelongToGeom::SetTolerance (double theTolerance)
242 myTolerance = theTolerance;
247 double Controls::BelongToGeom::GetTolerance()
254 Description : Predicate for verifying whether entiy lying or partially lying on
255 specified geometrical support
258 Controls::LyingOnGeom::LyingOnGeom()
262 myTolerance(Precision::Confusion())
265 void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
267 myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
271 void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
277 void Controls::LyingOnGeom::init()
279 if (!myMeshDS || myShape.IsNull()) return;
281 // is subshape of main shape?
282 TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
283 if (aMainShape.IsNull()) {
284 myIsSubshape = false;
287 TopTools_IndexedMapOfShape aMap;
288 TopExp::MapShapes(aMainShape, aMap);
289 myIsSubshape = IsSubShape(aMap, myShape);
294 myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
295 myElementsOnShapePtr->SetTolerance(myTolerance);
296 myElementsOnShapePtr->SetAllNodes(false); // lays on, while true means "belong"
297 myElementsOnShapePtr->SetMesh(myMeshDS);
298 myElementsOnShapePtr->SetShape(myShape, myType);
302 bool Controls::LyingOnGeom::IsSatisfy( long theId )
304 if ( myMeshDS == 0 || myShape.IsNull() )
309 return myElementsOnShapePtr->IsSatisfy(theId);
313 if( myType == SMDSAbs_Node )
315 if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
317 const SMDS_PositionPtr& aPosition = aNode->GetPosition();
318 SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
319 switch( aTypeOfPosition )
321 case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
322 case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
323 case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
324 case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
330 if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
332 if( myType == SMDSAbs_All )
334 return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
335 Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
336 Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
337 Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
339 else if( myType == anElem->GetType() )
343 case SMDSAbs_Edge : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE );
344 case SMDSAbs_Face : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE );
345 case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
346 Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
355 void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
361 SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
366 TopoDS_Shape Controls::LyingOnGeom::GetShape()
371 const SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() const
376 void Controls::LyingOnGeom::SetTolerance (double theTolerance)
378 myTolerance = theTolerance;
383 double Controls::LyingOnGeom::GetTolerance()
388 bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS,
389 const TopoDS_Shape& theShape,
390 const SMDS_MeshElement* theElem,
391 TopAbs_ShapeEnum theFindShapeEnum,
392 TopAbs_ShapeEnum theAvoidShapeEnum )
394 if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
397 TopTools_IndexedMapOfShape aSubShapes;
398 TopExp::MapShapes( theShape, aSubShapes );
400 for (int i = 1; i <= aSubShapes.Extent(); i++)
402 const TopoDS_Shape& aShape = aSubShapes.FindKey(i);
404 if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
405 if( aSubMesh->Contains( theElem ) )
408 SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
409 while ( aNodeIt->more() )
411 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
412 SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
413 while ( anElemIt->more() )
415 const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
416 if (anElement == theElem)
432 MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
434 SMESH_Mesh_i* anImplPtr = DownCast<SMESH_Mesh_i*>(theMesh);
435 return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
440 toArray( const TColStd_ListOfInteger& aList )
442 SMESH::long_array_var anArray = new SMESH::long_array;
443 anArray->length( aList.Extent() );
444 TColStd_ListIteratorOfListOfInteger anIter( aList );
446 for( ; anIter.More(); anIter.Next() )
447 anArray[ i++ ] = anIter.Value();
449 return anArray._retn();
454 toArray( const TColStd_ListOfReal& aList )
456 SMESH::double_array_var anArray = new SMESH::double_array;
457 anArray->length( aList.Extent() );
458 TColStd_ListIteratorOfListOfReal anIter( aList );
460 for( ; anIter.More(); anIter.Next() )
461 anArray[ i++ ] = anIter.Value();
463 return anArray._retn();
466 static SMESH::Filter::Criterion createCriterion()
468 SMESH::Filter::Criterion aCriterion;
470 aCriterion.Type = FT_Undefined;
471 aCriterion.Compare = FT_Undefined;
472 aCriterion.Threshold = 0;
473 aCriterion.UnaryOp = FT_Undefined;
474 aCriterion.BinaryOp = FT_Undefined;
475 aCriterion.ThresholdStr = "";
476 aCriterion.ThresholdID = "";
477 aCriterion.Tolerance = Precision::Confusion();
478 aCriterion.TypeOfElement = SMESH::ALL;
479 aCriterion.Precision = -1;
484 static TopoDS_Shape getShapeByName( const char* theName )
488 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
489 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
490 if (!CORBA::is_nil(aStudy))
492 SALOMEDS::Study::ListOfSObject_var aList =
493 aStudy->FindObjectByName( theName, "GEOM" );
494 if ( aList->length() > 0 )
496 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() );
497 if ( !aGeomObj->_is_nil() )
499 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
500 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
506 return TopoDS_Shape();
509 static TopoDS_Shape getShapeByID (const char* theID)
511 if (theID != 0 && theID != "") {
512 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
513 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
515 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
516 SALOMEDS::GenericAttribute_var anAttr;
517 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
518 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
519 CORBA::String_var aVal = anIOR->Value();
520 CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal);
521 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
523 if (!aGeomObj->_is_nil()) {
524 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
525 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
531 return TopoDS_Shape();
534 static char* getShapeNameByID (const char* theID)
538 if (theID != 0 && theID != "") {
539 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
540 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
542 //SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( theID );
543 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
544 SALOMEDS::GenericAttribute_var anAttr;
545 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeName")) {
546 SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr);
547 aName = aNameAttr->Value();
561 Description : An abstact class for all functors
563 Functor_i::Functor_i():
564 SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
566 //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method
567 //PortableServer::ObjectId_var anObjectId =
568 // SMESH_Gen_i::GetPOA()->activate_object( this );
571 Functor_i::~Functor_i()
573 //TPythonDump()<<this<<".Destroy()";
576 void Functor_i::SetMesh( SMESH_Mesh_ptr theMesh )
578 myFunctorPtr->SetMesh( MeshPtr2SMDSMesh( theMesh ) );
579 TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
582 ElementType Functor_i::GetElementType()
584 return ( ElementType )myFunctorPtr->GetType();
589 Class : NumericalFunctor_i
590 Description : Base class for numerical functors
592 CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId )
594 return myNumericalFunctorPtr->GetValue( theId );
597 void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision )
599 myNumericalFunctorPtr->SetPrecision( thePrecision );
600 TPythonDump()<<this<<".SetPrecision("<<thePrecision<<")";
603 CORBA::Long NumericalFunctor_i::GetPrecision()
605 return myNumericalFunctorPtr->GetPrecision();
608 Controls::NumericalFunctorPtr NumericalFunctor_i::GetNumericalFunctor()
610 return myNumericalFunctorPtr;
615 Class : SMESH_MinimumAngle
616 Description : Functor for calculation of minimum angle
618 MinimumAngle_i::MinimumAngle_i()
620 myNumericalFunctorPtr.reset( new Controls::MinimumAngle() );
621 myFunctorPtr = myNumericalFunctorPtr;
624 FunctorType MinimumAngle_i::GetFunctorType()
626 return SMESH::FT_MinimumAngle;
632 Description : Functor for calculating aspect ratio
634 AspectRatio_i::AspectRatio_i()
636 myNumericalFunctorPtr.reset( new Controls::AspectRatio() );
637 myFunctorPtr = myNumericalFunctorPtr;
640 FunctorType AspectRatio_i::GetFunctorType()
642 return SMESH::FT_AspectRatio;
647 Class : AspectRatio3D
648 Description : Functor for calculating aspect ratio 3D
650 AspectRatio3D_i::AspectRatio3D_i()
652 myNumericalFunctorPtr.reset( new Controls::AspectRatio3D() );
653 myFunctorPtr = myNumericalFunctorPtr;
656 FunctorType AspectRatio3D_i::GetFunctorType()
658 return SMESH::FT_AspectRatio3D;
664 Description : Functor for calculating warping
666 Warping_i::Warping_i()
668 myNumericalFunctorPtr.reset( new Controls::Warping() );
669 myFunctorPtr = myNumericalFunctorPtr;
672 FunctorType Warping_i::GetFunctorType()
674 return SMESH::FT_Warping;
680 Description : Functor for calculating taper
684 myNumericalFunctorPtr.reset( new Controls::Taper() );
685 myFunctorPtr = myNumericalFunctorPtr;
688 FunctorType Taper_i::GetFunctorType()
690 return SMESH::FT_Taper;
696 Description : Functor for calculating skew in degrees
700 myNumericalFunctorPtr.reset( new Controls::Skew() );
701 myFunctorPtr = myNumericalFunctorPtr;
704 FunctorType Skew_i::GetFunctorType()
706 return SMESH::FT_Skew;
711 Description : Functor for calculating area
715 myNumericalFunctorPtr.reset( new Controls::Area() );
716 myFunctorPtr = myNumericalFunctorPtr;
719 FunctorType Area_i::GetFunctorType()
721 return SMESH::FT_Area;
726 Description : Functor for calculating volume of 3D element
728 Volume3D_i::Volume3D_i()
730 myNumericalFunctorPtr.reset( new Controls::Volume() );
731 myFunctorPtr = myNumericalFunctorPtr;
734 FunctorType Volume3D_i::GetFunctorType()
736 return SMESH::FT_Volume3D;
741 Description : Functor for calculating length off edge
745 myNumericalFunctorPtr.reset( new Controls::Length() );
746 myFunctorPtr = myNumericalFunctorPtr;
749 FunctorType Length_i::GetFunctorType()
751 return SMESH::FT_Length;
756 Description : Functor for calculating length of edge
758 Length2D_i::Length2D_i()
760 myNumericalFunctorPtr.reset( new Controls::Length2D() );
761 myFunctorPtr = myNumericalFunctorPtr;
764 FunctorType Length2D_i::GetFunctorType()
766 return SMESH::FT_Length2D;
769 SMESH::Length2D::Values* Length2D_i::GetValues()
771 INFOS("Length2D_i::GetValues");
772 SMESH::Controls::Length2D::TValues aValues;
773 myLength2DPtr->GetValues( aValues );
775 long i = 0, iEnd = aValues.size();
777 SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd);
779 SMESH::Controls::Length2D::TValues::const_iterator anIter;
780 for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
782 const SMESH::Controls::Length2D::Value& aVal = *anIter;
783 SMESH::Length2D::Value &aValue = aResult[ i ];
785 aValue.myLength = aVal.myLength;
786 aValue.myPnt1 = aVal.myPntId[ 0 ];
787 aValue.myPnt2 = aVal.myPntId[ 1 ];
790 INFOS("Length2D_i::GetValuess~");
791 return aResult._retn();
795 Class : MultiConnection_i
796 Description : Functor for calculating number of faces conneted to the edge
798 MultiConnection_i::MultiConnection_i()
800 myNumericalFunctorPtr.reset( new Controls::MultiConnection() );
801 myFunctorPtr = myNumericalFunctorPtr;
804 FunctorType MultiConnection_i::GetFunctorType()
806 return SMESH::FT_MultiConnection;
810 Class : MultiConnection2D_i
811 Description : Functor for calculating number of faces conneted to the edge
813 MultiConnection2D_i::MultiConnection2D_i()
815 myNumericalFunctorPtr.reset( new Controls::MultiConnection2D() );
816 myFunctorPtr = myNumericalFunctorPtr;
819 FunctorType MultiConnection2D_i::GetFunctorType()
821 return SMESH::FT_MultiConnection2D;
824 SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues()
826 INFOS("MultiConnection2D_i::GetValues");
827 SMESH::Controls::MultiConnection2D::MValues aValues;
828 myMulticonnection2DPtr->GetValues( aValues );
830 long i = 0, iEnd = aValues.size();
832 SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd);
834 SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter;
835 for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
837 const SMESH::Controls::MultiConnection2D::Value& aVal = (*anIter).first;
838 SMESH::MultiConnection2D::Value &aValue = aResult[ i ];
840 aValue.myPnt1 = aVal.myPntId[ 0 ];
841 aValue.myPnt2 = aVal.myPntId[ 1 ];
842 aValue.myNbConnects = (*anIter).second;
845 INFOS("Multiconnection2D_i::GetValuess~");
846 return aResult._retn();
856 Description : Base class for all predicates
858 CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId )
860 return myPredicatePtr->IsSatisfy( theId );
863 Controls::PredicatePtr Predicate_i::GetPredicate()
865 return myPredicatePtr;
869 Class : BadOrientedVolume_i
870 Description : Verify whether a mesh volume is incorrectly oriented from
871 the point of view of MED convention
873 BadOrientedVolume_i::BadOrientedVolume_i()
875 Controls::PredicatePtr control( new Controls::BadOrientedVolume() );
876 myFunctorPtr = myPredicatePtr = control;
879 FunctorType BadOrientedVolume_i::GetFunctorType()
881 return SMESH::FT_BadOrientedVolume;
885 Class : BelongToGeom_i
886 Description : Predicate for selection on geometrical support
888 BelongToGeom_i::BelongToGeom_i()
890 myBelongToGeomPtr.reset( new Controls::BelongToGeom() );
891 myFunctorPtr = myPredicatePtr = myBelongToGeomPtr;
896 BelongToGeom_i::~BelongToGeom_i()
902 void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
904 if ( theGeom->_is_nil() )
906 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
907 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
908 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
909 myBelongToGeomPtr->SetGeom( aLocShape );
910 TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
913 void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape )
915 myBelongToGeomPtr->SetGeom( theShape );
918 void BelongToGeom_i::SetElementType(ElementType theType){
919 myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType));
920 TPythonDump()<<this<<".SetElementType("<<theType<<")";
923 FunctorType BelongToGeom_i::GetFunctorType()
925 return SMESH::FT_BelongToGeom;
928 void BelongToGeom_i::SetShapeName( const char* theName )
931 myShapeName = strdup( theName );
932 myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
933 TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
936 void BelongToGeom_i::SetShape( const char* theID, const char* theName )
939 myShapeName = strdup( theName );
942 myShapeID = strdup( theID );
946 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
947 myBelongToGeomPtr->SetGeom( getShapeByID(myShapeID) );
949 myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
952 char* BelongToGeom_i::GetShapeName()
954 return CORBA::string_dup( myShapeName );
957 char* BelongToGeom_i::GetShapeID()
959 return CORBA::string_dup( myShapeID );
962 void BelongToGeom_i::SetTolerance( CORBA::Double theToler )
964 myBelongToGeomPtr->SetTolerance( theToler );
965 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
968 CORBA::Double BelongToGeom_i::GetTolerance()
970 return myBelongToGeomPtr->GetTolerance();
974 Class : BelongToSurface_i
975 Description : Predicate for selection on geometrical support
977 BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceType )
979 myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() );
980 myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr;
983 mySurfaceType = theSurfaceType;
986 BelongToSurface_i::~BelongToSurface_i()
992 void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
994 if ( theGeom->_is_nil() )
996 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
997 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
998 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
1000 if ( aLocShape.ShapeType() == TopAbs_FACE )
1002 Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aLocShape ) );
1003 if ( !aSurf.IsNull() && aSurf->DynamicType() == mySurfaceType )
1005 myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
1010 myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType );
1013 void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
1016 myShapeName = strdup( theName );
1017 myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
1018 TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
1021 void BelongToSurface_i::SetShape( const char* theID, const char* theName, ElementType theType )
1024 myShapeName = strdup( theName );
1027 myShapeID = strdup( theID );
1031 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
1032 myElementsOnSurfacePtr->SetSurface( getShapeByID(myShapeID), (SMDSAbs_ElementType)theType );
1034 myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
1037 char* BelongToSurface_i::GetShapeName()
1039 return CORBA::string_dup( myShapeName );
1042 char* BelongToSurface_i::GetShapeID()
1044 return CORBA::string_dup( myShapeID );
1047 void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
1049 myElementsOnSurfacePtr->SetTolerance( theToler );
1050 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1053 CORBA::Double BelongToSurface_i::GetTolerance()
1055 return myElementsOnSurfacePtr->GetTolerance();
1058 void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions )
1060 myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions );
1061 TPythonDump()<<this<<".SetUseBoundaries( " << theUseBndRestrictions << " )";
1064 CORBA::Boolean BelongToSurface_i::GetUseBoundaries()
1066 return myElementsOnSurfacePtr->GetUseBoundaries();
1071 Class : BelongToPlane_i
1072 Description : Verify whether mesh element lie in pointed Geom planar object
1075 BelongToPlane_i::BelongToPlane_i()
1076 : BelongToSurface_i( STANDARD_TYPE( Geom_Plane ) )
1080 void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1082 BelongToSurface_i::SetSurface( theGeom, theType );
1083 TPythonDump()<<this<<".SetPlane("<<theGeom<<","<<theType<<")";
1086 FunctorType BelongToPlane_i::GetFunctorType()
1088 return FT_BelongToPlane;
1092 Class : BelongToCylinder_i
1093 Description : Verify whether mesh element lie in pointed Geom planar object
1096 BelongToCylinder_i::BelongToCylinder_i()
1097 : BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
1101 void BelongToCylinder_i::SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1103 BelongToSurface_i::SetSurface( theGeom, theType );
1104 TPythonDump()<<this<<".SetCylinder("<<theGeom<<","<<theType<<")";
1107 FunctorType BelongToCylinder_i::GetFunctorType()
1109 return FT_BelongToCylinder;
1113 Class : BelongToGenSurface_i
1114 Description : Verify whether mesh element lie in pointed Geom planar object
1117 BelongToGenSurface_i::BelongToGenSurface_i()
1118 : BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
1122 void BelongToGenSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1124 if ( theGeom->_is_nil() )
1126 TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom );
1127 if ( !aLocShape.IsNull() && aLocShape.ShapeType() != TopAbs_FACE )
1128 aLocShape.Nullify();
1130 BelongToSurface_i::myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
1131 TPythonDump()<<this<<".SetGenSurface("<<theGeom<<","<<theType<<")";
1134 FunctorType BelongToGenSurface_i::GetFunctorType()
1136 return FT_BelongToGenSurface;
1140 Class : LyingOnGeom_i
1141 Description : Predicate for selection on geometrical support
1143 LyingOnGeom_i::LyingOnGeom_i()
1145 myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
1146 myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
1151 LyingOnGeom_i::~LyingOnGeom_i()
1157 void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
1159 if ( theGeom->_is_nil() )
1161 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1162 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
1163 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
1164 myLyingOnGeomPtr->SetGeom( aLocShape );
1165 TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
1168 void LyingOnGeom_i::SetGeom( const TopoDS_Shape& theShape )
1170 myLyingOnGeomPtr->SetGeom( theShape );
1173 void LyingOnGeom_i::SetElementType(ElementType theType){
1174 myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType));
1175 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1178 FunctorType LyingOnGeom_i::GetFunctorType()
1180 return SMESH::FT_LyingOnGeom;
1183 void LyingOnGeom_i::SetShapeName( const char* theName )
1186 myShapeName = strdup( theName );
1187 myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
1188 TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
1191 void LyingOnGeom_i::SetShape( const char* theID, const char* theName )
1194 myShapeName = strdup( theName );
1197 myShapeID = strdup( theID );
1201 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
1202 myLyingOnGeomPtr->SetGeom( getShapeByID(myShapeID) );
1204 myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
1207 char* LyingOnGeom_i::GetShapeName()
1209 return CORBA::string_dup( myShapeName );
1212 char* LyingOnGeom_i::GetShapeID()
1214 return CORBA::string_dup( myShapeID );
1217 void LyingOnGeom_i::SetTolerance( CORBA::Double theToler )
1219 myLyingOnGeomPtr->SetTolerance( theToler );
1220 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1223 CORBA::Double LyingOnGeom_i::GetTolerance()
1225 return myLyingOnGeomPtr->GetTolerance();
1229 Class : FreeBorders_i
1230 Description : Predicate for free borders
1232 FreeBorders_i::FreeBorders_i()
1234 myPredicatePtr.reset(new Controls::FreeBorders());
1235 myFunctorPtr = myPredicatePtr;
1238 FunctorType FreeBorders_i::GetFunctorType()
1240 return SMESH::FT_FreeBorders;
1245 Description : Predicate for free borders
1247 FreeEdges_i::FreeEdges_i()
1248 : myFreeEdgesPtr( new Controls::FreeEdges() )
1250 myFunctorPtr = myPredicatePtr = myFreeEdgesPtr;
1253 SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders()
1255 INFOS("FreeEdges_i::GetBorders");
1256 SMESH::Controls::FreeEdges::TBorders aBorders;
1257 myFreeEdgesPtr->GetBoreders( aBorders );
1259 long i = 0, iEnd = aBorders.size();
1261 SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders;
1262 aResult->length(iEnd);
1264 SMESH::Controls::FreeEdges::TBorders::const_iterator anIter;
1265 for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ )
1267 const SMESH::Controls::FreeEdges::Border& aBord = *anIter;
1268 SMESH::FreeEdges::Border &aBorder = aResult[ i ];
1270 aBorder.myElemId = aBord.myElemId;
1271 aBorder.myPnt1 = aBord.myPntId[ 0 ];
1272 aBorder.myPnt2 = aBord.myPntId[ 1 ];
1275 INFOS("FreeEdges_i::GetBorders~");
1276 return aResult._retn();
1279 FunctorType FreeEdges_i::GetFunctorType()
1281 return SMESH::FT_FreeEdges;
1285 Class : RangeOfIds_i
1286 Description : Predicate for Range of Ids.
1287 Range may be specified with two ways.
1288 1. Using AddToRange method
1289 2. With SetRangeStr method. Parameter of this method is a string
1290 like as "1,2,3,50-60,63,67,70-"
1293 RangeOfIds_i::RangeOfIds_i()
1295 myRangeOfIdsPtr.reset( new Controls::RangeOfIds() );
1296 myFunctorPtr = myPredicatePtr = myRangeOfIdsPtr;
1299 void RangeOfIds_i::SetRange( const SMESH::long_array& theIds )
1301 CORBA::Long iEnd = theIds.length();
1302 for ( CORBA::Long i = 0; i < iEnd; i++ )
1303 myRangeOfIdsPtr->AddToRange( theIds[ i ] );
1304 TPythonDump()<<this<<".SetRange("<<theIds<<")";
1307 CORBA::Boolean RangeOfIds_i::SetRangeStr( const char* theRange )
1309 TPythonDump()<<this<<".SetRangeStr('"<<theRange<<"')";
1310 return myRangeOfIdsPtr->SetRangeStr(
1311 TCollection_AsciiString( (Standard_CString)theRange ) );
1314 char* RangeOfIds_i::GetRangeStr()
1316 TCollection_AsciiString aStr;
1317 myRangeOfIdsPtr->GetRangeStr( aStr );
1318 return CORBA::string_dup( aStr.ToCString() );
1321 void RangeOfIds_i::SetElementType( ElementType theType )
1323 myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) );
1324 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1327 FunctorType RangeOfIds_i::GetFunctorType()
1329 return SMESH::FT_RangeOfIds;
1333 Class : Comparator_i
1334 Description : Base class for comparators
1336 Comparator_i::Comparator_i():
1337 myNumericalFunctor( NULL )
1340 Comparator_i::~Comparator_i()
1342 if ( myNumericalFunctor )
1343 myNumericalFunctor->Destroy();
1346 void Comparator_i::SetMargin( CORBA::Double theValue )
1348 myComparatorPtr->SetMargin( theValue );
1349 TPythonDump()<<this<<".SetMargin("<<theValue<<")";
1352 CORBA::Double Comparator_i::GetMargin()
1354 return myComparatorPtr->GetMargin();
1357 void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
1359 if ( myNumericalFunctor )
1360 myNumericalFunctor->Destroy();
1362 myNumericalFunctor = DownCast<NumericalFunctor_i*>(theFunct);
1364 if ( myNumericalFunctor )
1366 myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() );
1367 myNumericalFunctor->Register();
1368 TPythonDump()<<this<<".SetNumFunctor("<<myNumericalFunctor<<")";
1372 Controls::ComparatorPtr Comparator_i::GetComparator()
1374 return myComparatorPtr;
1377 NumericalFunctor_i* Comparator_i::GetNumFunctor_i()
1379 return myNumericalFunctor;
1385 Description : Comparator "<"
1387 LessThan_i::LessThan_i()
1389 myComparatorPtr.reset( new Controls::LessThan() );
1390 myFunctorPtr = myPredicatePtr = myComparatorPtr;
1393 FunctorType LessThan_i::GetFunctorType()
1395 return SMESH::FT_LessThan;
1401 Description : Comparator ">"
1403 MoreThan_i::MoreThan_i()
1405 myComparatorPtr.reset( new Controls::MoreThan() );
1406 myFunctorPtr = myPredicatePtr = myComparatorPtr;
1409 FunctorType MoreThan_i::GetFunctorType()
1411 return SMESH::FT_MoreThan;
1417 Description : Comparator "="
1419 EqualTo_i::EqualTo_i()
1420 : myEqualToPtr( new Controls::EqualTo() )
1422 myFunctorPtr = myPredicatePtr = myComparatorPtr = myEqualToPtr;
1425 void EqualTo_i::SetTolerance( CORBA::Double theToler )
1427 myEqualToPtr->SetTolerance( theToler );
1428 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1431 CORBA::Double EqualTo_i::GetTolerance()
1433 return myEqualToPtr->GetTolerance();
1436 FunctorType EqualTo_i::GetFunctorType()
1438 return SMESH::FT_EqualTo;
1442 Class : LogicalNOT_i
1443 Description : Logical NOT predicate
1445 LogicalNOT_i::LogicalNOT_i()
1446 : myPredicate( NULL ),
1447 myLogicalNOTPtr( new Controls::LogicalNOT() )
1449 myFunctorPtr = myPredicatePtr = myLogicalNOTPtr;
1452 LogicalNOT_i::~LogicalNOT_i()
1455 myPredicate->Destroy();
1458 void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate )
1461 myPredicate->Destroy();
1463 myPredicate = SMESH::GetPredicate(thePredicate);
1466 myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate());
1467 myPredicate->Register();
1468 TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
1472 FunctorType LogicalNOT_i::GetFunctorType()
1474 return SMESH::FT_LogicalNOT;
1477 Predicate_i* LogicalNOT_i::GetPredicate_i()
1484 Class : LogicalBinary_i
1485 Description : Base class for binary logical predicate
1487 LogicalBinary_i::LogicalBinary_i()
1488 : myPredicate1( NULL ),
1489 myPredicate2( NULL )
1492 LogicalBinary_i::~LogicalBinary_i()
1495 myPredicate1->Destroy();
1498 myPredicate2->Destroy();
1501 void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh )
1504 myPredicate1->SetMesh( theMesh );
1507 myPredicate2->SetMesh( theMesh );
1510 void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate )
1513 myPredicate1->Destroy();
1515 myPredicate1 = SMESH::GetPredicate(thePredicate);
1517 if ( myPredicate1 ){
1518 myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate());
1519 myPredicate1->Register();
1520 TPythonDump()<<this<<".SetPredicate1("<<myPredicate1<<")";
1524 void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate )
1527 myPredicate2->Destroy();
1529 myPredicate2 = SMESH::GetPredicate(thePredicate);
1531 if ( myPredicate2 ){
1532 myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate());
1533 myPredicate2->Register();
1534 TPythonDump()<<this<<".SetPredicate2("<<myPredicate2<<")";
1538 Controls::LogicalBinaryPtr LogicalBinary_i::GetLogicalBinary()
1540 return myLogicalBinaryPtr;
1543 Predicate_i* LogicalBinary_i::GetPredicate1_i()
1545 return myPredicate1;
1547 Predicate_i* LogicalBinary_i::GetPredicate2_i()
1549 return myPredicate2;
1554 Class : LogicalAND_i
1555 Description : Logical AND
1557 LogicalAND_i::LogicalAND_i()
1559 myLogicalBinaryPtr.reset( new Controls::LogicalAND() );
1560 myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr;
1563 FunctorType LogicalAND_i::GetFunctorType()
1565 return SMESH::FT_LogicalAND;
1571 Description : Logical OR
1573 LogicalOR_i::LogicalOR_i()
1575 myLogicalBinaryPtr.reset( new Controls::LogicalOR() );
1576 myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr;
1579 FunctorType LogicalOR_i::GetFunctorType()
1581 return SMESH::FT_LogicalOR;
1589 FilterManager_i::FilterManager_i()
1590 : SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
1592 //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method
1593 //PortableServer::ObjectId_var anObjectId =
1594 // SMESH_Gen_i::GetPOA()->activate_object( this );
1598 FilterManager_i::~FilterManager_i()
1600 //TPythonDump()<<this<<".Destroy()";
1604 MinimumAngle_ptr FilterManager_i::CreateMinimumAngle()
1606 SMESH::MinimumAngle_i* aServant = new SMESH::MinimumAngle_i();
1607 SMESH::MinimumAngle_var anObj = aServant->_this();
1608 TPythonDump()<<aServant<<" = "<<this<<".CreateMinimumAngle()";
1609 return anObj._retn();
1613 AspectRatio_ptr FilterManager_i::CreateAspectRatio()
1615 SMESH::AspectRatio_i* aServant = new SMESH::AspectRatio_i();
1616 SMESH::AspectRatio_var anObj = aServant->_this();
1617 TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio()";
1618 return anObj._retn();
1622 AspectRatio3D_ptr FilterManager_i::CreateAspectRatio3D()
1624 SMESH::AspectRatio3D_i* aServant = new SMESH::AspectRatio3D_i();
1625 SMESH::AspectRatio3D_var anObj = aServant->_this();
1626 TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio3D()";
1627 return anObj._retn();
1631 Warping_ptr FilterManager_i::CreateWarping()
1633 SMESH::Warping_i* aServant = new SMESH::Warping_i();
1634 SMESH::Warping_var anObj = aServant->_this();
1635 TPythonDump()<<aServant<<" = "<<this<<".CreateWarping()";
1636 return anObj._retn();
1640 Taper_ptr FilterManager_i::CreateTaper()
1642 SMESH::Taper_i* aServant = new SMESH::Taper_i();
1643 SMESH::Taper_var anObj = aServant->_this();
1644 TPythonDump()<<aServant<<" = "<<this<<".CreateTaper()";
1645 return anObj._retn();
1649 Skew_ptr FilterManager_i::CreateSkew()
1651 SMESH::Skew_i* aServant = new SMESH::Skew_i();
1652 SMESH::Skew_var anObj = aServant->_this();
1653 TPythonDump()<<aServant<<" = "<<this<<".CreateSkew()";
1654 return anObj._retn();
1658 Area_ptr FilterManager_i::CreateArea()
1660 SMESH::Area_i* aServant = new SMESH::Area_i();
1661 SMESH::Area_var anObj = aServant->_this();
1662 TPythonDump()<<aServant<<" = "<<this<<".CreateArea()";
1663 return anObj._retn();
1667 Volume3D_ptr FilterManager_i::CreateVolume3D()
1669 SMESH::Volume3D_i* aServant = new SMESH::Volume3D_i();
1670 SMESH::Volume3D_var anObj = aServant->_this();
1671 TPythonDump()<<aServant<<" = "<<this<<".CreateVolume3D()";
1672 return anObj._retn();
1676 Length_ptr FilterManager_i::CreateLength()
1678 SMESH::Length_i* aServant = new SMESH::Length_i();
1679 SMESH::Length_var anObj = aServant->_this();
1680 TPythonDump()<<aServant<<" = "<<this<<".CreateLength()";
1681 return anObj._retn();
1684 Length2D_ptr FilterManager_i::CreateLength2D()
1686 SMESH::Length2D_i* aServant = new SMESH::Length2D_i();
1687 SMESH::Length2D_var anObj = aServant->_this();
1688 TPythonDump()<<aServant<<" = "<<this<<".CreateLength2D()";
1689 return anObj._retn();
1692 MultiConnection_ptr FilterManager_i::CreateMultiConnection()
1694 SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i();
1695 SMESH::MultiConnection_var anObj = aServant->_this();
1696 TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection()";
1697 return anObj._retn();
1700 MultiConnection2D_ptr FilterManager_i::CreateMultiConnection2D()
1702 SMESH::MultiConnection2D_i* aServant = new SMESH::MultiConnection2D_i();
1703 SMESH::MultiConnection2D_var anObj = aServant->_this();
1704 TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection2D()";
1705 return anObj._retn();
1708 BelongToGeom_ptr FilterManager_i::CreateBelongToGeom()
1710 SMESH::BelongToGeom_i* aServant = new SMESH::BelongToGeom_i();
1711 SMESH::BelongToGeom_var anObj = aServant->_this();
1712 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGeom()";
1713 return anObj._retn();
1716 BelongToPlane_ptr FilterManager_i::CreateBelongToPlane()
1718 SMESH::BelongToPlane_i* aServant = new SMESH::BelongToPlane_i();
1719 SMESH::BelongToPlane_var anObj = aServant->_this();
1720 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToPlane()";
1721 return anObj._retn();
1724 BelongToCylinder_ptr FilterManager_i::CreateBelongToCylinder()
1726 SMESH::BelongToCylinder_i* aServant = new SMESH::BelongToCylinder_i();
1727 SMESH::BelongToCylinder_var anObj = aServant->_this();
1728 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToCylinder()";
1729 return anObj._retn();
1732 BelongToGenSurface_ptr FilterManager_i::CreateBelongToGenSurface()
1734 SMESH::BelongToGenSurface_i* aServant = new SMESH::BelongToGenSurface_i();
1735 SMESH::BelongToGenSurface_var anObj = aServant->_this();
1736 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGenSurface()";
1737 return anObj._retn();
1740 LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
1742 SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
1743 SMESH::LyingOnGeom_var anObj = aServant->_this();
1744 TPythonDump()<<aServant<<" = "<<this<<".CreateLyingOnGeom()";
1745 return anObj._retn();
1748 FreeBorders_ptr FilterManager_i::CreateFreeBorders()
1750 SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
1751 SMESH::FreeBorders_var anObj = aServant->_this();
1752 TPythonDump()<<aServant<<" = "<<this<<".CreateFreeBorders()";
1753 return anObj._retn();
1756 FreeEdges_ptr FilterManager_i::CreateFreeEdges()
1758 SMESH::FreeEdges_i* aServant = new SMESH::FreeEdges_i();
1759 SMESH::FreeEdges_var anObj = aServant->_this();
1760 TPythonDump()<<aServant<<" = "<<this<<".CreateFreeEdges()";
1761 return anObj._retn();
1764 RangeOfIds_ptr FilterManager_i::CreateRangeOfIds()
1766 SMESH::RangeOfIds_i* aServant = new SMESH::RangeOfIds_i();
1767 SMESH::RangeOfIds_var anObj = aServant->_this();
1768 TPythonDump()<<aServant<<" = "<<this<<".CreateRangeOfIds()";
1769 return anObj._retn();
1772 BadOrientedVolume_ptr FilterManager_i::CreateBadOrientedVolume()
1774 SMESH::BadOrientedVolume_i* aServant = new SMESH::BadOrientedVolume_i();
1775 SMESH::BadOrientedVolume_var anObj = aServant->_this();
1776 TPythonDump()<<aServant<<" = "<<this<<".CreateBadOrientedVolume()";
1777 return anObj._retn();
1780 LessThan_ptr FilterManager_i::CreateLessThan()
1782 SMESH::LessThan_i* aServant = new SMESH::LessThan_i();
1783 SMESH::LessThan_var anObj = aServant->_this();
1784 TPythonDump()<<aServant<<" = "<<this<<".CreateLessThan()";
1785 return anObj._retn();
1789 MoreThan_ptr FilterManager_i::CreateMoreThan()
1791 SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
1792 SMESH::MoreThan_var anObj = aServant->_this();
1793 TPythonDump()<<aServant<<" = "<<this<<".CreateMoreThan()";
1794 return anObj._retn();
1797 EqualTo_ptr FilterManager_i::CreateEqualTo()
1799 SMESH::EqualTo_i* aServant = new SMESH::EqualTo_i();
1800 SMESH::EqualTo_var anObj = aServant->_this();
1801 TPythonDump()<<aServant<<" = "<<this<<".CreateEqualTo()";
1802 return anObj._retn();
1806 LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
1808 SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i();
1809 SMESH::LogicalNOT_var anObj = aServant->_this();
1810 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalNOT()";
1811 return anObj._retn();
1815 LogicalAND_ptr FilterManager_i::CreateLogicalAND()
1817 SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i();
1818 SMESH::LogicalAND_var anObj = aServant->_this();
1819 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalAND()";
1820 return anObj._retn();
1824 LogicalOR_ptr FilterManager_i::CreateLogicalOR()
1826 SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i();
1827 SMESH::LogicalOR_var anObj = aServant->_this();
1828 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalOR()";
1829 return anObj._retn();
1832 Filter_ptr FilterManager_i::CreateFilter()
1834 SMESH::Filter_i* aServant = new SMESH::Filter_i();
1835 SMESH::Filter_var anObj = aServant->_this();
1836 TPythonDump()<<aServant<<" = "<<this<<".CreateFilter()";
1837 return anObj._retn();
1840 FilterLibrary_ptr FilterManager_i::LoadLibrary( const char* aFileName )
1842 SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i( aFileName );
1843 SMESH::FilterLibrary_var anObj = aServant->_this();
1844 TPythonDump()<<aServant<<" = "<<this<<".LoadLibrary("<<aFileName<<")";
1845 return anObj._retn();
1848 FilterLibrary_ptr FilterManager_i::CreateLibrary()
1850 SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i();
1851 SMESH::FilterLibrary_var anObj = aServant->_this();
1852 TPythonDump()<<aServant<<" = "<<this<<".CreateLibrary()";
1853 return anObj._retn();
1856 CORBA::Boolean FilterManager_i::DeleteLibrary( const char* aFileName )
1858 TPythonDump()<<this<<".DeleteLibrary("<<aFileName<<")";
1859 return remove( aFileName ) ? false : true;
1862 //=============================================================================
1864 * SMESH_Gen_i::CreateFilterManager
1866 * Create filter manager
1868 //=============================================================================
1870 SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager()
1872 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
1873 SMESH::FilterManager_var anObj = aFilter->_this();
1874 return anObj._retn();
1882 //=======================================================================
1883 // name : Filter_i::Filter_i
1884 // Purpose : Constructor
1885 //=======================================================================
1886 Filter_i::Filter_i()
1887 : myPredicate( NULL )
1890 //=======================================================================
1891 // name : Filter_i::~Filter_i
1892 // Purpose : Destructor
1893 //=======================================================================
1894 Filter_i::~Filter_i()
1897 myPredicate->Destroy();
1899 if(!CORBA::is_nil(myMesh))
1902 //TPythonDump()<<this<<".Destroy()";
1905 //=======================================================================
1906 // name : Filter_i::SetPredicate
1907 // Purpose : Set predicate
1908 //=======================================================================
1909 void Filter_i::SetPredicate( Predicate_ptr thePredicate )
1912 myPredicate->Destroy();
1914 myPredicate = SMESH::GetPredicate(thePredicate);
1918 myFilter.SetPredicate( myPredicate->GetPredicate() );
1919 myPredicate->Register();
1920 TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
1924 //=======================================================================
1925 // name : Filter_i::GetElementType
1926 // Purpose : Get entity type
1927 //=======================================================================
1928 SMESH::ElementType Filter_i::GetElementType()
1930 return myPredicate != 0 ? myPredicate->GetElementType() : SMESH::ALL;
1933 //=======================================================================
1934 // name : Filter_i::SetMesh
1935 // Purpose : Set mesh
1936 //=======================================================================
1939 SetMesh( SMESH_Mesh_ptr theMesh )
1941 if(!CORBA::is_nil(theMesh))
1942 theMesh->Register();
1944 if(!CORBA::is_nil(myMesh))
1948 TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
1955 return GetElementsId(myMesh);
1958 //=======================================================================
1959 // name : Filter_i::GetElementsId
1960 // Purpose : Get ids of entities
1961 //=======================================================================
1964 GetElementsId( Predicate_i* thePredicate,
1965 const SMDS_Mesh* theMesh,
1966 Controls::Filter::TIdSequence& theSequence )
1969 Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
1974 GetElementsId( Predicate_i* thePredicate,
1975 SMESH_Mesh_ptr theMesh,
1976 Controls::Filter::TIdSequence& theSequence )
1979 if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
1980 Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
1985 GetElementsId( SMESH_Mesh_ptr theMesh )
1987 SMESH::long_array_var anArray = new SMESH::long_array;
1988 if(!CORBA::is_nil(theMesh) && myPredicate){
1989 Controls::Filter::TIdSequence aSequence;
1990 GetElementsId(myPredicate,theMesh,aSequence);
1991 long i = 0, iEnd = aSequence.size();
1992 anArray->length( iEnd );
1993 for ( ; i < iEnd; i++ )
1994 anArray[ i ] = aSequence[i];
1996 return anArray._retn();
1999 //=======================================================================
2000 // name : getCriteria
2001 // Purpose : Retrieve criterions from predicate
2002 //=======================================================================
2003 static inline bool getCriteria( Predicate_i* thePred,
2004 SMESH::Filter::Criteria_out theCriteria )
2006 int aFType = thePred->GetFunctorType();
2010 case FT_FreeBorders:
2013 CORBA::ULong i = theCriteria->length();
2014 theCriteria->length( i + 1 );
2016 theCriteria[ i ] = createCriterion();
2018 theCriteria[ i ].Type = aFType;
2019 theCriteria[ i ].TypeOfElement = thePred->GetElementType();
2022 case FT_BelongToGeom:
2024 BelongToGeom_i* aPred = dynamic_cast<BelongToGeom_i*>( thePred );
2026 CORBA::ULong i = theCriteria->length();
2027 theCriteria->length( i + 1 );
2029 theCriteria[ i ] = createCriterion();
2031 theCriteria[ i ].Type = FT_BelongToGeom;
2032 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2033 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2034 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2038 case FT_BelongToPlane:
2039 case FT_BelongToCylinder:
2040 case FT_BelongToGenSurface:
2042 BelongToSurface_i* aPred = dynamic_cast<BelongToSurface_i*>( thePred );
2044 CORBA::ULong i = theCriteria->length();
2045 theCriteria->length( i + 1 );
2047 theCriteria[ i ] = createCriterion();
2049 theCriteria[ i ].Type = aFType;
2050 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2051 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2052 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2053 theCriteria[ i ].Tolerance = aPred->GetTolerance();
2057 case FT_LyingOnGeom:
2059 LyingOnGeom_i* aPred = dynamic_cast<LyingOnGeom_i*>( thePred );
2061 CORBA::ULong i = theCriteria->length();
2062 theCriteria->length( i + 1 );
2064 theCriteria[ i ] = createCriterion();
2066 theCriteria[ i ].Type = FT_LyingOnGeom;
2067 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2068 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2069 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2075 RangeOfIds_i* aPred = dynamic_cast<RangeOfIds_i*>( thePred );
2077 CORBA::ULong i = theCriteria->length();
2078 theCriteria->length( i + 1 );
2080 theCriteria[ i ] = createCriterion();
2082 theCriteria[ i ].Type = FT_RangeOfIds;
2083 theCriteria[ i ].ThresholdStr = aPred->GetRangeStr();
2084 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2088 case FT_BadOrientedVolume:
2090 BadOrientedVolume_i* aPred = dynamic_cast<BadOrientedVolume_i*>( thePred );
2092 CORBA::ULong i = theCriteria->length();
2093 theCriteria->length( i + 1 );
2095 theCriteria[ i ] = createCriterion();
2097 theCriteria[ i ].Type = FT_BadOrientedVolume;
2098 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2106 Comparator_i* aCompar = dynamic_cast<Comparator_i*>( thePred );
2108 CORBA::ULong i = theCriteria->length();
2109 theCriteria->length( i + 1 );
2111 theCriteria[ i ] = createCriterion();
2113 theCriteria[ i ].Type = aCompar->GetNumFunctor_i()->GetFunctorType();
2114 theCriteria[ i ].Compare = aFType;
2115 theCriteria[ i ].Threshold = aCompar->GetMargin();
2116 theCriteria[ i ].TypeOfElement = aCompar->GetElementType();
2118 if ( aFType == FT_EqualTo )
2120 EqualTo_i* aCompar = dynamic_cast<EqualTo_i*>( thePred );
2121 theCriteria[ i ].Tolerance = aCompar->GetTolerance();
2128 Predicate_i* aPred = ( dynamic_cast<LogicalNOT_i*>( thePred ) )->GetPredicate_i();
2129 getCriteria( aPred, theCriteria );
2130 theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT;
2137 Predicate_i* aPred1 = ( dynamic_cast<LogicalBinary_i*>( thePred ) )->GetPredicate1_i();
2138 Predicate_i* aPred2 = ( dynamic_cast<LogicalBinary_i*>( thePred ) )->GetPredicate2_i();
2139 if ( !getCriteria( aPred1, theCriteria ) )
2141 theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType;
2142 return getCriteria( aPred2, theCriteria );
2152 //=======================================================================
2153 // name : Filter_i::GetCriteria
2154 // Purpose : Retrieve criterions from predicate
2155 //=======================================================================
2156 CORBA::Boolean Filter_i::GetCriteria( SMESH::Filter::Criteria_out theCriteria )
2158 theCriteria = new SMESH::Filter::Criteria;
2159 return myPredicate != 0 ? getCriteria( myPredicate, theCriteria ) : true;
2162 //=======================================================================
2163 // name : Filter_i::SetCriteria
2164 // Purpose : Create new predicate and set criterions in it
2165 //=======================================================================
2166 CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria )
2168 if ( myPredicate != 0 )
2169 myPredicate->Destroy();
2171 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
2172 FilterManager_ptr aFilterMgr = aFilter->_this();
2174 // CREATE two lists ( PREDICATES and LOG OP )
2177 TPythonDump()<<"aCriteria = []";
2178 std::list<SMESH::Predicate_ptr> aPredicates;
2179 std::list<int> aBinaries;
2180 for ( int i = 0, n = theCriteria.length(); i < n; i++ )
2182 int aCriterion = theCriteria[ i ].Type;
2183 int aCompare = theCriteria[ i ].Compare;
2184 double aThreshold = theCriteria[ i ].Threshold;
2185 const char* aThresholdStr = theCriteria[ i ].ThresholdStr;
2186 const char* aThresholdID = theCriteria[ i ].ThresholdID;
2187 int aUnary = theCriteria[ i ].UnaryOp;
2188 int aBinary = theCriteria[ i ].BinaryOp;
2189 double aTolerance = theCriteria[ i ].Tolerance;
2190 ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement;
2191 long aPrecision = theCriteria[ i ].Precision;
2195 pd << "aCriterion = SMESH.Filter.Criterion(" << aCriterion << "," << aCompare
2196 << "," << aThreshold << ",'" << aThresholdStr;
2198 pd << "',salome.ObjectToID(" << aThresholdID
2199 << ")," << aUnary << "," << aBinary << "," << aTolerance
2200 << "," << aTypeOfElem << "," << aPrecision << ")";
2202 pd << "',''," << aUnary << "," << aBinary << "," << aTolerance
2203 << "," << aTypeOfElem << "," << aPrecision << ")";
2206 SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil();
2207 SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil();
2209 switch ( aCriterion )
2213 case SMESH::FT_MultiConnection:
2214 aFunctor = aFilterMgr->CreateMultiConnection();
2216 case SMESH::FT_MultiConnection2D:
2217 aFunctor = aFilterMgr->CreateMultiConnection2D();
2219 case SMESH::FT_Length:
2220 aFunctor = aFilterMgr->CreateLength();
2222 case SMESH::FT_Length2D:
2223 aFunctor = aFilterMgr->CreateLength2D();
2225 case SMESH::FT_AspectRatio:
2226 aFunctor = aFilterMgr->CreateAspectRatio();
2228 case SMESH::FT_AspectRatio3D:
2229 aFunctor = aFilterMgr->CreateAspectRatio3D();
2231 case SMESH::FT_Warping:
2232 aFunctor = aFilterMgr->CreateWarping();
2234 case SMESH::FT_MinimumAngle:
2235 aFunctor = aFilterMgr->CreateMinimumAngle();
2237 case SMESH::FT_Taper:
2238 aFunctor = aFilterMgr->CreateTaper();
2240 case SMESH::FT_Skew:
2241 aFunctor = aFilterMgr->CreateSkew();
2243 case SMESH::FT_Area:
2244 aFunctor = aFilterMgr->CreateArea();
2246 case SMESH::FT_Volume3D:
2247 aFunctor = aFilterMgr->CreateVolume3D();
2252 case SMESH::FT_FreeBorders:
2253 aPredicate = aFilterMgr->CreateFreeBorders();
2255 case SMESH::FT_FreeEdges:
2256 aPredicate = aFilterMgr->CreateFreeEdges();
2258 case SMESH::FT_BelongToGeom:
2260 SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom();
2261 tmpPred->SetElementType( aTypeOfElem );
2262 tmpPred->SetShape( aThresholdID, aThresholdStr );
2263 aPredicate = tmpPred;
2266 case SMESH::FT_BelongToPlane:
2267 case SMESH::FT_BelongToCylinder:
2268 case SMESH::FT_BelongToGenSurface:
2270 SMESH::BelongToSurface_ptr tmpPred;
2271 switch ( aCriterion ) {
2272 case SMESH::FT_BelongToPlane:
2273 tmpPred = aFilterMgr->CreateBelongToPlane(); break;
2274 case SMESH::FT_BelongToCylinder:
2275 tmpPred = aFilterMgr->CreateBelongToCylinder(); break;
2277 tmpPred = aFilterMgr->CreateBelongToGenSurface();
2279 tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem );
2280 tmpPred->SetTolerance( aTolerance );
2281 aPredicate = tmpPred;
2284 case SMESH::FT_LyingOnGeom:
2286 SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
2287 tmpPred->SetElementType( aTypeOfElem );
2288 tmpPred->SetShape( aThresholdID, aThresholdStr );
2289 aPredicate = tmpPred;
2292 case SMESH::FT_RangeOfIds:
2294 SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds();
2295 tmpPred->SetRangeStr( aThresholdStr );
2296 tmpPred->SetElementType( aTypeOfElem );
2297 aPredicate = tmpPred;
2300 case SMESH::FT_BadOrientedVolume:
2302 aPredicate = aFilterMgr->CreateBadOrientedVolume();
2311 if ( !aFunctor->_is_nil() && aPredicate->_is_nil() )
2313 SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil();
2315 if ( aCompare == SMESH::FT_LessThan )
2316 aComparator = aFilterMgr->CreateLessThan();
2317 else if ( aCompare == SMESH::FT_MoreThan )
2318 aComparator = aFilterMgr->CreateMoreThan();
2319 else if ( aCompare == SMESH::FT_EqualTo )
2320 aComparator = aFilterMgr->CreateEqualTo();
2324 aComparator->SetNumFunctor( aFunctor );
2325 aComparator->SetMargin( aThreshold );
2327 if ( aCompare == FT_EqualTo )
2329 SMESH::EqualTo_var anEqualTo = SMESH::EqualTo::_narrow( aComparator );
2330 anEqualTo->SetTolerance( aTolerance );
2333 aPredicate = aComparator;
2335 aFunctor->SetPrecision( aPrecision );
2339 if ( aUnary == FT_LogicalNOT )
2341 SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT();
2342 aNotPred->SetPredicate( aPredicate );
2343 aPredicate = aNotPred;
2347 aPredicates.push_back( aPredicate );
2348 aBinaries.push_back( aBinary );
2349 TPythonDump()<<"aCriteria.append(aCriterion)";
2352 TPythonDump()<<this<<".SetCriteria(aCriteria)";
2354 // CREATE ONE PREDICATE FROM PREVIOUSLY CREATED MAP
2356 // combine all "AND" operations
2358 std::list<SMESH::Predicate_ptr> aResList;
2360 std::list<SMESH::Predicate_ptr>::iterator aPredIter;
2361 std::list<int>::iterator aBinaryIter;
2363 SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil();
2364 int aPrevBinary = SMESH::FT_Undefined;
2366 for ( aPredIter = aPredicates.begin(), aBinaryIter = aBinaries.begin();
2367 aPredIter != aPredicates.end() && aBinaryIter != aBinaries.end();
2368 ++aPredIter, ++aBinaryIter )
2370 int aCurrBinary = *aBinaryIter;
2372 SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil();
2374 if ( aPrevBinary == SMESH::FT_LogicalAND )
2377 SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND();
2378 aBinaryPred->SetPredicate1( aPrevPredicate );
2379 aBinaryPred->SetPredicate2( *aPredIter );
2380 aCurrPred = aBinaryPred;
2383 aCurrPred = *aPredIter;
2385 if ( aCurrBinary != SMESH::FT_LogicalAND )
2386 aResList.push_back( aCurrPred );
2388 aPrevPredicate = aCurrPred;
2389 aPrevBinary = aCurrBinary;
2392 // combine all "OR" operations
2394 SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil();
2396 if ( aResList.size() == 1 )
2397 aResPredicate = *aResList.begin();
2398 else if ( aResList.size() > 1 )
2400 std::list<SMESH::Predicate_ptr>::iterator anIter = aResList.begin();
2401 aResPredicate = *anIter;
2403 for ( ; anIter != aResList.end(); ++anIter )
2405 SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR();
2406 aBinaryPred->SetPredicate1( aResPredicate );
2407 aBinaryPred->SetPredicate2( *anIter );
2408 aResPredicate = aBinaryPred;
2412 SetPredicate( aResPredicate );
2414 return !aResPredicate->_is_nil();
2417 //=======================================================================
2418 // name : Filter_i::GetPredicate_i
2419 // Purpose : Get implementation of predicate
2420 //=======================================================================
2421 Predicate_i* Filter_i::GetPredicate_i()
2426 //=======================================================================
2427 // name : Filter_i::GetPredicate
2428 // Purpose : Get predicate
2429 //=======================================================================
2430 Predicate_ptr Filter_i::GetPredicate()
2432 if ( myPredicate == 0 )
2433 return SMESH::Predicate::_nil();
2436 SMESH::Predicate_var anObj = myPredicate->_this();
2437 return anObj._retn();
2445 #define ATTR_TYPE "type"
2446 #define ATTR_COMPARE "compare"
2447 #define ATTR_THRESHOLD "threshold"
2448 #define ATTR_UNARY "unary"
2449 #define ATTR_BINARY "binary"
2450 #define ATTR_THRESHOLD_STR "threshold_str"
2451 #define ATTR_TOLERANCE "tolerance"
2452 #define ATTR_ELEMENT_TYPE "ElementType"
2454 //=======================================================================
2456 // Purpose : Convert bool to LDOMString
2457 //=======================================================================
2458 static inline LDOMString toString( CORBA::Boolean val )
2460 return val ? "logical not" : "";
2463 //=======================================================================
2465 // Purpose : Convert LDOMString to bool
2466 //=======================================================================
2467 static inline bool toBool( const LDOMString& theStr )
2469 return theStr.equals( "logical not" );
2472 //=======================================================================
2474 // Purpose : Convert double to LDOMString
2475 //=======================================================================
2476 static inline LDOMString toString( CORBA::Double val )
2479 sprintf( a, "%e", val );
2480 return LDOMString( a );
2483 //=======================================================================
2485 // Purpose : Convert LDOMString to double
2486 //=======================================================================
2487 static inline double toDouble( const LDOMString& theStr )
2489 return atof( theStr.GetString() );
2492 //=======================================================================
2494 // Purpose : Convert functor type to LDOMString
2495 //=======================================================================
2496 static inline LDOMString toString( CORBA::Long theType )
2500 case FT_AspectRatio : return "Aspect ratio";
2501 case FT_Warping : return "Warping";
2502 case FT_MinimumAngle : return "Minimum angle";
2503 case FT_Taper : return "Taper";
2504 case FT_Skew : return "Skew";
2505 case FT_Area : return "Area";
2506 case FT_Volume3D : return "Volume3D";
2507 case FT_BelongToGeom : return "Belong to Geom";
2508 case FT_BelongToPlane : return "Belong to Plane";
2509 case FT_BelongToCylinder: return "Belong to Cylinder";
2510 case FT_BelongToGenSurface: return "Belong to Generic Surface";
2511 case FT_LyingOnGeom : return "Lying on Geom";
2512 case FT_BadOrientedVolume: return "Bad Oriented Volume";
2513 case FT_RangeOfIds : return "Range of IDs";
2514 case FT_FreeBorders : return "Free borders";
2515 case FT_FreeEdges : return "Free edges";
2516 case FT_MultiConnection : return "Borders at multi-connections";
2517 case FT_MultiConnection2D: return "Borders at multi-connections 2D";
2518 case FT_Length : return "Length";
2519 case FT_Length2D : return "Length2D";
2520 case FT_LessThan : return "Less than";
2521 case FT_MoreThan : return "More than";
2522 case FT_EqualTo : return "Equal to";
2523 case FT_LogicalNOT : return "Not";
2524 case FT_LogicalAND : return "And";
2525 case FT_LogicalOR : return "Or";
2526 case FT_Undefined : return "";
2527 default : return "";
2531 //=======================================================================
2532 // name : toFunctorType
2533 // Purpose : Convert LDOMString to functor type
2534 //=======================================================================
2535 static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
2537 if ( theStr.equals( "Aspect ratio" ) ) return FT_AspectRatio;
2538 else if ( theStr.equals( "Warping" ) ) return FT_Warping;
2539 else if ( theStr.equals( "Minimum angle" ) ) return FT_MinimumAngle;
2540 else if ( theStr.equals( "Taper" ) ) return FT_Taper;
2541 else if ( theStr.equals( "Skew" ) ) return FT_Skew;
2542 else if ( theStr.equals( "Area" ) ) return FT_Area;
2543 else if ( theStr.equals( "Volume3D" ) ) return FT_Volume3D;
2544 else if ( theStr.equals( "Belong to Geom" ) ) return FT_BelongToGeom;
2545 else if ( theStr.equals( "Belong to Plane" ) ) return FT_BelongToPlane;
2546 else if ( theStr.equals( "Belong to Cylinder" ) ) return FT_BelongToCylinder;
2547 else if ( theStr.equals( "Belong to Generic Surface" ) ) return FT_BelongToGenSurface;
2548 else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom;
2549 else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders;
2550 else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges;
2551 else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection;
2552 // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
2553 else if ( theStr.equals( "Length" ) ) return FT_Length;
2554 // else if ( theStr.equals( "Length2D" ) ) return FT_Length2D;
2555 else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds;
2556 else if ( theStr.equals( "Bad Oriented Volume" ) ) return FT_BadOrientedVolume;
2557 else if ( theStr.equals( "Less than" ) ) return FT_LessThan;
2558 else if ( theStr.equals( "More than" ) ) return FT_MoreThan;
2559 else if ( theStr.equals( "Equal to" ) ) return FT_EqualTo;
2560 else if ( theStr.equals( "Not" ) ) return FT_LogicalNOT;
2561 else if ( theStr.equals( "And" ) ) return FT_LogicalAND;
2562 else if ( theStr.equals( "Or" ) ) return FT_LogicalOR;
2563 else if ( theStr.equals( "" ) ) return FT_Undefined;
2564 else return FT_Undefined;
2567 //=======================================================================
2568 // name : toFunctorType
2569 // Purpose : Convert LDOMString to value of ElementType enumeration
2570 //=======================================================================
2571 static inline SMESH::ElementType toElementType( const LDOMString& theStr )
2573 if ( theStr.equals( "NODE" ) ) return SMESH::NODE;
2574 else if ( theStr.equals( "EDGE" ) ) return SMESH::EDGE;
2575 else if ( theStr.equals( "FACE" ) ) return SMESH::FACE;
2576 else if ( theStr.equals( "VOLUME" ) ) return SMESH::VOLUME;
2577 else return SMESH::ALL;
2580 //=======================================================================
2582 // Purpose : Convert ElementType to string
2583 //=======================================================================
2584 static inline LDOMString toString( const SMESH::ElementType theType )
2588 case SMESH::NODE : return "NODE";
2589 case SMESH::EDGE : return "EDGE";
2590 case SMESH::FACE : return "FACE";
2591 case SMESH::VOLUME : return "VOLUME";
2592 case SMESH::ALL : return "ALL";
2593 default : return "";
2597 //=======================================================================
2598 // name : findFilter
2599 // Purpose : Find filter in document
2600 //=======================================================================
2601 static LDOM_Element findFilter( const char* theFilterName,
2602 const LDOM_Document& theDoc,
2603 LDOM_Node* theParent = 0 )
2605 LDOM_Element aRootElement = theDoc.getDocumentElement();
2606 if ( aRootElement.isNull() || !aRootElement.hasChildNodes() )
2607 return LDOM_Element();
2609 for ( LDOM_Node aTypeNode = aRootElement.getFirstChild();
2610 !aTypeNode.isNull(); aTypeNode = aTypeNode.getNextSibling() )
2612 for ( LDOM_Node aFilter = aTypeNode.getFirstChild();
2613 !aFilter.isNull(); aFilter = aFilter.getNextSibling() )
2615 LDOM_Element* anElem = ( LDOM_Element* )&aFilter;
2616 if ( anElem->getTagName().equals( LDOMString( "filter" ) ) &&
2617 anElem->getAttribute( "name" ).equals( LDOMString( theFilterName ) ) )
2619 if ( theParent != 0 )
2620 *theParent = aTypeNode;
2621 return (LDOM_Element&)aFilter;
2625 return LDOM_Element();
2628 //=======================================================================
2629 // name : getSectionName
2630 // Purpose : Get name of section of filters
2631 //=======================================================================
2632 static const char* getSectionName( const ElementType theType )
2636 case SMESH::NODE : return "Filters for nodes";
2637 case SMESH::EDGE : return "Filters for edges";
2638 case SMESH::FACE : return "Filters for faces";
2639 case SMESH::VOLUME : return "Filters for volumes";
2640 case SMESH::ALL : return "Filters for elements";
2641 default : return "";
2645 //=======================================================================
2646 // name : getSection
2647 // Purpose : Create section for filters corresponding to the entity type
2648 //=======================================================================
2649 static LDOM_Node getSection( const ElementType theType,
2650 LDOM_Document& theDoc,
2651 const bool toCreate = false )
2653 LDOM_Element aRootElement = theDoc.getDocumentElement();
2654 if ( aRootElement.isNull() )
2658 bool anExist = false;
2659 const char* aSectionName = getSectionName( theType );
2660 if ( strcmp( aSectionName, "" ) == 0 )
2663 LDOM_NodeList aSections = theDoc.getElementsByTagName( "section" );
2665 for ( int i = 0, n = aSections.getLength(); i < n; i++ )
2667 aNode = aSections.item( i );
2668 LDOM_Element& anItem = ( LDOM_Element& )aNode;
2669 if ( anItem.getAttribute( "name" ).equals( LDOMString( aSectionName ) ) )
2676 // Create new section if necessary
2681 LDOM_Element aNewItem = theDoc.createElement( "section" );
2682 aNewItem.setAttribute( "name", aSectionName );
2683 aRootElement.appendChild( aNewItem );
2693 //=======================================================================
2694 // name : createFilterItem
2695 // Purpose : Create filter item or LDOM document
2696 //=======================================================================
2697 static LDOM_Element createFilterItem( const char* theName,
2698 SMESH::Filter_ptr theFilter,
2699 LDOM_Document& theDoc )
2701 // create new filter in document
2702 LDOM_Element aFilterItem = theDoc.createElement( "filter" );
2703 aFilterItem.setAttribute( "name", theName );
2705 // save filter criterions
2706 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
2708 if ( !theFilter->GetCriteria( aCriteria ) )
2709 return LDOM_Element();
2711 for ( CORBA::ULong i = 0, n = aCriteria->length(); i < n; i++ )
2713 LDOM_Element aCriterionItem = theDoc.createElement( "criterion" );
2715 aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type) );
2716 aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) );
2717 aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) );
2718 aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) );
2719 aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) );
2721 aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr );
2722 aCriterionItem.setAttribute( ATTR_TOLERANCE , toString( aCriteria[ i ].Tolerance ) );
2723 aCriterionItem.setAttribute( ATTR_ELEMENT_TYPE ,
2724 toString( (SMESH::ElementType)aCriteria[ i ].TypeOfElement ) );
2726 aFilterItem.appendChild( aCriterionItem );
2732 //=======================================================================
2733 // name : FilterLibrary_i::FilterLibrary_i
2734 // Purpose : Constructor
2735 //=======================================================================
2736 FilterLibrary_i::FilterLibrary_i( const char* theFileName )
2738 myFileName = strdup( theFileName );
2739 SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i();
2740 myFilterMgr = aFilterMgr->_this();
2744 // Try to use existing library file
2745 bool anExists = false;
2746 if ( !aParser.parse( myFileName ) )
2748 myDoc = aParser.getDocument();
2751 // Create a new XML document if it doesn't exist
2753 myDoc = LDOM_Document::createDocument( LDOMString() );
2755 LDOM_Element aRootElement = myDoc.getDocumentElement();
2756 if ( aRootElement.isNull() )
2758 // If the existing document is empty --> try to create a new one
2760 myDoc = LDOM_Document::createDocument( LDOMString() );
2764 //=======================================================================
2765 // name : FilterLibrary_i::FilterLibrary_i
2766 // Purpose : Constructor
2767 //=======================================================================
2768 FilterLibrary_i::FilterLibrary_i()
2771 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
2772 myFilterMgr = aFilter->_this();
2774 myDoc = LDOM_Document::createDocument( LDOMString() );
2777 FilterLibrary_i::~FilterLibrary_i()
2780 //TPythonDump()<<this<<".Destroy()";
2783 //=======================================================================
2784 // name : FilterLibrary_i::Copy
2785 // Purpose : Create filter and initialize it with values from library
2786 //=======================================================================
2787 Filter_ptr FilterLibrary_i::Copy( const char* theFilterName )
2789 Filter_ptr aRes = Filter::_nil();
2790 LDOM_Node aFilter = findFilter( theFilterName, myDoc );
2792 if ( aFilter.isNull() )
2795 std::list<SMESH::Filter::Criterion> aCriteria;
2797 for ( LDOM_Node aCritNode = aFilter.getFirstChild();
2798 !aCritNode.isNull() ; aCritNode = aCritNode.getNextSibling() )
2800 LDOM_Element* aCrit = (LDOM_Element*)&aCritNode;
2802 const char* aTypeStr = aCrit->getAttribute( ATTR_TYPE ).GetString();
2803 const char* aCompareStr = aCrit->getAttribute( ATTR_COMPARE ).GetString();
2804 const char* aUnaryStr = aCrit->getAttribute( ATTR_UNARY ).GetString();
2805 const char* aBinaryStr = aCrit->getAttribute( ATTR_BINARY ).GetString();
2806 const char* anElemTypeStr = aCrit->getAttribute( ATTR_ELEMENT_TYPE ).GetString();
2808 SMESH::Filter::Criterion aCriterion = createCriterion();
2810 aCriterion.Type = toFunctorType( aTypeStr );
2811 aCriterion.Compare = toFunctorType( aCompareStr );
2812 aCriterion.UnaryOp = toFunctorType( aUnaryStr );
2813 aCriterion.BinaryOp = toFunctorType( aBinaryStr );
2815 aCriterion.TypeOfElement = toElementType( anElemTypeStr );
2817 LDOMString str = aCrit->getAttribute( ATTR_THRESHOLD );
2819 aCriterion.Threshold = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val )
2820 ? val : atof( str.GetString() );
2822 str = aCrit->getAttribute( ATTR_TOLERANCE );
2823 aCriterion.Tolerance = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val )
2824 ? val : atof( str.GetString() );
2826 str = aCrit->getAttribute( ATTR_THRESHOLD_STR );
2827 if ( str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) )
2830 sprintf( a, "%d", val );
2831 aCriterion.ThresholdStr = strdup( a );
2834 aCriterion.ThresholdStr = str.GetString();
2836 aCriteria.push_back( aCriterion );
2839 SMESH::Filter::Criteria_var aCriteriaVar = new SMESH::Filter::Criteria;
2840 aCriteriaVar->length( aCriteria.size() );
2843 std::list<SMESH::Filter::Criterion>::iterator anIter = aCriteria.begin();
2845 for( ; anIter != aCriteria.end(); ++anIter )
2846 aCriteriaVar[ i++ ] = *anIter;
2848 aRes = myFilterMgr->CreateFilter();
2849 aRes->SetCriteria( aCriteriaVar.inout() );
2851 TPythonDump()<<this<<".Copy('"<<theFilterName<<"')";
2856 //=======================================================================
2857 // name : FilterLibrary_i::SetFileName
2858 // Purpose : Set file name for library
2859 //=======================================================================
2860 void FilterLibrary_i::SetFileName( const char* theFileName )
2863 myFileName = strdup( theFileName );
2864 TPythonDump()<<this<<".SetFileName('"<<theFileName<<"')";
2867 //=======================================================================
2868 // name : FilterLibrary_i::GetFileName
2869 // Purpose : Get file name of library
2870 //=======================================================================
2871 char* FilterLibrary_i::GetFileName()
2873 return CORBA::string_dup( myFileName );
2876 //=======================================================================
2877 // name : FilterLibrary_i::Add
2878 // Purpose : Add new filter to library
2879 //=======================================================================
2880 CORBA::Boolean FilterLibrary_i::Add( const char* theFilterName, Filter_ptr theFilter )
2882 // if filter already in library or entry filter is null do nothing
2883 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc );
2884 if ( !aFilterNode.isNull() || theFilter->_is_nil() )
2887 // get section corresponding to the filter type
2888 ElementType anEntType = theFilter->GetElementType();
2890 LDOM_Node aSection = getSection( anEntType, myDoc, true );
2891 if ( aSection.isNull() )
2894 // create filter item
2895 LDOM_Element aFilterItem = createFilterItem( theFilterName, theFilter, myDoc );
2896 if ( aFilterItem.isNull() )
2900 aSection.appendChild( aFilterItem );
2901 if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
2902 TPythonDump()<<this<<".Add('"<<theFilterName<<"',"<<aFilter<<")";
2907 //=======================================================================
2908 // name : FilterLibrary_i::Add
2909 // Purpose : Add new filter to library
2910 //=======================================================================
2911 CORBA::Boolean FilterLibrary_i::AddEmpty( const char* theFilterName, ElementType theType )
2913 // if filter already in library or entry filter is null do nothing
2914 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc );
2915 if ( !aFilterNode.isNull() )
2918 LDOM_Node aSection = getSection( theType, myDoc, true );
2919 if ( aSection.isNull() )
2922 // create filter item
2923 Filter_var aFilter = myFilterMgr->CreateFilter();
2925 LDOM_Element aFilterItem = createFilterItem( theFilterName, aFilter, myDoc );
2926 if ( aFilterItem.isNull() )
2930 aSection.appendChild( aFilterItem );
2931 TPythonDump()<<this<<".AddEmpty('"<<theFilterName<<"',"<<theType<<")";
2936 //=======================================================================
2937 // name : FilterLibrary_i::Delete
2938 // Purpose : Delete filter from library
2939 //=======================================================================
2940 CORBA::Boolean FilterLibrary_i::Delete ( const char* theFilterName )
2942 LDOM_Node aParentNode;
2943 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc, &aParentNode );
2944 if ( aFilterNode.isNull() || aParentNode.isNull() )
2947 aParentNode.removeChild( aFilterNode );
2948 TPythonDump()<<this<<".Delete('"<<theFilterName<<"')";
2952 //=======================================================================
2953 // name : FilterLibrary_i::Replace
2954 // Purpose : Replace existing filter with entry filter.
2955 // IMPORTANT : If filter does not exist it is not created
2956 //=======================================================================
2957 CORBA::Boolean FilterLibrary_i::Replace( const char* theFilterName,
2958 const char* theNewName,
2959 Filter_ptr theFilter )
2961 LDOM_Element aFilterItem = findFilter( theFilterName, myDoc );
2962 if ( aFilterItem.isNull() || theFilter->_is_nil() )
2965 LDOM_Element aNewItem = createFilterItem( theNewName, theFilter, myDoc );
2966 if ( aNewItem.isNull() )
2970 aFilterItem.ReplaceElement( aNewItem );
2971 if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
2972 TPythonDump()<<this<<".Replace('"<<theFilterName<<"',"<<theNewName<<"',"<<aFilter<<")";
2977 //=======================================================================
2978 // name : FilterLibrary_i::Save
2979 // Purpose : Save library on disk
2980 //=======================================================================
2981 CORBA::Boolean FilterLibrary_i::Save()
2983 if ( myFileName == 0 || strlen( myFileName ) == 0 )
2986 FILE* aOutFile = fopen( myFileName, "wt" );
2990 LDOM_XmlWriter aWriter( aOutFile );
2991 aWriter.SetIndentation( 2 );
2995 TPythonDump()<<this<<".Save()";
2999 //=======================================================================
3000 // name : FilterLibrary_i::SaveAs
3001 // Purpose : Save library on disk
3002 //=======================================================================
3003 CORBA::Boolean FilterLibrary_i::SaveAs( const char* aFileName )
3005 myFileName = strdup ( aFileName );
3006 TPythonDump()<<this<<".SaveAs('"<<aFileName<<"')";
3010 //=======================================================================
3011 // name : FilterLibrary_i::IsPresent
3012 // Purpose : Verify whether filter is in library
3013 //=======================================================================
3014 CORBA::Boolean FilterLibrary_i::IsPresent( const char* theFilterName )
3016 return !findFilter( theFilterName, myDoc ).isNull();
3019 //=======================================================================
3020 // name : FilterLibrary_i::NbFilters
3021 // Purpose : Return amount of filters in library
3022 //=======================================================================
3023 CORBA::Long FilterLibrary_i::NbFilters( ElementType theType )
3025 string_array_var aNames = GetNames( theType );
3026 return aNames->length();
3029 //=======================================================================
3030 // name : FilterLibrary_i::GetNames
3031 // Purpose : Get names of filters from library
3032 //=======================================================================
3033 string_array* FilterLibrary_i::GetNames( ElementType theType )
3035 string_array_var anArray = new string_array;
3036 TColStd_SequenceOfHAsciiString aSeq;
3038 LDOM_Node aSection = getSection( theType, myDoc, false );
3040 if ( !aSection.isNull() )
3042 for ( LDOM_Node aFilter = aSection.getFirstChild();
3043 !aFilter.isNull(); aFilter = aFilter.getNextSibling() )
3045 LDOM_Element& anElem = ( LDOM_Element& )aFilter;
3046 aSeq.Append( new TCollection_HAsciiString(
3047 (Standard_CString)anElem.getAttribute( "name" ).GetString() ) );
3051 anArray->length( aSeq.Length() );
3052 for ( int i = 1, n = aSeq.Length(); i <= n; i++ )
3053 anArray[ i - 1 ] = CORBA::string_dup( aSeq( i )->ToCString() );
3055 return anArray._retn();
3058 //=======================================================================
3059 // name : FilterLibrary_i::GetAllNames
3060 // Purpose : Get names of filters from library
3061 //=======================================================================
3062 string_array* FilterLibrary_i::GetAllNames()
3064 string_array_var aResArray = new string_array;
3065 for ( int type = SMESH::ALL; type <= SMESH::VOLUME; type++ )
3067 SMESH::string_array_var aNames = GetNames( (SMESH::ElementType)type );
3069 int aPrevLength = aResArray->length();
3070 aResArray->length( aPrevLength + aNames->length() );
3071 for ( int i = 0, n = aNames->length(); i < n; i++ )
3072 aResArray[ aPrevLength + i ] = aNames[ i ];
3075 return aResArray._retn();