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>
60 using namespace SMESH;
61 using namespace SMESH::Controls;
67 GetPredicate( Predicate_ptr thePredicate )
69 return DownCast<Predicate_i*>(thePredicate);
76 Description : Predicate for verifying whether entiy belong to
77 specified geometrical support
80 Controls::BelongToGeom::BelongToGeom()
85 void Controls::BelongToGeom::SetMesh( const SMDS_Mesh* theMesh )
87 myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
90 void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape )
95 static bool IsContains( const SMESHDS_Mesh* theMeshDS,
96 const TopoDS_Shape& theShape,
97 const SMDS_MeshElement* theElem,
98 TopAbs_ShapeEnum theFindShapeEnum,
99 TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE )
101 TopExp_Explorer anExp( theShape,theFindShapeEnum,theAvoidShapeEnum );
103 while( anExp.More() )
105 const TopoDS_Shape& aShape = anExp.Current();
106 if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
107 if( aSubMesh->Contains( theElem ) )
115 bool Controls::BelongToGeom::IsSatisfy( long theId )
117 if ( myMeshDS == 0 || myShape.IsNull() )
120 if( myType == SMDSAbs_Node )
122 if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
124 const SMDS_PositionPtr& aPosition = aNode->GetPosition();
125 SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
126 switch( aTypeOfPosition )
128 case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
129 case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
130 case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
131 case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
137 if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
139 if( myType == SMDSAbs_All )
141 return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
142 IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
143 IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
144 IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
146 else if( myType == anElem->GetType() )
150 case SMDSAbs_Edge : return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE );
151 case SMDSAbs_Face : return IsContains( myMeshDS,myShape,anElem,TopAbs_FACE );
152 case SMDSAbs_Volume: return IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
153 IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID );
162 void Controls::BelongToGeom::SetType( SMDSAbs_ElementType theType )
167 SMDSAbs_ElementType Controls::BelongToGeom::GetType() const
172 TopoDS_Shape Controls::BelongToGeom::GetShape()
178 Controls::BelongToGeom::
184 static bool IsSubShape (const TopTools_IndexedMapOfShape& theMap,
185 const TopoDS_Shape& theShape)
187 if (theMap.Contains(theShape)) return true;
189 if (theShape.ShapeType() == TopAbs_COMPOUND ||
190 theShape.ShapeType() == TopAbs_COMPSOLID)
192 TopoDS_Iterator anIt (theShape, Standard_True, Standard_True);
193 for (; anIt.More(); anIt.Next())
195 if (!IsSubShape(theMap, anIt.Value())) {
205 void Controls::BelongToGeom::init()
207 if (!myMeshDS || myShape.IsNull()) return;
209 // is subshape of main shape?
210 TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
211 if (aMainShape.IsNull()) {
212 myIsSubshape = false;
215 TopTools_IndexedMapOfShape aMap;
216 TopExp::MapShapes(aMainShape, aMap);
217 myIsSubshape = IsSubShape(aMap, myShape);
222 myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
223 myElementsOnShapePtr->SetTolerance(myTolerance);
224 myElementsOnShapePtr->SetAllNodes(true); // belong, while false means "lays on"
225 myElementsOnShapePtr->SetMesh(myMeshDS);
226 myElementsOnShapePtr->SetShape(myShape, myType);
230 void Controls::BelongToGeom::SetTolerance (double theTolerance)
232 myTolerance = theTolerance;
237 double Controls::BelongToGeom::GetTolerance()
244 Description : Predicate for verifying whether entiy lying or partially lying on
245 specified geometrical support
248 Controls::LyingOnGeom::LyingOnGeom()
253 void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
255 myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
258 void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
263 bool Controls::LyingOnGeom::IsSatisfy( long theId )
265 if ( myMeshDS == 0 || myShape.IsNull() )
268 if( myType == SMDSAbs_Node )
270 if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
272 const SMDS_PositionPtr& aPosition = aNode->GetPosition();
273 SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
274 switch( aTypeOfPosition )
276 case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
277 case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
278 case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
279 case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
285 if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
287 if( myType == SMDSAbs_All )
289 return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
290 Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
291 Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
292 Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
294 else if( myType == anElem->GetType() )
298 case SMDSAbs_Edge : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE );
299 case SMDSAbs_Face : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE );
300 case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
301 Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
310 void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
315 SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
320 TopoDS_Shape Controls::LyingOnGeom::GetShape()
326 Controls::LyingOnGeom::
332 void Controls::LyingOnGeom::init()
334 if (!myMeshDS || myShape.IsNull()) return;
336 // is subshape of main shape?
337 TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
338 if (aMainShape.IsNull()) {
339 myIsSubshape = false;
342 TopTools_IndexedMapOfShape aMap;
343 TopExp::MapShapes(aMainShape, aMap);
344 myIsSubshape = IsSubShape(aMap, myShape);
349 myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
350 myElementsOnShapePtr->SetTolerance(myTolerance);
351 myElementsOnShapePtr->SetAllNodes(false); // lays on, while true means "belong"
352 myElementsOnShapePtr->SetMesh(myMeshDS);
353 myElementsOnShapePtr->SetShape(myShape, myType);
357 void Controls::LyingOnGeom::SetTolerance (double theTolerance)
359 myTolerance = theTolerance;
364 double Controls::LyingOnGeom::GetTolerance()
369 bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS,
370 const TopoDS_Shape& theShape,
371 const SMDS_MeshElement* theElem,
372 TopAbs_ShapeEnum theFindShapeEnum,
373 TopAbs_ShapeEnum theAvoidShapeEnum )
375 if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
378 TopTools_IndexedMapOfShape aSubShapes;
379 TopExp::MapShapes( theShape, aSubShapes );
381 for (int i = 1; i <= aSubShapes.Extent(); i++)
383 const TopoDS_Shape& aShape = aSubShapes.FindKey(i);
385 if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
386 if( aSubMesh->Contains( theElem ) )
389 SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
390 while ( aNodeIt->more() )
392 const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
393 SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
394 while ( anElemIt->more() )
396 const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
397 if (anElement == theElem)
413 MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh )
415 SMESH_Mesh_i* anImplPtr = DownCast<SMESH_Mesh_i*>(theMesh);
416 return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0;
421 toArray( const TColStd_ListOfInteger& aList )
423 SMESH::long_array_var anArray = new SMESH::long_array;
424 anArray->length( aList.Extent() );
425 TColStd_ListIteratorOfListOfInteger anIter( aList );
427 for( ; anIter.More(); anIter.Next() )
428 anArray[ i++ ] = anIter.Value();
430 return anArray._retn();
435 toArray( const TColStd_ListOfReal& aList )
437 SMESH::double_array_var anArray = new SMESH::double_array;
438 anArray->length( aList.Extent() );
439 TColStd_ListIteratorOfListOfReal anIter( aList );
441 for( ; anIter.More(); anIter.Next() )
442 anArray[ i++ ] = anIter.Value();
444 return anArray._retn();
447 static SMESH::Filter::Criterion createCriterion()
449 SMESH::Filter::Criterion aCriterion;
451 aCriterion.Type = FT_Undefined;
452 aCriterion.Compare = FT_Undefined;
453 aCriterion.Threshold = 0;
454 aCriterion.UnaryOp = FT_Undefined;
455 aCriterion.BinaryOp = FT_Undefined;
456 aCriterion.ThresholdStr = "";
457 aCriterion.ThresholdID = "";
458 aCriterion.Tolerance = Precision::Confusion();
459 aCriterion.TypeOfElement = SMESH::ALL;
460 aCriterion.Precision = -1;
465 static TopoDS_Shape getShapeByName( const char* theName )
469 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
470 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
471 if (!CORBA::is_nil(aStudy))
473 SALOMEDS::Study::ListOfSObject_var aList =
474 aStudy->FindObjectByName( theName, "GEOM" );
475 if ( aList->length() > 0 )
477 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() );
478 if ( !aGeomObj->_is_nil() )
480 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
481 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
487 return TopoDS_Shape();
490 static TopoDS_Shape getShapeByID (const char* theID)
492 if (theID != 0 && theID != "") {
493 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
494 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
496 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
497 SALOMEDS::GenericAttribute_var anAttr;
498 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
499 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
500 CORBA::String_var aVal = anIOR->Value();
501 CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal);
502 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(obj);
504 if (!aGeomObj->_is_nil()) {
505 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
506 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
512 return TopoDS_Shape();
515 static char* getShapeNameByID (const char* theID)
519 if (theID != 0 && theID != "") {
520 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
521 SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
523 //SALOMEDS::SObject_var aSObj = aStudy->FindObjectIOR( theID );
524 SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theID);
525 SALOMEDS::GenericAttribute_var anAttr;
526 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeName")) {
527 SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr);
528 aName = aNameAttr->Value();
542 Description : An abstact class for all functors
544 Functor_i::Functor_i():
545 SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
547 //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method
548 //PortableServer::ObjectId_var anObjectId =
549 // SMESH_Gen_i::GetPOA()->activate_object( this );
552 Functor_i::~Functor_i()
554 //TPythonDump()<<this<<".Destroy()";
557 void Functor_i::SetMesh( SMESH_Mesh_ptr theMesh )
559 myFunctorPtr->SetMesh( MeshPtr2SMDSMesh( theMesh ) );
560 TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
563 ElementType Functor_i::GetElementType()
565 return ( ElementType )myFunctorPtr->GetType();
570 Class : NumericalFunctor_i
571 Description : Base class for numerical functors
573 CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId )
575 return myNumericalFunctorPtr->GetValue( theId );
578 void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision )
580 myNumericalFunctorPtr->SetPrecision( thePrecision );
581 TPythonDump()<<this<<".SetPrecision("<<thePrecision<<")";
584 CORBA::Long NumericalFunctor_i::GetPrecision()
586 return myNumericalFunctorPtr->GetPrecision();
589 Controls::NumericalFunctorPtr NumericalFunctor_i::GetNumericalFunctor()
591 return myNumericalFunctorPtr;
596 Class : SMESH_MinimumAngle
597 Description : Functor for calculation of minimum angle
599 MinimumAngle_i::MinimumAngle_i()
601 myNumericalFunctorPtr.reset( new Controls::MinimumAngle() );
602 myFunctorPtr = myNumericalFunctorPtr;
605 FunctorType MinimumAngle_i::GetFunctorType()
607 return SMESH::FT_MinimumAngle;
613 Description : Functor for calculating aspect ratio
615 AspectRatio_i::AspectRatio_i()
617 myNumericalFunctorPtr.reset( new Controls::AspectRatio() );
618 myFunctorPtr = myNumericalFunctorPtr;
621 FunctorType AspectRatio_i::GetFunctorType()
623 return SMESH::FT_AspectRatio;
628 Class : AspectRatio3D
629 Description : Functor for calculating aspect ratio 3D
631 AspectRatio3D_i::AspectRatio3D_i()
633 myNumericalFunctorPtr.reset( new Controls::AspectRatio3D() );
634 myFunctorPtr = myNumericalFunctorPtr;
637 FunctorType AspectRatio3D_i::GetFunctorType()
639 return SMESH::FT_AspectRatio3D;
645 Description : Functor for calculating warping
647 Warping_i::Warping_i()
649 myNumericalFunctorPtr.reset( new Controls::Warping() );
650 myFunctorPtr = myNumericalFunctorPtr;
653 FunctorType Warping_i::GetFunctorType()
655 return SMESH::FT_Warping;
661 Description : Functor for calculating taper
665 myNumericalFunctorPtr.reset( new Controls::Taper() );
666 myFunctorPtr = myNumericalFunctorPtr;
669 FunctorType Taper_i::GetFunctorType()
671 return SMESH::FT_Taper;
677 Description : Functor for calculating skew in degrees
681 myNumericalFunctorPtr.reset( new Controls::Skew() );
682 myFunctorPtr = myNumericalFunctorPtr;
685 FunctorType Skew_i::GetFunctorType()
687 return SMESH::FT_Skew;
692 Description : Functor for calculating area
696 myNumericalFunctorPtr.reset( new Controls::Area() );
697 myFunctorPtr = myNumericalFunctorPtr;
700 FunctorType Area_i::GetFunctorType()
702 return SMESH::FT_Area;
707 Description : Functor for calculating volume of 3D element
709 Volume3D_i::Volume3D_i()
711 myNumericalFunctorPtr.reset( new Controls::Volume() );
712 myFunctorPtr = myNumericalFunctorPtr;
715 FunctorType Volume3D_i::GetFunctorType()
717 return SMESH::FT_Volume3D;
722 Description : Functor for calculating length off edge
726 myNumericalFunctorPtr.reset( new Controls::Length() );
727 myFunctorPtr = myNumericalFunctorPtr;
730 FunctorType Length_i::GetFunctorType()
732 return SMESH::FT_Length;
737 Description : Functor for calculating length of edge
739 Length2D_i::Length2D_i()
741 myNumericalFunctorPtr.reset( new Controls::Length2D() );
742 myFunctorPtr = myNumericalFunctorPtr;
745 FunctorType Length2D_i::GetFunctorType()
747 return SMESH::FT_Length2D;
750 SMESH::Length2D::Values* Length2D_i::GetValues()
752 INFOS("Length2D_i::GetValues");
753 SMESH::Controls::Length2D::TValues aValues;
754 myLength2DPtr->GetValues( aValues );
756 long i = 0, iEnd = aValues.size();
758 SMESH::Length2D::Values_var aResult = new SMESH::Length2D::Values(iEnd);
760 SMESH::Controls::Length2D::TValues::const_iterator anIter;
761 for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
763 const SMESH::Controls::Length2D::Value& aVal = *anIter;
764 SMESH::Length2D::Value &aValue = aResult[ i ];
766 aValue.myLength = aVal.myLength;
767 aValue.myPnt1 = aVal.myPntId[ 0 ];
768 aValue.myPnt2 = aVal.myPntId[ 1 ];
771 INFOS("Length2D_i::GetValuess~");
772 return aResult._retn();
776 Class : MultiConnection_i
777 Description : Functor for calculating number of faces conneted to the edge
779 MultiConnection_i::MultiConnection_i()
781 myNumericalFunctorPtr.reset( new Controls::MultiConnection() );
782 myFunctorPtr = myNumericalFunctorPtr;
785 FunctorType MultiConnection_i::GetFunctorType()
787 return SMESH::FT_MultiConnection;
791 Class : MultiConnection2D_i
792 Description : Functor for calculating number of faces conneted to the edge
794 MultiConnection2D_i::MultiConnection2D_i()
796 myNumericalFunctorPtr.reset( new Controls::MultiConnection2D() );
797 myFunctorPtr = myNumericalFunctorPtr;
800 FunctorType MultiConnection2D_i::GetFunctorType()
802 return SMESH::FT_MultiConnection2D;
805 SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues()
807 INFOS("MultiConnection2D_i::GetValues");
808 SMESH::Controls::MultiConnection2D::MValues aValues;
809 myMulticonnection2DPtr->GetValues( aValues );
811 long i = 0, iEnd = aValues.size();
813 SMESH::MultiConnection2D::Values_var aResult = new SMESH::MultiConnection2D::Values(iEnd);
815 SMESH::Controls::MultiConnection2D::MValues::const_iterator anIter;
816 for ( anIter = aValues.begin() ; anIter != aValues.end(); anIter++, i++ )
818 const SMESH::Controls::MultiConnection2D::Value& aVal = (*anIter).first;
819 SMESH::MultiConnection2D::Value &aValue = aResult[ i ];
821 aValue.myPnt1 = aVal.myPntId[ 0 ];
822 aValue.myPnt2 = aVal.myPntId[ 1 ];
823 aValue.myNbConnects = (*anIter).second;
826 INFOS("Multiconnection2D_i::GetValuess~");
827 return aResult._retn();
837 Description : Base class for all predicates
839 CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId )
841 return myPredicatePtr->IsSatisfy( theId );
844 Controls::PredicatePtr Predicate_i::GetPredicate()
846 return myPredicatePtr;
850 Class : BadOrientedVolume_i
851 Description : Verify whether a mesh volume is incorrectly oriented from
852 the point of view of MED convention
854 BadOrientedVolume_i::BadOrientedVolume_i()
856 Controls::PredicatePtr control( new Controls::BadOrientedVolume() );
857 myFunctorPtr = myPredicatePtr = control;
860 FunctorType BadOrientedVolume_i::GetFunctorType()
862 return SMESH::FT_BadOrientedVolume;
866 Class : BelongToGeom_i
867 Description : Predicate for selection on geometrical support
869 BelongToGeom_i::BelongToGeom_i()
871 myBelongToGeomPtr.reset( new Controls::BelongToGeom() );
872 myFunctorPtr = myPredicatePtr = myBelongToGeomPtr;
877 BelongToGeom_i::~BelongToGeom_i()
883 void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
885 if ( theGeom->_is_nil() )
887 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
888 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
889 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
890 myBelongToGeomPtr->SetGeom( aLocShape );
891 TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
894 void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape )
896 myBelongToGeomPtr->SetGeom( theShape );
899 void BelongToGeom_i::SetElementType(ElementType theType){
900 myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType));
901 TPythonDump()<<this<<".SetElementType("<<theType<<")";
904 FunctorType BelongToGeom_i::GetFunctorType()
906 return SMESH::FT_BelongToGeom;
909 void BelongToGeom_i::SetShapeName( const char* theName )
912 myShapeName = strdup( theName );
913 myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
914 TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
917 void BelongToGeom_i::SetShape( const char* theID, const char* theName )
920 myShapeName = strdup( theName );
923 myShapeID = strdup( theID );
927 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
928 myBelongToGeomPtr->SetGeom( getShapeByID(myShapeID) );
930 myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) );
933 char* BelongToGeom_i::GetShapeName()
935 return CORBA::string_dup( myShapeName );
938 char* BelongToGeom_i::GetShapeID()
940 return CORBA::string_dup( myShapeID );
943 void BelongToGeom_i::SetTolerance( CORBA::Double theToler )
945 myBelongToGeomPtr->SetTolerance( theToler );
946 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
949 CORBA::Double BelongToGeom_i::GetTolerance()
951 return myBelongToGeomPtr->GetTolerance();
955 Class : BelongToSurface_i
956 Description : Predicate for selection on geometrical support
958 BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceType )
960 myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() );
961 myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr;
964 mySurfaceType = theSurfaceType;
967 BelongToSurface_i::~BelongToSurface_i()
973 void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
975 if ( theGeom->_is_nil() )
977 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
978 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
979 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
981 if ( aLocShape.ShapeType() == TopAbs_FACE )
983 Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aLocShape ) );
984 if ( !aSurf.IsNull() && aSurf->DynamicType() == mySurfaceType )
986 myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
991 myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType );
994 void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType )
997 myShapeName = strdup( theName );
998 myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
999 TPythonDump()<<this<<".SetShapeName('"<<theName<<"',"<<theType<<")";
1002 void BelongToSurface_i::SetShape( const char* theID, const char* theName, ElementType theType )
1005 myShapeName = strdup( theName );
1008 myShapeID = strdup( theID );
1012 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
1013 myElementsOnSurfacePtr->SetSurface( getShapeByID(myShapeID), (SMDSAbs_ElementType)theType );
1015 myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType );
1018 char* BelongToSurface_i::GetShapeName()
1020 return CORBA::string_dup( myShapeName );
1023 char* BelongToSurface_i::GetShapeID()
1025 return CORBA::string_dup( myShapeID );
1028 void BelongToSurface_i::SetTolerance( CORBA::Double theToler )
1030 myElementsOnSurfacePtr->SetTolerance( theToler );
1031 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1034 CORBA::Double BelongToSurface_i::GetTolerance()
1036 return myElementsOnSurfacePtr->GetTolerance();
1039 void BelongToSurface_i::SetUseBoundaries( CORBA::Boolean theUseBndRestrictions )
1041 myElementsOnSurfacePtr->SetUseBoundaries( theUseBndRestrictions );
1042 TPythonDump()<<this<<".SetUseBoundaries( " << theUseBndRestrictions << " )";
1045 CORBA::Boolean BelongToSurface_i::GetUseBoundaries()
1047 return myElementsOnSurfacePtr->GetUseBoundaries();
1052 Class : BelongToPlane_i
1053 Description : Verify whether mesh element lie in pointed Geom planar object
1056 BelongToPlane_i::BelongToPlane_i()
1057 : BelongToSurface_i( STANDARD_TYPE( Geom_Plane ) )
1061 void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1063 BelongToSurface_i::SetSurface( theGeom, theType );
1064 TPythonDump()<<this<<".SetPlane("<<theGeom<<","<<theType<<")";
1067 FunctorType BelongToPlane_i::GetFunctorType()
1069 return FT_BelongToPlane;
1073 Class : BelongToCylinder_i
1074 Description : Verify whether mesh element lie in pointed Geom planar object
1077 BelongToCylinder_i::BelongToCylinder_i()
1078 : BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
1082 void BelongToCylinder_i::SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1084 BelongToSurface_i::SetSurface( theGeom, theType );
1085 TPythonDump()<<this<<".SetCylinder("<<theGeom<<","<<theType<<")";
1088 FunctorType BelongToCylinder_i::GetFunctorType()
1090 return FT_BelongToCylinder;
1094 Class : BelongToGenSurface_i
1095 Description : Verify whether mesh element lie in pointed Geom planar object
1098 BelongToGenSurface_i::BelongToGenSurface_i()
1099 : BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) )
1103 void BelongToGenSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType )
1105 if ( theGeom->_is_nil() )
1107 TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom );
1108 if ( !aLocShape.IsNull() && aLocShape.ShapeType() != TopAbs_FACE )
1109 aLocShape.Nullify();
1111 BelongToSurface_i::myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType );
1112 TPythonDump()<<this<<".SetGenSurface("<<theGeom<<","<<theType<<")";
1115 FunctorType BelongToGenSurface_i::GetFunctorType()
1117 return FT_BelongToGenSurface;
1121 Class : LyingOnGeom_i
1122 Description : Predicate for selection on geometrical support
1124 LyingOnGeom_i::LyingOnGeom_i()
1126 myLyingOnGeomPtr.reset( new Controls::LyingOnGeom() );
1127 myFunctorPtr = myPredicatePtr = myLyingOnGeomPtr;
1132 LyingOnGeom_i::~LyingOnGeom_i()
1138 void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
1140 if ( theGeom->_is_nil() )
1142 SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
1143 GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
1144 TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
1145 myLyingOnGeomPtr->SetGeom( aLocShape );
1146 TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
1149 void LyingOnGeom_i::SetGeom( const TopoDS_Shape& theShape )
1151 myLyingOnGeomPtr->SetGeom( theShape );
1154 void LyingOnGeom_i::SetElementType(ElementType theType){
1155 myLyingOnGeomPtr->SetType(SMDSAbs_ElementType(theType));
1156 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1159 FunctorType LyingOnGeom_i::GetFunctorType()
1161 return SMESH::FT_LyingOnGeom;
1164 void LyingOnGeom_i::SetShapeName( const char* theName )
1167 myShapeName = strdup( theName );
1168 myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
1169 TPythonDump()<<this<<".SetShapeName('"<<theName<<"')";
1172 void LyingOnGeom_i::SetShape( const char* theID, const char* theName )
1175 myShapeName = strdup( theName );
1178 myShapeID = strdup( theID );
1182 if ( myShapeID && strcmp(myShapeName, getShapeNameByID(myShapeID)) == 0 )
1183 myLyingOnGeomPtr->SetGeom( getShapeByID(myShapeID) );
1185 myLyingOnGeomPtr->SetGeom( getShapeByName( myShapeName ) );
1188 char* LyingOnGeom_i::GetShapeName()
1190 return CORBA::string_dup( myShapeName );
1193 char* LyingOnGeom_i::GetShapeID()
1195 return CORBA::string_dup( myShapeID );
1198 void LyingOnGeom_i::SetTolerance( CORBA::Double theToler )
1200 myLyingOnGeomPtr->SetTolerance( theToler );
1201 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1204 CORBA::Double LyingOnGeom_i::GetTolerance()
1206 return myLyingOnGeomPtr->GetTolerance();
1210 Class : FreeBorders_i
1211 Description : Predicate for free borders
1213 FreeBorders_i::FreeBorders_i()
1215 myPredicatePtr.reset(new Controls::FreeBorders());
1216 myFunctorPtr = myPredicatePtr;
1219 FunctorType FreeBorders_i::GetFunctorType()
1221 return SMESH::FT_FreeBorders;
1226 Description : Predicate for free borders
1228 FreeEdges_i::FreeEdges_i()
1229 : myFreeEdgesPtr( new Controls::FreeEdges() )
1231 myFunctorPtr = myPredicatePtr = myFreeEdgesPtr;
1234 SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders()
1236 INFOS("FreeEdges_i::GetBorders");
1237 SMESH::Controls::FreeEdges::TBorders aBorders;
1238 myFreeEdgesPtr->GetBoreders( aBorders );
1240 long i = 0, iEnd = aBorders.size();
1242 SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders;
1243 aResult->length(iEnd);
1245 SMESH::Controls::FreeEdges::TBorders::const_iterator anIter;
1246 for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ )
1248 const SMESH::Controls::FreeEdges::Border& aBord = *anIter;
1249 SMESH::FreeEdges::Border &aBorder = aResult[ i ];
1251 aBorder.myElemId = aBord.myElemId;
1252 aBorder.myPnt1 = aBord.myPntId[ 0 ];
1253 aBorder.myPnt2 = aBord.myPntId[ 1 ];
1256 INFOS("FreeEdges_i::GetBorders~");
1257 return aResult._retn();
1260 FunctorType FreeEdges_i::GetFunctorType()
1262 return SMESH::FT_FreeEdges;
1266 Class : RangeOfIds_i
1267 Description : Predicate for Range of Ids.
1268 Range may be specified with two ways.
1269 1. Using AddToRange method
1270 2. With SetRangeStr method. Parameter of this method is a string
1271 like as "1,2,3,50-60,63,67,70-"
1274 RangeOfIds_i::RangeOfIds_i()
1276 myRangeOfIdsPtr.reset( new Controls::RangeOfIds() );
1277 myFunctorPtr = myPredicatePtr = myRangeOfIdsPtr;
1280 void RangeOfIds_i::SetRange( const SMESH::long_array& theIds )
1282 CORBA::Long iEnd = theIds.length();
1283 for ( CORBA::Long i = 0; i < iEnd; i++ )
1284 myRangeOfIdsPtr->AddToRange( theIds[ i ] );
1285 TPythonDump()<<this<<".SetRange("<<theIds<<")";
1288 CORBA::Boolean RangeOfIds_i::SetRangeStr( const char* theRange )
1290 TPythonDump()<<this<<".SetRangeStr('"<<theRange<<"')";
1291 return myRangeOfIdsPtr->SetRangeStr(
1292 TCollection_AsciiString( (Standard_CString)theRange ) );
1295 char* RangeOfIds_i::GetRangeStr()
1297 TCollection_AsciiString aStr;
1298 myRangeOfIdsPtr->GetRangeStr( aStr );
1299 return CORBA::string_dup( aStr.ToCString() );
1302 void RangeOfIds_i::SetElementType( ElementType theType )
1304 myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) );
1305 TPythonDump()<<this<<".SetElementType("<<theType<<")";
1308 FunctorType RangeOfIds_i::GetFunctorType()
1310 return SMESH::FT_RangeOfIds;
1314 Class : Comparator_i
1315 Description : Base class for comparators
1317 Comparator_i::Comparator_i():
1318 myNumericalFunctor( NULL )
1321 Comparator_i::~Comparator_i()
1323 if ( myNumericalFunctor )
1324 myNumericalFunctor->Destroy();
1327 void Comparator_i::SetMargin( CORBA::Double theValue )
1329 myComparatorPtr->SetMargin( theValue );
1330 TPythonDump()<<this<<".SetMargin("<<theValue<<")";
1333 CORBA::Double Comparator_i::GetMargin()
1335 return myComparatorPtr->GetMargin();
1338 void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct )
1340 if ( myNumericalFunctor )
1341 myNumericalFunctor->Destroy();
1343 myNumericalFunctor = DownCast<NumericalFunctor_i*>(theFunct);
1345 if ( myNumericalFunctor )
1347 myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() );
1348 myNumericalFunctor->Register();
1349 TPythonDump()<<this<<".SetNumFunctor("<<myNumericalFunctor<<")";
1353 Controls::ComparatorPtr Comparator_i::GetComparator()
1355 return myComparatorPtr;
1358 NumericalFunctor_i* Comparator_i::GetNumFunctor_i()
1360 return myNumericalFunctor;
1366 Description : Comparator "<"
1368 LessThan_i::LessThan_i()
1370 myComparatorPtr.reset( new Controls::LessThan() );
1371 myFunctorPtr = myPredicatePtr = myComparatorPtr;
1374 FunctorType LessThan_i::GetFunctorType()
1376 return SMESH::FT_LessThan;
1382 Description : Comparator ">"
1384 MoreThan_i::MoreThan_i()
1386 myComparatorPtr.reset( new Controls::MoreThan() );
1387 myFunctorPtr = myPredicatePtr = myComparatorPtr;
1390 FunctorType MoreThan_i::GetFunctorType()
1392 return SMESH::FT_MoreThan;
1398 Description : Comparator "="
1400 EqualTo_i::EqualTo_i()
1401 : myEqualToPtr( new Controls::EqualTo() )
1403 myFunctorPtr = myPredicatePtr = myComparatorPtr = myEqualToPtr;
1406 void EqualTo_i::SetTolerance( CORBA::Double theToler )
1408 myEqualToPtr->SetTolerance( theToler );
1409 TPythonDump()<<this<<".SetTolerance("<<theToler<<")";
1412 CORBA::Double EqualTo_i::GetTolerance()
1414 return myEqualToPtr->GetTolerance();
1417 FunctorType EqualTo_i::GetFunctorType()
1419 return SMESH::FT_EqualTo;
1423 Class : LogicalNOT_i
1424 Description : Logical NOT predicate
1426 LogicalNOT_i::LogicalNOT_i()
1427 : myPredicate( NULL ),
1428 myLogicalNOTPtr( new Controls::LogicalNOT() )
1430 myFunctorPtr = myPredicatePtr = myLogicalNOTPtr;
1433 LogicalNOT_i::~LogicalNOT_i()
1436 myPredicate->Destroy();
1439 void LogicalNOT_i::SetPredicate( Predicate_ptr thePredicate )
1442 myPredicate->Destroy();
1444 myPredicate = SMESH::GetPredicate(thePredicate);
1447 myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate());
1448 myPredicate->Register();
1449 TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
1453 FunctorType LogicalNOT_i::GetFunctorType()
1455 return SMESH::FT_LogicalNOT;
1458 Predicate_i* LogicalNOT_i::GetPredicate_i()
1465 Class : LogicalBinary_i
1466 Description : Base class for binary logical predicate
1468 LogicalBinary_i::LogicalBinary_i()
1469 : myPredicate1( NULL ),
1470 myPredicate2( NULL )
1473 LogicalBinary_i::~LogicalBinary_i()
1476 myPredicate1->Destroy();
1479 myPredicate2->Destroy();
1482 void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh )
1485 myPredicate1->SetMesh( theMesh );
1488 myPredicate2->SetMesh( theMesh );
1491 void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate )
1494 myPredicate1->Destroy();
1496 myPredicate1 = SMESH::GetPredicate(thePredicate);
1498 if ( myPredicate1 ){
1499 myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate());
1500 myPredicate1->Register();
1501 TPythonDump()<<this<<".SetPredicate1("<<myPredicate1<<")";
1505 void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate )
1508 myPredicate2->Destroy();
1510 myPredicate2 = SMESH::GetPredicate(thePredicate);
1512 if ( myPredicate2 ){
1513 myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate());
1514 myPredicate2->Register();
1515 TPythonDump()<<this<<".SetPredicate2("<<myPredicate2<<")";
1519 Controls::LogicalBinaryPtr LogicalBinary_i::GetLogicalBinary()
1521 return myLogicalBinaryPtr;
1524 Predicate_i* LogicalBinary_i::GetPredicate1_i()
1526 return myPredicate1;
1528 Predicate_i* LogicalBinary_i::GetPredicate2_i()
1530 return myPredicate2;
1535 Class : LogicalAND_i
1536 Description : Logical AND
1538 LogicalAND_i::LogicalAND_i()
1540 myLogicalBinaryPtr.reset( new Controls::LogicalAND() );
1541 myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr;
1544 FunctorType LogicalAND_i::GetFunctorType()
1546 return SMESH::FT_LogicalAND;
1552 Description : Logical OR
1554 LogicalOR_i::LogicalOR_i()
1556 myLogicalBinaryPtr.reset( new Controls::LogicalOR() );
1557 myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr;
1560 FunctorType LogicalOR_i::GetFunctorType()
1562 return SMESH::FT_LogicalOR;
1570 FilterManager_i::FilterManager_i()
1571 : SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() )
1573 //Base class Salome_GenericObject do it inmplicitly by overriding PortableServer::POA_ptr _default_POA() method
1574 //PortableServer::ObjectId_var anObjectId =
1575 // SMESH_Gen_i::GetPOA()->activate_object( this );
1579 FilterManager_i::~FilterManager_i()
1581 //TPythonDump()<<this<<".Destroy()";
1585 MinimumAngle_ptr FilterManager_i::CreateMinimumAngle()
1587 SMESH::MinimumAngle_i* aServant = new SMESH::MinimumAngle_i();
1588 SMESH::MinimumAngle_var anObj = aServant->_this();
1589 TPythonDump()<<aServant<<" = "<<this<<".CreateMinimumAngle()";
1590 return anObj._retn();
1594 AspectRatio_ptr FilterManager_i::CreateAspectRatio()
1596 SMESH::AspectRatio_i* aServant = new SMESH::AspectRatio_i();
1597 SMESH::AspectRatio_var anObj = aServant->_this();
1598 TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio()";
1599 return anObj._retn();
1603 AspectRatio3D_ptr FilterManager_i::CreateAspectRatio3D()
1605 SMESH::AspectRatio3D_i* aServant = new SMESH::AspectRatio3D_i();
1606 SMESH::AspectRatio3D_var anObj = aServant->_this();
1607 TPythonDump()<<aServant<<" = "<<this<<".CreateAspectRatio3D()";
1608 return anObj._retn();
1612 Warping_ptr FilterManager_i::CreateWarping()
1614 SMESH::Warping_i* aServant = new SMESH::Warping_i();
1615 SMESH::Warping_var anObj = aServant->_this();
1616 TPythonDump()<<aServant<<" = "<<this<<".CreateWarping()";
1617 return anObj._retn();
1621 Taper_ptr FilterManager_i::CreateTaper()
1623 SMESH::Taper_i* aServant = new SMESH::Taper_i();
1624 SMESH::Taper_var anObj = aServant->_this();
1625 TPythonDump()<<aServant<<" = "<<this<<".CreateTaper()";
1626 return anObj._retn();
1630 Skew_ptr FilterManager_i::CreateSkew()
1632 SMESH::Skew_i* aServant = new SMESH::Skew_i();
1633 SMESH::Skew_var anObj = aServant->_this();
1634 TPythonDump()<<aServant<<" = "<<this<<".CreateSkew()";
1635 return anObj._retn();
1639 Area_ptr FilterManager_i::CreateArea()
1641 SMESH::Area_i* aServant = new SMESH::Area_i();
1642 SMESH::Area_var anObj = aServant->_this();
1643 TPythonDump()<<aServant<<" = "<<this<<".CreateArea()";
1644 return anObj._retn();
1648 Volume3D_ptr FilterManager_i::CreateVolume3D()
1650 SMESH::Volume3D_i* aServant = new SMESH::Volume3D_i();
1651 SMESH::Volume3D_var anObj = aServant->_this();
1652 TPythonDump()<<aServant<<" = "<<this<<".CreateVolume3D()";
1653 return anObj._retn();
1657 Length_ptr FilterManager_i::CreateLength()
1659 SMESH::Length_i* aServant = new SMESH::Length_i();
1660 SMESH::Length_var anObj = aServant->_this();
1661 TPythonDump()<<aServant<<" = "<<this<<".CreateLength()";
1662 return anObj._retn();
1665 Length2D_ptr FilterManager_i::CreateLength2D()
1667 SMESH::Length2D_i* aServant = new SMESH::Length2D_i();
1668 SMESH::Length2D_var anObj = aServant->_this();
1669 TPythonDump()<<aServant<<" = "<<this<<".CreateLength2D()";
1670 return anObj._retn();
1673 MultiConnection_ptr FilterManager_i::CreateMultiConnection()
1675 SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i();
1676 SMESH::MultiConnection_var anObj = aServant->_this();
1677 TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection()";
1678 return anObj._retn();
1681 MultiConnection2D_ptr FilterManager_i::CreateMultiConnection2D()
1683 SMESH::MultiConnection2D_i* aServant = new SMESH::MultiConnection2D_i();
1684 SMESH::MultiConnection2D_var anObj = aServant->_this();
1685 TPythonDump()<<aServant<<" = "<<this<<".CreateMultiConnection2D()";
1686 return anObj._retn();
1689 BelongToGeom_ptr FilterManager_i::CreateBelongToGeom()
1691 SMESH::BelongToGeom_i* aServant = new SMESH::BelongToGeom_i();
1692 SMESH::BelongToGeom_var anObj = aServant->_this();
1693 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGeom()";
1694 return anObj._retn();
1697 BelongToPlane_ptr FilterManager_i::CreateBelongToPlane()
1699 SMESH::BelongToPlane_i* aServant = new SMESH::BelongToPlane_i();
1700 SMESH::BelongToPlane_var anObj = aServant->_this();
1701 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToPlane()";
1702 return anObj._retn();
1705 BelongToCylinder_ptr FilterManager_i::CreateBelongToCylinder()
1707 SMESH::BelongToCylinder_i* aServant = new SMESH::BelongToCylinder_i();
1708 SMESH::BelongToCylinder_var anObj = aServant->_this();
1709 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToCylinder()";
1710 return anObj._retn();
1713 BelongToGenSurface_ptr FilterManager_i::CreateBelongToGenSurface()
1715 SMESH::BelongToGenSurface_i* aServant = new SMESH::BelongToGenSurface_i();
1716 SMESH::BelongToGenSurface_var anObj = aServant->_this();
1717 TPythonDump()<<aServant<<" = "<<this<<".CreateBelongToGenSurface()";
1718 return anObj._retn();
1721 LyingOnGeom_ptr FilterManager_i::CreateLyingOnGeom()
1723 SMESH::LyingOnGeom_i* aServant = new SMESH::LyingOnGeom_i();
1724 SMESH::LyingOnGeom_var anObj = aServant->_this();
1725 TPythonDump()<<aServant<<" = "<<this<<".CreateLyingOnGeom()";
1726 return anObj._retn();
1729 FreeBorders_ptr FilterManager_i::CreateFreeBorders()
1731 SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i();
1732 SMESH::FreeBorders_var anObj = aServant->_this();
1733 TPythonDump()<<aServant<<" = "<<this<<".CreateFreeBorders()";
1734 return anObj._retn();
1737 FreeEdges_ptr FilterManager_i::CreateFreeEdges()
1739 SMESH::FreeEdges_i* aServant = new SMESH::FreeEdges_i();
1740 SMESH::FreeEdges_var anObj = aServant->_this();
1741 TPythonDump()<<aServant<<" = "<<this<<".CreateFreeEdges()";
1742 return anObj._retn();
1745 RangeOfIds_ptr FilterManager_i::CreateRangeOfIds()
1747 SMESH::RangeOfIds_i* aServant = new SMESH::RangeOfIds_i();
1748 SMESH::RangeOfIds_var anObj = aServant->_this();
1749 TPythonDump()<<aServant<<" = "<<this<<".CreateRangeOfIds()";
1750 return anObj._retn();
1753 BadOrientedVolume_ptr FilterManager_i::CreateBadOrientedVolume()
1755 SMESH::BadOrientedVolume_i* aServant = new SMESH::BadOrientedVolume_i();
1756 SMESH::BadOrientedVolume_var anObj = aServant->_this();
1757 TPythonDump()<<aServant<<" = "<<this<<".CreateBadOrientedVolume()";
1758 return anObj._retn();
1761 LessThan_ptr FilterManager_i::CreateLessThan()
1763 SMESH::LessThan_i* aServant = new SMESH::LessThan_i();
1764 SMESH::LessThan_var anObj = aServant->_this();
1765 TPythonDump()<<aServant<<" = "<<this<<".CreateLessThan()";
1766 return anObj._retn();
1770 MoreThan_ptr FilterManager_i::CreateMoreThan()
1772 SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i();
1773 SMESH::MoreThan_var anObj = aServant->_this();
1774 TPythonDump()<<aServant<<" = "<<this<<".CreateMoreThan()";
1775 return anObj._retn();
1778 EqualTo_ptr FilterManager_i::CreateEqualTo()
1780 SMESH::EqualTo_i* aServant = new SMESH::EqualTo_i();
1781 SMESH::EqualTo_var anObj = aServant->_this();
1782 TPythonDump()<<aServant<<" = "<<this<<".CreateEqualTo()";
1783 return anObj._retn();
1787 LogicalNOT_ptr FilterManager_i::CreateLogicalNOT()
1789 SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i();
1790 SMESH::LogicalNOT_var anObj = aServant->_this();
1791 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalNOT()";
1792 return anObj._retn();
1796 LogicalAND_ptr FilterManager_i::CreateLogicalAND()
1798 SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i();
1799 SMESH::LogicalAND_var anObj = aServant->_this();
1800 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalAND()";
1801 return anObj._retn();
1805 LogicalOR_ptr FilterManager_i::CreateLogicalOR()
1807 SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i();
1808 SMESH::LogicalOR_var anObj = aServant->_this();
1809 TPythonDump()<<aServant<<" = "<<this<<".CreateLogicalOR()";
1810 return anObj._retn();
1813 Filter_ptr FilterManager_i::CreateFilter()
1815 SMESH::Filter_i* aServant = new SMESH::Filter_i();
1816 SMESH::Filter_var anObj = aServant->_this();
1817 TPythonDump()<<aServant<<" = "<<this<<".CreateFilter()";
1818 return anObj._retn();
1821 FilterLibrary_ptr FilterManager_i::LoadLibrary( const char* aFileName )
1823 SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i( aFileName );
1824 SMESH::FilterLibrary_var anObj = aServant->_this();
1825 TPythonDump()<<aServant<<" = "<<this<<".LoadLibrary("<<aFileName<<")";
1826 return anObj._retn();
1829 FilterLibrary_ptr FilterManager_i::CreateLibrary()
1831 SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i();
1832 SMESH::FilterLibrary_var anObj = aServant->_this();
1833 TPythonDump()<<aServant<<" = "<<this<<".CreateLibrary()";
1834 return anObj._retn();
1837 CORBA::Boolean FilterManager_i::DeleteLibrary( const char* aFileName )
1839 TPythonDump()<<this<<".DeleteLibrary("<<aFileName<<")";
1840 return remove( aFileName ) ? false : true;
1843 //=============================================================================
1845 * SMESH_Gen_i::CreateFilterManager
1847 * Create filter manager
1849 //=============================================================================
1851 SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager()
1853 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
1854 SMESH::FilterManager_var anObj = aFilter->_this();
1855 return anObj._retn();
1863 //=======================================================================
1864 // name : Filter_i::Filter_i
1865 // Purpose : Constructor
1866 //=======================================================================
1867 Filter_i::Filter_i()
1868 : myPredicate( NULL )
1871 //=======================================================================
1872 // name : Filter_i::~Filter_i
1873 // Purpose : Destructor
1874 //=======================================================================
1875 Filter_i::~Filter_i()
1878 myPredicate->Destroy();
1880 if(!CORBA::is_nil(myMesh))
1883 //TPythonDump()<<this<<".Destroy()";
1886 //=======================================================================
1887 // name : Filter_i::SetPredicate
1888 // Purpose : Set predicate
1889 //=======================================================================
1890 void Filter_i::SetPredicate( Predicate_ptr thePredicate )
1893 myPredicate->Destroy();
1895 myPredicate = SMESH::GetPredicate(thePredicate);
1899 myFilter.SetPredicate( myPredicate->GetPredicate() );
1900 myPredicate->Register();
1901 TPythonDump()<<this<<".SetPredicate("<<myPredicate<<")";
1905 //=======================================================================
1906 // name : Filter_i::GetElementType
1907 // Purpose : Get entity type
1908 //=======================================================================
1909 SMESH::ElementType Filter_i::GetElementType()
1911 return myPredicate != 0 ? myPredicate->GetElementType() : SMESH::ALL;
1914 //=======================================================================
1915 // name : Filter_i::SetMesh
1916 // Purpose : Set mesh
1917 //=======================================================================
1920 SetMesh( SMESH_Mesh_ptr theMesh )
1922 if(!CORBA::is_nil(theMesh))
1923 theMesh->Register();
1925 if(!CORBA::is_nil(myMesh))
1929 TPythonDump()<<this<<".SetMesh("<<theMesh<<")";
1936 return GetElementsId(myMesh);
1939 //=======================================================================
1940 // name : Filter_i::GetElementsId
1941 // Purpose : Get ids of entities
1942 //=======================================================================
1945 GetElementsId( Predicate_i* thePredicate,
1946 const SMDS_Mesh* theMesh,
1947 Controls::Filter::TIdSequence& theSequence )
1950 Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
1955 GetElementsId( Predicate_i* thePredicate,
1956 SMESH_Mesh_ptr theMesh,
1957 Controls::Filter::TIdSequence& theSequence )
1960 if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
1961 Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
1966 GetElementsId( SMESH_Mesh_ptr theMesh )
1968 SMESH::long_array_var anArray = new SMESH::long_array;
1969 if(!CORBA::is_nil(theMesh) && myPredicate){
1970 Controls::Filter::TIdSequence aSequence;
1971 GetElementsId(myPredicate,theMesh,aSequence);
1972 long i = 0, iEnd = aSequence.size();
1973 anArray->length( iEnd );
1974 for ( ; i < iEnd; i++ )
1975 anArray[ i ] = aSequence[i];
1977 return anArray._retn();
1980 //=======================================================================
1981 // name : getCriteria
1982 // Purpose : Retrieve criterions from predicate
1983 //=======================================================================
1984 static inline bool getCriteria( Predicate_i* thePred,
1985 SMESH::Filter::Criteria_out theCriteria )
1987 int aFType = thePred->GetFunctorType();
1991 case FT_FreeBorders:
1994 CORBA::ULong i = theCriteria->length();
1995 theCriteria->length( i + 1 );
1997 theCriteria[ i ] = createCriterion();
1999 theCriteria[ i ].Type = aFType;
2000 theCriteria[ i ].TypeOfElement = thePred->GetElementType();
2003 case FT_BelongToGeom:
2005 BelongToGeom_i* aPred = dynamic_cast<BelongToGeom_i*>( thePred );
2007 CORBA::ULong i = theCriteria->length();
2008 theCriteria->length( i + 1 );
2010 theCriteria[ i ] = createCriterion();
2012 theCriteria[ i ].Type = FT_BelongToGeom;
2013 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2014 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2015 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2016 theCriteria[ i ].Tolerance = aPred->GetTolerance();
2020 case FT_BelongToPlane:
2021 case FT_BelongToCylinder:
2022 case FT_BelongToGenSurface:
2024 BelongToSurface_i* aPred = dynamic_cast<BelongToSurface_i*>( thePred );
2026 CORBA::ULong i = theCriteria->length();
2027 theCriteria->length( i + 1 );
2029 theCriteria[ i ] = createCriterion();
2031 theCriteria[ i ].Type = aFType;
2032 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2033 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2034 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2035 theCriteria[ i ].Tolerance = aPred->GetTolerance();
2039 case FT_LyingOnGeom:
2041 LyingOnGeom_i* aPred = dynamic_cast<LyingOnGeom_i*>( thePred );
2043 CORBA::ULong i = theCriteria->length();
2044 theCriteria->length( i + 1 );
2046 theCriteria[ i ] = createCriterion();
2048 theCriteria[ i ].Type = FT_LyingOnGeom;
2049 theCriteria[ i ].ThresholdStr = aPred->GetShapeName();
2050 theCriteria[ i ].ThresholdID = aPred->GetShapeID();
2051 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2052 theCriteria[ i ].Tolerance = aPred->GetTolerance();
2058 RangeOfIds_i* aPred = dynamic_cast<RangeOfIds_i*>( thePred );
2060 CORBA::ULong i = theCriteria->length();
2061 theCriteria->length( i + 1 );
2063 theCriteria[ i ] = createCriterion();
2065 theCriteria[ i ].Type = FT_RangeOfIds;
2066 theCriteria[ i ].ThresholdStr = aPred->GetRangeStr();
2067 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2071 case FT_BadOrientedVolume:
2073 BadOrientedVolume_i* aPred = dynamic_cast<BadOrientedVolume_i*>( thePred );
2075 CORBA::ULong i = theCriteria->length();
2076 theCriteria->length( i + 1 );
2078 theCriteria[ i ] = createCriterion();
2080 theCriteria[ i ].Type = FT_BadOrientedVolume;
2081 theCriteria[ i ].TypeOfElement = aPred->GetElementType();
2089 Comparator_i* aCompar = dynamic_cast<Comparator_i*>( thePred );
2091 CORBA::ULong i = theCriteria->length();
2092 theCriteria->length( i + 1 );
2094 theCriteria[ i ] = createCriterion();
2096 theCriteria[ i ].Type = aCompar->GetNumFunctor_i()->GetFunctorType();
2097 theCriteria[ i ].Compare = aFType;
2098 theCriteria[ i ].Threshold = aCompar->GetMargin();
2099 theCriteria[ i ].TypeOfElement = aCompar->GetElementType();
2101 if ( aFType == FT_EqualTo )
2103 EqualTo_i* aCompar = dynamic_cast<EqualTo_i*>( thePred );
2104 theCriteria[ i ].Tolerance = aCompar->GetTolerance();
2111 Predicate_i* aPred = ( dynamic_cast<LogicalNOT_i*>( thePred ) )->GetPredicate_i();
2112 getCriteria( aPred, theCriteria );
2113 theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT;
2120 Predicate_i* aPred1 = ( dynamic_cast<LogicalBinary_i*>( thePred ) )->GetPredicate1_i();
2121 Predicate_i* aPred2 = ( dynamic_cast<LogicalBinary_i*>( thePred ) )->GetPredicate2_i();
2122 if ( !getCriteria( aPred1, theCriteria ) )
2124 theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType;
2125 return getCriteria( aPred2, theCriteria );
2135 //=======================================================================
2136 // name : Filter_i::GetCriteria
2137 // Purpose : Retrieve criterions from predicate
2138 //=======================================================================
2139 CORBA::Boolean Filter_i::GetCriteria( SMESH::Filter::Criteria_out theCriteria )
2141 theCriteria = new SMESH::Filter::Criteria;
2142 return myPredicate != 0 ? getCriteria( myPredicate, theCriteria ) : true;
2145 //=======================================================================
2146 // name : Filter_i::SetCriteria
2147 // Purpose : Create new predicate and set criterions in it
2148 //=======================================================================
2149 CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria )
2151 if ( myPredicate != 0 )
2152 myPredicate->Destroy();
2154 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
2155 FilterManager_ptr aFilterMgr = aFilter->_this();
2157 // CREATE two lists ( PREDICATES and LOG OP )
2160 TPythonDump()<<"aCriteria = []";
2161 std::list<SMESH::Predicate_ptr> aPredicates;
2162 std::list<int> aBinaries;
2163 for ( int i = 0, n = theCriteria.length(); i < n; i++ )
2165 int aCriterion = theCriteria[ i ].Type;
2166 int aCompare = theCriteria[ i ].Compare;
2167 double aThreshold = theCriteria[ i ].Threshold;
2168 const char* aThresholdStr = theCriteria[ i ].ThresholdStr;
2169 const char* aThresholdID = theCriteria[ i ].ThresholdID;
2170 int aUnary = theCriteria[ i ].UnaryOp;
2171 int aBinary = theCriteria[ i ].BinaryOp;
2172 double aTolerance = theCriteria[ i ].Tolerance;
2173 ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement;
2174 long aPrecision = theCriteria[ i ].Precision;
2178 pd << "aCriterion = SMESH.Filter.Criterion(" << aCriterion << "," << aCompare
2179 << "," << aThreshold << ",'" << aThresholdStr;
2181 pd << "',salome.ObjectToID(" << aThresholdID
2182 << ")," << aUnary << "," << aBinary << "," << aTolerance
2183 << "," << aTypeOfElem << "," << aPrecision << ")";
2185 pd << "',''," << aUnary << "," << aBinary << "," << aTolerance
2186 << "," << aTypeOfElem << "," << aPrecision << ")";
2189 SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil();
2190 SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil();
2192 switch ( aCriterion )
2196 case SMESH::FT_MultiConnection:
2197 aFunctor = aFilterMgr->CreateMultiConnection();
2199 case SMESH::FT_MultiConnection2D:
2200 aFunctor = aFilterMgr->CreateMultiConnection2D();
2202 case SMESH::FT_Length:
2203 aFunctor = aFilterMgr->CreateLength();
2205 case SMESH::FT_Length2D:
2206 aFunctor = aFilterMgr->CreateLength2D();
2208 case SMESH::FT_AspectRatio:
2209 aFunctor = aFilterMgr->CreateAspectRatio();
2211 case SMESH::FT_AspectRatio3D:
2212 aFunctor = aFilterMgr->CreateAspectRatio3D();
2214 case SMESH::FT_Warping:
2215 aFunctor = aFilterMgr->CreateWarping();
2217 case SMESH::FT_MinimumAngle:
2218 aFunctor = aFilterMgr->CreateMinimumAngle();
2220 case SMESH::FT_Taper:
2221 aFunctor = aFilterMgr->CreateTaper();
2223 case SMESH::FT_Skew:
2224 aFunctor = aFilterMgr->CreateSkew();
2226 case SMESH::FT_Area:
2227 aFunctor = aFilterMgr->CreateArea();
2229 case SMESH::FT_Volume3D:
2230 aFunctor = aFilterMgr->CreateVolume3D();
2235 case SMESH::FT_FreeBorders:
2236 aPredicate = aFilterMgr->CreateFreeBorders();
2238 case SMESH::FT_FreeEdges:
2239 aPredicate = aFilterMgr->CreateFreeEdges();
2241 case SMESH::FT_BelongToGeom:
2243 SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom();
2244 tmpPred->SetElementType( aTypeOfElem );
2245 tmpPred->SetShape( aThresholdID, aThresholdStr );
2246 tmpPred->SetTolerance( aTolerance );
2247 aPredicate = tmpPred;
2250 case SMESH::FT_BelongToPlane:
2251 case SMESH::FT_BelongToCylinder:
2252 case SMESH::FT_BelongToGenSurface:
2254 SMESH::BelongToSurface_ptr tmpPred;
2255 switch ( aCriterion ) {
2256 case SMESH::FT_BelongToPlane:
2257 tmpPred = aFilterMgr->CreateBelongToPlane(); break;
2258 case SMESH::FT_BelongToCylinder:
2259 tmpPred = aFilterMgr->CreateBelongToCylinder(); break;
2261 tmpPred = aFilterMgr->CreateBelongToGenSurface();
2263 tmpPred->SetShape( aThresholdID, aThresholdStr, aTypeOfElem );
2264 tmpPred->SetTolerance( aTolerance );
2265 aPredicate = tmpPred;
2268 case SMESH::FT_LyingOnGeom:
2270 SMESH::LyingOnGeom_ptr tmpPred = aFilterMgr->CreateLyingOnGeom();
2271 tmpPred->SetElementType( aTypeOfElem );
2272 tmpPred->SetShape( aThresholdID, aThresholdStr );
2273 tmpPred->SetTolerance( aTolerance );
2274 aPredicate = tmpPred;
2277 case SMESH::FT_RangeOfIds:
2279 SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds();
2280 tmpPred->SetRangeStr( aThresholdStr );
2281 tmpPred->SetElementType( aTypeOfElem );
2282 aPredicate = tmpPred;
2285 case SMESH::FT_BadOrientedVolume:
2287 aPredicate = aFilterMgr->CreateBadOrientedVolume();
2296 if ( !aFunctor->_is_nil() && aPredicate->_is_nil() )
2298 SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil();
2300 if ( aCompare == SMESH::FT_LessThan )
2301 aComparator = aFilterMgr->CreateLessThan();
2302 else if ( aCompare == SMESH::FT_MoreThan )
2303 aComparator = aFilterMgr->CreateMoreThan();
2304 else if ( aCompare == SMESH::FT_EqualTo )
2305 aComparator = aFilterMgr->CreateEqualTo();
2309 aComparator->SetNumFunctor( aFunctor );
2310 aComparator->SetMargin( aThreshold );
2312 if ( aCompare == FT_EqualTo )
2314 SMESH::EqualTo_var anEqualTo = SMESH::EqualTo::_narrow( aComparator );
2315 anEqualTo->SetTolerance( aTolerance );
2318 aPredicate = aComparator;
2320 aFunctor->SetPrecision( aPrecision );
2324 if ( aUnary == FT_LogicalNOT )
2326 SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT();
2327 aNotPred->SetPredicate( aPredicate );
2328 aPredicate = aNotPred;
2332 aPredicates.push_back( aPredicate );
2333 aBinaries.push_back( aBinary );
2334 TPythonDump()<<"aCriteria.append(aCriterion)";
2337 TPythonDump()<<this<<".SetCriteria(aCriteria)";
2339 // CREATE ONE PREDICATE FROM PREVIOUSLY CREATED MAP
2341 // combine all "AND" operations
2343 std::list<SMESH::Predicate_ptr> aResList;
2345 std::list<SMESH::Predicate_ptr>::iterator aPredIter;
2346 std::list<int>::iterator aBinaryIter;
2348 SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil();
2349 int aPrevBinary = SMESH::FT_Undefined;
2351 for ( aPredIter = aPredicates.begin(), aBinaryIter = aBinaries.begin();
2352 aPredIter != aPredicates.end() && aBinaryIter != aBinaries.end();
2353 ++aPredIter, ++aBinaryIter )
2355 int aCurrBinary = *aBinaryIter;
2357 SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil();
2359 if ( aPrevBinary == SMESH::FT_LogicalAND )
2362 SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND();
2363 aBinaryPred->SetPredicate1( aPrevPredicate );
2364 aBinaryPred->SetPredicate2( *aPredIter );
2365 aCurrPred = aBinaryPred;
2368 aCurrPred = *aPredIter;
2370 if ( aCurrBinary != SMESH::FT_LogicalAND )
2371 aResList.push_back( aCurrPred );
2373 aPrevPredicate = aCurrPred;
2374 aPrevBinary = aCurrBinary;
2377 // combine all "OR" operations
2379 SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil();
2381 if ( aResList.size() == 1 )
2382 aResPredicate = *aResList.begin();
2383 else if ( aResList.size() > 1 )
2385 std::list<SMESH::Predicate_ptr>::iterator anIter = aResList.begin();
2386 aResPredicate = *anIter;
2388 for ( ; anIter != aResList.end(); ++anIter )
2390 SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR();
2391 aBinaryPred->SetPredicate1( aResPredicate );
2392 aBinaryPred->SetPredicate2( *anIter );
2393 aResPredicate = aBinaryPred;
2397 SetPredicate( aResPredicate );
2399 return !aResPredicate->_is_nil();
2402 //=======================================================================
2403 // name : Filter_i::GetPredicate_i
2404 // Purpose : Get implementation of predicate
2405 //=======================================================================
2406 Predicate_i* Filter_i::GetPredicate_i()
2411 //=======================================================================
2412 // name : Filter_i::GetPredicate
2413 // Purpose : Get predicate
2414 //=======================================================================
2415 Predicate_ptr Filter_i::GetPredicate()
2417 if ( myPredicate == 0 )
2418 return SMESH::Predicate::_nil();
2421 SMESH::Predicate_var anObj = myPredicate->_this();
2422 return anObj._retn();
2430 #define ATTR_TYPE "type"
2431 #define ATTR_COMPARE "compare"
2432 #define ATTR_THRESHOLD "threshold"
2433 #define ATTR_UNARY "unary"
2434 #define ATTR_BINARY "binary"
2435 #define ATTR_THRESHOLD_STR "threshold_str"
2436 #define ATTR_TOLERANCE "tolerance"
2437 #define ATTR_ELEMENT_TYPE "ElementType"
2439 //=======================================================================
2441 // Purpose : Convert bool to LDOMString
2442 //=======================================================================
2443 static inline LDOMString toString( CORBA::Boolean val )
2445 return val ? "logical not" : "";
2448 //=======================================================================
2450 // Purpose : Convert LDOMString to bool
2451 //=======================================================================
2452 static inline bool toBool( const LDOMString& theStr )
2454 return theStr.equals( "logical not" );
2457 //=======================================================================
2459 // Purpose : Convert double to LDOMString
2460 //=======================================================================
2461 static inline LDOMString toString( CORBA::Double val )
2464 sprintf( a, "%e", val );
2465 return LDOMString( a );
2468 //=======================================================================
2470 // Purpose : Convert LDOMString to double
2471 //=======================================================================
2472 static inline double toDouble( const LDOMString& theStr )
2474 return atof( theStr.GetString() );
2477 //=======================================================================
2479 // Purpose : Convert functor type to LDOMString
2480 //=======================================================================
2481 static inline LDOMString toString( CORBA::Long theType )
2485 case FT_AspectRatio : return "Aspect ratio";
2486 case FT_Warping : return "Warping";
2487 case FT_MinimumAngle : return "Minimum angle";
2488 case FT_Taper : return "Taper";
2489 case FT_Skew : return "Skew";
2490 case FT_Area : return "Area";
2491 case FT_Volume3D : return "Volume3D";
2492 case FT_BelongToGeom : return "Belong to Geom";
2493 case FT_BelongToPlane : return "Belong to Plane";
2494 case FT_BelongToCylinder: return "Belong to Cylinder";
2495 case FT_BelongToGenSurface: return "Belong to Generic Surface";
2496 case FT_LyingOnGeom : return "Lying on Geom";
2497 case FT_BadOrientedVolume: return "Bad Oriented Volume";
2498 case FT_RangeOfIds : return "Range of IDs";
2499 case FT_FreeBorders : return "Free borders";
2500 case FT_FreeEdges : return "Free edges";
2501 case FT_MultiConnection : return "Borders at multi-connections";
2502 case FT_MultiConnection2D: return "Borders at multi-connections 2D";
2503 case FT_Length : return "Length";
2504 case FT_Length2D : return "Length2D";
2505 case FT_LessThan : return "Less than";
2506 case FT_MoreThan : return "More than";
2507 case FT_EqualTo : return "Equal to";
2508 case FT_LogicalNOT : return "Not";
2509 case FT_LogicalAND : return "And";
2510 case FT_LogicalOR : return "Or";
2511 case FT_Undefined : return "";
2512 default : return "";
2516 //=======================================================================
2517 // name : toFunctorType
2518 // Purpose : Convert LDOMString to functor type
2519 //=======================================================================
2520 static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr )
2522 if ( theStr.equals( "Aspect ratio" ) ) return FT_AspectRatio;
2523 else if ( theStr.equals( "Warping" ) ) return FT_Warping;
2524 else if ( theStr.equals( "Minimum angle" ) ) return FT_MinimumAngle;
2525 else if ( theStr.equals( "Taper" ) ) return FT_Taper;
2526 else if ( theStr.equals( "Skew" ) ) return FT_Skew;
2527 else if ( theStr.equals( "Area" ) ) return FT_Area;
2528 else if ( theStr.equals( "Volume3D" ) ) return FT_Volume3D;
2529 else if ( theStr.equals( "Belong to Geom" ) ) return FT_BelongToGeom;
2530 else if ( theStr.equals( "Belong to Plane" ) ) return FT_BelongToPlane;
2531 else if ( theStr.equals( "Belong to Cylinder" ) ) return FT_BelongToCylinder;
2532 else if ( theStr.equals( "Belong to Generic Surface" ) ) return FT_BelongToGenSurface;
2533 else if ( theStr.equals( "Lying on Geom" ) ) return FT_LyingOnGeom;
2534 else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders;
2535 else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges;
2536 else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection;
2537 // else if ( theStr.equals( "Borders at multi-connections 2D" ) ) return FT_MultiConnection2D;
2538 else if ( theStr.equals( "Length" ) ) return FT_Length;
2539 // else if ( theStr.equals( "Length2D" ) ) return FT_Length2D;
2540 else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds;
2541 else if ( theStr.equals( "Bad Oriented Volume" ) ) return FT_BadOrientedVolume;
2542 else if ( theStr.equals( "Less than" ) ) return FT_LessThan;
2543 else if ( theStr.equals( "More than" ) ) return FT_MoreThan;
2544 else if ( theStr.equals( "Equal to" ) ) return FT_EqualTo;
2545 else if ( theStr.equals( "Not" ) ) return FT_LogicalNOT;
2546 else if ( theStr.equals( "And" ) ) return FT_LogicalAND;
2547 else if ( theStr.equals( "Or" ) ) return FT_LogicalOR;
2548 else if ( theStr.equals( "" ) ) return FT_Undefined;
2549 else return FT_Undefined;
2552 //=======================================================================
2553 // name : toFunctorType
2554 // Purpose : Convert LDOMString to value of ElementType enumeration
2555 //=======================================================================
2556 static inline SMESH::ElementType toElementType( const LDOMString& theStr )
2558 if ( theStr.equals( "NODE" ) ) return SMESH::NODE;
2559 else if ( theStr.equals( "EDGE" ) ) return SMESH::EDGE;
2560 else if ( theStr.equals( "FACE" ) ) return SMESH::FACE;
2561 else if ( theStr.equals( "VOLUME" ) ) return SMESH::VOLUME;
2562 else return SMESH::ALL;
2565 //=======================================================================
2567 // Purpose : Convert ElementType to string
2568 //=======================================================================
2569 static inline LDOMString toString( const SMESH::ElementType theType )
2573 case SMESH::NODE : return "NODE";
2574 case SMESH::EDGE : return "EDGE";
2575 case SMESH::FACE : return "FACE";
2576 case SMESH::VOLUME : return "VOLUME";
2577 case SMESH::ALL : return "ALL";
2578 default : return "";
2582 //=======================================================================
2583 // name : findFilter
2584 // Purpose : Find filter in document
2585 //=======================================================================
2586 static LDOM_Element findFilter( const char* theFilterName,
2587 const LDOM_Document& theDoc,
2588 LDOM_Node* theParent = 0 )
2590 LDOM_Element aRootElement = theDoc.getDocumentElement();
2591 if ( aRootElement.isNull() || !aRootElement.hasChildNodes() )
2592 return LDOM_Element();
2594 for ( LDOM_Node aTypeNode = aRootElement.getFirstChild();
2595 !aTypeNode.isNull(); aTypeNode = aTypeNode.getNextSibling() )
2597 for ( LDOM_Node aFilter = aTypeNode.getFirstChild();
2598 !aFilter.isNull(); aFilter = aFilter.getNextSibling() )
2600 LDOM_Element* anElem = ( LDOM_Element* )&aFilter;
2601 if ( anElem->getTagName().equals( LDOMString( "filter" ) ) &&
2602 anElem->getAttribute( "name" ).equals( LDOMString( theFilterName ) ) )
2604 if ( theParent != 0 )
2605 *theParent = aTypeNode;
2606 return (LDOM_Element&)aFilter;
2610 return LDOM_Element();
2613 //=======================================================================
2614 // name : getSectionName
2615 // Purpose : Get name of section of filters
2616 //=======================================================================
2617 static const char* getSectionName( const ElementType theType )
2621 case SMESH::NODE : return "Filters for nodes";
2622 case SMESH::EDGE : return "Filters for edges";
2623 case SMESH::FACE : return "Filters for faces";
2624 case SMESH::VOLUME : return "Filters for volumes";
2625 case SMESH::ALL : return "Filters for elements";
2626 default : return "";
2630 //=======================================================================
2631 // name : getSection
2632 // Purpose : Create section for filters corresponding to the entity type
2633 //=======================================================================
2634 static LDOM_Node getSection( const ElementType theType,
2635 LDOM_Document& theDoc,
2636 const bool toCreate = false )
2638 LDOM_Element aRootElement = theDoc.getDocumentElement();
2639 if ( aRootElement.isNull() )
2643 bool anExist = false;
2644 const char* aSectionName = getSectionName( theType );
2645 if ( strcmp( aSectionName, "" ) == 0 )
2648 LDOM_NodeList aSections = theDoc.getElementsByTagName( "section" );
2650 for ( int i = 0, n = aSections.getLength(); i < n; i++ )
2652 aNode = aSections.item( i );
2653 LDOM_Element& anItem = ( LDOM_Element& )aNode;
2654 if ( anItem.getAttribute( "name" ).equals( LDOMString( aSectionName ) ) )
2661 // Create new section if necessary
2666 LDOM_Element aNewItem = theDoc.createElement( "section" );
2667 aNewItem.setAttribute( "name", aSectionName );
2668 aRootElement.appendChild( aNewItem );
2678 //=======================================================================
2679 // name : createFilterItem
2680 // Purpose : Create filter item or LDOM document
2681 //=======================================================================
2682 static LDOM_Element createFilterItem( const char* theName,
2683 SMESH::Filter_ptr theFilter,
2684 LDOM_Document& theDoc )
2686 // create new filter in document
2687 LDOM_Element aFilterItem = theDoc.createElement( "filter" );
2688 aFilterItem.setAttribute( "name", theName );
2690 // save filter criterions
2691 SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria;
2693 if ( !theFilter->GetCriteria( aCriteria ) )
2694 return LDOM_Element();
2696 for ( CORBA::ULong i = 0, n = aCriteria->length(); i < n; i++ )
2698 LDOM_Element aCriterionItem = theDoc.createElement( "criterion" );
2700 aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type) );
2701 aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) );
2702 aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) );
2703 aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) );
2704 aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) );
2706 aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr );
2707 aCriterionItem.setAttribute( ATTR_TOLERANCE , toString( aCriteria[ i ].Tolerance ) );
2708 aCriterionItem.setAttribute( ATTR_ELEMENT_TYPE ,
2709 toString( (SMESH::ElementType)aCriteria[ i ].TypeOfElement ) );
2711 aFilterItem.appendChild( aCriterionItem );
2717 //=======================================================================
2718 // name : FilterLibrary_i::FilterLibrary_i
2719 // Purpose : Constructor
2720 //=======================================================================
2721 FilterLibrary_i::FilterLibrary_i( const char* theFileName )
2723 myFileName = strdup( theFileName );
2724 SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i();
2725 myFilterMgr = aFilterMgr->_this();
2729 // Try to use existing library file
2730 bool anExists = false;
2731 if ( !aParser.parse( myFileName ) )
2733 myDoc = aParser.getDocument();
2736 // Create a new XML document if it doesn't exist
2738 myDoc = LDOM_Document::createDocument( LDOMString() );
2740 LDOM_Element aRootElement = myDoc.getDocumentElement();
2741 if ( aRootElement.isNull() )
2743 // If the existing document is empty --> try to create a new one
2745 myDoc = LDOM_Document::createDocument( LDOMString() );
2749 //=======================================================================
2750 // name : FilterLibrary_i::FilterLibrary_i
2751 // Purpose : Constructor
2752 //=======================================================================
2753 FilterLibrary_i::FilterLibrary_i()
2756 SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i();
2757 myFilterMgr = aFilter->_this();
2759 myDoc = LDOM_Document::createDocument( LDOMString() );
2762 FilterLibrary_i::~FilterLibrary_i()
2765 //TPythonDump()<<this<<".Destroy()";
2768 //=======================================================================
2769 // name : FilterLibrary_i::Copy
2770 // Purpose : Create filter and initialize it with values from library
2771 //=======================================================================
2772 Filter_ptr FilterLibrary_i::Copy( const char* theFilterName )
2774 Filter_ptr aRes = Filter::_nil();
2775 LDOM_Node aFilter = findFilter( theFilterName, myDoc );
2777 if ( aFilter.isNull() )
2780 std::list<SMESH::Filter::Criterion> aCriteria;
2782 for ( LDOM_Node aCritNode = aFilter.getFirstChild();
2783 !aCritNode.isNull() ; aCritNode = aCritNode.getNextSibling() )
2785 LDOM_Element* aCrit = (LDOM_Element*)&aCritNode;
2787 const char* aTypeStr = aCrit->getAttribute( ATTR_TYPE ).GetString();
2788 const char* aCompareStr = aCrit->getAttribute( ATTR_COMPARE ).GetString();
2789 const char* aUnaryStr = aCrit->getAttribute( ATTR_UNARY ).GetString();
2790 const char* aBinaryStr = aCrit->getAttribute( ATTR_BINARY ).GetString();
2791 const char* anElemTypeStr = aCrit->getAttribute( ATTR_ELEMENT_TYPE ).GetString();
2793 SMESH::Filter::Criterion aCriterion = createCriterion();
2795 aCriterion.Type = toFunctorType( aTypeStr );
2796 aCriterion.Compare = toFunctorType( aCompareStr );
2797 aCriterion.UnaryOp = toFunctorType( aUnaryStr );
2798 aCriterion.BinaryOp = toFunctorType( aBinaryStr );
2800 aCriterion.TypeOfElement = toElementType( anElemTypeStr );
2802 LDOMString str = aCrit->getAttribute( ATTR_THRESHOLD );
2804 aCriterion.Threshold = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val )
2805 ? val : atof( str.GetString() );
2807 str = aCrit->getAttribute( ATTR_TOLERANCE );
2808 aCriterion.Tolerance = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val )
2809 ? val : atof( str.GetString() );
2811 str = aCrit->getAttribute( ATTR_THRESHOLD_STR );
2812 if ( str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) )
2815 sprintf( a, "%d", val );
2816 aCriterion.ThresholdStr = strdup( a );
2819 aCriterion.ThresholdStr = str.GetString();
2821 aCriteria.push_back( aCriterion );
2824 SMESH::Filter::Criteria_var aCriteriaVar = new SMESH::Filter::Criteria;
2825 aCriteriaVar->length( aCriteria.size() );
2828 std::list<SMESH::Filter::Criterion>::iterator anIter = aCriteria.begin();
2830 for( ; anIter != aCriteria.end(); ++anIter )
2831 aCriteriaVar[ i++ ] = *anIter;
2833 aRes = myFilterMgr->CreateFilter();
2834 aRes->SetCriteria( aCriteriaVar.inout() );
2836 TPythonDump()<<this<<".Copy('"<<theFilterName<<"')";
2841 //=======================================================================
2842 // name : FilterLibrary_i::SetFileName
2843 // Purpose : Set file name for library
2844 //=======================================================================
2845 void FilterLibrary_i::SetFileName( const char* theFileName )
2848 myFileName = strdup( theFileName );
2849 TPythonDump()<<this<<".SetFileName('"<<theFileName<<"')";
2852 //=======================================================================
2853 // name : FilterLibrary_i::GetFileName
2854 // Purpose : Get file name of library
2855 //=======================================================================
2856 char* FilterLibrary_i::GetFileName()
2858 return CORBA::string_dup( myFileName );
2861 //=======================================================================
2862 // name : FilterLibrary_i::Add
2863 // Purpose : Add new filter to library
2864 //=======================================================================
2865 CORBA::Boolean FilterLibrary_i::Add( const char* theFilterName, Filter_ptr theFilter )
2867 // if filter already in library or entry filter is null do nothing
2868 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc );
2869 if ( !aFilterNode.isNull() || theFilter->_is_nil() )
2872 // get section corresponding to the filter type
2873 ElementType anEntType = theFilter->GetElementType();
2875 LDOM_Node aSection = getSection( anEntType, myDoc, true );
2876 if ( aSection.isNull() )
2879 // create filter item
2880 LDOM_Element aFilterItem = createFilterItem( theFilterName, theFilter, myDoc );
2881 if ( aFilterItem.isNull() )
2885 aSection.appendChild( aFilterItem );
2886 if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
2887 TPythonDump()<<this<<".Add('"<<theFilterName<<"',"<<aFilter<<")";
2892 //=======================================================================
2893 // name : FilterLibrary_i::Add
2894 // Purpose : Add new filter to library
2895 //=======================================================================
2896 CORBA::Boolean FilterLibrary_i::AddEmpty( const char* theFilterName, ElementType theType )
2898 // if filter already in library or entry filter is null do nothing
2899 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc );
2900 if ( !aFilterNode.isNull() )
2903 LDOM_Node aSection = getSection( theType, myDoc, true );
2904 if ( aSection.isNull() )
2907 // create filter item
2908 Filter_var aFilter = myFilterMgr->CreateFilter();
2910 LDOM_Element aFilterItem = createFilterItem( theFilterName, aFilter, myDoc );
2911 if ( aFilterItem.isNull() )
2915 aSection.appendChild( aFilterItem );
2916 TPythonDump()<<this<<".AddEmpty('"<<theFilterName<<"',"<<theType<<")";
2921 //=======================================================================
2922 // name : FilterLibrary_i::Delete
2923 // Purpose : Delete filter from library
2924 //=======================================================================
2925 CORBA::Boolean FilterLibrary_i::Delete ( const char* theFilterName )
2927 LDOM_Node aParentNode;
2928 LDOM_Node aFilterNode = findFilter( theFilterName, myDoc, &aParentNode );
2929 if ( aFilterNode.isNull() || aParentNode.isNull() )
2932 aParentNode.removeChild( aFilterNode );
2933 TPythonDump()<<this<<".Delete('"<<theFilterName<<"')";
2937 //=======================================================================
2938 // name : FilterLibrary_i::Replace
2939 // Purpose : Replace existing filter with entry filter.
2940 // IMPORTANT : If filter does not exist it is not created
2941 //=======================================================================
2942 CORBA::Boolean FilterLibrary_i::Replace( const char* theFilterName,
2943 const char* theNewName,
2944 Filter_ptr theFilter )
2946 LDOM_Element aFilterItem = findFilter( theFilterName, myDoc );
2947 if ( aFilterItem.isNull() || theFilter->_is_nil() )
2950 LDOM_Element aNewItem = createFilterItem( theNewName, theFilter, myDoc );
2951 if ( aNewItem.isNull() )
2955 aFilterItem.ReplaceElement( aNewItem );
2956 if(Filter_i* aFilter = DownCast<Filter_i*>(theFilter))
2957 TPythonDump()<<this<<".Replace('"<<theFilterName<<"',"<<theNewName<<"',"<<aFilter<<")";
2962 //=======================================================================
2963 // name : FilterLibrary_i::Save
2964 // Purpose : Save library on disk
2965 //=======================================================================
2966 CORBA::Boolean FilterLibrary_i::Save()
2968 if ( myFileName == 0 || strlen( myFileName ) == 0 )
2971 FILE* aOutFile = fopen( myFileName, "wt" );
2975 LDOM_XmlWriter aWriter( aOutFile );
2976 aWriter.SetIndentation( 2 );
2980 TPythonDump()<<this<<".Save()";
2984 //=======================================================================
2985 // name : FilterLibrary_i::SaveAs
2986 // Purpose : Save library on disk
2987 //=======================================================================
2988 CORBA::Boolean FilterLibrary_i::SaveAs( const char* aFileName )
2990 myFileName = strdup ( aFileName );
2991 TPythonDump()<<this<<".SaveAs('"<<aFileName<<"')";
2995 //=======================================================================
2996 // name : FilterLibrary_i::IsPresent
2997 // Purpose : Verify whether filter is in library
2998 //=======================================================================
2999 CORBA::Boolean FilterLibrary_i::IsPresent( const char* theFilterName )
3001 return !findFilter( theFilterName, myDoc ).isNull();
3004 //=======================================================================
3005 // name : FilterLibrary_i::NbFilters
3006 // Purpose : Return amount of filters in library
3007 //=======================================================================
3008 CORBA::Long FilterLibrary_i::NbFilters( ElementType theType )
3010 string_array_var aNames = GetNames( theType );
3011 return aNames->length();
3014 //=======================================================================
3015 // name : FilterLibrary_i::GetNames
3016 // Purpose : Get names of filters from library
3017 //=======================================================================
3018 string_array* FilterLibrary_i::GetNames( ElementType theType )
3020 string_array_var anArray = new string_array;
3021 TColStd_SequenceOfHAsciiString aSeq;
3023 LDOM_Node aSection = getSection( theType, myDoc, false );
3025 if ( !aSection.isNull() )
3027 for ( LDOM_Node aFilter = aSection.getFirstChild();
3028 !aFilter.isNull(); aFilter = aFilter.getNextSibling() )
3030 LDOM_Element& anElem = ( LDOM_Element& )aFilter;
3031 aSeq.Append( new TCollection_HAsciiString(
3032 (Standard_CString)anElem.getAttribute( "name" ).GetString() ) );
3036 anArray->length( aSeq.Length() );
3037 for ( int i = 1, n = aSeq.Length(); i <= n; i++ )
3038 anArray[ i - 1 ] = CORBA::string_dup( aSeq( i )->ToCString() );
3040 return anArray._retn();
3043 //=======================================================================
3044 // name : FilterLibrary_i::GetAllNames
3045 // Purpose : Get names of filters from library
3046 //=======================================================================
3047 string_array* FilterLibrary_i::GetAllNames()
3049 string_array_var aResArray = new string_array;
3050 for ( int type = SMESH::ALL; type <= SMESH::VOLUME; type++ )
3052 SMESH::string_array_var aNames = GetNames( (SMESH::ElementType)type );
3054 int aPrevLength = aResArray->length();
3055 aResArray->length( aPrevLength + aNames->length() );
3056 for ( int i = 0, n = aNames->length(); i < n; i++ )
3057 aResArray[ aPrevLength + i ] = aNames[ i ];
3060 return aResArray._retn();