SMH: Preparation version 3.0.0 - merge (HEAD+POLYWORK)

This commit is contained in:
smh 2005-06-07 13:22:20 +00:00
parent e90b1a5ede
commit c38c10811a
192 changed files with 27939 additions and 19111 deletions

View File

@ -1,5 +1,6 @@
This is the version 2.2.0 of SMESH This is the version 3.0.0 of SMESH
Compatible with : Compatible with :
- KERNEL 2.2.0 - KERNEL 3.0.0
- GEOM 2.2.0 - GUI 3.0.0
- MED 2.2.0 - GEOM 3.0.0
- MED 3.0.0

View File

@ -53,6 +53,8 @@ mesh_line.png \
mesh_move_node.png \ mesh_move_node.png \
mesh_orientation.png \ mesh_orientation.png \
mesh.png \ mesh.png \
mesh_polygon.png \
mesh_polyhedron.png \
mesh_pyramid_n.png \ mesh_pyramid_n.png \
mesh_pyramid.png \ mesh_pyramid.png \
mesh_quad_n.png \ mesh_quad_n.png \

View File

@ -67,7 +67,7 @@ QT_MT_LIBS = @QT_MT_LIBS@
MOC = @MOC@ MOC = @MOC@
UIC = @UIC@ UIC = @UIC@
MSG2QM = @MSG2QM@
#QWT #QWT

View File

@ -327,11 +327,7 @@ distclean: clean
$(SWIG) $(SWIG_FLAGS) -o $@ $< $(SWIG) $(SWIG_FLAGS) -o $@ $<
$(top_builddir)/share/salome/resources/%.qm: %.po $(top_builddir)/share/salome/resources/%.qm: %.po
if test -e ${KERNEL_ROOT_DIR}/bin/salome/msg2qm ; then \ $(MSG2QM) $< $@ ; \
${KERNEL_ROOT_DIR}/bin/salome/msg2qm $< $@ ; \
else \
$(top_builddir)/bin/salome/msg2qm $< $@ ; \
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# The following section of this makefile contains dependencies between the # The following section of this makefile contains dependencies between the

View File

@ -1,2 +1,2 @@
THIS IS SALOME - SMESH VERSION: 2.2.0 THIS IS SALOME - SMESH VERSION: 3.0.0

View File

@ -217,6 +217,14 @@ echo
CHECK_QT CHECK_QT
echo
echo ---------------------------------------------
echo testing MSG2QM
echo ---------------------------------------------
echo
CHECK_MSG2QM
echo echo
echo --------------------------------------------- echo ---------------------------------------------
echo testing VTK echo testing VTK

View File

@ -278,7 +278,7 @@ module SMESH
/*! /*!
* Filter * Filter
*/ */
interface Filter: SALOME::GenericObj interface Filter: SALOME::GenericObj, SMESH_IDSource
{ {
/*! /*!
* Structure containing information about one criterion * Structure containing information about one criterion
@ -312,6 +312,8 @@ module SMESH
typedef sequence<Criterion> Criteria; typedef sequence<Criterion> Criteria;
void SetPredicate( in Predicate thePredicate ); void SetPredicate( in Predicate thePredicate );
void SetMesh( in SMESH_Mesh theMesh );
long_array GetElementsId( in SMESH_Mesh theMesh ); long_array GetElementsId( in SMESH_Mesh theMesh );
ElementType GetElementType(); ElementType GetElementType();
Predicate GetPredicate(); Predicate GetPredicate();

View File

@ -33,6 +33,8 @@
module SMESH module SMESH
{ {
interface Predicate;
/*! /*!
* SMESH_Group: base interface of group object * SMESH_Group: base interface of group object
*/ */
@ -98,11 +100,13 @@ module SMESH
* Adds elements to the group * Adds elements to the group
*/ */
long Add( in long_array elem_ids ); long Add( in long_array elem_ids );
long AddByPredicate( in Predicate thePredicate );
/*! /*!
* Removes elements from the group * Removes elements from the group
*/ */
long Remove( in long_array elem_ids ); long Remove( in long_array elem_ids );
long RemoveByPredicate( in Predicate thePredicate );
}; };
/*! /*!

View File

@ -58,14 +58,17 @@ module SMESH
ADD_EDGE, ADD_EDGE,
ADD_TRIANGLE, ADD_TRIANGLE,
ADD_QUADRANGLE, ADD_QUADRANGLE,
ADD_POLYGON,
ADD_TETRAHEDRON, ADD_TETRAHEDRON,
ADD_PYRAMID, ADD_PYRAMID,
ADD_PRISM, ADD_PRISM,
ADD_HEXAHEDRON, ADD_HEXAHEDRON,
ADD_POLYHEDRON,
REMOVE_NODE, REMOVE_NODE,
REMOVE_ELEMENT, REMOVE_ELEMENT,
MOVE_NODE, MOVE_NODE,
CHANGE_ELEMENT_NODES, CHANGE_ELEMENT_NODES,
CHANGE_POLYHEDRON_NODES,
RENUMBER RENUMBER
}; };
@ -375,6 +378,9 @@ module SMESH
long NbQuadrangles() long NbQuadrangles()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long NbPolygons()
raises (SALOME::SALOME_Exception);
long NbVolumes() long NbVolumes()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
@ -390,6 +396,9 @@ module SMESH
long NbPrisms() long NbPrisms()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
long NbPolyhedrons()
raises (SALOME::SALOME_Exception);
long NbSubMesh() long NbSubMesh()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
@ -461,7 +470,7 @@ module SMESH
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
}; };
/* /*!
* This interface makes modifications on the Mesh - removing elements and nodes etc. * This interface makes modifications on the Mesh - removing elements and nodes etc.
*/ */
interface NumericalFunctor; interface NumericalFunctor;
@ -480,6 +489,25 @@ module SMESH
boolean AddVolume(in long_array IDsOfNodes); boolean AddVolume(in long_array IDsOfNodes);
//boolean AddPolygonalFace (in long_array IdsOfNodes);
/*!
* Create volume of many faces, giving nodes for each face.
* \param IdsOfNodes List of node IDs for volume creation face by face.
* \param Quantities List of integer values, Quantities[i]
* gives quantity of nodes in face number i.
*/
boolean AddPolyhedralVolume (in long_array IdsOfNodes,
in long_array Quantities);
/*!
* Create volume of many faces, giving IDs of existing faces.
* \param IdsOfFaces List of face IDs for volume creation.
* \note The created volume will refer only to nodes
* of the given faces, not to the faces itself.
*/
boolean AddPolyhedralVolumeByFaces (in long_array IdsOfFaces);
boolean MoveNode(in long NodeID, in double x, in double y, in double z); boolean MoveNode(in long NodeID, in double x, in double y, in double z);
boolean InverseDiag(in long NodeID1, in long NodeID2); boolean InverseDiag(in long NodeID1, in long NodeID2);
@ -521,6 +549,18 @@ module SMESH
in double MaxAspectRatio, in double MaxAspectRatio,
in Smooth_Method Method); in Smooth_Method Method);
boolean SmoothParametric(in long_array IDsOfElements,
in long_array IDsOfFixedNodes,
in long MaxNbOfIterations,
in double MaxAspectRatio,
in Smooth_Method Method);
boolean SmoothParametricObject(in SMESH_IDSource theObject,
in long_array IDsOfFixedNodes,
in long MaxNbOfIterations,
in double MaxAspectRatio,
in Smooth_Method Method);
void RenumberNodes(); void RenumberNodes();
void RenumberElements(); void RenumberElements();
@ -637,7 +677,9 @@ module SMESH
in long LastNodeID1, in long LastNodeID1,
in long FirstNodeID2, in long FirstNodeID2,
in long SecondNodeID2, in long SecondNodeID2,
in long LastNodeID2); in long LastNodeID2,
in boolean CreatePolygons,
in boolean CreatePolyedrs);
Sew_Error SewConformFreeBorders (in long FirstNodeID1, Sew_Error SewConformFreeBorders (in long FirstNodeID1,
in long SecondNodeID1, in long SecondNodeID1,
@ -649,7 +691,9 @@ module SMESH
in long SecondNodeIDOnFreeBorder, in long SecondNodeIDOnFreeBorder,
in long LastNodeIDOnFreeBorder, in long LastNodeIDOnFreeBorder,
in long FirstNodeIDOnSide, in long FirstNodeIDOnSide,
in long LastNodeIDOnSide); in long LastNodeIDOnSide,
in boolean CreatePolygons,
in boolean CreatePolyedrs);
Sew_Error SewSideElements (in long_array IDsOfSide1Elements, Sew_Error SewSideElements (in long_array IDsOfSide1Elements,
in long_array IDsOfSide2Elements, in long_array IDsOfSide2Elements,

View File

@ -103,9 +103,15 @@ module SMESH
/*! /*!
* Create nodes and elements in <theMesh> using nodes * Create nodes and elements in <theMesh> using nodes
* coordinates computed by either of Apply...() methods * coordinates computed by either of Apply...() methods.
* If CreatePolygons is TRUE, replace adjacent faces by polygons
* to keep mesh conformity.
* If CreatePolyedrs is TRUE, replace adjacent volumes by polyedrs
* to keep mesh conformity.
*/ */
boolean MakeMesh(in SMESH_Mesh theMesh); boolean MakeMesh (in SMESH_Mesh theMesh,
in boolean CreatePolygons,
in boolean CreatePolyedrs);
/*! /*!
* Return the loaded pattern in the string form to be saved in file * Return the loaded pattern in the string form to be saved in file

View File

@ -16,7 +16,7 @@
<component-username>Mesh</component-username> <component-username>Mesh</component-username>
<component-type>MESH</component-type> <component-type>MESH</component-type>
<component-author>NRI</component-author> <component-author>NRI</component-author>
<component-version>2.2.0</component-version> <component-version>3.0.0</component-version>
<component-comment>Mesh component</component-comment> <component-comment>Mesh component</component-comment>
<component-multistudy>1</component-multistudy> <component-multistudy>1</component-multistudy>
<component-icone>ModuleMesh.png</component-icone> <component-icone>ModuleMesh.png</component-icone>

View File

@ -97,8 +97,10 @@
<popup-item item-id="401" pos-id="" label-id="Edge" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="401" pos-id="" label-id="Edge" icon-id="mesh_line.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4021" pos-id="" label-id="Triangle" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="4021" pos-id="" label-id="Triangle" icon-id="mesh_triangle.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4022" pos-id="" label-id="Quadrangle" icon-id="mesh_quad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="4022" pos-id="" label-id="Quadrangle" icon-id="mesh_quad.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4023" pos-id="" label-id="Polygon" icon-id="mesh_polygon.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4031" pos-id="" label-id="Tetrahedron" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="4031" pos-id="" label-id="Tetrahedron" icon-id="mesh_tetra.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4032" pos-id="" label-id="Hexahedron" icon-id="mesh_hexa.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/> <popup-item item-id="4032" pos-id="" label-id="Hexahedron" icon-id="mesh_hexa.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
<popup-item item-id="4033" pos-id="" label-id="Polyhedron" icon-id="mesh_polyhedron.png" tooltip-id="" accel-id="" toggle-id="" execute-action=""/>
</submenu> </submenu>
<endsubmenu /> <endsubmenu />
<submenu label-id="Remove" item-id="403" pos-id=""> <submenu label-id="Remove" item-id="403" pos-id="">
@ -440,8 +442,10 @@
<toolbutton-item item-id="401" label-id="Edge" icon-id="mesh_line.png" tooltip-id="Add Edge" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="401" label-id="Edge" icon-id="mesh_line.png" tooltip-id="Add Edge" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4021" label-id="Triangle" icon-id="mesh_triangle.png" tooltip-id="Add Triangle" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="4021" label-id="Triangle" icon-id="mesh_triangle.png" tooltip-id="Add Triangle" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4022" label-id="Quadrangle" icon-id="mesh_quad.png" tooltip-id="Add Quadrangle" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="4022" label-id="Quadrangle" icon-id="mesh_quad.png" tooltip-id="Add Quadrangle" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4023" label-id="Polygon" icon-id="mesh_polygon.png" tooltip-id="Add Polygon" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4031" label-id="Tetrahedron" icon-id="mesh_tetra.png" tooltip-id="Add Tetrahedron" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="4031" label-id="Tetrahedron" icon-id="mesh_tetra.png" tooltip-id="Add Tetrahedron" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4032" label-id="Hexahedron" icon-id="mesh_hexa.png" tooltip-id="Add Hexahedron" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="4032" label-id="Hexahedron" icon-id="mesh_hexa.png" tooltip-id="Add Hexahedron" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4033" label-id="Polyhedron" icon-id="mesh_polyhedron.png" tooltip-id="Add Polyhedron" accel-id="" toggle-id="" execute-action=""/>
<separatorTB/> <separatorTB/>
<toolbutton-item item-id="4041" label-id="Nodes" icon-id="mesh_rem_node.png" tooltip-id="Remove Nodes" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="4041" label-id="Nodes" icon-id="mesh_rem_node.png" tooltip-id="Remove Nodes" accel-id="" toggle-id="" execute-action=""/>
<toolbutton-item item-id="4042" label-id="Elements" icon-id="mesh_rem_element.png" tooltip-id="Remove Elements" accel-id="" toggle-id="" execute-action=""/> <toolbutton-item item-id="4042" label-id="Elements" icon-id="mesh_rem_element.png" tooltip-id="Remove Elements" accel-id="" toggle-id="" execute-action=""/>

BIN
resources/mesh_polygon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

View File

@ -81,7 +81,7 @@ namespace{
return aDist; return aDist;
} }
int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId ) int getNbMultiConnection( const SMDS_Mesh* theMesh, const int theId )
{ {
if ( theMesh == 0 ) if ( theMesh == 0 )
return 0; return 0;
@ -137,7 +137,7 @@ NumericalFunctor::NumericalFunctor():
myPrecision = -1; myPrecision = -1;
} }
void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh ) void NumericalFunctor::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -213,26 +213,17 @@ double MinimumAngle::GetValue( const TSequenceOfXYZ& P )
{ {
double aMin; double aMin;
if ( P.size() == 3 ) if (P.size() <3)
{
double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) );
double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) );
aMin = Min( A0, Min( A1, A2 ) );
}
else if ( P.size() == 4 )
{
double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) );
double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) );
double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) );
double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) );
aMin = Min( Min( A0, A1 ), Min( A2, A3 ) );
}
else
return 0.; return 0.;
aMin = getAngle(P( P.size() ), P( 1 ), P( 2 ));
aMin = Min(aMin,getAngle(P( P.size()-1 ), P( P.size() ), P( 1 )));
for (int i=2; i<P.size();i++){
double A0 = getAngle( P( i-1 ), P( i ), P( i+1 ) );
aMin = Min(aMin,A0);
}
return aMin * 180 / PI; return aMin * 180 / PI;
} }
@ -354,7 +345,7 @@ namespace{
gp_Vec aVec2( P( 3 ) - P( 1 ) ); gp_Vec aVec2( P( 3 ) - P( 1 ) );
gp_Vec aVec3( P( 4 ) - P( 1 ) ); gp_Vec aVec3( P( 4 ) - P( 1 ) );
gp_Vec anAreaVec( aVec1 ^ aVec2 ); gp_Vec anAreaVec( aVec1 ^ aVec2 );
return abs(aVec3 * anAreaVec) / 6.0; return fabs(aVec3 * anAreaVec) / 6.0;
} }
inline double getMaxHeight(double theLen[6]) inline double getMaxHeight(double theLen[6])
@ -638,8 +629,8 @@ double Warping::ComputeA( const gp_XYZ& thePnt1,
if ( L < Precision::Confusion()) if ( L < Precision::Confusion())
return 0.; return 0.;
gp_XYZ GI = ( thePnt2 - thePnt1 ) / 2. - theG; gp_XYZ GI = ( thePnt2 + thePnt1 ) / 2. - theG;
gp_XYZ GJ = ( thePnt3 - thePnt2 ) / 2. - theG; gp_XYZ GJ = ( thePnt3 + thePnt2 ) / 2. - theG;
gp_XYZ N = GI.Crossed( GJ ); gp_XYZ N = GI.Crossed( GJ );
if ( N.Modulus() < gp::Resolution() ) if ( N.Modulus() < gp::Resolution() )
@ -771,12 +762,17 @@ SMDSAbs_ElementType Skew::GetType() const
*/ */
double Area::GetValue( const TSequenceOfXYZ& P ) double Area::GetValue( const TSequenceOfXYZ& P )
{ {
double aArea = 0;
if ( P.size() == 3 ) if ( P.size() == 3 )
return getArea( P( 1 ), P( 2 ), P( 3 ) ); return getArea( P( 1 ), P( 2 ), P( 3 ) );
else if ( P.size() == 4 ) else if (P.size() > 3)
return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) ); aArea = getArea( P( 1 ), P( 2 ), P( 3 ) );
else else
return 0; return 0;
for (int i=4; i<=P.size(); i++)
aArea += getArea(P(1),P(i-1),P(i));
return aArea;
} }
double Area::GetBadRate( double Value, int /*nbNodes*/ ) const double Area::GetBadRate( double Value, int /*nbNodes*/ ) const
@ -1034,7 +1030,6 @@ double MultiConnection2D::GetValue( long theElementId )
int aResult = 0; int aResult = 0;
if (GetPoints(theElementId,P)){ if (GetPoints(theElementId,P)){
double aVal;
const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId ); const SMDS_MeshElement* anFaceElem = myMesh->FindElement( theElementId );
SMDSAbs_ElementType aType = anFaceElem->GetType(); SMDSAbs_ElementType aType = anFaceElem->GetType();
@ -1116,7 +1111,6 @@ void MultiConnection2D::GetValues(MValues& theValues){
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
for(; anIter->more(); ){ for(; anIter->more(); ){
const SMDS_MeshFace* anElem = anIter->next(); const SMDS_MeshFace* anElem = anIter->next();
long anElemId = anElem->GetID();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
long aNodeId[3]; long aNodeId[3];
@ -1176,7 +1170,7 @@ BadOrientedVolume::BadOrientedVolume()
myMesh = 0; myMesh = 0;
} }
void BadOrientedVolume::SetMesh( SMDS_Mesh* theMesh ) void BadOrientedVolume::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1207,7 +1201,7 @@ FreeBorders::FreeBorders()
myMesh = 0; myMesh = 0;
} }
void FreeBorders::SetMesh( SMDS_Mesh* theMesh ) void FreeBorders::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1232,7 +1226,7 @@ FreeEdges::FreeEdges()
myMesh = 0; myMesh = 0;
} }
void FreeEdges::SetMesh( SMDS_Mesh* theMesh ) void FreeEdges::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1379,7 +1373,7 @@ RangeOfIds::RangeOfIds()
// name : SetMesh // name : SetMesh
// Purpose : Set mesh // Purpose : Set mesh
//======================================================================= //=======================================================================
void RangeOfIds::SetMesh( SMDS_Mesh* theMesh ) void RangeOfIds::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
} }
@ -1581,7 +1575,7 @@ Comparator::Comparator():
Comparator::~Comparator() Comparator::~Comparator()
{} {}
void Comparator::SetMesh( SMDS_Mesh* theMesh ) void Comparator::SetMesh( const SMDS_Mesh* theMesh )
{ {
if ( myFunctor ) if ( myFunctor )
myFunctor->SetMesh( theMesh ); myFunctor->SetMesh( theMesh );
@ -1666,7 +1660,7 @@ bool LogicalNOT::IsSatisfy( long theId )
return myPredicate && !myPredicate->IsSatisfy( theId ); return myPredicate && !myPredicate->IsSatisfy( theId );
} }
void LogicalNOT::SetMesh( SMDS_Mesh* theMesh ) void LogicalNOT::SetMesh( const SMDS_Mesh* theMesh )
{ {
if ( myPredicate ) if ( myPredicate )
myPredicate->SetMesh( theMesh ); myPredicate->SetMesh( theMesh );
@ -1693,7 +1687,7 @@ LogicalBinary::LogicalBinary()
LogicalBinary::~LogicalBinary() LogicalBinary::~LogicalBinary()
{} {}
void LogicalBinary::SetMesh( SMDS_Mesh* theMesh ) void LogicalBinary::SetMesh( const SMDS_Mesh* theMesh )
{ {
if ( myPredicate1 ) if ( myPredicate1 )
myPredicate1->SetMesh( theMesh ); myPredicate1->SetMesh( theMesh );
@ -1767,9 +1761,8 @@ void Filter::SetPredicate( PredicatePtr thePredicate )
myPredicate = thePredicate; myPredicate = thePredicate;
} }
template<class TElement, class TIterator, class TPredicate> template<class TElement, class TIterator, class TPredicate>
void FillSequence(const TIterator& theIterator, inline void FillSequence(const TIterator& theIterator,
TPredicate& thePredicate, TPredicate& thePredicate,
Filter::TIdSequence& theSequence) Filter::TIdSequence& theSequence)
{ {
@ -1783,40 +1776,46 @@ void FillSequence(const TIterator& theIterator,
} }
} }
Filter::TIdSequence void
Filter::GetElementsId( SMDS_Mesh* theMesh ) Filter::
GetElementsId( const SMDS_Mesh* theMesh,
PredicatePtr thePredicate,
TIdSequence& theSequence )
{ {
TIdSequence aSequence; theSequence.clear();
if ( !theMesh || !myPredicate ) return aSequence;
myPredicate->SetMesh( theMesh ); if ( !theMesh || !thePredicate )
return;
SMDSAbs_ElementType aType = myPredicate->GetType(); thePredicate->SetMesh( theMesh );
SMDSAbs_ElementType aType = thePredicate->GetType();
switch(aType){ switch(aType){
case SMDSAbs_Node:{ case SMDSAbs_Node:
FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),myPredicate,aSequence); FillSequence<const SMDS_MeshNode*>(theMesh->nodesIterator(),thePredicate,theSequence);
break; break;
} case SMDSAbs_Edge:
case SMDSAbs_Edge:{ FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
break; break;
} case SMDSAbs_Face:
case SMDSAbs_Face:{ FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
break; break;
} case SMDSAbs_Volume:
case SMDSAbs_Volume:{ FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
break; break;
} case SMDSAbs_All:
case SMDSAbs_All:{ FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence); FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence); FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
break; break;
} }
} }
return aSequence;
void
Filter::GetElementsId( const SMDS_Mesh* theMesh,
Filter::TIdSequence& theSequence )
{
GetElementsId(theMesh,myPredicate,theSequence);
} }
/* /*
@ -1880,7 +1879,7 @@ ManifoldPart::~ManifoldPart()
myMesh = 0; myMesh = 0;
} }
void ManifoldPart::SetMesh( SMDS_Mesh* theMesh ) void ManifoldPart::SetMesh( const SMDS_Mesh* theMesh )
{ {
myMesh = theMesh; myMesh = theMesh;
process(); process();
@ -2209,7 +2208,7 @@ ElementsOnSurface::~ElementsOnSurface()
myMesh = 0; myMesh = 0;
} }
void ElementsOnSurface::SetMesh( SMDS_Mesh* theMesh ) void ElementsOnSurface::SetMesh( const SMDS_Mesh* theMesh )
{ {
if ( myMesh == theMesh ) if ( myMesh == theMesh )
return; return;

View File

@ -97,14 +97,14 @@ namespace SMESH{
{ {
public: public:
~Functor(){} ~Functor(){}
virtual void SetMesh( SMDS_Mesh* theMesh ) = 0; virtual void SetMesh( const SMDS_Mesh* theMesh ) = 0;
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
}; };
class NumericalFunctor: public virtual Functor{ class NumericalFunctor: public virtual Functor{
public: public:
NumericalFunctor(); NumericalFunctor();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual double GetValue( long theElementId ); virtual double GetValue( long theElementId );
virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;}; virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
@ -117,7 +117,7 @@ namespace SMESH{
static bool GetPoints(const SMDS_MeshElement* theElem, static bool GetPoints(const SMDS_MeshElement* theElem,
TSequenceOfXYZ& theRes); TSequenceOfXYZ& theRes);
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
long myPrecision; long myPrecision;
}; };
@ -295,12 +295,12 @@ namespace SMESH{
class FreeBorders: public virtual Predicate{ class FreeBorders: public virtual Predicate{
public: public:
FreeBorders(); FreeBorders();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
}; };
@ -311,12 +311,12 @@ namespace SMESH{
class BadOrientedVolume: public virtual Predicate{ class BadOrientedVolume: public virtual Predicate{
public: public:
BadOrientedVolume(); BadOrientedVolume();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
}; };
@ -327,7 +327,7 @@ namespace SMESH{
class FreeEdges: public virtual Predicate{ class FreeEdges: public virtual Predicate{
public: public:
FreeEdges(); FreeEdges();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId ); static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
@ -342,7 +342,7 @@ namespace SMESH{
void GetBoreders(TBorders& theBorders); void GetBoreders(TBorders& theBorders);
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
}; };
typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr; typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
@ -359,7 +359,7 @@ namespace SMESH{
{ {
public: public:
RangeOfIds(); RangeOfIds();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theNodeId ); virtual bool IsSatisfy( long theNodeId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
virtual void SetType( SMDSAbs_ElementType theType ); virtual void SetType( SMDSAbs_ElementType theType );
@ -369,7 +369,7 @@ namespace SMESH{
bool SetRangeStr( const TCollection_AsciiString& ); bool SetRangeStr( const TCollection_AsciiString& );
protected: protected:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
TColStd_SequenceOfInteger myMin; TColStd_SequenceOfInteger myMin;
TColStd_SequenceOfInteger myMax; TColStd_SequenceOfInteger myMax;
@ -389,7 +389,7 @@ namespace SMESH{
public: public:
Comparator(); Comparator();
virtual ~Comparator(); virtual ~Comparator();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetMargin(double theValue); virtual void SetMargin(double theValue);
virtual void SetNumFunctor(NumericalFunctorPtr theFunct); virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
virtual bool IsSatisfy( long theElementId ) = 0; virtual bool IsSatisfy( long theElementId ) = 0;
@ -449,7 +449,7 @@ namespace SMESH{
LogicalNOT(); LogicalNOT();
virtual ~LogicalNOT(); virtual ~LogicalNOT();
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetPredicate(PredicatePtr thePred); virtual void SetPredicate(PredicatePtr thePred);
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
@ -467,7 +467,7 @@ namespace SMESH{
public: public:
LogicalBinary(); LogicalBinary();
virtual ~LogicalBinary(); virtual ~LogicalBinary();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual void SetPredicate1(PredicatePtr thePred); virtual void SetPredicate1(PredicatePtr thePred);
virtual void SetPredicate2(PredicatePtr thePred); virtual void SetPredicate2(PredicatePtr thePred);
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
@ -532,7 +532,7 @@ namespace SMESH{
ManifoldPart(); ManifoldPart();
~ManifoldPart(); ~ManifoldPart();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
// inoke when all parameters already set // inoke when all parameters already set
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
@ -560,7 +560,7 @@ namespace SMESH{
TVectorOfFacePtr& theFaces ) const; TVectorOfFacePtr& theFaces ) const;
private: private:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
TColStd_MapOfInteger myMapIds; TColStd_MapOfInteger myMapIds;
TColStd_MapOfInteger myMapBadGeomIds; TColStd_MapOfInteger myMapBadGeomIds;
TVectorOfFacePtr myAllFacePtr; TVectorOfFacePtr myAllFacePtr;
@ -582,7 +582,7 @@ namespace SMESH{
public: public:
ElementsOnSurface(); ElementsOnSurface();
~ElementsOnSurface(); ~ElementsOnSurface();
virtual void SetMesh( SMDS_Mesh* theMesh ); virtual void SetMesh( const SMDS_Mesh* theMesh );
virtual bool IsSatisfy( long theElementId ); virtual bool IsSatisfy( long theElementId );
virtual SMDSAbs_ElementType GetType() const; virtual SMDSAbs_ElementType GetType() const;
@ -597,7 +597,7 @@ namespace SMESH{
bool isOnSurface( const SMDS_MeshNode* theNode ) const; bool isOnSurface( const SMDS_MeshNode* theNode ) const;
private: private:
SMDS_Mesh* myMesh; const SMDS_Mesh* myMesh;
TColStd_MapOfInteger myIds; TColStd_MapOfInteger myIds;
SMDSAbs_ElementType myType; SMDSAbs_ElementType myType;
Handle(Geom_Surface) mySurf; Handle(Geom_Surface) mySurf;
@ -615,8 +615,19 @@ namespace SMESH{
Filter(); Filter();
virtual ~Filter(); virtual ~Filter();
virtual void SetPredicate(PredicatePtr thePred); virtual void SetPredicate(PredicatePtr thePred);
typedef std::vector<long> TIdSequence; typedef std::vector<long> TIdSequence;
virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh );
virtual
void
GetElementsId( const SMDS_Mesh* theMesh,
TIdSequence& theSequence );
static
void
GetElementsId( const SMDS_Mesh* theMesh,
PredicatePtr thePredicate,
TIdSequence& theSequence );
protected: protected:
PredicatePtr myPredicate; PredicatePtr myPredicate;

View File

@ -268,7 +268,175 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
MED::TGeom::const_iterator anTGeomIter = aTGeom.begin(); MED::TGeom::const_iterator anTGeomIter = aTGeom.begin();
for(; anTGeomIter != aTGeom.end(); anTGeomIter++){ for(; anTGeomIter != aTGeom.end(); anTGeomIter++){
const EGeometrieElement& aGeom = anTGeomIter->first; const EGeometrieElement& aGeom = anTGeomIter->first;
if(aGeom == ePOINT1) continue;
if (aGeom == ePOINT1) {
continue;
} else if (aGeom == ePOLYGONE) {
PPolygoneInfo aPolygoneInfo = aMed->GetPPolygoneInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aPolygoneInfo->IsElemNum() : eFAUX;
TElemNum aConn = aPolygoneInfo->GetConnectivite();
TElemNum aIndex = aPolygoneInfo->GetIndex();
TInt nbPolygons = aPolygoneInfo->GetNbElem();
for (TInt iPG = 0; iPG < nbPolygons; iPG++) {
// get nodes
TInt aCurrPG_FirstNodeIndex = aIndex[iPG] - 1;
int nbNodes = aPolygoneInfo->GetNbConn(iPG);
std::vector<int> nodes_ids (nbNodes);
//for (TInt inode = 0; inode < nbNodes; inode++) {
// nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
//}
#ifdef _EDF_NODE_IDS_
if (anIsNodeNum) {
for (TInt inode = 0; inode < nbNodes; inode++) {
nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPG_FirstNodeIndex + inode] - 1);
}
} else {
for (TInt inode = 0; inode < nbNodes; inode++) {
nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
}
}
#else
for (TInt inode = 0; inode < nbNodes; inode++) {
nodes_ids[inode] = aConn[aCurrPG_FirstNodeIndex + inode];
}
#endif
bool isRenum = false;
SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aPolygoneInfo->GetFamNum(iPG);
try {
if (anIsElemNum) {
anElement = myMesh->AddPolygonalFaceWithID
(nodes_ids, aPolygoneInfo->GetElemNum(iPG));
}
if (!anElement) {
std::vector<const SMDS_MeshNode*> nodes (nbNodes);
for (int inode = 0; inode < nbNodes; inode++) {
nodes[inode] = FindNode(myMesh, nodes_ids[inode]);
}
anElement = myMesh->AddPolygonalFace(nodes);
isRenum = anIsElemNum;
}
} catch (const std::exception& exc) {
aResult = DRS_FAIL;
} catch (...) {
aResult = DRS_FAIL;
}
if (!anElement) {
aResult = DRS_WARN_SKIP_ELEM;
} else {
if (isRenum) {
anIsElemNum = eFAUX;
takeNumbers = false;
if (aResult < DRS_WARN_RENUMBER)
aResult = DRS_WARN_RENUMBER;
}
if (myFamilies.find(aFamNum) != myFamilies.end()) {
// Save reference to this element from its family
myFamilies[aFamNum]->AddElement(anElement);
myFamilies[aFamNum]->SetType(anElement->GetType());
}
}
} // for (TInt iPG = 0; iPG < nbPolygons; iPG++)
continue;
} else if (aGeom == ePOLYEDRE) {
PPolyedreInfo aPolyedreInfo = aMed->GetPPolyedreInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aPolyedreInfo->IsElemNum() : eFAUX;
TElemNum aConn = aPolyedreInfo->GetConnectivite();
TElemNum aFacesIndex = aPolyedreInfo->GetFacesIndex();
TElemNum aIndex = aPolyedreInfo->GetIndex();
TInt nbPolyedres = aPolyedreInfo->GetNbElem();
for (int iPE = 0; iPE < nbPolyedres; iPE++) {
// get faces
int aCurrPE_FirstFaceIndex = aIndex[iPE] - 1;
int aNextPE_FirstFaceIndex = aIndex[iPE + 1] - 1;
int nbFaces = aNextPE_FirstFaceIndex - aCurrPE_FirstFaceIndex;
std::vector<int> quantities (nbFaces);
for (int iFa = 0; iFa < nbFaces; iFa++) {
int aCurrFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa] - 1;
int aNextFace_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex + iFa + 1] - 1;
int nbNodes = aNextFace_FirstNodeIndex - aCurrFace_FirstNodeIndex;
quantities[iFa] = nbNodes;
}
// get nodes
int aCurrPE_FirstNodeIndex = aFacesIndex[aCurrPE_FirstFaceIndex] - 1;
int nbPENodes = aPolyedreInfo->GetNbConn(iPE);
std::vector<int> nodes_ids (nbPENodes);
//for (int inode = 0; inode < nbPENodes; inode++) {
// nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
//}
#ifdef _EDF_NODE_IDS_
if (anIsNodeNum) {
for (int inode = 0; inode < nbPENodes; inode++) {
nodes_ids[inode] = aNodeInfo->GetElemNum(aConn[aCurrPE_FirstNodeIndex + inode] - 1);
}
} else {
for (int inode = 0; inode < nbPENodes; inode++) {
nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
}
}
#else
for (int inode = 0; inode < nbPENodes; inode++) {
nodes_ids[inode] = aConn[aCurrPE_FirstNodeIndex + inode];
}
#endif
bool isRenum = false;
SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aPolyedreInfo->GetFamNum(iPE);
try {
if (anIsElemNum) {
anElement = myMesh->AddPolyhedralVolumeWithID
(nodes_ids, quantities, aPolyedreInfo->GetElemNum(iPE));
}
if (!anElement) {
std::vector<const SMDS_MeshNode*> nodes (nbPENodes);
for (int inode = 0; inode < nbPENodes; inode++) {
nodes[inode] = FindNode(myMesh, nodes_ids[inode]);
}
anElement = myMesh->AddPolyhedralVolume(nodes, quantities);
isRenum = anIsElemNum;
}
} catch (const std::exception& exc) {
aResult = DRS_FAIL;
} catch (...) {
aResult = DRS_FAIL;
}
if (!anElement) {
aResult = DRS_WARN_SKIP_ELEM;
} else {
if (isRenum) {
anIsElemNum = eFAUX;
takeNumbers = false;
if (aResult < DRS_WARN_RENUMBER)
aResult = DRS_WARN_RENUMBER;
}
if (myFamilies.find(aFamNum) != myFamilies.end()) {
// Save reference to this element from its family
myFamilies[aFamNum]->AddElement(anElement);
myFamilies[aFamNum]->SetType(anElement->GetType());
}
}
} // for (int iPE = 0; iPE < nbPolyedres; iPE++)
continue;
} else {
}
PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom); PCellInfo aCellInfo = aMed->GetPCellInfo(aMeshInfo,anEntity,aGeom);
EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX; EBooleen anIsElemNum = takeNumbers ? aCellInfo->IsElemNum() : eFAUX;
TInt aNbElems = aCellInfo->GetNbElem(); TInt aNbElems = aCellInfo->GetNbElem();
@ -343,6 +511,8 @@ Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform()
SMDS_MeshElement* anElement = NULL; SMDS_MeshElement* anElement = NULL;
TInt aFamNum = aCellInfo->GetFamNum(iElem); TInt aFamNum = aCellInfo->GetFamNum(iElem);
try{ try{
//MESSAGE("Try to create element # " << iElem << " with id = "
// << aCellInfo->GetElemNum(iElem));
switch(aGeom){ switch(aGeom){
case eSEG2: case eSEG2:
case eSEG3: case eSEG3:

View File

@ -33,6 +33,8 @@
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
#include "utilities.h" #include "utilities.h"
#include "MED_Utilities.hxx" #include "MED_Utilities.hxx"
@ -61,7 +63,7 @@ void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName,
void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName) void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
{ {
return SetFile(theFileName,MED::eV2_1); return SetFile(theFileName,MED::eV2_2);
} }
void DriverMED_W_SMESHDS_Mesh::SetMeshName(const std::string& theMeshName) void DriverMED_W_SMESHDS_Mesh::SetMeshName(const std::string& theMeshName)
@ -440,6 +442,16 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MED::TIntVector aQuadConn; MED::TIntVector aQuadConn;
aQuadConn.reserve(aNbElems*aNbQuadConn); aQuadConn.reserve(aNbElems*aNbQuadConn);
MED::TIntVector aPolygoneElemNums;
aPolygoneElemNums.reserve(aNbElems);
MED::TIntVector aPolygoneInds;
aPolygoneInds.reserve(aNbElems + 1);
aPolygoneInds.push_back(1); // reference on the first element in the connectivities
MED::TIntVector aPolygoneFamilyNums;
aPolygoneFamilyNums.reserve(aNbElems);
MED::TIntVector aPolygoneConn;
aPolygoneConn.reserve(aNbElems*aNbQuadConn);
for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){ for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
const SMDS_MeshFace* anElem = anIter->next(); const SMDS_MeshFace* anElem = anIter->next();
TInt aNbNodes = anElem->NbNodes(); TInt aNbNodes = anElem->NbNodes();
@ -448,6 +460,12 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MED::TIntVector* anElemNums; MED::TIntVector* anElemNums;
MED::TIntVector* aFamilyNums; MED::TIntVector* aFamilyNums;
MED::TIntVector* aConnectivity; MED::TIntVector* aConnectivity;
if (anElem->IsPoly()) {
aNbConnectivity = aNbNodes;
anElemNums = &aPolygoneElemNums;
aFamilyNums = &aPolygoneFamilyNums;
aConnectivity = &aPolygoneConn;
} else {
switch(aNbNodes){ switch(aNbNodes){
case 3: case 3:
aNbConnectivity = aNbTriaConn; aNbConnectivity = aNbTriaConn;
@ -461,28 +479,23 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
aFamilyNums = &aQuadFamilyNums; aFamilyNums = &aQuadFamilyNums;
aConnectivity = &aQuadConn; aConnectivity = &aQuadConn;
break; break;
default:
break;
}
} }
MED::TIntVector aVector(aNbNodes); MED::TIntVector aVector(aNbNodes);
for(TInt iNode = 0; aNodesIter->more(); iNode++){ for(TInt iNode = 0; aNodesIter->more(); iNode++){
const SMDS_MeshElement* aNode = aNodesIter->next(); const SMDS_MeshElement* aNode = aNodesIter->next();
#ifdef _EDF_NODE_IDS_
aVector[iNode] = aNodeIdMap[aNode->GetID()];
#else
aVector[iNode] = aNode->GetID(); aVector[iNode] = aNode->GetID();
#endif
} }
TInt aSize = aConnectivity->size(); TInt aSize = aConnectivity->size();
aConnectivity->resize(aSize+aNbConnectivity); aConnectivity->resize(aSize+aNbConnectivity);
// There is some differnce between SMDS and MED in cells mapping // There is some differences between SMDS and MED in cells mapping
#ifdef _EDF_NODE_IDS_
switch(aNbNodes){
case 4:
(*aConnectivity)[aSize+0] = aNodeIdMap[aVector[0]];
(*aConnectivity)[aSize+1] = aNodeIdMap[aVector[1]];
(*aConnectivity)[aSize+2] = aNodeIdMap[aVector[3]];
(*aConnectivity)[aSize+3] = aNodeIdMap[aVector[2]];
default:
for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aNodeIdMap[aVector[iNode]];
}
#else
switch(aNbNodes){ switch(aNbNodes){
case 4: case 4:
(*aConnectivity)[aSize+0] = aVector[0]; (*aConnectivity)[aSize+0] = aVector[0];
@ -493,7 +506,13 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
for(TInt iNode = 0; iNode < aNbNodes; iNode++) for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aVector[iNode]; (*aConnectivity)[aSize+iNode] = aVector[iNode];
} }
#endif
if (anElem->IsPoly()) {
// fill indices for polygonal element
TInt aPrevPos = aPolygoneInds.back();
aPolygoneInds.push_back(aPrevPos + aNbNodes);
}
anElemNums->push_back(anElem->GetID()); anElemNums->push_back(anElem->GetID());
if (anElemFamMap.find(anElem) != anElemFamMap.end()) if (anElemFamMap.find(anElem) != anElemFamMap.end())
@ -523,6 +542,22 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems); MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eQUAD4<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo); myMed->SetCellInfo(aCellInfo);
} }
if(TInt aNbElems = aPolygoneElemNums.size()){
// add one element in connectivities,
// referenced by the last element in indices
aPolygoneConn.push_back(0);
PPolygoneInfo aCellInfo = myMed->CrPolygoneInfo(aMeshInfo,
SMDS_MED_ENTITY,
ePOLYGONE,
SMDS_MED_CONNECTIVITY,
aPolygoneConn,
aPolygoneInds,
aPolygoneFamilyNums,
aPolygoneElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYGONE<<"; aNbElems = "<<aNbElems);
myMed->SetPolygoneInfo(aCellInfo);
}
} }
// Storing SMDS Volumes // Storing SMDS Volumes
@ -563,13 +598,57 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MED::TIntVector aHexaConn; MED::TIntVector aHexaConn;
aHexaConn.reserve(aNbElems*aNbHexaConn); aHexaConn.reserve(aNbElems*aNbHexaConn);
MED::TIntVector aPolyedreElemNums;
aPolyedreElemNums.reserve(aNbElems);
MED::TIntVector aPolyedreInds;
aPolyedreInds.reserve(aNbElems + 1);
aPolyedreInds.push_back(1); // reference on the first element in the faces
MED::TIntVector aPolyedreFaces;
aPolyedreFaces.reserve(aNbElems + 1);
aPolyedreFaces.push_back(1); // reference on the first element in the connectivities
MED::TIntVector aPolyedreFamilyNums;
aPolyedreFamilyNums.reserve(aNbElems);
MED::TIntVector aPolyedreConn;
aPolyedreConn.reserve(aNbElems*aNbHexaConn);
for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){ for(TInt iElem = 0; iElem < aNbElems && anIter->more(); iElem++){
const SMDS_MeshVolume* anElem = anIter->next(); const SMDS_MeshVolume* anElem = anIter->next();
MED::TIntVector* anElemNums;
MED::TIntVector* aFamilyNums;
if (anElem->IsPoly()) {
const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
(const SMDS_PolyhedralVolumeOfNodes*) anElem;
if (!aPolyedre) {
MESSAGE("Warning: bad volumic element");
continue;
}
anElemNums = &aPolyedreElemNums;
aFamilyNums = &aPolyedreFamilyNums;
TInt aNodeId, aNbFaces = aPolyedre->NbFaces();
for (int iface = 1; iface <= aNbFaces; iface++) {
int aNbFaceNodes = aPolyedre->NbFaceNodes(iface);
for (int inode = 1; inode <= aNbFaceNodes; inode++) {
aNodeId = aPolyedre->GetFaceNode(iface, inode)->GetID();
#ifdef _EDF_NODE_IDS_
aPolyedreConn.push_back(aNodeIdMap[aNodeId]);
#else
aPolyedreConn.push_back(aNodeId);
#endif
}
TInt aPrevPos = aPolyedreFaces.back();
aPolyedreFaces.push_back(aPrevPos + aNbFaceNodes);
}
TInt aPrevPos = aPolyedreInds.back();
aPolyedreInds.push_back(aPrevPos + aNbFaces);
} else {
TInt aNbNodes = anElem->NbNodes(); TInt aNbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
TInt aNbConnectivity; TInt aNbConnectivity;
MED::TIntVector* anElemNums;
MED::TIntVector* aFamilyNums;
MED::TIntVector* aConnectivity; MED::TIntVector* aConnectivity;
switch(aNbNodes){ switch(aNbNodes){
case 4: case 4:
@ -597,27 +676,19 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
aConnectivity = &aHexaConn; aConnectivity = &aHexaConn;
} }
TInt aSize = aConnectivity->size();
aConnectivity->resize(aSize + aNbConnectivity);
MED::TIntVector aVector(aNbNodes); MED::TIntVector aVector(aNbNodes);
for(TInt iNode = 0; aNodesIter->more(); iNode++){ for(TInt iNode = 0; aNodesIter->more(); iNode++){
const SMDS_MeshElement* aNode = aNodesIter->next(); const SMDS_MeshElement* aNode = aNodesIter->next();
aVector[iNode] = aNode->GetID();
}
TInt aSize = aConnectivity->size();
aConnectivity->resize(aSize+aNbConnectivity);
// There is some difference between SMDS and MED in cells mapping
#ifdef _EDF_NODE_IDS_ #ifdef _EDF_NODE_IDS_
switch(aNbNodes){ aVector[iNode] = aNodeIdMap[aNode->GetID()];
case 5:
(*aConnectivity)[aSize+0] = aNodeIdMap[aVector[0]];
(*aConnectivity)[aSize+1] = aNodeIdMap[aVector[3]];
(*aConnectivity)[aSize+2] = aNodeIdMap[aVector[2]];
(*aConnectivity)[aSize+3] = aNodeIdMap[aVector[1]];
(*aConnectivity)[aSize+4] = aNodeIdMap[aVector[4]];
default:
for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aNodeIdMap[aVector[iNode]];
}
#else #else
aVector[iNode] = aNode->GetID();
#endif
}
// There is some difference between SMDS and MED in cells mapping
switch(aNbNodes){ switch(aNbNodes){
case 5: case 5:
(*aConnectivity)[aSize+0] = aVector[0]; (*aConnectivity)[aSize+0] = aVector[0];
@ -629,7 +700,8 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
for(TInt iNode = 0; iNode < aNbNodes; iNode++) for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aVector[iNode]; (*aConnectivity)[aSize+iNode] = aVector[iNode];
} }
#endif }
anElemNums->push_back(anElem->GetID()); anElemNums->push_back(anElem->GetID());
if (anElemFamMap.find(anElem) != anElemFamMap.end()) if (anElemFamMap.find(anElem) != anElemFamMap.end())
@ -682,6 +754,23 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems); MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<eHEXA8<<"; aNbElems = "<<aNbElems);
myMed->SetCellInfo(aCellInfo); myMed->SetCellInfo(aCellInfo);
} }
if(TInt aNbElems = aPolyedreElemNums.size()){
// add one element in connectivities,
// referenced by the last element in faces
aPolyedreConn.push_back(0);
PPolyedreInfo aCellInfo = myMed->CrPolyedreInfo(aMeshInfo,
SMDS_MED_ENTITY,
ePOLYEDRE,
SMDS_MED_CONNECTIVITY,
aPolyedreConn,
aPolyedreFaces,
aPolyedreInds,
aPolyedreFamilyNums,
aPolyedreElemNums);
MESSAGE("Perform - anEntity = "<<SMDS_MED_ENTITY<<"; aGeom = "<<ePOLYEDRE<<"; aNbElems = "<<aNbElems);
myMed->SetPolyedreInfo(aCellInfo);
}
} }
}catch(const std::exception& exc){ }catch(const std::exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.what()); INFOS("Follow exception was cought:\n\t"<<exc.what());

View File

@ -18,40 +18,13 @@
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include <stdio.h> #include <stdio.h>
#include "DriverSTL_R_SMDS_Mesh.h"
#include "SMDS_Mesh.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#include <OSD_Path.hxx>
#include <OSD_File.hxx>
#include <OSD_FromWhere.hxx>
#include <OSD_Protection.hxx>
#include <OSD_SingleProtection.hxx>
#include <NCollection_DataMap.hxx>
#include <Standard_NoMoreObject.hxx>
#include "utilities.h"
static const int HEADER_SIZE = 84;
static const int SIZEOF_STL_FACET = 50;
//static const int STL_MIN_FILE_SIZE = 284;
static const int ASCII_LINES_PER_FACET = 7;
static Standard_Real tab1[3];
static Standard_Real tab2[3];
typedef NCollection_DataMap<gp_Pnt,SMDS_MeshNode*> DriverSTL_DataMapOfPntNodePtr;
//typedef NCollection_BaseCollection<SMDS_MeshNodePtr> DriverSTL_ColOfNodePtr;
//======================================================================= //=======================================================================
//function : HashCode //function : HashCode
//purpose : //purpose :
//======================================================================= //=======================================================================
inline Standard_Integer HashCode inline Standard_Integer HashCode
(const gp_Pnt& point, const Standard_Integer Upper) (const gp_Pnt& point, Standard_Integer Upper)
{ {
union union
{ {
@ -63,7 +36,8 @@ inline Standard_Integer HashCode
return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper); return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper);
} }
static Standard_Real tab1[3];
static Standard_Real tab2[3];
//======================================================================= //=======================================================================
//function : IsEqual //function : IsEqual
//purpose : //purpose :
@ -75,7 +49,32 @@ inline Standard_Boolean IsEqual
point2.Coord(tab2[0],tab2[1],tab2[2]); point2.Coord(tab2[0],tab2[1],tab2[2]);
return (memcmp(tab1,tab2,sizeof(tab1)) == 0); return (memcmp(tab1,tab2,sizeof(tab1)) == 0);
} }
#include "DriverSTL_R_SMDS_Mesh.h"
#include "SMDS_Mesh.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include <OSD_Path.hxx>
#include <OSD_File.hxx>
#include <OSD_FromWhere.hxx>
#include <OSD_Protection.hxx>
#include <OSD_SingleProtection.hxx>
#include <Standard_NoMoreObject.hxx>
#include "utilities.h"
static const int HEADER_SIZE = 84;
static const int SIZEOF_STL_FACET = 50;
//static const int STL_MIN_FILE_SIZE = 284;
static const int ASCII_LINES_PER_FACET = 7;
//typedef NCollection_BaseCollection<SMDS_MeshNodePtr> DriverSTL_ColOfNodePtr;
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<gp_Pnt,SMDS_MeshNode*> DriverSTL_DataMapOfPntNodePtr;
//======================================================================= //=======================================================================
//function : DriverSTL_R_SMDS_Mesh //function : DriverSTL_R_SMDS_Mesh
//purpose : //purpose :

View File

@ -50,9 +50,9 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \
BIN = BIN =
BIN_SRC = BIN_SRC =
CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \ CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
$(BOOST_CPPFLAGS) $(QT_INCLUDES) $(BOOST_CPPFLAGS) $(QT_INCLUDES)
LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lSMDS \ LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lSMDS \
-lSalomeGUI -lSalomeObject -lSMESHControls -lSalomeApp -lSalomeObject -lSMESHControls
@CONCLUDE@ @CONCLUDE@

View File

@ -31,9 +31,9 @@
#include "SMESH_ActorUtils.h" #include "SMESH_ActorUtils.h"
#include "SMESH_DeviceActor.h" #include "SMESH_DeviceActor.h"
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
#include "SALOME_ExtractUnstructuredGrid.h" #include <VTKViewer_ExtractUnstructuredGrid.h>
#include "QAD_Config.h" //#include "QAD_Config.h"
#include <qstringlist.h> #include <qstringlist.h>
#include <vtkTimeStamp.h> #include <vtkTimeStamp.h>
@ -73,7 +73,7 @@
#include "utilities.h" #include "utilities.h"
#ifdef _DEBUG_ #ifdef _DEBUG_
static int MYDEBUG = 0; static int MYDEBUG = 1;
#else #else
static int MYDEBUG = 0; static int MYDEBUG = 0;
#endif #endif
@ -118,7 +118,7 @@ SMESH_ActorDef::SMESH_ActorDef()
float aLineWidth = SMESH::GetFloat("SMESH:SettingsWidth",1); float aLineWidth = SMESH::GetFloat("SMESH:SettingsWidth",1);
vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
SALOME_ExtractUnstructuredGrid* aFilter = NULL; VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
//Definition 2D and 3D divices of the actor //Definition 2D and 3D divices of the actor
//----------------------------------------- //-----------------------------------------
@ -142,7 +142,7 @@ SMESH_ActorDef::SMESH_ActorDef()
my2DActor->SetBackfaceProperty(myBackSurfaceProp); my2DActor->SetBackfaceProperty(myBackSurfaceProp);
my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface); my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
aFilter = my2DActor->GetExtractUnstructuredGrid(); aFilter = my2DActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_TRIANGLE); aFilter->RegisterCellsWithType(VTK_TRIANGLE);
aFilter->RegisterCellsWithType(VTK_POLYGON); aFilter->RegisterCellsWithType(VTK_POLYGON);
aFilter->RegisterCellsWithType(VTK_QUAD); aFilter->RegisterCellsWithType(VTK_QUAD);
@ -154,13 +154,13 @@ SMESH_ActorDef::SMESH_ActorDef()
my3DActor->SetBackfaceProperty(myBackSurfaceProp); my3DActor->SetBackfaceProperty(myBackSurfaceProp);
my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface); my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
aFilter = my3DActor->GetExtractUnstructuredGrid(); aFilter = my3DActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_TETRA); aFilter->RegisterCellsWithType(VTK_TETRA);
aFilter->RegisterCellsWithType(VTK_VOXEL); aFilter->RegisterCellsWithType(VTK_VOXEL);
aFilter->RegisterCellsWithType(VTK_HEXAHEDRON); aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
aFilter->RegisterCellsWithType(VTK_WEDGE); aFilter->RegisterCellsWithType(VTK_WEDGE);
aFilter->RegisterCellsWithType(VTK_PYRAMID); aFilter->RegisterCellsWithType(VTK_PYRAMID);
aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
//Definition 1D divice of the actor //Definition 1D divice of the actor
//--------------------------------- //---------------------------------
@ -181,7 +181,7 @@ SMESH_ActorDef::SMESH_ActorDef()
my1DActor->SetProperty(myEdgeProp); my1DActor->SetProperty(myEdgeProp);
my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface); my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
aFilter = my1DActor->GetExtractUnstructuredGrid(); aFilter = my1DActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_LINE); aFilter->RegisterCellsWithType(VTK_LINE);
my1DProp = vtkProperty::New(); my1DProp = vtkProperty::New();
@ -206,7 +206,7 @@ SMESH_ActorDef::SMESH_ActorDef()
my1DExtActor->SetProperty(my1DExtProp); my1DExtActor->SetProperty(my1DExtProp);
my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe); my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
aFilter = my1DExtActor->GetExtractUnstructuredGrid(); aFilter = my1DExtActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_LINE); aFilter->RegisterCellsWithType(VTK_LINE);
@ -227,7 +227,7 @@ SMESH_ActorDef::SMESH_ActorDef()
myNodeActor->SetProperty(myNodeProp); myNodeActor->SetProperty(myNodeProp);
myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint); myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
aFilter = myNodeActor->GetExtractUnstructuredGrid(); aFilter = myNodeActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints); aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
//Definition of Pickable and Highlitable engines //Definition of Pickable and Highlitable engines
@ -288,38 +288,38 @@ SMESH_ActorDef::SMESH_ActorDef()
vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New(); vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) { /* if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) {
QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false ); QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false );
aScalarBarTitleProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ), aScalarBarTitleProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ),
( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) ); ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
} }
else else*/
aScalarBarTitleProp->SetColor( 1.0, 1.0, 1.0 ); aScalarBarTitleProp->SetColor( 1.0, 1.0, 1.0 );
aScalarBarTitleProp->SetFontFamilyToArial(); aScalarBarTitleProp->SetFontFamilyToArial();
if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){ /*if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){
if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" ) if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" )
aScalarBarTitleProp->SetFontFamilyToArial(); aScalarBarTitleProp->SetFontFamilyToArial();
else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" ) else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" )
aScalarBarTitleProp->SetFontFamilyToCourier(); aScalarBarTitleProp->SetFontFamilyToCourier();
else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" ) else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" )
aScalarBarTitleProp->SetFontFamilyToTimes(); aScalarBarTitleProp->SetFontFamilyToTimes();
} }*/
if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" ) /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" )
aScalarBarTitleProp->BoldOn(); aScalarBarTitleProp->BoldOn();
else else*/
aScalarBarTitleProp->BoldOff(); aScalarBarTitleProp->BoldOff();
if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" ) /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" )
aScalarBarTitleProp->ItalicOn(); aScalarBarTitleProp->ItalicOn();
else else*/
aScalarBarTitleProp->ItalicOff(); aScalarBarTitleProp->ItalicOff();
if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" ) /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" )
aScalarBarTitleProp->ShadowOn(); aScalarBarTitleProp->ShadowOn();
else else*/
aScalarBarTitleProp->ShadowOff(); aScalarBarTitleProp->ShadowOff();
myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp ); myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
@ -327,74 +327,74 @@ SMESH_ActorDef::SMESH_ActorDef()
vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New(); vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) { /*if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) {
QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false ); QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false );
aScalarBarLabelProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ), aScalarBarLabelProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ),
( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ),
( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) ); ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) );
} }
else else*/
aScalarBarLabelProp->SetColor( 1.0, 1.0, 1.0 ); aScalarBarLabelProp->SetColor( 1.0, 1.0, 1.0 );
aScalarBarLabelProp->SetFontFamilyToArial(); aScalarBarLabelProp->SetFontFamilyToArial();
if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){ /*if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){
if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" ) if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" )
aScalarBarLabelProp->SetFontFamilyToArial(); aScalarBarLabelProp->SetFontFamilyToArial();
else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" ) else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" )
aScalarBarLabelProp->SetFontFamilyToCourier(); aScalarBarLabelProp->SetFontFamilyToCourier();
else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" ) else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" )
aScalarBarLabelProp->SetFontFamilyToTimes(); aScalarBarLabelProp->SetFontFamilyToTimes();
} }*/
if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" ) /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" )
aScalarBarLabelProp->BoldOn(); aScalarBarLabelProp->BoldOn();
else else*/
aScalarBarLabelProp->BoldOff(); aScalarBarLabelProp->BoldOff();
if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" ) /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" )
aScalarBarLabelProp->ItalicOn(); aScalarBarLabelProp->ItalicOn();
else else*/
aScalarBarLabelProp->ItalicOff(); aScalarBarLabelProp->ItalicOff();
if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" ) /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" )
aScalarBarLabelProp->ShadowOn(); aScalarBarLabelProp->ShadowOn();
else else*/
aScalarBarLabelProp->ShadowOff(); aScalarBarLabelProp->ShadowOff();
myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp ); myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
aScalarBarLabelProp->Delete(); aScalarBarLabelProp->Delete();
if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ) /*if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" )
myScalarBarActor->SetOrientationToHorizontal(); myScalarBarActor->SetOrientationToHorizontal();
else else*/
myScalarBarActor->SetOrientationToVertical(); myScalarBarActor->SetOrientationToVertical();
float aXVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01; float aXVal = 0.01; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01;
if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) ) //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) )
aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat(); // aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat();
float aYVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1; float aYVal = 0.1; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1;
if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) ) //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) )
aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat(); // aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat();
myScalarBarActor->SetPosition( aXVal, aYVal ); myScalarBarActor->SetPosition( aXVal, aYVal );
float aWVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10; float aWVal = 0.1; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10;
if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) ) //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) )
aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat(); // aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat();
myScalarBarActor->SetWidth( aWVal ); myScalarBarActor->SetWidth( aWVal );
float aHVal = QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80; float aHVal = 0.8; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80;
if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) ) //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) )
aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat(); // aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat();
myScalarBarActor->SetHeight( aHVal ); myScalarBarActor->SetHeight( aHVal );
int anIntVal = 5; int anIntVal = 5;
if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) ) //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) )
anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt(); // anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt();
myScalarBarActor->SetNumberOfLabels(anIntVal == 0? 5: anIntVal); myScalarBarActor->SetNumberOfLabels(anIntVal == 0? 5: anIntVal);
anIntVal = 64; anIntVal = 64;
if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) ) //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) )
anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt(); // anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt();
myScalarBarActor->SetMaximumNumberOfColors(anIntVal == 0? 64: anIntVal); myScalarBarActor->SetMaximumNumberOfColors(anIntVal == 0? 64: anIntVal);
@ -623,7 +623,7 @@ SetControlMode(eControl theMode,
bool theCheckEntityMode) bool theCheckEntityMode)
{ {
myControlMode = eNone; myControlMode = eNone;
theCheckEntityMode &= QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true"; //theCheckEntityMode &= QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true";
my1DActor->GetMapper()->SetScalarVisibility(false); my1DActor->GetMapper()->SetScalarVisibility(false);
my2DActor->GetMapper()->SetScalarVisibility(false); my2DActor->GetMapper()->SetScalarVisibility(false);
@ -851,8 +851,9 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
//SetIsShrunkable(theGrid->GetNumberOfCells() > 10); //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
SetIsShrunkable(true); SetIsShrunkable(true);
QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); //QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode");
SetRepresentation(-1); SetRepresentation(-1);
/*
if(aMode.compare("Wireframe") == 0){ if(aMode.compare("Wireframe") == 0){
SetRepresentation(eEdge); SetRepresentation(eEdge);
}else if(aMode.compare("Shading") == 0){ }else if(aMode.compare("Shading") == 0){
@ -860,11 +861,11 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
}else if(aMode.compare("Nodes") == 0){ }else if(aMode.compare("Nodes") == 0){
SetRepresentation(ePoint); SetRepresentation(ePoint);
} }
*/
aMode = QAD_CONFIG->getSetting("SMESH:Shrink"); /*aMode = QAD_CONFIG->getSetting("SMESH:Shrink");
if(aMode == "yes"){ if(aMode == "yes"){
SetShrink(); SetShrink();
} }*/
myTimeStamp->Modified(); myTimeStamp->Modified();
Modified(); Modified();
@ -882,7 +883,7 @@ vtkDataSet* SMESH_ActorDef::GetInput(){
} }
void SMESH_ActorDef::SetTransform(SALOME_Transform* theTransform){ void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
myNodeActor->SetTransform(theTransform); myNodeActor->SetTransform(theTransform);
myBaseActor->SetTransform(theTransform); myBaseActor->SetTransform(theTransform);
@ -1101,10 +1102,10 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState); myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
myEntityMode = theMode; myEntityMode = theMode;
SALOME_ExtractUnstructuredGrid* aFilter = NULL; VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
aFilter = myBaseActor->GetExtractUnstructuredGrid(); aFilter = myBaseActor->GetExtractUnstructuredGrid();
aFilter->ClearRegisteredCellsWithType(); aFilter->ClearRegisteredCellsWithType();
aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
if(myEntityMode & eEdges){ if(myEntityMode & eEdges){
if (MYDEBUG) MESSAGE("EDGES"); if (MYDEBUG) MESSAGE("EDGES");
@ -1255,13 +1256,13 @@ void SMESH_ActorDef::UpdateHighlight(){
myHighlitableActor->SetHighlited(anIsVisible); myHighlitableActor->SetHighlited(anIsVisible);
myHighlitableActor->SetVisibility(anIsVisible); myHighlitableActor->SetVisibility(anIsVisible);
myHighlitableActor->GetExtractUnstructuredGrid()-> myHighlitableActor->GetExtractUnstructuredGrid()->
SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::eCells); SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
}else if(myRepresentation == ePoint || GetPointRepresentation()){ }else if(myRepresentation == ePoint || GetPointRepresentation()){
myHighlitableActor->SetHighlited(anIsVisible); myHighlitableActor->SetHighlited(anIsVisible);
myHighlitableActor->SetVisibility(anIsVisible); myHighlitableActor->SetVisibility(anIsVisible);
myHighlitableActor->GetExtractUnstructuredGrid()-> myHighlitableActor->GetExtractUnstructuredGrid()->
SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints); SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
} }
} }

View File

@ -29,7 +29,7 @@
#ifndef SMESH_ACTOR_H #ifndef SMESH_ACTOR_H
#define SMESH_ACTOR_H #define SMESH_ACTOR_H
#include "SALOME_Actor.h" #include <SALOME_Actor.h>
#include "SMESH_Object.h" #include "SMESH_Object.h"
class vtkUnstructuredGrid; class vtkUnstructuredGrid;

View File

@ -50,7 +50,7 @@ public:
return *this; return *this;
} }
TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;} TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
T* Get() const { return GetPointer();} T* Get() const { return this->GetPointer();}
}; };
@ -147,7 +147,7 @@ class SMESH_ActorDef : public SMESH_Actor{
virtual bool GetPointRepresentation(); virtual bool GetPointRepresentation();
virtual float* GetBounds(); virtual float* GetBounds();
virtual void SetTransform(SALOME_Transform* theTransform); virtual void SetTransform(VTKViewer_Transform* theTransform);
virtual vtkUnstructuredGrid* GetUnstructuredGrid(); virtual vtkUnstructuredGrid* GetUnstructuredGrid();
virtual vtkDataSet* GetInput(); virtual vtkDataSet* GetInput();

View File

@ -20,7 +20,7 @@
#include "SMESH_ActorUtils.h" #include "SMESH_ActorUtils.h"
#include "QAD_Config.h" //#include "QAD_Config.h"
#include "utilities.h" #include "utilities.h"
#include <vtkUnstructuredGrid.h> #include <vtkUnstructuredGrid.h>
@ -36,9 +36,10 @@ namespace SMESH{
float GetFloat(const QString& theValue, float theDefault){ float GetFloat(const QString& theValue, float theDefault){
if(theValue.isEmpty()) return theDefault; if(theValue.isEmpty()) return theDefault;
QString aValue = QAD_CONFIG->getSetting(theValue); //QString aValue = QAD_CONFIG->getSetting(theValue);
if(aValue.isEmpty()) return theDefault; //if(aValue.isEmpty())
return aValue.toFloat(); return theDefault;
//return aValue.toFloat();
} }
void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName){ void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName){

View File

@ -32,10 +32,10 @@
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
#include "SMESH_ActorUtils.h" #include "SMESH_ActorUtils.h"
#include "SALOME_Transform.h" #include <VTKViewer_Transform.h>
#include "SALOME_TransformFilter.h" #include <VTKViewer_TransformFilter.h>
#include "SALOME_PassThroughFilter.h" #include <VTKViewer_PassThroughFilter.h>
#include "SALOME_ExtractUnstructuredGrid.h" #include <VTKViewer_ExtractUnstructuredGrid.h>
// VTK Includes // VTK Includes
#include <vtkObjectFactory.h> #include <vtkObjectFactory.h>
@ -100,16 +100,16 @@ SMESH_DeviceActor::SMESH_DeviceActor()
myExtractGeometry->SetReleaseDataFlag(true); myExtractGeometry->SetReleaseDataFlag(true);
myIsImplicitFunctionUsed = false; myIsImplicitFunctionUsed = false;
myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New(); myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New();
myMergeFilter = vtkMergeFilter::New(); myMergeFilter = vtkMergeFilter::New();
myGeomFilter = SALOME_GeometryFilter::New(); myGeomFilter = VTKViewer_GeometryFilter::New();
myTransformFilter = SALOME_TransformFilter::New(); myTransformFilter = VTKViewer_TransformFilter::New();
for(int i = 0; i < 6; i++) for(int i = 0; i < 6; i++)
myPassFilter.push_back(SALOME_PassThroughFilter::New()); myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
} }
@ -231,7 +231,7 @@ void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
} }
SALOME_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){ VTKViewer_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){
return myExtractUnstructuredGrid; return myExtractUnstructuredGrid;
} }
@ -300,7 +300,7 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
bool anIsInitialized = theFunctor; bool anIsInitialized = theFunctor;
myExtractUnstructuredGrid->ClearRegisteredCells(); myExtractUnstructuredGrid->ClearRegisteredCells();
myExtractUnstructuredGrid->ClearRegisteredCellsWithType(); myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
myVisualObj->UpdateFunctor(theFunctor); myVisualObj->UpdateFunctor(theFunctor);
using namespace SMESH::Controls; using namespace SMESH::Controls;
@ -436,12 +436,12 @@ void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor
{ {
myExtractUnstructuredGrid->ClearRegisteredCells(); myExtractUnstructuredGrid->ClearRegisteredCells();
myExtractUnstructuredGrid->ClearRegisteredCellsWithType(); myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
myVisualObj->UpdateFunctor(theFunctor); myVisualObj->UpdateFunctor(theFunctor);
using namespace SMESH::Controls; using namespace SMESH::Controls;
if(FreeBorders* aFreeBorders = dynamic_cast<FreeBorders*>(theFunctor.get())){ if(FreeBorders* aFreeBorders = dynamic_cast<FreeBorders*>(theFunctor.get())){
myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid(); vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
vtkIdType aNbCells = aGrid->GetNumberOfCells(); vtkIdType aNbCells = aGrid->GetNumberOfCells();
for( vtkIdType i = 0; i < aNbCells; i++ ){ for( vtkIdType i = 0; i < aNbCells; i++ ){
@ -516,7 +516,7 @@ unsigned long int SMESH_DeviceActor::GetMTime(){
} }
void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){ void SMESH_DeviceActor::SetTransform(VTKViewer_Transform* theTransform){
myTransformFilter->SetTransform(theTransform); myTransformFilter->SetTransform(theTransform);
} }

View File

@ -29,7 +29,7 @@
#ifndef SMESH_DEVICE_ACTOR_H #ifndef SMESH_DEVICE_ACTOR_H
#define SMESH_DEVICE_ACTOR_H #define SMESH_DEVICE_ACTOR_H
#include "SALOME_GeometryFilter.h" #include <VTKViewer_GeometryFilter.h>
#include "SMESH_Controls.hxx" #include "SMESH_Controls.hxx"
#include "SMESH_Object.h" #include "SMESH_Object.h"
@ -46,10 +46,10 @@ class vtkScalarBarActor;
class vtkLookupTable; class vtkLookupTable;
class vtkImplicitBoolean; class vtkImplicitBoolean;
class SALOME_Transform; class VTKViewer_Transform;
class SALOME_TransformFilter; class VTKViewer_TransformFilter;
class SALOME_PassThroughFilter; class VTKViewer_PassThroughFilter;
class SALOME_ExtractUnstructuredGrid; class VTKViewer_ExtractUnstructuredGrid;
class SMESH_ExtractGeometry; class SMESH_ExtractGeometry;
@ -71,7 +71,7 @@ class SMESH_DeviceActor: public vtkLODActor{
virtual int GetElemObjId(int theVtkID); virtual int GetElemObjId(int theVtkID);
virtual vtkCell* GetElemCell(int theObjID); virtual vtkCell* GetElemCell(int theObjID);
virtual void SetTransform(SALOME_Transform* theTransform); virtual void SetTransform(VTKViewer_Transform* theTransform);
virtual unsigned long int GetMTime(); virtual unsigned long int GetMTime();
float GetShrinkFactor(); float GetShrinkFactor();
@ -89,7 +89,7 @@ class SMESH_DeviceActor: public vtkLODActor{
virtual void SetVisibility(int theMode); virtual void SetVisibility(int theMode);
virtual int GetVisibility(); virtual int GetVisibility();
SALOME_ExtractUnstructuredGrid* GetExtractUnstructuredGrid(); VTKViewer_ExtractUnstructuredGrid* GetExtractUnstructuredGrid();
vtkUnstructuredGrid* GetUnstructuredGrid(); vtkUnstructuredGrid* GetUnstructuredGrid();
void SetControlMode(SMESH::Controls::FunctorPtr theFunctor, void SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
@ -122,12 +122,12 @@ class SMESH_DeviceActor: public vtkLODActor{
bool myIsImplicitFunctionUsed; bool myIsImplicitFunctionUsed;
vtkMergeFilter* myMergeFilter; vtkMergeFilter* myMergeFilter;
SALOME_ExtractUnstructuredGrid* myExtractUnstructuredGrid; VTKViewer_ExtractUnstructuredGrid* myExtractUnstructuredGrid;
bool myStoreClippingMapping; bool myStoreClippingMapping;
SALOME_GeometryFilter *myGeomFilter; VTKViewer_GeometryFilter *myGeomFilter;
SALOME_TransformFilter *myTransformFilter; VTKViewer_TransformFilter *myTransformFilter;
std::vector<SALOME_PassThroughFilter*> myPassFilter; std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
vtkShrinkFilter* myShrinkFilter; vtkShrinkFilter* myShrinkFilter;
bool myIsShrinkable; bool myIsShrinkable;

View File

@ -31,7 +31,7 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
#include "SALOME_ExtractUnstructuredGrid.h" #include <VTKViewer_ExtractUnstructuredGrid.h>
#include CORBA_SERVER_HEADER(SALOME_Exception) #include CORBA_SERVER_HEADER(SALOME_Exception)
@ -160,6 +160,30 @@ namespace{
} }
inline void AddPolygonsWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
int aFaceId = anIndexes[anIndexId++];
int aNbNodes = anIndexes[anIndexId++];
std::vector<int> nodes_ids (aNbNodes);
for (int i = 0; i < aNbNodes; i++) {
nodes_ids[i] = anIndexes[anIndexId++];
}
SMDS_MeshElement* anElem = theMesh->AddPolygonalFaceWithID(nodes_ids, aFaceId);
if (!anElem)
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolygonalFaceWithID for ID = "
<< anElemId);
}
}
inline void AddTetrasWithID(SMDS_Mesh* theMesh, inline void AddTetrasWithID(SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq, SMESH::log_array_var& theSeq,
CORBA::Long theId) CORBA::Long theId)
@ -175,7 +199,7 @@ namespace{
anIndexes[anIndexId+4], anIndexes[anIndexId+4],
anIndexes[anIndexId]); anIndexes[anIndexId]);
if(!anElem) if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId); EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
} }
} }
@ -196,7 +220,7 @@ namespace{
anIndexes[anIndexId+5], anIndexes[anIndexId+5],
anIndexes[anIndexId]); anIndexes[anIndexId]);
if(!anElem) if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId); EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
} }
} }
@ -218,7 +242,7 @@ namespace{
anIndexes[anIndexId+6], anIndexes[anIndexId+6],
anIndexes[anIndexId]); anIndexes[anIndexId]);
if(!anElem) if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId); EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
} }
} }
@ -242,7 +266,69 @@ namespace{
anIndexes[anIndexId+8], anIndexes[anIndexId+8],
anIndexes[anIndexId]); anIndexes[anIndexId]);
if(!anElem) if(!anElem)
EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<<anElemId); EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddVolumeWithID for ID = "<<anElemId);
}
}
inline void AddPolyhedronsWithID (SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long anIndexId = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++) {
int aFaceId = anIndexes[anIndexId++];
int aNbNodes = anIndexes[anIndexId++];
std::vector<int> nodes_ids (aNbNodes);
for (int i = 0; i < aNbNodes; i++) {
nodes_ids[i] = anIndexes[anIndexId++];
}
int aNbFaces = anIndexes[anIndexId++];
std::vector<int> quantities (aNbFaces);
for (int i = 0; i < aNbFaces; i++) {
quantities[i] = anIndexes[anIndexId++];
}
SMDS_MeshElement* anElem =
theMesh->AddPolyhedralVolumeWithID(nodes_ids, quantities, aFaceId);
if (!anElem)
EXCEPTION(runtime_error, "SMDS_Mesh::FindElement - cannot AddPolyhedralVolumeWithID for ID = "
<< anElemId);
}
}
inline void ChangePolyhedronNodes (SMDS_Mesh* theMesh,
SMESH::log_array_var& theSeq,
CORBA::Long theId)
{
const SMESH::long_array& anIndexes = theSeq[theId].indexes;
CORBA::Long iind = 0, aNbElems = theSeq[theId].number;
for (CORBA::Long anElemId = 0; anElemId < aNbElems; anElemId++)
{
// find element
const SMDS_MeshElement* elem = FindElement(theMesh, anIndexes[iind++]);
// nb nodes
int nbNodes = anIndexes[iind++];
// nodes
std::vector<const SMDS_MeshNode*> aNodes (nbNodes);
for (int iNode = 0; iNode < nbNodes; iNode++) {
aNodes[iNode] = FindNode(theMesh, anIndexes[iind++]);
}
// nb faces
int nbFaces = anIndexes[iind++];
// quantities
std::vector<int> quantities (nbFaces);
for (int iFace = 0; iFace < nbFaces; iFace++) {
quantities[iFace] = anIndexes[iind++];
}
// change
theMesh->ChangePolyhedronNodes(elem, aNodes, quantities);
} }
} }
@ -258,6 +344,7 @@ namespace{
// purpose : Get type of VTK cell // purpose : Get type of VTK cell
//================================================================================= //=================================================================================
static inline vtkIdType getCellType( const SMDSAbs_ElementType theType, static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
const bool thePoly,
const int theNbNodes ) const int theNbNodes )
{ {
switch( theType ) switch( theType )
@ -266,12 +353,14 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
return theNbNodes == 2 ? VTK_LINE : VTK_EMPTY_CELL; return theNbNodes == 2 ? VTK_LINE : VTK_EMPTY_CELL;
case SMDSAbs_Face : case SMDSAbs_Face :
if ( theNbNodes == 3 ) return VTK_TRIANGLE; if (thePoly && theNbNodes>2 ) return VTK_POLYGON;
else if ( theNbNodes == 3 ) return VTK_TRIANGLE;
else if ( theNbNodes == 4 ) return VTK_QUAD; else if ( theNbNodes == 4 ) return VTK_QUAD;
else return VTK_EMPTY_CELL; else return VTK_EMPTY_CELL;
case SMDSAbs_Volume: case SMDSAbs_Volume:
if ( theNbNodes == 4 ) return VTK_TETRA; if (thePoly && theNbNodes>3 ) return VTK_CONVEX_POINT_SET;
else if ( theNbNodes == 4 ) return VTK_TETRA;
else if ( theNbNodes == 5 ) return VTK_PYRAMID; else if ( theNbNodes == 5 ) return VTK_PYRAMID;
else if ( theNbNodes == 6 ) return VTK_WEDGE; else if ( theNbNodes == 6 ) return VTK_WEDGE;
else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON; else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
@ -287,15 +376,12 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
//================================================================================= //=================================================================================
SMESH_VisualObjDef::SMESH_VisualObjDef() SMESH_VisualObjDef::SMESH_VisualObjDef()
{ {
if(MYDEBUG) MESSAGE("SMESH_MeshObj - "<<this);
myGrid = vtkUnstructuredGrid::New(); myGrid = vtkUnstructuredGrid::New();
} }
SMESH_VisualObjDef::~SMESH_VisualObjDef() SMESH_VisualObjDef::~SMESH_VisualObjDef()
{ {
if(MYDEBUG) { if ( MYDEBUG )
MESSAGE("~SMESH_MeshObj - "<<this); MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() );
myGrid->DebugOn();
}
myGrid->Delete(); myGrid->Delete();
} }
@ -545,35 +631,37 @@ void SMESH_VisualObjDef::buildElemPrs()
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
switch(aType){ switch(aType){
case SMDSAbs_Volume:{ case SMDSAbs_Volume:{
int* aConnectivities = NULL; std::vector<int> aConnectivities;
GetConnect(aNodesIter,aConnect); GetConnect(aNodesIter,aConnect);
// Convertions connectivities from SMDS to VTK // Convertions connectivities from SMDS to VTK
switch(aNbNodes){ if (anElem->IsPoly() && aNbNodes > 3) { // POLYEDRE
case 4:{ for (int k = 0; k < aNbNodes; k++) {
static int anIds[] = {0,2,1,3}; aConnectivities.push_back(k);
aConnectivities = anIds;
break;
} }
case 5:{
static int anIds[] = {0,3,2,1,4};
aConnectivities = anIds;
break;
}
case 6:{
static int anIds[] = {0,1,2,3,4,5};
aConnectivities = anIds;
break;
}
case 8:{
static int anIds[] = {0,3,2,1,4,7,6,5};
aConnectivities = anIds;
break;
}}
if(aConnectivities) } else if (aNbNodes == 4) {
static int anIds[] = {0,2,1,3};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else if (aNbNodes == 5) {
static int anIds[] = {0,3,2,1,4};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else if (aNbNodes == 6) {
static int anIds[] = {0,1,2,3,4,5};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else if (aNbNodes == 8) {
static int anIds[] = {0,3,2,1,4,7,6,5};
for (int k = 0; k < aNbNodes; k++) aConnectivities.push_back(anIds[k]);
} else {
}
if (aConnectivities.size() > 0) {
for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++) for (vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++)
SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]); SetId(anIdList,mySMDS2VTKNodes,aConnect,aNodeId,aConnectivities[aNodeId]);
}
break; break;
} }
default: default:
@ -584,7 +672,7 @@ void SMESH_VisualObjDef::buildElemPrs()
} }
aConnectivity->InsertNextCell( anIdList ); aConnectivity->InsertNextCell( anIdList );
aCellTypesArray->InsertNextValue( getCellType( aType, aNbNodes ) ); aCellTypesArray->InsertNextValue( getCellType( aType, anElem->IsPoly(), aNbNodes ) );
iElem++; iElem++;
} }
@ -628,7 +716,7 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
int nbNodes = anElem->NbNodes(); int nbNodes = anElem->NbNodes();
if ( theEdgeNum < 1 || theEdgeNum > 4 || nbNodes != 3 && nbNodes != 4 || theEdgeNum > nbNodes ) if ( theEdgeNum < 0 || theEdgeNum > 3 || nbNodes != 3 && nbNodes != 4 || theEdgeNum > nbNodes )
return false; return false;
int anIds[ nbNodes ]; int anIds[ nbNodes ];
@ -637,10 +725,10 @@ bool SMESH_VisualObjDef::GetEdgeNodes( const int theElemId,
while( anIter->more() ) while( anIter->more() )
anIds[ i++ ] = anIter->next()->GetID(); anIds[ i++ ] = anIter->next()->GetID();
if ( nbNodes != theEdgeNum ) if ( theEdgeNum < nbNodes - 1 )
{ {
theNodeId1 = anIds[ theEdgeNum - 1 ]; theNodeId1 = anIds[ theEdgeNum ];
theNodeId2 = anIds[ theEdgeNum ]; theNodeId2 = anIds[ theEdgeNum + 1 ];
} }
else else
{ {
@ -711,10 +799,12 @@ void SMESH_MeshObj::Update( int theIsClear )
case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_EDGE : AddEdgesWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_TRIANGLE : AddTriasWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_QUADRANGLE : AddQuadsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_POLYGON : AddPolygonsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_PYRAMID : AddPiramidsWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_PYRAMID : AddPiramidsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_POLYHEDRON : AddPolyhedronsWithID( myMesh, aSeq, anId ); break;
case SMESH::REMOVE_NODE: case SMESH::REMOVE_NODE:
for( ; anElemId < aNbElems; anElemId++ ) for( ; anElemId < aNbElems; anElemId++ )
@ -743,8 +833,8 @@ void SMESH_MeshObj::Update( int theIsClear )
// nb nodes // nb nodes
int nbNodes = anIndexes[i++]; int nbNodes = anIndexes[i++];
// nodes // nodes
ASSERT( nbNodes < 9 ); //ASSERT( nbNodes < 9 );
const SMDS_MeshNode* aNodes[ 8 ]; const SMDS_MeshNode* aNodes[ nbNodes ];
for ( int iNode = 0; iNode < nbNodes; iNode++ ) for ( int iNode = 0; iNode < nbNodes; iNode++ )
aNodes[ iNode ] = FindNode( myMesh, anIndexes[i++] ); aNodes[ iNode ] = FindNode( myMesh, anIndexes[i++] );
// change // change
@ -752,6 +842,9 @@ void SMESH_MeshObj::Update( int theIsClear )
} }
break; break;
case SMESH::CHANGE_POLYHEDRON_NODES:
ChangePolyhedronNodes(myMesh, aSeq, anId);
break;
case SMESH::RENUMBER: case SMESH::RENUMBER:
for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3) for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3)
{ {

View File

@ -30,7 +30,7 @@
#define SMESH_OBJECTDEF_H #define SMESH_OBJECTDEF_H
// IDL Headers // IDL Headers
#include "SALOMEconfig.h" #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Group)

View File

@ -55,8 +55,10 @@ LIB_SRC = \
SMDS_IteratorOfElements.cxx \ SMDS_IteratorOfElements.cxx \
SMDS_VolumeOfFaces.cxx \ SMDS_VolumeOfFaces.cxx \
SMDS_VolumeOfNodes.cxx \ SMDS_VolumeOfNodes.cxx \
SMDS_PolyhedralVolumeOfNodes.cxx \
SMDS_FaceOfEdges.cxx \ SMDS_FaceOfEdges.cxx \
SMDS_FaceOfNodes.cxx \ SMDS_FaceOfNodes.cxx \
SMDS_PolygonalFaceOfNodes.cxx \
SMDS_VolumeTool.cxx SMDS_VolumeTool.cxx
# SMDS_Tria3OfNodes.cxx \ # SMDS_Tria3OfNodes.cxx \
# SMDS_HexahedronOfNodes.cxx # SMDS_HexahedronOfNodes.cxx
@ -107,8 +109,10 @@ EXPORT_HEADERS= \
SMDS_IteratorOfElements.hxx \ SMDS_IteratorOfElements.hxx \
SMDS_VolumeOfFaces.hxx \ SMDS_VolumeOfFaces.hxx \
SMDS_VolumeOfNodes.hxx \ SMDS_VolumeOfNodes.hxx \
SMDS_PolyhedralVolumeOfNodes.hxx \
SMDS_FaceOfEdges.hxx \ SMDS_FaceOfEdges.hxx \
SMDS_FaceOfNodes.hxx \ SMDS_FaceOfNodes.hxx \
SMDS_PolygonalFaceOfNodes.hxx \
SMDS_VolumeTool.hxx SMDS_VolumeTool.hxx
# SMDS_Tria3OfNodes.hxx \ # SMDS_Tria3OfNodes.hxx \
# SMDS_HexahedronOfNodes.hxx # SMDS_HexahedronOfNodes.hxx

View File

@ -29,6 +29,8 @@
#include "SMDS_VolumeOfFaces.hxx" #include "SMDS_VolumeOfFaces.hxx"
#include "SMDS_FaceOfNodes.hxx" #include "SMDS_FaceOfNodes.hxx"
#include "SMDS_FaceOfEdges.hxx" #include "SMDS_FaceOfEdges.hxx"
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
#include "SMDS_PolygonalFaceOfNodes.hxx"
#include <algorithm> #include <algorithm>
#include <map> #include <map>
@ -786,6 +788,126 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshFace * f1,
return volume; return volume;
} }
///////////////////////////////////////////////////////////////////////////////
/// Add a polygon defined by its nodes IDs
///////////////////////////////////////////////////////////////////////////////
SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
const int ID)
{
int nbNodes = nodes_ids.size();
std::vector<const SMDS_MeshNode*> nodes (nbNodes);
for (int i = 0; i < nbNodes; i++) {
nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]);
if (!nodes[i]) return NULL;
}
return SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
}
///////////////////////////////////////////////////////////////////////////////
/// Add a polygon defined by its nodes
///////////////////////////////////////////////////////////////////////////////
SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
(std::vector<const SMDS_MeshNode*> nodes,
const int ID)
{
SMDS_MeshFace * face;
if (hasConstructionEdges())
{
MESSAGE("Error : Not implemented");
return NULL;
}
else
{
face = new SMDS_PolygonalFaceOfNodes(nodes);
myFaces.Add(face);
}
if (!registerElement(ID, face)) {
RemoveElement(face, false);
face = NULL;
}
return face;
}
///////////////////////////////////////////////////////////////////////////////
/// Add a polygon defined by its nodes.
/// An ID is automatically affected to the created face.
///////////////////////////////////////////////////////////////////////////////
SMDS_MeshFace* SMDS_Mesh::AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes)
{
return SMDS_Mesh::AddPolygonalFaceWithID(nodes, myElementIDFactory->GetFreeID());
}
///////////////////////////////////////////////////////////////////////////////
/// Create a new polyhedral volume and add it to the mesh.
/// @param ID The ID of the new volume
/// @return The created volume or NULL if an element with this ID already exists
/// or if input nodes are not found.
///////////////////////////////////////////////////////////////////////////////
SMDS_MeshVolume * SMDS_Mesh::AddPolyhedralVolumeWithID
(std::vector<int> nodes_ids,
std::vector<int> quantities,
const int ID)
{
int nbNodes = nodes_ids.size();
std::vector<const SMDS_MeshNode*> nodes (nbNodes);
for (int i = 0; i < nbNodes; i++) {
nodes[i] = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(nodes_ids[i]);
if (!nodes[i]) return NULL;
}
return SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
}
///////////////////////////////////////////////////////////////////////////////
/// Create a new polyhedral volume and add it to the mesh.
/// @param ID The ID of the new volume
/// @return The created volume
///////////////////////////////////////////////////////////////////////////////
SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities,
const int ID)
{
SMDS_MeshVolume* volume;
if (hasConstructionFaces()) {
MESSAGE("Error : Not implemented");
return NULL;
} else if (hasConstructionEdges()) {
MESSAGE("Error : Not implemented");
return NULL;
} else {
volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities);
myVolumes.Add(volume);
}
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
volume = NULL;
}
return volume;
}
///////////////////////////////////////////////////////////////////////////////
/// Create a new polyhedral volume and add it to the mesh.
/// @return The created volume
///////////////////////////////////////////////////////////////////////////////
SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities)
{
int ID = myElementIDFactory->GetFreeID();
SMDS_MeshVolume * v = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
if (v == NULL) myElementIDFactory->ReleaseID(ID);
return v;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Registers element with the given ID, maintains inverse connections /// Registers element with the given ID, maintains inverse connections
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -966,10 +1088,25 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
} }
case SMDSAbs_Face: { case SMDSAbs_Face: {
const SMDS_FaceOfNodes* face = dynamic_cast<const SMDS_FaceOfNodes*>( elem ); const SMDS_FaceOfNodes* face = dynamic_cast<const SMDS_FaceOfNodes*>( elem );
if ( face ) if ( face ) {
Ok = const_cast<SMDS_FaceOfNodes*>( face )->ChangeNodes( nodes, nbnodes ); Ok = const_cast<SMDS_FaceOfNodes*>( face )->ChangeNodes( nodes, nbnodes );
} else {
/// ??? begin
const SMDS_PolygonalFaceOfNodes* face = dynamic_cast<const SMDS_PolygonalFaceOfNodes*>(elem);
if (face) {
Ok = const_cast<SMDS_PolygonalFaceOfNodes*>(face)->ChangeNodes(nodes, nbnodes);
}
/// ??? end
}
break; break;
} }
//case SMDSAbs_PolygonalFace: {
// const SMDS_PolygonalFaceOfNodes* face = dynamic_cast<const SMDS_PolygonalFaceOfNodes*>(elem);
// if (face) {
// Ok = const_cast<SMDS_PolygonalFaceOfNodes*>(face)->ChangeNodes(nodes, nbnodes);
// }
// break;
//}
case SMDSAbs_Volume: { case SMDSAbs_Volume: {
const SMDS_VolumeOfNodes* vol = dynamic_cast<const SMDS_VolumeOfNodes*>( elem ); const SMDS_VolumeOfNodes* vol = dynamic_cast<const SMDS_VolumeOfNodes*>( elem );
if ( vol ) if ( vol )
@ -1007,6 +1144,62 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
return Ok; return Ok;
} }
//=======================================================================
//function : ChangePolyhedronNodes
//purpose : to change nodes of polyhedral volume
//=======================================================================
bool SMDS_Mesh::ChangePolyhedronNodes (const SMDS_MeshElement * elem,
std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities)
{
if (elem->GetType() != SMDSAbs_Volume) {
MESSAGE("WRONG ELEM TYPE");
return false;
}
const SMDS_PolyhedralVolumeOfNodes* vol = dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>(elem);
if (!vol) {
return false;
}
// keep current nodes of elem
set<const SMDS_MeshElement*> oldNodes;
SMDS_ElemIteratorPtr itn = elem->nodesIterator();
while (itn->more()) {
oldNodes.insert(itn->next());
}
// change nodes
bool Ok = const_cast<SMDS_PolyhedralVolumeOfNodes*>(vol)->ChangeNodes(nodes, quantities);
if (!Ok) {
return false;
}
// update InverseElements
// AddInverseElement to new nodes
int nbnodes = nodes.size();
for (int i = 0; i < nbnodes; i++) {
if (oldNodes.find(nodes[i]) == oldNodes.end()) {
// new node
const_cast<SMDS_MeshNode*>(nodes[i])->AddInverseElement(elem);
} else {
// remove from oldNodes a node that remains in elem
oldNodes.erase(nodes[i]);
}
}
// RemoveInverseElement from the nodes removed from elem
set<const SMDS_MeshElement*>::iterator it;
for (it = oldNodes.begin(); it != oldNodes.end(); it++) {
SMDS_MeshNode * n = static_cast<SMDS_MeshNode *>
(const_cast<SMDS_MeshElement *>( *it ));
n->RemoveInverseElement(elem);
}
return Ok;
}
//======================================================================= //=======================================================================
//function : FindEdge //function : FindEdge
//purpose : //purpose :
@ -1192,6 +1385,55 @@ const SMDS_MeshElement* SMDS_Mesh::FindElement(int IDelem) const
return myElementIDFactory->MeshElement(IDelem); return myElementIDFactory->MeshElement(IDelem);
} }
//=======================================================================
//function : FindFace
//purpose : find polygon
//=======================================================================
const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector<int> nodes_ids) const
{
int nbnodes = nodes_ids.size();
std::vector<const SMDS_MeshNode *> poly_nodes (nbnodes);
for (int inode = 0; inode < nbnodes; inode++) {
const SMDS_MeshNode * node = FindNode(nodes_ids[inode]);
if (node == NULL) return NULL;
}
return FindFace(poly_nodes);
}
const SMDS_MeshFace* SMDS_Mesh::FindFace (std::vector<const SMDS_MeshNode *> nodes)
{
int nbNodes = nodes.size();
if (nbNodes < 1) return NULL;
bool isFound = true;
const SMDS_MeshFace * face;
set<const SMDS_MeshFace *> faces;
for (int inode = 0; inode < nbNodes && isFound; inode++) {
set<const SMDS_MeshFace *> new_faces;
SMDS_ElemIteratorPtr itF = nodes[inode]->facesIterator();
while (itF->more()) {
face = static_cast<const SMDS_MeshFace *>(itF->next());
if (face->NbNodes() == nbNodes) {
if (inode == 0 || faces.find(face) != faces.end()) {
new_faces.insert(face);
}
}
}
faces = new_faces;
if (new_faces.size() == 0) {
isFound = false;
}
}
if (isFound)
return face;
return NULL;
}
//======================================================================= //=======================================================================
//function : DumpNodes //function : DumpNodes
//purpose : //purpose :
@ -1743,7 +1985,8 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
// get finite elements built on elem // get finite elements built on elem
set<const SMDS_MeshElement*> * s1; set<const SMDS_MeshElement*> * s1;
if (!hasConstructionEdges() && elem->GetType() == SMDSAbs_Edge || if (!hasConstructionEdges() && elem->GetType() == SMDSAbs_Edge ||
!hasConstructionFaces() && elem->GetType() == SMDSAbs_Face) !hasConstructionFaces() && elem->GetType() == SMDSAbs_Face ||
elem->GetType() == SMDSAbs_Volume)
{ {
s1 = new set<const SMDS_MeshElement*>(); s1 = new set<const SMDS_MeshElement*>();
s1->insert(elem); s1->insert(elem);
@ -1936,4 +2179,3 @@ void SMDS_Mesh::Renumber (const bool isNodes, const int startID, const int del
ID += deltaID; ID += deltaID;
} }
} }

View File

@ -201,6 +201,28 @@ public:
const SMDS_MeshFace * f5, const SMDS_MeshFace * f5,
const SMDS_MeshFace * f6); const SMDS_MeshFace * f6);
virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
const int ID);
virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<const SMDS_MeshNode*> nodes,
const int ID);
virtual SMDS_MeshFace* AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes);
virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
(std::vector<int> nodes_ids,
std::vector<int> quantities,
const int ID);
virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities,
const int ID);
virtual SMDS_MeshVolume* AddPolyhedralVolume
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities);
virtual void RemoveElement(const SMDS_MeshElement * elem, virtual void RemoveElement(const SMDS_MeshElement * elem,
std::list<const SMDS_MeshElement *>& removedElems, std::list<const SMDS_MeshElement *>& removedElems,
std::list<const SMDS_MeshElement *>& removedNodes, std::list<const SMDS_MeshElement *>& removedNodes,
@ -217,6 +239,9 @@ public:
static bool ChangeElementNodes(const SMDS_MeshElement * elem, static bool ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[], const SMDS_MeshNode * nodes[],
const int nbnodes); const int nbnodes);
static bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities);
virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1); virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
// Renumber all nodes or elements. // Renumber all nodes or elements.
@ -235,6 +260,10 @@ public:
const SMDS_MeshNode *n2, const SMDS_MeshNode *n2,
const SMDS_MeshNode *n3, const SMDS_MeshNode *n3,
const SMDS_MeshNode *n4); const SMDS_MeshNode *n4);
const SMDS_MeshFace *FindFace(std::vector<int> nodes_ids) const;
static const SMDS_MeshFace* FindFace(std::vector<const SMDS_MeshNode *> nodes);
int MaxNodeID() const; int MaxNodeID() const;
int MinNodeID() const; int MinNodeID() const;
int MaxElementID() const; int MaxElementID() const;

View File

@ -59,6 +59,8 @@ class SMDS_MeshElement:public SMDS_MeshObject
///Return the type of the current element ///Return the type of the current element
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
virtual bool IsPoly() const { return false; };
friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *); friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem); friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);

View File

@ -125,7 +125,7 @@ void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
// the type of the group is determined by the first element added // the type of the group is determined by the first element added
if (myElements.empty()) myType = theElem->GetType(); if (myElements.empty()) myType = theElem->GetType();
else if (theElem->GetType() != myType) else if (theElem->GetType() != myType)
MESSAGE("SMDS_MeshGroup::Add : Type Mismatch"); MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
myElements.insert(theElem); myElements.insert(theElem);
} }

View File

@ -44,8 +44,9 @@ int SMDS_MeshIDFactory::GetFreeID()
if (myPoolOfID.empty()) return ++myMaxID; if (myPoolOfID.empty()) return ++myMaxID;
else else
{ {
int ID = myPoolOfID.top(); set<int>::iterator i = myPoolOfID.begin();
myPoolOfID.pop(); int ID = *i;//myPoolOfID.top();
myPoolOfID.erase( i );//myPoolOfID.pop();
return ID; return ID;
} }
} }
@ -56,5 +57,27 @@ int SMDS_MeshIDFactory::GetFreeID()
//======================================================================= //=======================================================================
void SMDS_MeshIDFactory::ReleaseID(const int ID) void SMDS_MeshIDFactory::ReleaseID(const int ID)
{ {
if (ID > 0 && ID < myMaxID) myPoolOfID.push(ID); if ( ID > 0 )
{
if ( ID < myMaxID )
{
myPoolOfID.insert(ID);
}
else if ( ID == myMaxID )
{
--myMaxID;
if ( !myPoolOfID.empty() ) // assure that myMaxID is not in myPoolOfID
{
set<int>::iterator i = --myPoolOfID.end();
while ( i != myPoolOfID.begin() && myMaxID == *i ) {
--myMaxID; --i;
}
if ( myMaxID == *i )
--myMaxID; // begin of myPoolOfID reached
else
++i;
myPoolOfID.erase( i, myPoolOfID.end() );
}
}
}
} }

View File

@ -28,7 +28,7 @@
#define _SMDS_MeshIDFactory_HeaderFile #define _SMDS_MeshIDFactory_HeaderFile
#include "SMDS_MeshObject.hxx" #include "SMDS_MeshObject.hxx"
#include <stack> #include <set>
class SMDS_MeshIDFactory:public SMDS_MeshObject class SMDS_MeshIDFactory:public SMDS_MeshObject
@ -40,7 +40,7 @@ class SMDS_MeshIDFactory:public SMDS_MeshObject
protected: protected:
SMDS_MeshIDFactory(); SMDS_MeshIDFactory();
int myMaxID; int myMaxID;
std::stack<int> myPoolOfID; std::set<int> myPoolOfID;
}; };
#endif #endif

View File

@ -0,0 +1,174 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
#include "SMDS_PolygonalFaceOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
//#include "SMDS_MeshNode.hxx"
#include "utilities.h"
using namespace std;
//=======================================================================
//function : Constructor
//purpose :
//=======================================================================
SMDS_PolygonalFaceOfNodes::SMDS_PolygonalFaceOfNodes
(std::vector<const SMDS_MeshNode *> nodes)
{
myNodes = nodes;
}
//=======================================================================
//function : GetType
//purpose :
//=======================================================================
SMDSAbs_ElementType SMDS_PolygonalFaceOfNodes::GetType() const
{
return SMDSAbs_Face;
//return SMDSAbs_PolygonalFace;
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_PolygonalFaceOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode *> nodes)
{
if (nodes.size() < 3)
return false;
myNodes = nodes;
return true;
}
//=======================================================================
//function : ChangeNodes
//purpose : to support the same interface, as SMDS_FaceOfNodes
//=======================================================================
bool SMDS_PolygonalFaceOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],
const int nbNodes)
{
if (nbNodes < 3)
return false;
myNodes.resize(nbNodes);
int i = 0;
for (; i < nbNodes; i++) {
myNodes[i] = nodes[i];
}
return true;
}
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
int SMDS_PolygonalFaceOfNodes::NbNodes() const
{
return myNodes.size();
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
int SMDS_PolygonalFaceOfNodes::NbEdges() const
{
return NbNodes();
}
//=======================================================================
//function : NbFaces
//purpose :
//=======================================================================
int SMDS_PolygonalFaceOfNodes::NbFaces() const
{
return 1;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_PolygonalFaceOfNodes::Print(ostream & OS) const
{
OS << "polygonal face <" << GetID() << " > : ";
int i, nbNodes = myNodes.size();
for (i = 0; i < nbNodes - 1; i++)
OS << myNodes[i] << ",";
OS << myNodes[i] << ") " << endl;
}
//=======================================================================
//function : elementsIterator
//purpose :
//=======================================================================
class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_ElemIterator
{
//const SMDS_MeshNode* const *mySet;
const std::vector<const SMDS_MeshNode *> mySet;
//int myLength;
int index;
public:
//SMDS_PolygonalFaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
// mySet(s),myLength(l),index(0) {}
SMDS_PolygonalFaceOfNodes_MyIterator(const std::vector<const SMDS_MeshNode *> s):
mySet(s),index(0) {}
bool more()
{
return index < mySet.size();
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
};
SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator
(SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Face:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes));
case SMDSAbs_Edge:
MESSAGE("Error : edge iterator for SMDS_PolygonalFaceOfNodes not implemented");
break;
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type,SMDS_ElemIteratorPtr
(new SMDS_PolygonalFaceOfNodes_MyIterator(myNodes))));
}
return SMDS_ElemIteratorPtr();
}

View File

@ -0,0 +1,60 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifndef _SMDS_PolygonalFaceOfNodes_HeaderFile
#define _SMDS_PolygonalFaceOfNodes_HeaderFile
#include "SMDS_MeshFace.hxx"
//#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_Iterator.hxx"
#include <iostream>
//class SMDS_PolygonalFaceOfNodes:public SMDS_FaceOfNodes
class SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace
{
public:
SMDS_PolygonalFaceOfNodes (std::vector<const SMDS_MeshNode *> nodes);
virtual SMDSAbs_ElementType GetType() const;
virtual bool IsPoly() const { return true; };
bool ChangeNodes (std::vector<const SMDS_MeshNode *> nodes);
bool ChangeNodes (const SMDS_MeshNode* nodes[],
const int nbNodes);
// to support the same interface, as SMDS_FaceOfNodes
virtual int NbNodes() const;
virtual int NbEdges() const;
virtual int NbFaces() const;
virtual void Print (std::ostream & OS) const;
protected:
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
private:
std::vector<const SMDS_MeshNode *> myNodes;
};
#endif

View File

@ -0,0 +1,182 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#ifdef _MSC_VER
#pragma warning(disable:4786)
#endif
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
#include <set>
using namespace std;
//=======================================================================
//function : Constructor
//purpose : Create a volume of many faces
//=======================================================================
SMDS_PolyhedralVolumeOfNodes::SMDS_PolyhedralVolumeOfNodes
(std::vector<const SMDS_MeshNode *> nodes,
std::vector<int> quantities)
: SMDS_VolumeOfNodes(NULL, NULL, NULL, NULL)
{
ChangeNodes(nodes, quantities);
}
//=======================================================================
//function : GetType
//purpose :
//=======================================================================
SMDSAbs_ElementType SMDS_PolyhedralVolumeOfNodes::GetType() const
{
// return SMDSAbs_PolyhedralVolume;
return SMDSAbs_Volume;
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (std::vector<const SMDS_MeshNode *> nodes,
std::vector<int> quantities)
{
myNodesByFaces = nodes;
myQuantities = quantities;
// Init fields of parent class
int aNbNodes = 0;
std::set<const SMDS_MeshNode *> aSet;
int nodes_len = nodes.size();
for (int j = 0; j < nodes_len; j++) {
if (aSet.find(nodes[j]) == aSet.end()) {
aSet.insert(nodes[j]);
aNbNodes++;
}
}
int k = 0;
const SMDS_MeshNode* aNodes [aNbNodes];
std::set<const SMDS_MeshNode *>::iterator anIter = aSet.begin();
for (; anIter != aSet.end(); anIter++, k++) {
aNodes[k] = *anIter;
}
//SMDS_VolumeOfNodes::ChangeNodes(aNodes, aNbNodes);
delete [] myNodes;
//myNbNodes = nodes.size();
myNbNodes = aNbNodes;
myNodes = new const SMDS_MeshNode* [myNbNodes];
for (int i = 0; i < myNbNodes; i++) {
//myNodes[i] = nodes[i];
myNodes[i] = aNodes[i];
}
return true;
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
int SMDS_PolyhedralVolumeOfNodes::NbEdges() const
{
int nbEdges = 0;
for (int ifa = 0; ifa < myQuantities.size(); ifa++) {
nbEdges += myQuantities[ifa];
}
nbEdges /= 2;
return nbEdges;
}
//=======================================================================
//function : NbFaces
//purpose :
//=======================================================================
int SMDS_PolyhedralVolumeOfNodes::NbFaces() const
{
return myQuantities.size();
}
//=======================================================================
//function : NbFaceNodes
//purpose :
//=======================================================================
int SMDS_PolyhedralVolumeOfNodes::NbFaceNodes (const int face_ind) const
{
if (face_ind < 1 || myQuantities.size() < face_ind)
return 0;
return myQuantities[face_ind - 1];
}
//=======================================================================
//function : GetFaceNode
//purpose :
//=======================================================================
const SMDS_MeshNode* SMDS_PolyhedralVolumeOfNodes::GetFaceNode (const int face_ind,
const int node_ind) const
{
if (node_ind < 1 || NbFaceNodes(face_ind) < node_ind)
return NULL;
int i, first_node = 0;
for (i = 0; i < face_ind - 1; i++) {
first_node += myQuantities[i];
}
return myNodesByFaces[first_node + node_ind - 1];
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_PolyhedralVolumeOfNodes::Print (ostream & OS) const
{
OS << "polyhedral volume <" << GetID() << "> : ";
int faces_len = myQuantities.size();
//int nodes_len = myNodesByFaces.size();
int cur_first_node = 0;
int i, j;
for (i = 0; i < faces_len; i++) {
OS << "face_" << i << " (";
for (j = 0; j < myQuantities[i] - 1; j++) {
OS << myNodesByFaces[cur_first_node + j] << ",";
}
OS << myNodesByFaces[cur_first_node + j] << ") ";
cur_first_node += myQuantities[i];
}
}
//=======================================================================
//function : ChangeNodes
//purpose : usage disabled
//=======================================================================
bool SMDS_PolyhedralVolumeOfNodes::ChangeNodes (const SMDS_MeshNode* nodes[],
const int nbNodes)
{
return false;
}

View File

@ -0,0 +1,72 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_PolyhedralVolumeOfNodes.hxx
// Module : SMESH
#ifndef _SMDS_PolyhedralVolumeOfNodes_HeaderFile
#define _SMDS_PolyhedralVolumeOfNodes_HeaderFile
#include "SMDS_VolumeOfNodes.hxx"
class SMDS_PolyhedralVolumeOfNodes:public SMDS_VolumeOfNodes
{
public:
SMDS_PolyhedralVolumeOfNodes (std::vector<const SMDS_MeshNode *> nodes,
std::vector<int> quantities);
//virtual ~SMDS_PolyhedralVolumeOfNodes();
virtual SMDSAbs_ElementType GetType() const;
virtual bool IsPoly() const { return true; };
bool ChangeNodes (std::vector<const SMDS_MeshNode *> nodes,
std::vector<int> quantities);
//virtual int NbNodes() const;
virtual int NbEdges() const;
virtual int NbFaces() const;
int NbFaceNodes (const int face_ind) const;
// 1 <= face_ind <= NbFaces()
const SMDS_MeshNode* GetFaceNode (const int face_ind, const int node_ind) const;
// 1 <= face_ind <= NbFaces()
// 1 <= node_ind <= NbFaceNodes()
virtual void Print (std::ostream & OS) const;
protected:
//virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
private:
// usage disabled
bool ChangeNodes (const SMDS_MeshNode* nodes[],
const int nbNodes);
private:
std::vector<const SMDS_MeshNode *> myNodesByFaces;
std::vector<int> myQuantities;
};
#endif

View File

@ -11,6 +11,10 @@
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_PolyhedralVolumeOfNodes.hxx"
#include "utilities.h"
#include <map> #include <map>
#include <float.h> #include <float.h>
#include <math.h> #include <math.h>
@ -200,19 +204,36 @@ double XYZ::Magnitude() {
SMDS_VolumeTool::SMDS_VolumeTool () SMDS_VolumeTool::SMDS_VolumeTool ()
: myVolume( 0 ), : myVolume( 0 ),
myPolyedre( 0 ),
myVolForward( true ), myVolForward( true ),
myNbFaces( 0 ), myNbFaces( 0 ),
myVolumeNbNodes( 0 ), myVolumeNbNodes( 0 ),
myExternalFaces( false ) myVolumeNodes( NULL ),
myExternalFaces( false ),
myFaceNbNodes( 0 ),
myCurFace( -1 ),
myFaceNodeIndices( NULL ),
myFaceNodes( NULL )
{ {
} }
//======================================================================= //=======================================================================
//function : SMDS_VolumeTool //function : SMDS_VolumeTool
//purpose : //purpose :
//======================================================================= //=======================================================================
SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume) SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume)
: myExternalFaces( false ) : myVolume( 0 ),
myPolyedre( 0 ),
myVolForward( true ),
myNbFaces( 0 ),
myVolumeNbNodes( 0 ),
myVolumeNodes( NULL ),
myExternalFaces( false ),
myFaceNbNodes( 0 ),
myCurFace( -1 ),
myFaceNodeIndices( NULL ),
myFaceNodes( NULL )
{ {
Set( theVolume ); Set( theVolume );
} }
@ -224,6 +245,14 @@ SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume)
SMDS_VolumeTool::~SMDS_VolumeTool() SMDS_VolumeTool::~SMDS_VolumeTool()
{ {
if (myVolumeNodes != NULL) {
delete [] myVolumeNodes;
myVolumeNodes = NULL;
}
if (myFaceNodes != NULL) {
delete [] myFaceNodes;
myFaceNodes = NULL;
}
} }
//======================================================================= //=======================================================================
@ -234,38 +263,53 @@ SMDS_VolumeTool::~SMDS_VolumeTool()
bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume) bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume)
{ {
myVolume = 0; myVolume = 0;
myPolyedre = 0;
myVolForward = true; myVolForward = true;
myCurFace = -1;
myVolumeNbNodes = 0;
myNbFaces = 0; myNbFaces = 0;
myVolumeNbNodes = 0;
if (myVolumeNodes != NULL) {
delete [] myVolumeNodes;
myVolumeNodes = NULL;
}
myExternalFaces = false;
myFaceNbNodes = 0;
myCurFace = -1;
myFaceNodeIndices = NULL;
if (myFaceNodes != NULL) {
delete [] myFaceNodes;
myFaceNodes = NULL;
}
if ( theVolume && theVolume->GetType() == SMDSAbs_Volume ) if ( theVolume && theVolume->GetType() == SMDSAbs_Volume )
{ {
myVolume = theVolume;
myNbFaces = theVolume->NbFaces();
myVolumeNbNodes = theVolume->NbNodes(); myVolumeNbNodes = theVolume->NbNodes();
// set volume nodes
int iNode = 0;
myVolumeNodes = new const SMDS_MeshNode* [myVolumeNbNodes];
SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator();
while ( nodeIt->more() ) {
myVolumeNodes[ iNode++ ] = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
}
if (myVolume->IsPoly()) {
myPolyedre = static_cast<const SMDS_PolyhedralVolumeOfNodes*>( myVolume );
if (!myPolyedre) {
MESSAGE("Warning: bad volumic element");
return false;
}
} else {
switch ( myVolumeNbNodes ) { switch ( myVolumeNbNodes ) {
case 4: case 4:
case 5: case 5:
case 6: case 6:
case 8: case 8: {
{
myVolume = theVolume;
myNbFaces = theVolume->NbFaces();
// set volume nodes
int iNode = 0;
SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator();
while ( nodeIt->more() )
myVolumeNodes[ iNode++ ] = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// nb nodes in each face
if ( myVolumeNbNodes == 4 )
myFaceNbNodes = Tetra_nbN;
else if ( myVolumeNbNodes == 5 )
myFaceNbNodes = Pyramid_nbN;
else if ( myVolumeNbNodes == 6 )
myFaceNbNodes = Penta_nbN;
else
myFaceNbNodes = Hexa_nbN;
// define volume orientation // define volume orientation
XYZ botNormal; XYZ botNormal;
GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z ); GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z );
@ -277,15 +321,17 @@ bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume)
myVolForward = ( botNormal.Dot( upDir ) < 0 ); myVolForward = ( botNormal.Dot( upDir ) < 0 );
break; break;
} }
default: myVolume = 0; default:
break;
}
} }
} }
return ( myVolume != 0 ); return ( myVolume != 0 );
} }
//======================================================================= //=======================================================================
//function : GetInverseNodes //function : Inverse
//purpose : Return nodes vector of an inverse volume //purpose : Inverse volume
//======================================================================= //=======================================================================
#define SWAP_NODES(nodes,i1,i2) \ #define SWAP_NODES(nodes,i1,i2) \
@ -298,6 +344,11 @@ void SMDS_VolumeTool::Inverse ()
{ {
if ( !myVolume ) return; if ( !myVolume ) return;
if (myVolume->IsPoly()) {
MESSAGE("Warning: attempt to inverse polyhedral volume");
return;
}
myVolForward = !myVolForward; myVolForward = !myVolForward;
myCurFace = -1; myCurFace = -1;
@ -374,7 +425,7 @@ int SMDS_VolumeTool::NbFaceNodes( int faceIndex )
{ {
if ( !setFace( faceIndex )) if ( !setFace( faceIndex ))
return 0; return 0;
return myFaceNbNodes[ faceIndex ]; return myFaceNbNodes;
} }
//======================================================================= //=======================================================================
@ -402,6 +453,10 @@ const SMDS_MeshNode** SMDS_VolumeTool::GetFaceNodes( int faceIndex )
const int* SMDS_VolumeTool::GetFaceNodesIndices( int faceIndex ) const int* SMDS_VolumeTool::GetFaceNodesIndices( int faceIndex )
{ {
if (myVolume->IsPoly()) {
MESSAGE("Warning: attempt to obtain FaceNodesIndices of polyhedral volume");
return NULL;
}
if ( !setFace( faceIndex )) if ( !setFace( faceIndex ))
return 0; return 0;
return myFaceNodeIndices; return myFaceNodeIndices;
@ -419,7 +474,7 @@ bool SMDS_VolumeTool::GetFaceNodes (int faceIndex,
return false; return false;
theFaceNodes.clear(); theFaceNodes.clear();
int iNode, nbNode = myFaceNbNodes[ faceIndex ]; int iNode, nbNode = myFaceNbNodes;
for ( iNode = 0; iNode < nbNode; iNode++ ) for ( iNode = 0; iNode < nbNode; iNode++ )
theFaceNodes.insert( myFaceNodes[ iNode ]); theFaceNodes.insert( myFaceNodes[ iNode ]);
@ -436,6 +491,16 @@ bool SMDS_VolumeTool::IsFaceExternal( int faceIndex )
if ( myExternalFaces || !myVolume ) if ( myExternalFaces || !myVolume )
return true; return true;
if (myVolume->IsPoly()) {
XYZ aNormal, baryCenter, p0 (myPolyedre->GetFaceNode(faceIndex + 1, 1));
GetFaceNormal(faceIndex, aNormal.x, aNormal.y, aNormal.z);
GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z);
XYZ insideVec (baryCenter - p0);
if (insideVec.Dot(aNormal) > 0)
return false;
return true;
}
switch ( myVolumeNbNodes ) { switch ( myVolumeNbNodes ) {
case 4: case 4:
case 5: case 5:
@ -482,7 +547,6 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub
return true; return true;
} }
//======================================================================= //=======================================================================
//function : GetFaceArea //function : GetFaceArea
//purpose : Return face area //purpose : Return face area
@ -490,6 +554,11 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub
double SMDS_VolumeTool::GetFaceArea( int faceIndex ) double SMDS_VolumeTool::GetFaceArea( int faceIndex )
{ {
if (myVolume->IsPoly()) {
MESSAGE("Warning: attempt to obtain area of a face of polyhedral volume");
return 0;
}
if ( !setFace( faceIndex )) if ( !setFace( faceIndex ))
return 0; return 0;
@ -500,7 +569,7 @@ double SMDS_VolumeTool::GetFaceArea( int faceIndex )
XYZ aVec13( p3 - p1 ); XYZ aVec13( p3 - p1 );
double area = aVec12.Crossed( aVec13 ).Magnitude() * 0.5; double area = aVec12.Crossed( aVec13 ).Magnitude() * 0.5;
if ( myFaceNbNodes[ faceIndex ] == 4 ) { if ( myFaceNbNodes == 4 ) {
XYZ p4 ( myFaceNodes[3] ); XYZ p4 ( myFaceNodes[3] );
XYZ aVec14( p4 - p1 ); XYZ aVec14( p4 - p1 );
area += aVec14.Crossed( aVec13 ).Magnitude() * 0.5; area += aVec14.Crossed( aVec13 ).Magnitude() * 0.5;
@ -516,6 +585,11 @@ double SMDS_VolumeTool::GetFaceArea( int faceIndex )
int SMDS_VolumeTool::GetOppFaceIndex( int faceIndex ) const int SMDS_VolumeTool::GetOppFaceIndex( int faceIndex ) const
{ {
int ind = -1; int ind = -1;
if (myVolume->IsPoly()) {
MESSAGE("Warning: attempt to obtain opposite face on polyhedral volume");
return ind;
}
if ( faceIndex >= 0 && faceIndex < NbFaces() ) { if ( faceIndex >= 0 && faceIndex < NbFaces() ) {
switch ( myVolumeNbNodes ) { switch ( myVolumeNbNodes ) {
case 6: case 6:
@ -542,6 +616,33 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1,
if ( !myVolume ) if ( !myVolume )
return false; return false;
if (myVolume->IsPoly()) {
if (!myPolyedre) {
MESSAGE("Warning: bad volumic element");
return false;
}
bool isLinked = false;
int iface;
for (iface = 1; iface <= myNbFaces && !isLinked; iface++) {
int inode, nbFaceNodes = myPolyedre->NbFaceNodes(iface);
for (inode = 1; inode <= nbFaceNodes && !isLinked; inode++) {
const SMDS_MeshNode* curNode = myPolyedre->GetFaceNode(iface, inode);
if (curNode == theNode1 || curNode == theNode2) {
int inextnode = (inode == nbFaceNodes) ? 1 : inode + 1;
const SMDS_MeshNode* nextNode = myPolyedre->GetFaceNode(iface, inextnode);
if ((curNode == theNode1 && nextNode == theNode2) ||
(curNode == theNode2 && nextNode == theNode1)) {
isLinked = true;
}
}
}
}
return isLinked;
}
// find nodes indices // find nodes indices
int i1 = -1, i2 = -1; int i1 = -1, i2 = -1;
for ( int i = 0; i < myVolumeNbNodes; i++ ) { for ( int i = 0; i < myVolumeNbNodes; i++ ) {
@ -562,6 +663,10 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1,
bool SMDS_VolumeTool::IsLinked (const int theNode1Index, bool SMDS_VolumeTool::IsLinked (const int theNode1Index,
const int theNode2Index) const const int theNode2Index) const
{ {
if (myVolume->IsPoly()) {
return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]);
}
int minInd = theNode1Index < theNode2Index ? theNode1Index : theNode2Index; int minInd = theNode1Index < theNode2Index ? theNode1Index : theNode2Index;
int maxInd = theNode1Index < theNode2Index ? theNode2Index : theNode1Index; int maxInd = theNode1Index < theNode2Index ? theNode2Index : theNode1Index;
@ -617,7 +722,6 @@ int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const
return -1; return -1;
} }
//======================================================================= //=======================================================================
//function : IsFreeFace //function : IsFreeFace
//purpose : check that only one volume is build on the face nodes //purpose : check that only one volume is build on the face nodes
@ -626,11 +730,12 @@ int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const
bool SMDS_VolumeTool::IsFreeFace( int faceIndex ) bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
{ {
const int free = true; const int free = true;
if (!setFace( faceIndex )) if (!setFace( faceIndex ))
return !free; return !free;
const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex ); const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex );
int nbFaceNodes = NbFaceNodes( faceIndex ); int nbFaceNodes = myFaceNbNodes;
// evaluate nb of face nodes shared by other volume // evaluate nb of face nodes shared by other volume
int maxNbShared = -1; int maxNbShared = -1;
@ -706,7 +811,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
// check traingle parts 1 & 3 // check traingle parts 1 & 3
if ( isShared[1] && isShared[3] ) if ( isShared[1] && isShared[3] )
return !free; // is not free return !free; // is not free
// check traingle parts 0 & 2; // check triangle parts 0 & 2;
// 0 part could not be checked in the loop; check it here // 0 part could not be checked in the loop; check it here
if ( isShared[2] && prevLinkShared && if ( isShared[2] && prevLinkShared &&
volume.IsLinked( nodes[ 0 ], nodes[ 1 ] ) && volume.IsLinked( nodes[ 0 ], nodes[ 1 ] ) &&
@ -741,7 +846,7 @@ int SMDS_VolumeTool::GetFaceIndex( const set<const SMDS_MeshNode*>& theFaceNodes
//purpose : Return index of a face formed by theFaceNodes //purpose : Return index of a face formed by theFaceNodes
//======================================================================= //=======================================================================
int SMDS_VolumeTool::GetFaceIndex( const set<int>& theFaceNodesIndices ) /*int SMDS_VolumeTool::GetFaceIndex( const set<int>& theFaceNodesIndices )
{ {
for ( int iFace = 0; iFace < myNbFaces; iFace++ ) { for ( int iFace = 0; iFace < myNbFaces; iFace++ ) {
const int* nodes = GetFaceNodesIndices( iFace ); const int* nodes = GetFaceNodesIndices( iFace );
@ -753,7 +858,7 @@ int SMDS_VolumeTool::GetFaceIndex( const set<int>& theFaceNodesIndices )
return iFace; return iFace;
} }
return -1; return -1;
} }*/
//======================================================================= //=======================================================================
//function : setFace //function : setFace
@ -768,44 +873,163 @@ bool SMDS_VolumeTool::setFace( int faceIndex )
if ( myCurFace == faceIndex ) if ( myCurFace == faceIndex )
return true; return true;
myCurFace = -1;
if ( faceIndex < 0 || faceIndex >= NbFaces() ) if ( faceIndex < 0 || faceIndex >= NbFaces() )
return false; return false;
if (myFaceNodes != NULL) {
delete [] myFaceNodes;
myFaceNodes = NULL;
}
if (myVolume->IsPoly()) {
if (!myPolyedre) {
MESSAGE("Warning: bad volumic element");
return false;
}
// check orientation
bool isGoodOri = true;
if (myExternalFaces) {
// get natural orientation
XYZ aNormal, baryCenter, p0 (myPolyedre->GetFaceNode(faceIndex + 1, 1));
SMDS_VolumeTool vTool (myPolyedre);
vTool.GetFaceNormal(faceIndex, aNormal.x, aNormal.y, aNormal.z);
vTool.GetBaryCenter(baryCenter.x, baryCenter.y, baryCenter.z);
XYZ insideVec (baryCenter - p0);
if (insideVec.Dot(aNormal) > 0)
isGoodOri = false;
}
// set face nodes
int iNode;
myFaceNbNodes = myPolyedre->NbFaceNodes(faceIndex + 1);
myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1];
if (isGoodOri) {
for ( iNode = 0; iNode < myFaceNbNodes; iNode++ )
myFaceNodes[ iNode ] = myPolyedre->GetFaceNode(faceIndex + 1, iNode + 1);
} else {
for ( iNode = 0; iNode < myFaceNbNodes; iNode++ )
myFaceNodes[ iNode ] = myPolyedre->GetFaceNode(faceIndex + 1, myFaceNbNodes - iNode);
}
myFaceNodes[ myFaceNbNodes ] = myFaceNodes[ 0 ]; // last = first
} else {
// choose face node indices // choose face node indices
switch ( myVolumeNbNodes ) { switch ( myVolumeNbNodes ) {
case 4: case 4:
myFaceNbNodes = Tetra_nbN[ faceIndex ];
if ( myExternalFaces ) if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ]; myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ];
else else
myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ]; myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ];
break; break;
case 5: case 5:
myFaceNbNodes = Pyramid_nbN[ faceIndex ];
if ( myExternalFaces ) if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ]; myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ];
else else
myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ]; myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ];
break; break;
case 6: case 6:
myFaceNbNodes = Penta_nbN[ faceIndex ];
if ( myExternalFaces ) if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ]; myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ];
else else
myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ]; myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ];
break; break;
case 8: case 8:
myFaceNbNodes = Hexa_nbN[ faceIndex ];
if ( myExternalFaces ) if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ]; myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ];
else else
myFaceNodeIndices = Hexa_F[ faceIndex ]; myFaceNodeIndices = Hexa_F[ faceIndex ];
break; break;
default: return false; default:
return false;
} }
// set face nodes // set face nodes
int iNode, nbNode = myFaceNbNodes[ faceIndex ]; myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1];
for ( iNode = 0; iNode <= nbNode; iNode++ ) for ( int iNode = 0; iNode <= myFaceNbNodes; iNode++ )
myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]]; myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]];
}
myCurFace = faceIndex; myCurFace = faceIndex;
return true; return true;
} }
//=======================================================================
//function : GetType
//purpose : return VolumeType by nb of nodes in a volume
//=======================================================================
SMDS_VolumeTool::VolumeType SMDS_VolumeTool::GetType(int nbNodes)
{
switch ( nbNodes ) {
case 4: return TETRA;
case 5: return PYRAM;
case 6: return PENTA;
case 8: return HEXA;
default:return UNKNOWN;
}
}
//=======================================================================
//function : NbFaces
//purpose : return nb of faces by volume type
//=======================================================================
int SMDS_VolumeTool::NbFaces( VolumeType type )
{
switch ( type ) {
case TETRA: return 4;
case PYRAM: return 5;
case PENTA: return 5;
case HEXA : return 6;
default: return 0;
}
}
//=======================================================================
//function : GetFaceNodesIndices
//purpose : Return the array of face nodes indices
// To comfort link iteration, the array
// length == NbFaceNodes( faceIndex ) + 1 and
// the last node index == the first one.
//=======================================================================
const int* SMDS_VolumeTool::GetFaceNodesIndices(VolumeType type,
int faceIndex,
bool external)
{
switch ( type ) {
case TETRA: return Tetra_F[ faceIndex ];
case PYRAM: return Pyramid_F[ faceIndex ];
case PENTA: return external ? Penta_FE[ faceIndex ] : Penta_F[ faceIndex ];
case HEXA: return external ? Hexa_FE[ faceIndex ] : Hexa_F[ faceIndex ];
default:;
}
return 0;
}
//=======================================================================
//function : NbFaceNodes
//purpose : Return number of nodes in the array of face nodes
//=======================================================================
int SMDS_VolumeTool::NbFaceNodes(VolumeType type,
int faceIndex )
{
switch ( type ) {
case TETRA: return Tetra_nbN[ faceIndex ];
case PYRAM: return Pyramid_nbN[ faceIndex ];
case PENTA: return Penta_nbN[ faceIndex ];
case HEXA: return Hexa_nbN[ faceIndex ];
default:;
}
return 0;
}

View File

@ -32,6 +32,7 @@
class SMDS_MeshElement; class SMDS_MeshElement;
class SMDS_MeshNode; class SMDS_MeshNode;
class SMDS_PolyhedralVolumeOfNodes;
#include <vector> #include <vector>
#include <set> #include <set>
@ -149,26 +150,52 @@ class SMDS_VolumeTool
// Return index of a face formed by theFaceNodes. // Return index of a face formed by theFaceNodes.
// Return -1 if a face not found // Return -1 if a face not found
int GetFaceIndex( const std::set<int>& theFaceNodesIndices ); //int GetFaceIndex( const std::set<int>& theFaceNodesIndices );
// Return index of a face formed by theFaceNodesIndices // Return index of a face formed by theFaceNodesIndices
// Return -1 if a face not found // Return -1 if a face not found
// ------------------------
// static methods for faces
// ------------------------
enum VolumeType { UNKNOWN, TETRA, PYRAM, PENTA, HEXA };
static VolumeType GetType(int nbNodes);
// return VolumeType by nb of nodes in a volume
static int NbFaces( VolumeType type );
// return nb of faces by volume type
static const int* GetFaceNodesIndices(VolumeType type,
int faceIndex,
bool external);
// Return the array of face nodes indices
// To comfort link iteration, the array
// length == NbFaceNodes( faceIndex ) + 1 and
// the last node index == the first one.
static int NbFaceNodes(VolumeType type,
int faceIndex );
// Return number of nodes in the array of face nodes
private: private:
bool setFace( int faceIndex ); bool setFace( int faceIndex );
const SMDS_MeshElement* myVolume; const SMDS_MeshElement* myVolume;
const SMDS_PolyhedralVolumeOfNodes* myPolyedre;
bool myVolForward; bool myVolForward;
int myNbFaces; int myNbFaces;
int myVolumeNbNodes; int myVolumeNbNodes;
const SMDS_MeshNode* myVolumeNodes[ 8 ]; const SMDS_MeshNode** myVolumeNodes;
bool myExternalFaces; bool myExternalFaces;
int* myFaceNodeIndices;
int* myFaceNbNodes;
const SMDS_MeshNode* myFaceNodes[ 5 ];
int myCurFace; int myCurFace;
int myFaceNbNodes;
int* myFaceNodeIndices;
const SMDS_MeshNode** myFaceNodes;
}; };
#endif #endif

View File

@ -79,7 +79,7 @@ static int MYDEBUG = 0;
SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument) SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument)
: _groupId( 0 ) : _groupId( 0 )
{ {
INFOS("SMESH_Mesh::SMESH_Mesh; this = "<<this); INFOS("SMESH_Mesh::SMESH_Mesh(int localId)");
_id = localId; _id = localId;
_studyId = studyId; _studyId = studyId;
_gen = gen; _gen = gen;
@ -97,7 +97,7 @@ SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Docume
SMESH_Mesh::~SMESH_Mesh() SMESH_Mesh::~SMESH_Mesh()
{ {
INFOS("SMESH_Mesh::~SMESH_Mesh; this = "<<this); INFOS("SMESH_Mesh::~SMESH_Mesh");
// delete groups // delete groups
map < int, SMESH_Group * >::iterator itg; map < int, SMESH_Group * >::iterator itg;
@ -660,6 +660,24 @@ throw(SALOME_Exception)
return aSubMesh; return aSubMesh;
} }
//=============================================================================
/*!
* Get the SMESH_subMesh object implementation. Dont create it, return null
* if it does not exist.
*/
//=============================================================================
SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const int aShapeID)
throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(aShapeID);
if (i_sm == _mapSubMesh.end())
return NULL;
return i_sm->second;
}
//======================================================================= //=======================================================================
//function : IsUsedHypothesis //function : IsUsedHypothesis
//purpose : Return True if anHyp is used to mesh aSubShape //purpose : Return True if anHyp is used to mesh aSubShape
@ -833,7 +851,12 @@ int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
int Nb = 0; int Nb = 0;
SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++; //while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++;
const SMDS_MeshFace * curFace;
while (itFaces->more()) {
curFace = itFaces->next();
if (!curFace->IsPoly() && curFace->NbNodes() == 3) Nb++;
}
return Nb; return Nb;
} }
@ -846,7 +869,25 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
int Nb = 0; int Nb = 0;
SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++; //while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++;
const SMDS_MeshFace * curFace;
while (itFaces->more()) {
curFace = itFaces->next();
if (!curFace->IsPoly() && curFace->NbNodes() == 4) Nb++;
}
return Nb;
}
///////////////////////////////////////////////////////////////////////////////
/// Return the number of polygonal faces in the mesh. This method run in O(n)
///////////////////////////////////////////////////////////////////////////////
int SMESH_Mesh::NbPolygons() throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
int Nb = 0;
SMDS_FaceIteratorPtr itFaces = _myMeshDS->facesIterator();
while (itFaces->more())
if (itFaces->next()->IsPoly()) Nb++;
return Nb; return Nb;
} }
@ -866,7 +907,12 @@ int SMESH_Mesh::NbTetras() throw(SALOME_Exception)
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++; //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++;
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 4) Nb++;
}
return Nb; return Nb;
} }
@ -875,7 +921,12 @@ int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++; //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++;
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 8) Nb++;
}
return Nb; return Nb;
} }
@ -884,7 +935,12 @@ int SMESH_Mesh::NbPyramids() throw(SALOME_Exception)
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++; //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++;
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 5) Nb++;
}
return Nb; return Nb;
} }
@ -893,7 +949,22 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception)
Unexpect aCatch(SalomeException); Unexpect aCatch(SalomeException);
int Nb = 0; int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++; //while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++;
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 6) Nb++;
}
return Nb;
}
int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
int Nb = 0;
SMDS_VolumeIteratorPtr itVolumes = _myMeshDS->volumesIterator();
while (itVolumes->more())
if (itVolumes->next()->IsPoly()) Nb++;
return Nb; return Nb;
} }
@ -992,8 +1063,8 @@ void SMESH_Mesh::RemoveGroup (const int theGroupID)
if (_mapGroup.find(theGroupID) == _mapGroup.end()) if (_mapGroup.find(theGroupID) == _mapGroup.end())
return; return;
GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() ); GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
delete _mapGroup[theGroupID];
_mapGroup.erase (theGroupID); _mapGroup.erase (theGroupID);
delete _mapGroup[theGroupID];
} }
//============================================================================= //=============================================================================

View File

@ -129,6 +129,9 @@ public:
SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape) SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape)
throw(SALOME_Exception); throw(SALOME_Exception);
SMESH_subMesh *GetSubMeshContaining(const int aShapeID)
throw(SALOME_Exception);
const list < SMESH_subMesh * >& const list < SMESH_subMesh * >&
GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
throw(SALOME_Exception); throw(SALOME_Exception);
@ -166,6 +169,8 @@ public:
int NbQuadrangles() throw(SALOME_Exception); int NbQuadrangles() throw(SALOME_Exception);
int NbPolygons() throw(SALOME_Exception);
int NbVolumes() throw(SALOME_Exception); int NbVolumes() throw(SALOME_Exception);
int NbTetras() throw(SALOME_Exception); int NbTetras() throw(SALOME_Exception);
@ -176,6 +181,8 @@ public:
int NbPrisms() throw(SALOME_Exception); int NbPrisms() throw(SALOME_Exception);
int NbPolyhedrons() throw(SALOME_Exception);
int NbSubMesh() throw(SALOME_Exception); int NbSubMesh() throw(SALOME_Exception);
int NbGroup() const { return _mapGroup.size(); } int NbGroup() const { return _mapGroup.size(); }

File diff suppressed because it is too large Load Diff

View File

@ -98,13 +98,16 @@ class SMESH_MeshEditor {
std::set<const SMDS_MeshNode*> & theFixedNodes, std::set<const SMDS_MeshNode*> & theFixedNodes,
const SmoothMethod theSmoothMethod, const SmoothMethod theSmoothMethod,
const int theNbIterations, const int theNbIterations,
double theTgtAspectRatio = 1.0); double theTgtAspectRatio = 1.0,
const bool the2D = true);
// Smooth theElements using theSmoothMethod during theNbIterations // Smooth theElements using theSmoothMethod during theNbIterations
// or until a worst element has aspect ratio <= theTgtAspectRatio. // or until a worst element has aspect ratio <= theTgtAspectRatio.
// Aspect Ratio varies in range [1.0, inf]. // Aspect Ratio varies in range [1.0, inf].
// If theElements is empty, the whole mesh is smoothed. // If theElements is empty, the whole mesh is smoothed.
// theFixedNodes contains additionally fixed nodes. Nodes built // theFixedNodes contains additionally fixed nodes. Nodes built
// on edges and boundary nodes are always fixed. // on edges and boundary nodes are always fixed.
// If the2D, smoothing is performed using UV parameters of nodes
// on geometrical faces
void RotationSweep (std::set<const SMDS_MeshElement*> & theElements, void RotationSweep (std::set<const SMDS_MeshElement*> & theElements,
@ -154,6 +157,12 @@ class SMESH_MeshEditor {
// Return list of group of nodes close to each other within theTolerance. // Return list of group of nodes close to each other within theTolerance.
// Search among theNodes or in the whole mesh if theNodes is empty. // Search among theNodes or in the whole mesh if theNodes is empty.
int SimplifyFace (const vector<const SMDS_MeshNode *> faceNodes,
vector<const SMDS_MeshNode *>& poly_nodes,
vector<int>& quantities) const;
// Split face, defined by <faceNodes>, into several faces by repeating nodes.
// Is used by MergeNodes()
void MergeNodes (TListOfListOfNodes & theNodeGroups); void MergeNodes (TListOfListOfNodes & theNodeGroups);
// In each group, the cdr of nodes are substituted by the first one // In each group, the cdr of nodes are substituted by the first one
// in all elements. // in all elements.
@ -189,7 +198,9 @@ class SMESH_MeshEditor {
const SMDS_MeshNode* theSide2FirstNode, const SMDS_MeshNode* theSide2FirstNode,
const SMDS_MeshNode* theSide2SecondNode, const SMDS_MeshNode* theSide2SecondNode,
const SMDS_MeshNode* theSide2ThirdNode = 0, const SMDS_MeshNode* theSide2ThirdNode = 0,
bool theSide2IsFreeBorder = true); const bool theSide2IsFreeBorder = true,
const bool toCreatePolygons = false,
const bool toCreatePolyedrs = false);
// Sew the free border to the side2 by replacing nodes in // Sew the free border to the side2 by replacing nodes in
// elements on the free border with nodes of the elements // elements on the free border with nodes of the elements
// of the side 2. If nb of links in the free border and // of the side 2. If nb of links in the free border and
@ -225,21 +236,28 @@ class SMESH_MeshEditor {
void InsertNodesIntoLink(const SMDS_MeshElement* theFace, void InsertNodesIntoLink(const SMDS_MeshElement* theFace,
const SMDS_MeshNode* theBetweenNode1, const SMDS_MeshNode* theBetweenNode1,
const SMDS_MeshNode* theBetweenNode2,
std::list<const SMDS_MeshNode*>& theNodesToInsert,
const bool toCreatePoly = false);
// insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
// If toCreatePoly is true, replace theFace by polygon, else split theFace.
void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1,
const SMDS_MeshNode* theBetweenNode2, const SMDS_MeshNode* theBetweenNode2,
std::list<const SMDS_MeshNode*>& theNodesToInsert); std::list<const SMDS_MeshNode*>& theNodesToInsert);
// insert theNodesToInsert into theFace between theBetweenNode1 // insert theNodesToInsert into all volumes, containing link
// and theBetweenNode2 and split theElement. // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
static int SortQuadNodes (const SMDS_Mesh * theMesh, // static int SortQuadNodes (const SMDS_Mesh * theMesh,
int theNodeIds[] ); // int theNodeIds[] );
// Set 4 nodes of a quadrangle face in a good order. // // Set 4 nodes of a quadrangle face in a good order.
// Swap 1<->2 or 2<->3 nodes and correspondingly return // // Swap 1<->2 or 2<->3 nodes and correspondingly return
// 1 or 2 else 0. // // 1 or 2 else 0.
//
static bool SortHexaNodes (const SMDS_Mesh * theMesh, // static bool SortHexaNodes (const SMDS_Mesh * theMesh,
int theNodeIds[] ); // int theNodeIds[] );
// Set 8 nodes of a hexahedron in a good order. // // Set 8 nodes of a hexahedron in a good order.
// Return success status // // Return success status
static void AddToSameGroups (const SMDS_MeshElement* elemToAdd, static void AddToSameGroups (const SMDS_MeshElement* elemToAdd,
const SMDS_MeshElement* elemInGroups, const SMDS_MeshElement* elemInGroups,

File diff suppressed because it is too large Load Diff

View File

@ -100,7 +100,7 @@ class SMESH_Pattern {
// the loaded pattern to <theFace>. The first key-point // the loaded pattern to <theFace>. The first key-point
// will be mapped into <theNodeIndexOnKeyPoint1>-th node // will be mapped into <theNodeIndexOnKeyPoint1>-th node
bool Apply (std::set<const SMDS_MeshFace*> theFaces, bool Apply (std::set<const SMDS_MeshFace*>& theFaces,
const int theNodeIndexOnKeyPoint1, const int theNodeIndexOnKeyPoint1,
const bool theReverse); const bool theReverse);
// Compute nodes coordinates applying // Compute nodes coordinates applying
@ -116,7 +116,7 @@ class SMESH_Pattern {
// (0,0,1) key-point will be mapped into <theNode000Index>-th // (0,0,1) key-point will be mapped into <theNode000Index>-th
// node. // node.
bool Apply (std::set<const SMDS_MeshVolume*> theVolumes, bool Apply (std::set<const SMDS_MeshVolume*>& theVolumes,
const int theNode000Index, const int theNode000Index,
const int theNode001Index); const int theNode001Index);
// Compute nodes coordinates applying // Compute nodes coordinates applying
@ -128,7 +128,9 @@ class SMESH_Pattern {
bool GetMappedPoints ( std::list<const gp_XYZ *> & thePoints ) const; bool GetMappedPoints ( std::list<const gp_XYZ *> & thePoints ) const;
// Return nodes coordinates computed by Apply() method // Return nodes coordinates computed by Apply() method
bool MakeMesh(SMESH_Mesh* theMesh); bool MakeMesh(SMESH_Mesh* theMesh,
const bool toCreatePolygons = false,
const bool toCreatePolyedrs = false);
// Create nodes and elements in <theMesh> using nodes // Create nodes and elements in <theMesh> using nodes
// coordinates computed by either of Apply...() methods // coordinates computed by either of Apply...() methods
@ -271,19 +273,44 @@ class SMESH_Pattern {
// are appended to theEdgesPointsList // are appended to theEdgesPointsList
typedef std::set<const SMDS_MeshNode*> TNodeSet; typedef std::set<const SMDS_MeshNode*> TNodeSet;
void mergePoints (std::map<TNodeSet,std::list<std::list<int> > >& xyzIndGroups,
std::map< int, std::list< std::list< int >* > >& reverseConnectivity); void mergePoints (const bool uniteGroups);
// Look for coincident points between myXYZs indexed with // Merge XYZ on edges and/or faces.
// list<int> of each element of xyzIndGroups. Coincident indices
// are merged in myElemXYZIDs using reverseConnectivity. void makePolyElements(const std::vector< const SMDS_MeshNode* >& theNodes,
const bool toCreatePolygons,
const bool toCreatePolyedrs);
// prepare intermediate data to create Polygons and Polyhedrons
void createElements(SMESH_Mesh* theMesh,
const std::vector<const SMDS_MeshNode* >& theNodesVector,
const std::list< std::list< int > > & theElemNodeIDs,
const std::vector<const SMDS_MeshElement*>& theElements);
// add elements to the mesh
bool getFacesDefinition(const SMDS_MeshNode** theBndNodes,
const int theNbBndNodes,
const std::vector< const SMDS_MeshNode* >& theNodes,
std::list< int >& theFaceDefs,
std::vector<int>& theQuantity);
// fill faces definition for a volume face defined by theBndNodes
// return true if a face definition changes
bool isReversed(const SMDS_MeshNode* theFirstNode,
const std::list< int >& theIdsList) const;
// check xyz ids order in theIdsList taking into account
// theFirstNode on a link
private: private:
// fields // fields
typedef std::list< int > TElemDef; // element definition is its nodes ids
bool myIs2D; bool myIs2D;
std::vector< TPoint > myPoints; std::vector< TPoint > myPoints;
std::list< int > myKeyPointIDs; std::list< int > myKeyPointIDs;
std::list< std::list< int > > myElemPointIDs; std::list< TElemDef > myElemPointIDs;
ErrorCode myErrorCode; ErrorCode myErrorCode;
bool myIsComputed; bool myIsComputed;
@ -293,19 +320,33 @@ class SMESH_Pattern {
// all functions assure that shapes are indexed so that first go // all functions assure that shapes are indexed so that first go
// ordered vertices, then ordered edge, then faces and maybe a shell // ordered vertices, then ordered edge, then faces and maybe a shell
TopTools_IndexedMapOfOrientedShape myShapeIDMap; TopTools_IndexedMapOfOrientedShape myShapeIDMap;
//TopTools_IndexedMapOfShape myShapeIDMap;
std::map< int, list< TPoint* > > myShapeIDToPointsMap; std::map< int, list< TPoint* > > myShapeIDToPointsMap;
// for the 2d case: // for the 2d case:
// nb of key-points in each of pattern boundaries // nb of key-points in each of pattern boundaries
std::list< int > myNbKeyPntInBoundary; std::list< int > myNbKeyPntInBoundary;
// to compute while applying to mesh elements, not to shapes // to compute while applying to mesh elements, not to shapes
std::vector<gp_XYZ> myXYZ;
std::list< std::list< int > > myElemXYZIDs; std::vector<gp_XYZ> myXYZ; // XYZ of nodes to create
std::map< int, const SMDS_MeshNode*> myXYZIdToNodeMap; // map id to node of a refined element std::list< TElemDef > myElemXYZIDs; // new elements definitions
std::map< int, const SMDS_MeshNode*> myXYZIdToNodeMap; // map XYZ id to node of a refined element
std::vector<const SMDS_MeshElement*> myElements; // refined elements std::vector<const SMDS_MeshElement*> myElements; // refined elements
std::vector<const SMDS_MeshNode*> myOrderedNodes; std::vector<const SMDS_MeshNode*> myOrderedNodes;
// elements to replace with polygon or polyhedron
std::vector<const SMDS_MeshElement*> myPolyElems;
// definitions of new poly elements
std::list< TElemDef > myPolyElemXYZIDs;
std::list< std::vector<int> > myPolyhedronQuantities;
// map a boundary to XYZs on it;
// a boundary (edge or face) is defined as a set of its nodes,
// XYZs on a boundary are indices of myXYZ s
std::map<TNodeSet,std::list<std::list<int> > > myIdsOnBoundary;
// map XYZ id to element it is in
std::map< int, std::list< TElemDef* > > myReverseConnectivity;
}; };

View File

@ -792,18 +792,21 @@ SMESH_Hypothesis::Hypothesis_Status
ASSERT(algo); ASSERT(algo);
if (!algo->CheckHypothesis((*_father),_subShape, ret )) if (!algo->CheckHypothesis((*_father),_subShape, ret ))
{ {
//two applying algo on the same shape not allowed
_meshDS->RemoveHypothesis(_subShape, anHyp);
if ( !SMESH_Hypothesis::IsStatusFatal( ret )) if ( !SMESH_Hypothesis::IsStatusFatal( ret ))
// ret should be fatal: anHyp was not added // ret should be fatal: anHyp was not added
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
} }
else if (!_father->IsUsedHypothesis( anHyp, _subShape )) else if (SMESH_Hypothesis::IsStatusFatal( ret ))
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
if (SMESH_Hypothesis::IsStatusFatal( ret ))
{ {
MESSAGE("do not add extra hypothesis");
_meshDS->RemoveHypothesis(_subShape, anHyp); _meshDS->RemoveHypothesis(_subShape, anHyp);
} }
else if (!_father->IsUsedHypothesis( anHyp, _subShape ))
{
_meshDS->RemoveHypothesis(_subShape, anHyp);
ret = SMESH_Hypothesis::HYP_INCOMPATIBLE;
}
else else
{ {
modifiedHyp = true; modifiedHyp = true;
@ -812,19 +815,11 @@ SMESH_Hypothesis::Hypothesis_Status
} }
case ADD_ALGO: { //already existing algo : on father ? case ADD_ALGO: { //already existing algo : on father ?
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// check if algo changes SetAlgoState(HYP_OK);
SMESH_HypoFilter f;
f.Init( SMESH_HypoFilter::IsAlgo() );
f.And( SMESH_HypoFilter::IsApplicableTo( _subShape ));
f.AndNot( SMESH_HypoFilter::Is( algo ));
const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( _subShape, f, true );
if (prevAlgo &&
string(algo->GetName()) != string(prevAlgo->GetName()) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
modifiedHyp = true;
break; break;
} }
case REMOVE_HYP: { case REMOVE_HYP: {
@ -845,13 +840,13 @@ SMESH_Hypothesis::Hypothesis_Status
} }
else else
{ {
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// check if algo remains SetAlgoState(HYP_OK);
if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
// check if same algo remains
if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) )
modifiedHyp = true;
} }
break; break;
} }
@ -860,6 +855,7 @@ SMESH_Hypothesis::Hypothesis_Status
ASSERT(algo); ASSERT(algo);
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
{ {
SetAlgoState(HYP_OK);
if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp if (_father->IsUsedHypothesis( anHyp, _subShape )) // new Hyp
modifiedHyp = true; modifiedHyp = true;
} }
@ -867,35 +863,27 @@ SMESH_Hypothesis::Hypothesis_Status
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
break; break;
} }
case ADD_FATHER_ALGO: { case ADD_FATHER_ALGO: { // a new algo on father
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
if ( algo == anHyp ) { // a new algo on father if ( algo == anHyp ) {
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// check if algo changes SetAlgoState(HYP_OK);
SMESH_HypoFilter f;
f.Init( SMESH_HypoFilter::IsAlgo() );
f.And( SMESH_HypoFilter::IsApplicableTo( _subShape ));
f.AndNot( SMESH_HypoFilter::Is( algo ));
const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( _subShape, f, true );
if (prevAlgo &&
string(algo->GetName()) != string(prevAlgo->GetName()) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
modifiedHyp = true;
} }
break; break;
} }
case REMOVE_FATHER_HYP: { case REMOVE_FATHER_HYP: {
SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape);
ASSERT(algo); ASSERT(algo);
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
SetAlgoState(HYP_OK);
else
SetAlgoState(MISSING_HYP);
// is there the same local hyp or maybe a new father algo applied? // is there the same local hyp or maybe a new father algo applied?
if ( !GetSimilarAttached( _subShape, anHyp ) ) if ( !GetSimilarAttached( _subShape, anHyp ) )
modifiedHyp = true; modifiedHyp = true;
}
else
SetAlgoState(MISSING_HYP);
break; break;
} }
case REMOVE_FATHER_ALGO: { case REMOVE_FATHER_ALGO: {
@ -906,13 +894,13 @@ SMESH_Hypothesis::Hypothesis_Status
} }
else else
{ {
if ( algo->CheckHypothesis((*_father),_subShape, aux_ret )) { if ( algo->CheckHypothesis((*_father),_subShape, aux_ret ))
// check if algo changes SetAlgoState(HYP_OK);
if ( string(algo->GetName()) != string( anHyp->GetName()) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
// is there the same local algo or maybe a new father algo applied?
if ( !GetSimilarAttached( _subShape, anHyp ))
modifiedHyp = true;
} }
break; break;
} }
@ -1497,21 +1485,21 @@ void SMESH_subMesh::UpdateDependantsState(const compute_event theEvent)
void SMESH_subMesh::CleanDependants() void SMESH_subMesh::CleanDependants()
{ {
//MESSAGE("SMESH_subMesh::CleanDependants: shape type " << _subShape.ShapeType() );
TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape ));
for (; it.More(); it.Next()) for (; it.More(); it.Next())
{ {
const TopoDS_Shape& ancestor = it.Value(); const TopoDS_Shape& ancestor = it.Value();
// PAL8021. do not go upper than SOLID, else ComputeStateEngine(CLEANDEP) //MESSAGE("ancestor shape type " << ancestor.ShapeType() );
// will erase mesh on other shapes in a compound
if ( ancestor.ShapeType() >= TopAbs_SOLID ) {
SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor); SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
if (aSubMesh) if (aSubMesh)
aSubMesh->ComputeStateEngine(CLEANDEP); aSubMesh->ComputeStateEngine(CLEANDEP);
} }
}
ComputeStateEngine(CLEAN); ComputeStateEngine(CLEAN);
} }
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -224,6 +224,57 @@ void SMESHDS_Command::AddVolume(int NewVolID,
myNumber++; myNumber++;
} }
//=======================================================================
//function : AddPolygonalFace
//purpose :
//=======================================================================
void SMESHDS_Command::AddPolygonalFace (const int ElementID,
std::vector<int> nodes_ids)
{
if (!myType == SMESHDS_AddPolygon) {
MESSAGE("SMESHDS_Command::AddPolygonalFace : Bad Type");
return;
}
myIntegers.push_back(ElementID);
int i, nbNodes = nodes_ids.size();
myIntegers.push_back(nbNodes);
for (i = 0; i < nbNodes; i++) {
myIntegers.push_back(nodes_ids[i]);
}
myNumber++;
}
//=======================================================================
//function : AddPolyhedralVolume
//purpose :
//=======================================================================
void SMESHDS_Command::AddPolyhedralVolume (const int ElementID,
std::vector<int> nodes_ids,
std::vector<int> quantities)
{
if (!myType == SMESHDS_AddPolyhedron) {
MESSAGE("SMESHDS_Command::AddPolyhedralVolume : Bad Type");
return;
}
myIntegers.push_back(ElementID);
int i, nbNodes = nodes_ids.size();
myIntegers.push_back(nbNodes);
for (i = 0; i < nbNodes; i++) {
myIntegers.push_back(nodes_ids[i]);
}
int nbFaces = quantities.size();
myIntegers.push_back(nbFaces);
for (i = 0; i < nbFaces; i++) {
myIntegers.push_back(quantities[i]);
}
myNumber++;
}
//======================================================================= //=======================================================================
//function : //function :
//purpose : //purpose :
@ -263,7 +314,7 @@ void SMESHDS_Command::ChangeElementNodes(int ElementID, int nodes[], int nbnodes
{ {
if (!myType == SMESHDS_ChangeElementNodes) if (!myType == SMESHDS_ChangeElementNodes)
{ {
MESSAGE("SMESHDS_Command::RemoveElement : Bad Type"); MESSAGE("SMESHDS_Command::ChangeElementNodes : Bad Type");
return; return;
} }
myIntegers.push_back(ElementID); myIntegers.push_back(ElementID);
@ -274,6 +325,36 @@ void SMESHDS_Command::ChangeElementNodes(int ElementID, int nodes[], int nbnodes
myNumber++; myNumber++;
} }
//=======================================================================
//function : ChangePolyhedronNodes
//purpose :
//=======================================================================
void SMESHDS_Command::ChangePolyhedronNodes (const int ElementID,
std::vector<int> nodes_ids,
std::vector<int> quantities)
{
if (myType != SMESHDS_ChangePolyhedronNodes)
{
MESSAGE("SMESHDS_Command::ChangePolyhedronNodes : Bad Type");
return;
}
myIntegers.push_back(ElementID);
int i, nbNodes = nodes_ids.size();
myIntegers.push_back(nbNodes);
for (i = 0; i < nbNodes; i++) {
myIntegers.push_back(nodes_ids[i]);
}
int nbFaces = quantities.size();
myIntegers.push_back(nbFaces);
for (i = 0; i < nbFaces; i++) {
myIntegers.push_back(quantities[i]);
}
myNumber++;
}
//======================================================================= //=======================================================================
//function : Renumber //function : Renumber
//purpose : //purpose :

View File

@ -29,6 +29,7 @@
#include "SMESHDS_CommandType.hxx" #include "SMESHDS_CommandType.hxx"
#include <list> #include <list>
#include <vector>
class SMESHDS_Command class SMESHDS_Command
{ {
@ -48,10 +49,18 @@ class SMESHDS_Command
int idnode4, int idnode5, int idnode6); int idnode4, int idnode5, int idnode6);
void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6, int idnode7, int idnode8); int idnode4, int idnode5, int idnode6, int idnode7, int idnode8);
void AddPolygonalFace (const int ElementID,
std::vector<int> nodes_ids);
void AddPolyhedralVolume (const int ElementID,
std::vector<int> nodes_ids,
std::vector<int> quantities);
void MoveNode(int NewNodeID, double x, double y, double z); void MoveNode(int NewNodeID, double x, double y, double z);
void RemoveNode(int NodeID); void RemoveNode(int NodeID);
void RemoveElement(int ElementID); void RemoveElement(int ElementID);
void ChangeElementNodes(int ElementID, int nodes[], int nbnodes); void ChangeElementNodes(int ElementID, int nodes[], int nbnodes);
void ChangePolyhedronNodes(const int ElementID,
std::vector<int> nodes_ids,
std::vector<int> quantities);
void Renumber (const bool isNodes, const int startID, const int deltaID); void Renumber (const bool isNodes, const int startID, const int deltaID);
SMESHDS_CommandType GetType(); SMESHDS_CommandType GetType();
int GetNumber(); int GetNumber();

View File

@ -34,14 +34,17 @@ enum SMESHDS_CommandType {
SMESHDS_AddEdge, SMESHDS_AddEdge,
SMESHDS_AddTriangle, SMESHDS_AddTriangle,
SMESHDS_AddQuadrangle, SMESHDS_AddQuadrangle,
SMESHDS_AddPolygon,
SMESHDS_AddTetrahedron, SMESHDS_AddTetrahedron,
SMESHDS_AddPyramid, SMESHDS_AddPyramid,
SMESHDS_AddPrism, SMESHDS_AddPrism,
SMESHDS_AddHexahedron, SMESHDS_AddHexahedron,
SMESHDS_AddPolyhedron,
SMESHDS_RemoveNode, SMESHDS_RemoveNode,
SMESHDS_RemoveElement, SMESHDS_RemoveElement,
SMESHDS_MoveNode, SMESHDS_MoveNode,
SMESHDS_ChangeElementNodes, SMESHDS_ChangeElementNodes,
SMESHDS_ChangePolyhedronNodes,
SMESHDS_Renumber SMESHDS_Renumber
}; };

View File

@ -171,8 +171,9 @@ bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes )) if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
return false; return false;
ASSERT( nbnodes < 9 ); //ASSERT( nbnodes < 9 );
int i, IDs[ 8 ]; //int i, IDs[ 8 ];
int i, IDs[ nbnodes ];
for ( i = 0; i < nbnodes; i++ ) for ( i = 0; i < nbnodes; i++ )
IDs [ i ] = nodes[ i ]->GetID(); IDs [ i ] = nodes[ i ]->GetID();
myScript->ChangeElementNodes( elem->GetID(), IDs, nbnodes); myScript->ChangeElementNodes( elem->GetID(), IDs, nbnodes);
@ -180,6 +181,49 @@ bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
return true; return true;
} }
//=======================================================================
//function : ChangePolygonNodes
//purpose :
//=======================================================================
bool SMESHDS_Mesh::ChangePolygonNodes
(const SMDS_MeshElement * elem,
std::vector<const SMDS_MeshNode*> nodes)
{
ASSERT(nodes.size() > 3);
int nb = nodes.size();
const SMDS_MeshNode* nodes_array [nb];
for (int inode = 0; inode < nb; inode++) {
nodes_array[inode] = nodes[inode];
}
return ChangeElementNodes(elem, nodes_array, nb);
}
//=======================================================================
//function : ChangePolyhedronNodes
//purpose :
//=======================================================================
bool SMESHDS_Mesh::ChangePolyhedronNodes
(const SMDS_MeshElement * elem,
std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities)
{
ASSERT(nodes.size() > 3);
if (!SMDS_Mesh::ChangePolyhedronNodes(elem, nodes, quantities))
return false;
int i, len = nodes.size();
std::vector<int> nodes_ids (len);
for (i = 0; i < len; i++) {
nodes_ids[i] = nodes[i]->GetID();
}
myScript->ChangePolyhedronNodes(elem->GetID(), nodes_ids, quantities);
return true;
}
//======================================================================= //=======================================================================
//function : Renumber //function : Renumber
//purpose : //purpose :
@ -472,6 +516,100 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1,
n8->GetID()); n8->GetID());
return anElem; return anElem;
} }
//=======================================================================
//function : AddPolygonalFace
//purpose :
//=======================================================================
SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID (std::vector<int> nodes_ids,
const int ID)
{
SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes_ids, ID);
if (anElem) {
myScript->AddPolygonalFace(ID, nodes_ids);
}
return anElem;
}
SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFaceWithID
(std::vector<const SMDS_MeshNode*> nodes,
const int ID)
{
SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFaceWithID(nodes, ID);
if (anElem) {
int i, len = nodes.size();
std::vector<int> nodes_ids (len);
for (i = 0; i < len; i++) {
nodes_ids[i] = nodes[i]->GetID();
}
myScript->AddPolygonalFace(ID, nodes_ids);
}
return anElem;
}
SMDS_MeshFace* SMESHDS_Mesh::AddPolygonalFace
(std::vector<const SMDS_MeshNode*> nodes)
{
SMDS_MeshFace *anElem = SMDS_Mesh::AddPolygonalFace(nodes);
if (anElem) {
int i, len = nodes.size();
std::vector<int> nodes_ids (len);
for (i = 0; i < len; i++) {
nodes_ids[i] = nodes[i]->GetID();
}
myScript->AddPolygonalFace(anElem->GetID(), nodes_ids);
}
return anElem;
}
//=======================================================================
//function : AddPolyhedralVolume
//purpose :
//=======================================================================
SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID (std::vector<int> nodes_ids,
std::vector<int> quantities,
const int ID)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes_ids, quantities, ID);
if (anElem) {
myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
}
return anElem;
}
SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolumeWithID
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities,
const int ID)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolumeWithID(nodes, quantities, ID);
if (anElem) {
int i, len = nodes.size();
std::vector<int> nodes_ids (len);
for (i = 0; i < len; i++) {
nodes_ids[i] = nodes[i]->GetID();
}
myScript->AddPolyhedralVolume(ID, nodes_ids, quantities);
}
return anElem;
}
SMDS_MeshVolume* SMESHDS_Mesh::AddPolyhedralVolume
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities)
{
SMDS_MeshVolume *anElem = SMDS_Mesh::AddPolyhedralVolume(nodes, quantities);
if (anElem) {
int i, len = nodes.size();
std::vector<int> nodes_ids (len);
for (i = 0; i < len; i++) {
nodes_ids[i] = nodes[i]->GetID();
}
myScript->AddPolyhedralVolume(anElem->GetID(), nodes_ids, quantities);
}
return anElem;
}
//======================================================================= //=======================================================================
//function : removeFromContainers //function : removeFromContainers
//purpose : //purpose :
@ -738,13 +876,14 @@ bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const
/// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given
/// TopoDS_Shape is unknown /// TopoDS_Shape is unknown
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) const
{ {
if (myShape.IsNull()) MESSAGE("myShape is NULL"); if (myShape.IsNull()) MESSAGE("myShape is NULL");
int Index = ShapeToIndex(S); int Index = ShapeToIndex(S);
if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end()) TShapeIndexToSubMesh::const_iterator anIter = myShapeIndexToSubMesh.find(Index);
return myShapeIndexToSubMesh[Index]; if (anIter != myShapeIndexToSubMesh.end())
return anIter->second;
else else
return NULL; return NULL;
} }
@ -895,7 +1034,7 @@ TopoDS_Shape SMESHDS_Mesh::IndexToShape(int ShapeIndex)
//function : ShapeToIndex //function : ShapeToIndex
//purpose : //purpose :
//======================================================================= //=======================================================================
int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) const
{ {
if (myShape.IsNull()) if (myShape.IsNull())
MESSAGE("myShape is NULL"); MESSAGE("myShape is NULL");

View File

@ -158,12 +158,39 @@ public:
const SMDS_MeshNode * n7, const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8); const SMDS_MeshNode * n8);
virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
const int ID);
virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<const SMDS_MeshNode*> nodes,
const int ID);
virtual SMDS_MeshFace* AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes);
virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
(std::vector<int> nodes_ids,
std::vector<int> quantities,
const int ID);
virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities,
const int ID);
virtual SMDS_MeshVolume* AddPolyhedralVolume
(std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities);
void MoveNode(const SMDS_MeshNode *, double x, double y, double z); void MoveNode(const SMDS_MeshNode *, double x, double y, double z);
virtual void RemoveNode(const SMDS_MeshNode *); virtual void RemoveNode(const SMDS_MeshNode *);
void RemoveElement(const SMDS_MeshElement *); void RemoveElement(const SMDS_MeshElement *);
bool ChangeElementNodes(const SMDS_MeshElement * elem, bool ChangeElementNodes(const SMDS_MeshElement * elem,
const SMDS_MeshNode * nodes[], const SMDS_MeshNode * nodes[],
const int nbnodes); const int nbnodes);
bool ChangePolygonNodes(const SMDS_MeshElement * elem,
std::vector<const SMDS_MeshNode*> nodes);
bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
std::vector<const SMDS_MeshNode*> nodes,
std::vector<int> quantities);
void Renumber (const bool isNodes, const int startID=1, const int deltaID=1); void Renumber (const bool isNodes, const int startID=1, const int deltaID=1);
void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S); void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S);
@ -177,7 +204,7 @@ public:
const TopoDS_Shape & S); const TopoDS_Shape & S);
TopoDS_Shape ShapeToMesh() const; TopoDS_Shape ShapeToMesh() const;
bool HasMeshElements(const TopoDS_Shape & S); bool HasMeshElements(const TopoDS_Shape & S);
SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S); SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S) const;
SMESHDS_SubMesh * MeshElements(const int Index); SMESHDS_SubMesh * MeshElements(const int Index);
std::list<int> SubMeshIndices(); std::list<int> SubMeshIndices();
const std::map<int,SMESHDS_SubMesh*>& SubMeshes() const std::map<int,SMESHDS_SubMesh*>& SubMeshes()
@ -187,7 +214,7 @@ public:
const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const; const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
SMESHDS_Script * GetScript(); SMESHDS_Script * GetScript();
void ClearScript(); void ClearScript();
int ShapeToIndex(const TopoDS_Shape & aShape); int ShapeToIndex(const TopoDS_Shape & aShape) const;
TopoDS_Shape IndexToShape(int ShapeIndex); TopoDS_Shape IndexToShape(int ShapeIndex);
SMESHDS_SubMesh * NewSubMesh(int Index); SMESHDS_SubMesh * NewSubMesh(int Index);
@ -219,9 +246,15 @@ private:
int myMeshID; int myMeshID;
TopoDS_Shape myShape; TopoDS_Shape myShape;
typedef std::map<int,SMESHDS_SubMesh*> TShapeIndexToSubMesh;
TShapeIndexToSubMesh myShapeIndexToSubMesh;
TopTools_IndexedMapOfShape myIndexToShape; TopTools_IndexedMapOfShape myIndexToShape;
std::map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
std::set<SMESHDS_GroupBase*> myGroups; typedef std::set<SMESHDS_GroupBase*> TGroups;
TGroups myGroups;
SMESHDS_Script* myScript; SMESHDS_Script* myScript;
}; };

View File

@ -148,6 +148,27 @@ void SMESHDS_Script::AddVolume(int NewID,
idnode5, idnode6, idnode7, idnode8); idnode5, idnode6, idnode7, idnode8);
} }
//=======================================================================
//function : AddPolygonalFace
//purpose :
//=======================================================================
void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
{
getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
}
//=======================================================================
//function : AddPolyhedralVolume
//purpose :
//=======================================================================
void SMESHDS_Script::AddPolyhedralVolume (int NewID,
std::vector<int> nodes_ids,
std::vector<int> quantities)
{
getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
(NewID, nodes_ids, quantities);
}
//======================================================================= //=======================================================================
//function : //function :
//purpose : //purpose :
@ -185,6 +206,18 @@ void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes ); getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
} }
//=======================================================================
//function : ChangePolyhedronNodes
//purpose :
//=======================================================================
void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
std::vector<int> nodes_ids,
std::vector<int> quantities)
{
getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
(ElementID, nodes_ids, quantities);
}
//======================================================================= //=======================================================================
//function : Renumber //function : Renumber
//purpose : //purpose :

View File

@ -30,6 +30,7 @@
#include "SMESHDS_Command.hxx" #include "SMESHDS_Command.hxx"
#include <list> #include <list>
#include <vector>
class SMESHDS_Script class SMESHDS_Script
@ -48,10 +49,20 @@ class SMESHDS_Script
int idnode4, int idnode5, int idnode6); int idnode4, int idnode5, int idnode6);
void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3, void AddVolume(int NewVolID, int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6, int idnode7, int idnode8); int idnode4, int idnode5, int idnode6, int idnode7, int idnode8);
void AddPolygonalFace (const int NewFaceID,
std::vector<int> nodes_ids);
void AddPolyhedralVolume (const int NewVolID,
std::vector<int> nodes_ids,
std::vector<int> quantities);
void MoveNode(int NewNodeID, double x, double y, double z); void MoveNode(int NewNodeID, double x, double y, double z);
void RemoveNode(int NodeID); void RemoveNode(int NodeID);
void RemoveElement(int ElementID); void RemoveElement(int ElementID);
void ChangeElementNodes(int ElementID, int nodes[], int nbnodes); void ChangeElementNodes(int ElementID, int nodes[], int nbnodes);
void ChangePolyhedronNodes(const int ElementID,
std::vector<int> nodes_ids,
std::vector<int> quantities);
void Renumber (const bool isNodes, const int startID, const int deltaID); void Renumber (const bool isNodes, const int startID, const int deltaID);
void Clear(); void Clear();
const std::list<SMESHDS_Command*> & GetCommands(); const std::list<SMESHDS_Command*> & GetCommands();

View File

@ -58,14 +58,16 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \
# header files # header files
EXPORT_HEADERS= SMESH_Type.h \ EXPORT_HEADERS= SMESH_Type.h \
SMESH_TypeFilter.hxx \ SMESH_TypeFilter.hxx \
Handle_SMESH_TypeFilter.hxx \
SMESH_NumberFilter.hxx \ SMESH_NumberFilter.hxx \
SMESH_LogicalFilter.hxx SMESH_LogicalFilter.hxx
# additionnal information to compil and link file # additionnal information to compil and link file
CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) \
CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
LDFLAGS += $(OCC_KERNEL_LIBS) -L${GEOM_ROOT_DIR}/lib/salome -I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR}
CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome -I${BOOSTDIR}
LDFLAGS += $(OCC_KERNEL_LIBS) -L${GUI_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeApp -lsuit
# additional file to be cleaned # additional file to be cleaned
MOSTLYCLEAN = MOSTLYCLEAN =
@ -73,4 +75,3 @@ CLEAN =
DISTCLEAN = DISTCLEAN =
@CONCLUDE@ @CONCLUDE@

View File

@ -1,49 +1,17 @@
// SALOME SALOMEGUI : implementation of desktop and GUI kernel
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_LogicalFilter.cxx // File : SMESH_LogicalFilter.cxx
// Author : Sergey LITONIN
// Module : SMESH // Module : SMESH
#include "SMESH_LogicalFilter.hxx" #include "SMESH_LogicalFilter.hxx"
/*
Class : SMESH_LogicalFilter
Description : Filter for combaining several filters with logical operation (OR or AND)
*/
IMPLEMENT_STANDARD_HANDLE( SMESH_LogicalFilter, SALOME_Filter )
IMPLEMENT_STANDARD_RTTIEXT( SMESH_LogicalFilter, SALOME_Filter )
//======================================================================= //=======================================================================
// name : SMESH_LogicalFilter::SMESH_LogicalFilter // name : SMESH_LogicalFilter::SMESH_LogicalFilter
// Purpose : Constructor // Purpose : Constructor
//======================================================================= //=======================================================================
SMESH_LogicalFilter::SMESH_LogicalFilter( const SMESH_ListOfFilter& theFilters, SMESH_LogicalFilter::SMESH_LogicalFilter (const QPtrList<SUIT_SelectionFilter>& theFilters,
const int theLogOp) const int theLogOp)
{ {
myFilters = theFilters; setFilters(theFilters);
myLogOp = theLogOp; setOperation(theLogOp);
} }
//======================================================================= //=======================================================================
@ -58,91 +26,56 @@ SMESH_LogicalFilter::~SMESH_LogicalFilter()
// name : SMESH_LogicalFilter::IsOk // name : SMESH_LogicalFilter::IsOk
// Purpose : Verify validity of entry object // Purpose : Verify validity of entry object
//======================================================================= //=======================================================================
Standard_Boolean SMESH_LogicalFilter::IsOk( const Handle(SALOME_InteractiveObject)& theIO ) const bool SMESH_LogicalFilter::isOk (const SUIT_DataOwner* owner) const
{ {
SMESH_ListOfFilter::Iterator anIter( myFilters ); bool res = true;
for ( ; anIter.More(); anIter.Next() ) QPtrListIterator<SUIT_SelectionFilter> it (myFilters);
SUIT_SelectionFilter* filter;
for (; ((filter = it.current()) != 0) && res; ++it)
{ {
Handle(SALOME_Filter) aFilter = anIter.Value(); if (myOperation == LO_OR && filter->isOk(owner))
if ( !aFilter.IsNull() )
{
if ( myLogOp == LO_OR && anIter.Value()->IsOk( theIO ) )
return true; return true;
if ( myLogOp == LO_AND && !anIter.Value()->IsOk( theIO ) ) if (myOperation == LO_AND && !filter->isOk(owner))
return false; return false;
} if (myOperation == LO_NOT)
return !filter->isOk(owner);
} }
return myLogOp == LO_OR ? false : true; return (myOperation != LO_OR);
} }
//======================================================================= //=======================================================================
// name : SMESH_LogicalFilter::SetFilters // name : SMESH_LogicalFilter::setFilters
// Purpose : Set new list of filters. Old wilters are removed // Purpose : Set new list of filters. Old wilters are removed
//======================================================================= //=======================================================================
void SMESH_LogicalFilter::SetFilters( const SMESH_ListOfFilter& theFilters ) void SMESH_LogicalFilter::setFilters (const QPtrList<SUIT_SelectionFilter>& theFilters)
{ {
myFilters = theFilters; myFilters = theFilters;
} }
//======================================================================= //=======================================================================
// name : SMESH_LogicalFilter::SetLogOp // name : SMESH_LogicalFilter::setOperation
// Purpose : Set logical operation // Purpose : Set logical operation
//======================================================================= //=======================================================================
void SMESH_LogicalFilter::SetLogOp( const int theLogOp ) void SMESH_LogicalFilter::setOperation (const int theLogOp)
{ {
myLogOp = theLogOp; myOperation = theLogOp;
} }
//======================================================================= //=======================================================================
// name : SMESH_LogicalFilter::GetFilters // name : SMESH_LogicalFilter::getFilters
// Purpose : Get list of filters // Purpose : Get list of filters
//======================================================================= //=======================================================================
const SMESH_ListOfFilter& SMESH_LogicalFilter::GetFilters() const const QPtrList<SUIT_SelectionFilter> SMESH_LogicalFilter::getFilters() const
{ {
return myFilters; return myFilters;
} }
//======================================================================= //=======================================================================
// name : SMESH_LogicalFilter::GetLogOp // name : SMESH_LogicalFilter::getOperation
// Purpose : Get logical operation // Purpose : Get logical operation
//======================================================================= //=======================================================================
int SMESH_LogicalFilter::GetLogOp() const int SMESH_LogicalFilter::getOperation() const
{ {
return myLogOp; return myOperation;
} }

View File

@ -1,102 +1,33 @@
// SALOME SALOMEGUI : implementation of desktop and GUI kernel
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_LogicalFilter.hxx // File : SMESH_LogicalFilter.hxx
// Author : Sergey LITONIN
// Module : SMESH // Module : SMESH
#ifndef _SMESH_LogicalFilter_HeaderFile #ifndef _SMESH_LogicalFilter_HeaderFile
#define _SMESH_LogicalFilter_HeaderFile #define _SMESH_LogicalFilter_HeaderFile
#include "SALOME_Filter.hxx" #include <SUIT_SelectionFilter.h>
#include <Standard_DefineHandle.hxx> #include <qptrlist.h>
#include <NCollection_StdBase.hxx>
#include <NCollection_DefineList.hxx>
DEFINE_STANDARD_HANDLE( SMESH_LogicalFilter, SALOME_Filter ) class SMESH_LogicalFilter : public SUIT_SelectionFilter
DEFINE_BASECOLLECTION( SMESH_FilterColl, Handle(SALOME_Filter) )
DEFINE_LIST( SMESH_ListOfFilter, SMESH_FilterColl, Handle(SALOME_Filter) )
/*
Class : SMESH_LogicalFilter
Description : Filter for combaining several filters with logical operation (OR or AND)
*/
class SMESH_LogicalFilter : public SALOME_Filter
{ {
public: public:
enum { LO_OR, LO_AND, LO_NOT, LO_UNDEFINED };
enum { LO_OR, LO_AND, LO_UNDEFINED };
public: public:
SMESH_LogicalFilter (const QPtrList<SUIT_SelectionFilter>&,
SMESH_LogicalFilter( const SMESH_ListOfFilter&, const int ); const int);
virtual ~SMESH_LogicalFilter(); virtual ~SMESH_LogicalFilter();
virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const;
void SetFilters( const SMESH_ListOfFilter& ); virtual bool isOk (const SUIT_DataOwner*) const;
void SetLogOp( const int );
const SMESH_ListOfFilter& GetFilters() const; void setFilters (const QPtrList<SUIT_SelectionFilter>&);
int GetLogOp() const; void setOperation (const int);
const QPtrList<SUIT_SelectionFilter> getFilters() const;
int getOperation() const;
private: private:
QPtrList<SUIT_SelectionFilter> myFilters;
SMESH_ListOfFilter myFilters; int myOperation;
int myLogOp;
public:
DEFINE_STANDARD_RTTI( SMESH_LogicalFilter )
}; };
#endif #endif

View File

@ -1,48 +1,29 @@
// SALOME SALOMEGUI : implementation of desktop and GUI kernel
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_NumberFilter.cxx // File : SMESH_NumberFilter.cxx
// Author : Sergey LITONIN
// Module : SMESH // Module : SMESH
#include "SMESH_NumberFilter.hxx" #include "SMESH_NumberFilter.hxx"
#include "GEOMBase.h" #include "GEOMBase.h"
#include "TopTools_MapOfShape.hxx"
#include "TopExp_Explorer.hxx" #include "SUIT_Application.h"
#include "SUIT_Session.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_DataOwner.h"
#include "SALOME_InteractiveObject.hxx" #include "SALOME_InteractiveObject.hxx"
#include "QAD_Application.h" #include "SALOMEDSClient_SObject.hxx"
#include "QAD_Desktop.h" #include "SALOMEDS_SObject.hxx"
#include <TopTools_MapOfShape.hxx>
#include <TopExp_Explorer.hxx>
/* /*!
Class : SMESH_NumberFilter * Class : SMESH_NumberFilter
Description : Filter for geom objects. * Description : Filter for geom objects.
Filter geom objects by number of subshapes of the given type * Filter geom objects by number of subshapes of the given type
*/ */
IMPLEMENT_STANDARD_HANDLE( SMESH_NumberFilter, SALOME_TypeFilter )
IMPLEMENT_STANDARD_RTTIEXT( SMESH_NumberFilter, SALOME_TypeFilter )
//======================================================================= //=======================================================================
// name : SMESH_NumberFilter::SMESH_NumberFilter // name : SMESH_NumberFilter::SMESH_NumberFilter
// Purpose : Constructor // Purpose : Constructor
@ -53,8 +34,8 @@ SMESH_NumberFilter::SMESH_NumberFilter( const char* theKind,
const TopAbs_ShapeEnum theShapeType, const TopAbs_ShapeEnum theShapeType,
GEOM::GEOM_Object_ptr theMainObj, GEOM::GEOM_Object_ptr theMainObj,
const bool theIsClosedOnly) const bool theIsClosedOnly)
: SALOME_TypeFilter( (char*)theKind )
{ {
myKind = (char*)theKind;
mySubShapeType = theSubShapeType; mySubShapeType = theSubShapeType;
myNumber = theNumber; myNumber = theNumber;
myIsClosedOnly = theIsClosedOnly; myIsClosedOnly = theIsClosedOnly;
@ -72,8 +53,8 @@ SMESH_NumberFilter::SMESH_NumberFilter( const char* theKind,
const TColStd_MapOfInteger& theShapeTypes, const TColStd_MapOfInteger& theShapeTypes,
GEOM::GEOM_Object_ptr theMainObj, GEOM::GEOM_Object_ptr theMainObj,
const bool theIsClosedOnly ) const bool theIsClosedOnly )
: SALOME_TypeFilter( (char*)theKind )
{ {
myKind = (char*)theKind;
mySubShapeType = theSubShapeType; mySubShapeType = theSubShapeType;
myNumber = theNumber; myNumber = theNumber;
myIsClosedOnly = theIsClosedOnly; myIsClosedOnly = theIsClosedOnly;
@ -89,13 +70,13 @@ SMESH_NumberFilter::~SMESH_NumberFilter()
// name : SMESH_NumberFilter::SMESH_NumberFilter // name : SMESH_NumberFilter::SMESH_NumberFilter
// Purpose : Verify validity of entry object // Purpose : Verify validity of entry object
//======================================================================= //=======================================================================
Standard_Boolean SMESH_NumberFilter::IsOk( const Handle(SALOME_InteractiveObject)& theObj ) const bool SMESH_NumberFilter::isOk (const SUIT_DataOwner* theDataOwner) const
{ {
if ( theObj.IsNull() || !SALOME_TypeFilter::IsOk( theObj ) ) if (!theDataOwner)
return false; return false;
// Get geom object from IO // Get geom object from IO
GEOM::GEOM_Object_var aGeomObj = getGeom( theObj ); GEOM::GEOM_Object_var aGeomObj = getGeom(theDataOwner);
if (aGeomObj->_is_nil()) if (aGeomObj->_is_nil())
return false; return false;
@ -103,13 +84,14 @@ Standard_Boolean SMESH_NumberFilter::IsOk( const Handle(SALOME_InteractiveObject
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (!GEOMBase::GetShape(aGeomObj, aShape) || if (!GEOMBase::GetShape(aGeomObj, aShape) ||
aShape.IsNull() || aShape.IsNull() ||
!myShapeTypes.Contains( aShape.ShapeType() ) || !myShapeTypes.Contains(aShape.ShapeType()))
myIsClosedOnly && aShape.ShapeType() == TopAbs_SHELL && !aShape.Closed() ) return false;
if (myIsClosedOnly && aShape.ShapeType() == TopAbs_SHELL && !aShape.Closed())
return false; return false;
// Verify whether shape of entry object is sub-shape of myMainObj // Verify whether shape of entry object is sub-shape of myMainObj
if ( !myMainObj->_is_nil() ) if (!myMainObj->_is_nil()) {
{
TopoDS_Shape aMainShape; TopoDS_Shape aMainShape;
if (!GEOMBase::GetShape(myMainObj, aMainShape)) if (!GEOMBase::GetShape(myMainObj, aMainShape))
return false; return false;
@ -117,20 +99,20 @@ Standard_Boolean SMESH_NumberFilter::IsOk( const Handle(SALOME_InteractiveObject
bool isFound = false; bool isFound = false;
TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); TopAbs_ShapeEnum aShapeType = aShape.ShapeType();
TopExp_Explorer anExp (aMainShape, aShapeType); TopExp_Explorer anExp (aMainShape, aShapeType);
for ( ; anExp.More(); anExp.Next() ) for (; anExp.More(); anExp.Next()) {
if ( anExp.Current() == aShape ) if (anExp.Current() == aShape) {
{
isFound = true; isFound = true;
break; break;
} }
}
if (!isFound) if (!isFound)
return false; return false;
} }
// Verify number of sub-shapes // Verify number of sub-shapes
if (mySubShapeType == TopAbs_SHAPE); if (mySubShapeType == TopAbs_SHAPE);
return true; return true;
int nbShapes = 0;
TopExp_Explorer anExp2 (aShape, mySubShapeType); TopExp_Explorer anExp2 (aShape, mySubShapeType);
TopTools_MapOfShape aMap; TopTools_MapOfShape aMap;
for (; anExp2.More(); anExp2.Next()) for (; anExp2.More(); anExp2.Next())
@ -143,31 +125,47 @@ Standard_Boolean SMESH_NumberFilter::IsOk( const Handle(SALOME_InteractiveObject
// name : SMESH_NumberFilter::getGeom // name : SMESH_NumberFilter::getGeom
// Purpose : Retrieve geom object from SALOME_InteractiveObject // Purpose : Retrieve geom object from SALOME_InteractiveObject
//======================================================================= //=======================================================================
GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom( GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom
const Handle(SALOME_InteractiveObject)& theObj ) const (const SUIT_DataOwner* theDataOwner) const
{ {
if ( theObj->isComponentType( "GEOM" ) ) const SalomeApp_DataOwner* owner =
{ dynamic_cast<const SalomeApp_DataOwner*>(theDataOwner);
Standard_Boolean aRes = Standard_False; SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( theObj, aRes ); (SUIT_Session::session()->activeApplication()->activeStudy());
return aRes ? aGeomObj._retn() : GEOM::GEOM_Object::_nil();
} GEOM::GEOM_Object_var anObj;
else
{ if (!owner || !appStudy)
// Get geom object corresponding to the mesh
SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
SALOMEDS::SObject_var aSO = aStudy->FindObjectID( theObj->getEntry() );
if ( aSO->_is_nil() )
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO ); _PTR(Study) study = appStudy->studyDS();
for( ; anIter->More(); anIter->Next() ) QString entry = owner->entry();
{
SALOMEDS::SObject_var aSO = anIter->Value();
SALOMEDS::SObject_var aRefSO;
GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow( _PTR(SObject) aSO(study->FindObjectID(entry.latin1()));
aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() ); if (!aSO)
return GEOM::GEOM_Object::_nil();
CORBA::Object_var anObject = _CAST(SObject,aSO)->GetObject();
anObj = GEOM::GEOM_Object::_narrow(anObject);
if (!CORBA::is_nil(anObj))
return anObj._retn();
// Get geom object corresponding to the mesh
_PTR(ChildIterator) anIter = study->NewChildIterator(aSO);
for (; anIter->More(); anIter->Next()) {
_PTR(SObject) aSO = anIter->Value();
if (!aSO)
continue;
_PTR(SObject) aRefSO;
_PTR(SObject) anObj;
if (aSO->ReferencedObject(aRefSO))
anObj = aRefSO;
if (!anObj)
anObj = aSO;
anObject = _CAST(SObject,anObj)->GetObject();
GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow(anObject);
if (!aMeshShape->_is_nil()) if (!aMeshShape->_is_nil())
return aMeshShape._retn(); return aMeshShape._retn();
@ -175,8 +173,6 @@ GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom(
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
} }
}
void SMESH_NumberFilter::SetSubShapeType (const TopAbs_ShapeEnum theSubShapeType) void SMESH_NumberFilter::SetSubShapeType (const TopAbs_ShapeEnum theSubShapeType)
{ {
@ -202,24 +198,3 @@ void SMESH_NumberFilter::SetMainShape( GEOM::GEOM_Object_ptr theMainObj )
{ {
myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj); myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj);
} }

View File

@ -1,61 +1,34 @@
// SALOME SALOMEGUI : implementation of desktop and GUI kernel
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESH_NumberFilter.hxx // File : SMESH_NumberFilter.hxx
// Author : Sergey LITONIN
// Module : SMESH // Module : SMESH
#ifndef _SMESH_NumberFilter_HeaderFile #ifndef _SMESH_NumberFilter_HeaderFile
#define _SMESH_NumberFilter_HeaderFile #define _SMESH_NumberFilter_HeaderFile
#include <Standard_DefineHandle.hxx> #include "SUIT_SelectionFilter.h"
#include "SALOME_TypeFilter.hxx"
#include <TopAbs_ShapeEnum.hxx> #include <TopAbs_ShapeEnum.hxx>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(GEOM_Gen) #include CORBA_SERVER_HEADER(GEOM_Gen)
DEFINE_STANDARD_HANDLE( SMESH_NumberFilter, SALOME_TypeFilter ) class SUIT_DataOwner;
/* /*!
Class : SMESH_NumberFilter * Class : SMESH_NumberFilter
Description : Filter for geom or smesh objects. * Description : Filter for geom or smesh objects.
Filter geom objects by number of subshapes of the given type * Filter geom objects by number of subshapes of the given type
Parameters of constructor: * Parameters of constructor:
* theSubShapeType - Type of subshape * * theSubShapeType - Type of subshape
* theNumber - Number of subshapes. Object is selected if it contains theNumber of * * theNumber - Number of subshapes. Object is selected if it contains theNumber of
theSubShapeType sub-shapes * theSubShapeType sub-shapes
* theShapeType - This map specifies types of object to be selected * * theShapeType - This map specifies types of object to be selected
* theMainObject - Sub-shapes of this object is selected only * * theMainObject - Sub-shapes of this object is selected only
* theIsClosedOnly - Closed shapes is selected if this parameter is true * * theIsClosedOnly - Closed shapes is selected if this parameter is true
*/ */
class SMESH_NumberFilter : public SALOME_TypeFilter class SMESH_NumberFilter : public SUIT_SelectionFilter
{ {
public: public:
SMESH_NumberFilter (const char* theKind, SMESH_NumberFilter (const char* theKind,
const TopAbs_ShapeEnum theSubShapeType, const TopAbs_ShapeEnum theSubShapeType,
const int theNumber, const int theNumber,
@ -71,7 +44,8 @@ public:
const bool theIsClosedOnly = false ); const bool theIsClosedOnly = false );
virtual ~SMESH_NumberFilter(); virtual ~SMESH_NumberFilter();
virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const;
virtual bool isOk (const SUIT_DataOwner*) const;
void SetSubShapeType (const TopAbs_ShapeEnum); void SetSubShapeType (const TopAbs_ShapeEnum);
void SetNumber (const int); void SetNumber (const int);
@ -81,44 +55,15 @@ public:
void SetMainShape (GEOM::GEOM_Object_ptr); void SetMainShape (GEOM::GEOM_Object_ptr);
private: private:
GEOM::GEOM_Object_ptr getGeom( const Handle(SALOME_InteractiveObject)& theObj ) const; GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner*) const;
private: private:
char* myKind;
TopAbs_ShapeEnum mySubShapeType; TopAbs_ShapeEnum mySubShapeType;
int myNumber; int myNumber;
bool myIsClosedOnly; bool myIsClosedOnly;
TColStd_MapOfInteger myShapeTypes; TColStd_MapOfInteger myShapeTypes;
GEOM::GEOM_Object_var myMainObj; GEOM::GEOM_Object_var myMainObj;
public:
DEFINE_STANDARD_RTTI( SMESH_NumberFilter )
}; };
#endif #endif

View File

@ -7,6 +7,9 @@
// Copyright : Open CASCADE 2002 // Copyright : Open CASCADE 2002
// $Header$ // $Header$
#ifndef SMESH_TYPE_HEADER
#define SMESH_TYPE_HEADER
enum MeshObjectType { enum MeshObjectType {
HYPOTHESIS, HYPOTHESIS,
ALGORITHM, ALGORITHM,
@ -20,3 +23,5 @@ enum MeshObjectType {
SUBMESH_COMPOUND, SUBMESH_COMPOUND,
GROUP GROUP
}; };
#endif

View File

@ -1,43 +1,37 @@
// File : SMESH_TypeFilter.cxx #include "SMESH_TypeFilter.hxx"
// Created : Fri Dec 07 09:57:24 2001
// Author : Nicolas REJNERI
// Project : SALOME
// Module : SMESH
// Copyright : Open CASCADE
// $Header$
#include "SMESH_TypeFilter.ixx" #include <SUIT_Session.h>
#include "SALOME_InteractiveObject.hxx" #include <SalomeApp_Study.h>
#include "SALOME_TypeFilter.hxx" #include <SalomeApp_DataOwner.h>
#include "utilities.h" SMESH_TypeFilter::SMESH_TypeFilter (MeshObjectType theType)
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Study.h"
using namespace std;
SMESH_TypeFilter::SMESH_TypeFilter(MeshObjectType aType)
{ {
myKind = aType; myType = theType;
} }
Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const SMESH_TypeFilter::~SMESH_TypeFilter()
{ {
Handle(SALOME_TypeFilter) meshFilter = new SALOME_TypeFilter( "SMESH" ); }
if ( !meshFilter->IsOk(anObj) )
return false;
bool SMESH_TypeFilter::isOk (const SUIT_DataOwner* theDataOwner) const
{
bool Ok = false; bool Ok = false;
if ( anObj->hasEntry() ) { const SalomeApp_DataOwner* owner =
QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); dynamic_cast<const SalomeApp_DataOwner*>(theDataOwner);
SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); (SUIT_Session::session()->activeApplication()->activeStudy());
SALOMEDS::SObject_var objFather = obj->GetFather(); if (owner && appStudy) {
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); _PTR(Study) study = appStudy->studyDS();
QString entry = owner->entry();
_PTR(SObject) obj (study->FindObjectID(entry.latin1()));
if (!obj) return false;
_PTR(SObject) objFather = obj->GetFather();
_PTR(SComponent) objComponent = obj->GetFatherComponent();
int aLevel = obj->Depth() - objComponent->Depth(); int aLevel = obj->Depth() - objComponent->Depth();
@ -58,7 +52,7 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)&
if (aLevel <= 0) if (aLevel <= 0)
return false; return false;
switch ( myKind ) switch (myType)
{ {
case HYPOTHESIS: case HYPOTHESIS:
{ {
@ -133,3 +127,8 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)&
} }
return Ok; return Ok;
} }
MeshObjectType SMESH_TypeFilter::type() const
{
return myType;
}

View File

@ -1,95 +1,25 @@
// File generated by CPPExt (Transient) // File : SMESH_TypeFilter.hxx
// // Module : SMESH
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#ifndef _SMESH_TypeFilter_HeaderFile #ifndef _SMESH_TypeFilter_HeaderFile
#define _SMESH_TypeFilter_HeaderFile #define _SMESH_TypeFilter_HeaderFile
#ifndef _Handle_SMESH_TypeFilter_HeaderFile
#include "Handle_SMESH_TypeFilter.hxx"
#endif
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_Filter.hxx"
#include "SMESH_Type.h" #include "SMESH_Type.h"
#include "SUIT_SelectionFilter.h"
// Open CASCADE Includes class SUIT_DataOwner;
#include <Standard.hxx>
class SMESH_TypeFilter : public SALOME_Filter {
class SMESH_TypeFilter : public SUIT_SelectionFilter
{
public: public:
SMESH_TypeFilter (MeshObjectType theType);
~SMESH_TypeFilter();
inline void* operator new(size_t,void* anAddress) virtual bool isOk (const SUIT_DataOwner*) const;
{ MeshObjectType type() const;
return anAddress;
}
inline void* operator new(size_t size)
{
return Standard::Allocate(size);
}
inline void operator delete(void *anAddress)
{
if (anAddress) Standard::Free((Standard_Address&)anAddress);
}
// inline void operator delete(void *anAddress, size_t size)
// {
// if (anAddress) Standard::Free((Standard_Address&)anAddress,size);
// }
// Methods PUBLIC
//
Standard_EXPORT SMESH_TypeFilter(MeshObjectType aType);
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const;
Standard_EXPORT ~SMESH_TypeFilter();
// Type management
//
Standard_EXPORT friend Handle_Standard_Type& SMESH_TypeFilter_Type_();
Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const;
protected: protected:
MeshObjectType myType;
// Methods PROTECTED
//
// Fields PROTECTED
//
MeshObjectType myKind;
private:
// Methods PRIVATE
//
// Fields PRIVATE
//
}; };
// other inline functions and methods (like "C++: function call" methods)
//
#endif #endif

View File

@ -43,15 +43,16 @@ EXPORT_HEADERS= SMESHGUI_Swig.hxx \
SMESHGUI_HypothesesUtils.h \ SMESHGUI_HypothesesUtils.h \
SMESHGUI_SpinBox.h \ SMESHGUI_SpinBox.h \
SMESHGUI_aParameter.h \ SMESHGUI_aParameter.h \
SMESHGUI_aParameterDlg.h SMESHGUI_aParameterDlg.h \
SMESHGUI_Selection.h
# .po files to transform in .qm # .po files to transform in .qm
PO_FILES = \ PO_FILES = \
SMESH_icons.po \ SMESH_images.po \
SMESH_msg_en.po SMESH_msg_en.po
# Libraries targets # Libraries targets
LIB = libSMESHGUI.la LIB = libSMESH.la
LIB_SRC = SMESHGUI.cxx \ LIB_SRC = SMESHGUI.cxx \
SMESHGUI_PatternWidget.cxx \ SMESHGUI_PatternWidget.cxx \
SMESHGUI_CreatePatternDlg.cxx \ SMESHGUI_CreatePatternDlg.cxx \
@ -96,7 +97,6 @@ LIB_SRC = SMESHGUI.cxx \
SMESHGUI_SewingDlg.cxx \ SMESHGUI_SewingDlg.cxx \
SMESHGUI_MergeNodesDlg.cxx \ SMESHGUI_MergeNodesDlg.cxx \
SMESHGUI_Utils.cxx \ SMESHGUI_Utils.cxx \
SMESHGUI_SMESHGenUtils.cxx \
SMESHGUI_GEOMGenUtils.cxx \ SMESHGUI_GEOMGenUtils.cxx \
SMESHGUI_MeshUtils.cxx \ SMESHGUI_MeshUtils.cxx \
SMESHGUI_GroupUtils.cxx \ SMESHGUI_GroupUtils.cxx \
@ -104,7 +104,9 @@ LIB_SRC = SMESHGUI.cxx \
SMESHGUI_PatternUtils.cxx \ SMESHGUI_PatternUtils.cxx \
SMESHGUI_HypothesesUtils.cxx \ SMESHGUI_HypothesesUtils.cxx \
SMESHGUI_PrecisionDlg.cxx \ SMESHGUI_PrecisionDlg.cxx \
SMESHGUI_VTKUtils.cxx SMESHGUI_VTKUtils.cxx \
SMESHGUI_Selection.cxx \
SMESHGUI_CreatePolyhedralVolumeDlg.cxx
LIB_MOC = \ LIB_MOC = \
SMESHGUI.h \ SMESHGUI.h \
@ -146,7 +148,8 @@ LIB_MOC = \
SMESHGUI_SymmetryDlg.h \ SMESHGUI_SymmetryDlg.h \
SMESHGUI_SewingDlg.h \ SMESHGUI_SewingDlg.h \
SMESHGUI_PrecisionDlg.h \ SMESHGUI_PrecisionDlg.h \
SMESHGUI_MergeNodesDlg.h SMESHGUI_MergeNodesDlg.h \
SMESHGUI_CreatePolyhedralVolumeDlg.h
LIB_CLIENT_IDL = SALOME_Exception.idl \ LIB_CLIENT_IDL = SALOME_Exception.idl \
GEOM_Gen.idl \ GEOM_Gen.idl \
@ -171,13 +174,14 @@ LIB_SERVER_IDL =
#BIN = SMESHBin #BIN = SMESHBin
CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \ CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \
-I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \ -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
$(BOOST_CPPFLAGS) -I${GEOM_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome \
-I${GEOM_ROOT_DIR}/include/salome
LDFLAGS += -lSMESHObject -lSMESHFiltersSelection -lSMDS -lSMESHControls -lDlgRef $(OCC_KERNEL_LIBS) -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome -lVTKViewer -lSalomeGUI -lSalomePrs -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent -lSALOMELocalTrace -lSalomeVTKFilter -lOCCViewer -L${GEOM_ROOT_DIR}/lib/salome -lGEOMGUI -lGEOMClient -lGEOMFiltersSelection -lGEOMBase -lGEOMObject LDFLAGS += -lSMESHObject -lSMESHFiltersSelection -lSMDS -lSMESHControls -lDlgRef $(OCC_KERNEL_LIBS) -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lVTKViewer -lSalomeApp -lSalomePrs -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent -lSALOMELocalTrace -lSVTK -lOCCViewer -L${GEOM_ROOT_DIR}/lib/salome -lGEOM -lGEOMClient -lGEOMBase -lGEOMObject
LDFLAGSFORBIN += $(LDFLAGS) LDFLAGSFORBIN += $(LDFLAGS)

File diff suppressed because it is too large Load Diff

View File

@ -30,39 +30,48 @@
#define SMESHGUI_HeaderFile #define SMESHGUI_HeaderFile
// SALOME Includes // SALOME Includes
#include "SALOMEGUI.h" #include <SalomeApp_Module.h>
#include "SALOME_InteractiveObject.hxx" #include <SALOME_InteractiveObject.hxx>
class QAD_Desktop; #include <SALOMEconfig.h>
class QAD_Study; #include CORBA_SERVER_HEADER(SMESH_Gen)
class QDialog; class QDialog;
class SUIT_Desktop;
class SUIT_Study;
class SUIT_ViewWindow;
class SUIT_ResourceMgr;
class SUIT_ViewManager;
class SalomeApp_Study;
class SalomeApp_SelectionMgr;
//================================================================================= //=================================================================================
// class : SMESHGUI // class : SMESHGUI
// purpose : // purpose :
//================================================================================= //=================================================================================
class SMESHGUI : public SALOMEGUI class SMESHGUI : public SalomeApp_Module
{ {
Q_OBJECT; Q_OBJECT;
private :
QAD_Desktop* myDesktop;
QAD_Study* myActiveStudy;
QDialog* myActiveDialogBox;
int myState;
bool myAutomaticUpdate;
public : public :
SMESHGUI( const QString& name = "", QObject* parent = 0 ); SMESHGUI();
static SMESHGUI* GetSMESHGUI() ;
~SMESHGUI(); ~SMESHGUI();
QAD_Desktop* GetDesktop() ; static SMESH::SMESH_Gen_var GetSMESHGen();
QAD_Study* GetActiveStudy() ; static SMESHGUI* GetSMESHGUI();
bool ActiveStudyLocked(); static SalomeApp_SelectionMgr* selectionMgr();
static SUIT_ResourceMgr* resourceMgr();
static SUIT_Desktop* desktop() ;
static SalomeApp_Study* activeStudy();
bool isActiveStudyLocked();
virtual QString engineIOR() const;
virtual void initialize( CAM_Application* );
virtual void windows( QMap<int, int>& ) const;
virtual void viewManagers( QStringList& ) const;
QDialog* GetActiveDialogBox() ; QDialog* GetActiveDialogBox() ;
void SetActiveDialogBox(QDialog* aDlg) ; void SetActiveDialogBox(QDialog* aDlg) ;
@ -71,30 +80,46 @@ public :
void SetState(int aState) ; void SetState(int aState) ;
bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ; bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
virtual bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); virtual bool OnGUIEvent ( int id );
virtual bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); virtual bool OnMousePress ( QMouseEvent*, SUIT_ViewWindow* );
virtual bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); virtual bool OnMouseMove ( QMouseEvent*, SUIT_ViewWindow* );
virtual bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); virtual bool OnKeyPress ( QKeyEvent*, SUIT_ViewWindow* );
virtual bool ActiveStudyChanged( QAD_Desktop* parent );
virtual bool SetSettings ( QAD_Desktop* parent );
virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject );
virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
const QString & theParent, const QString & theObject );
virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO,
QAD_ViewFrame* = 0 );
virtual void SupportedViewType (int* buffer, int bufferSize);
virtual void Deactivate ();
/* Non modal dialog boxes magement */ virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
virtual bool SetSettings ( SUIT_Desktop* );
virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)&,
SUIT_ViewWindow* = 0 );
/* Non modal dialog boxes management */
void EmitSignalDeactivateDialog() ; void EmitSignalDeactivateDialog() ;
void EmitSignalStudyFrameChanged() ; void EmitSignalStudyFrameChanged() ;
void EmitSignalCloseAllDialogs() ; void EmitSignalCloseAllDialogs() ;
public slots:
virtual void deactivateModule( SUIT_Study* );
virtual void activateModule( SUIT_Study* );
private slots:
void OnGUIEvent();
signals: signals:
void SignalDeactivateActiveDialog() ; void SignalDeactivateActiveDialog() ;
void SignalStudyFrameChanged() ; void SignalStudyFrameChanged() ;
void SignalCloseAllDialogs() ; void SignalCloseAllDialogs() ;
protected:
void createSMESHAction( const int, const QString&, const QString& = QString(""),
const int = 0, const bool = false );
void createPopupItem( const int, const QString&, const QString&,
const QString& = QString::null, const int = -1 );
private :
static SMESH::SMESH_Gen_var myComponentSMESH;
QDialog* myActiveDialogBox;
int myState;
bool myAutomaticUpdate;
QMap<int,QString> myRules;
}; };

View File

@ -35,16 +35,29 @@
#include "SMESHGUI_IdValidator.h" #include "SMESHGUI_IdValidator.h"
#include "SMESH_ActorUtils.h" #include "SMESH_ActorUtils.h"
#include "VTKViewer_ViewFrame.h"
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "QAD_Application.h" #include "SUIT_Session.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h" #include "SVTK_Selection.h"
#include "SVTK_Selector.h"
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SalomeApp_Study.h"
#include "SalomeApp_Application.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
#include "utilities.h" #include "utilities.h"
// OCCT Includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
// VTK Includes
#include <vtkCell.h> #include <vtkCell.h>
#include <vtkIdList.h> #include <vtkIdList.h>
#include <vtkIntArray.h> #include <vtkIntArray.h>
@ -69,29 +82,31 @@
#include <qcheckbox.h> #include <qcheckbox.h>
#include <qregexp.h> #include <qregexp.h>
// STL includes
#include <list> #include <list>
#include <TColStd_IndexedMapOfInteger.hxx>
using namespace std; using namespace std;
namespace SMESH { namespace SMESH {
class TElementSimulation { class TElementSimulation {
QAD_Study* myStudy; SalomeApp_Application* myApplication;
QAD_StudyFrame* myStudyFrame; SUIT_ViewWindow* myViewWindow;
VTKViewer_ViewFrame* myViewFrame; SVTK_ViewWindow* myVTKViewWindow;
SALOME_Actor* myPreviewActor; SALOME_Actor* myPreviewActor;
vtkDataSetMapper* myMapper; vtkDataSetMapper* myMapper;
vtkUnstructuredGrid* myGrid; vtkUnstructuredGrid* myGrid;
public: public:
TElementSimulation (SalomeApp_Application* theApplication)
TElementSimulation(QAD_Study* theStudy):
myStudy(theStudy),
myStudyFrame(theStudy->getActiveStudyFrame()),
myViewFrame(GetVtkViewFrame(theStudy->getActiveStudyFrame()))
{ {
myApplication = theApplication;
SUIT_ViewManager* mgr = theApplication->activeViewManager();
if (!mgr) return;
myViewWindow = mgr->getActiveView();
myVTKViewWindow = GetVtkViewWindow(myViewWindow);
myGrid = vtkUnstructuredGrid::New(); myGrid = vtkUnstructuredGrid::New();
// Create and display actor // Create and display actor
@ -120,11 +135,9 @@ namespace SMESH{
myPreviewActor->SetBackfaceProperty(aBackProp); myPreviewActor->SetBackfaceProperty(aBackProp);
aBackProp->Delete(); aBackProp->Delete();
myViewFrame->AddActor( myPreviewActor ); myVTKViewWindow->AddActor(myPreviewActor);
} }
typedef std::vector<vtkIdType> TVTKIds; typedef std::vector<vtkIdType> TVTKIds;
void SetPosition (SMESH_Actor* theActor, void SetPosition (SMESH_Actor* theActor,
vtkIdType theType, vtkIdType theType,
@ -135,21 +148,25 @@ namespace SMESH{
const int* aConn = NULL; const int* aConn = NULL;
switch (theType) { switch (theType) {
case VTK_TETRA:{ case VTK_TETRA:
{
static int anIds[] = {0,2,1,3}; static int anIds[] = {0,2,1,3};
aConn = anIds; aConn = anIds;
break; break;
} }
case VTK_PYRAMID:{ case VTK_PYRAMID:
{
static int anIds[] = {0,3,2,1,4}; static int anIds[] = {0,3,2,1,4};
aConn = anIds; aConn = anIds;
break; break;
} }
case VTK_HEXAHEDRON:{ case VTK_HEXAHEDRON:
{
static int anIds[] = {0,3,2,1,4,7,6,5}; static int anIds[] = {0,3,2,1,4,7,6,5};
aConn = anIds; aConn = anIds;
break; break;
}} }
}
myGrid->Reset(); myGrid->Reset();
vtkIdList *anIds = vtkIdList::New(); vtkIdList *anIds = vtkIdList::New();
@ -170,15 +187,17 @@ namespace SMESH{
} }
void SetVisibility(bool theVisibility){ void SetVisibility (bool theVisibility)
{
myPreviewActor->SetVisibility(theVisibility); myPreviewActor->SetVisibility(theVisibility);
RepaintCurrentView(); RepaintCurrentView();
} }
~TElementSimulation(){ ~TElementSimulation()
if(FindVtkViewFrame(myStudy,myStudyFrame)){ {
myViewFrame->RemoveActor(myPreviewActor); if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
myVTKViewWindow->RemoveActor(myPreviewActor);
} }
myPreviewActor->Delete(); myPreviewActor->Delete();
@ -187,35 +206,40 @@ namespace SMESH{
myGrid->Delete(); myGrid->Delete();
} }
}; };
} }
//================================================================================= //=================================================================================
// class : SMESHGUI_AddMeshElementDlg() // function : SMESHGUI_AddMeshElementDlg()
// purpose : // purpose : constructor
//================================================================================= //=================================================================================
SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const char* name, SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
SALOME_Selection* Sel, const char* name,
SMDSAbs_ElementType ElementType, int nbNodes, SMDSAbs_ElementType ElementType, int nbNodes,
bool modal, WFlags fl) bool modal, WFlags fl)
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
Qt::WDestructiveClose) WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myViewWindow( SMESH::GetViewWindow( theModule ) ),
mySelector( myViewWindow->GetSelector() )
{ {
mySimulation = new SMESH::TElementSimulation(SMESH::GetActiveStudy()); SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
(SUIT_Session::session()->activeApplication());
myIsPoly = false;
mySimulation = new SMESH::TElementSimulation (anApp);
// verify nb nodes and type // verify nb nodes and type
myNbNodes = nbNodes; myNbNodes = nbNodes;
myElementType = ElementType; myElementType = ElementType;
switch (ElementType) { switch (ElementType) {
case SMDSAbs_Face: case SMDSAbs_Face:
if ( myNbNodes != 3 && myNbNodes != 4 ) // if (myNbNodes != 3 && myNbNodes != 4)
myNbNodes = 3; // myNbNodes = 3;
break; // break;
case SMDSAbs_Volume: case SMDSAbs_Volume:
if ( myNbNodes != 4 && myNbNodes != 8 ) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7) // if (myNbNodes != 4 && myNbNodes != 8) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
myNbNodes = 4; // myNbNodes = 4;
break; break;
default: default:
myElementType = SMDSAbs_Edge; myElementType = SMDSAbs_Edge;
@ -223,23 +247,29 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const c
} }
QString elemName; QString elemName;
switch ( myNbNodes ) { if (myNbNodes == 2)
case 2: elemName = "EDGE"; break; elemName = "EDGE";
case 3: elemName = "TRIANGLE"; break; else if (myNbNodes == 3)
case 4: elemName = elemName = "TRIANGLE";
myElementType == SMDSAbs_Face ? elemName = "QUADRANGLE" : elemName = "TETRAS"; break; else if (myNbNodes == 4)
// case 5: if (myElementType == SMDSAbs_Face)
// case 6: elemName = "QUADRANGLE";
default: // 8 else
elemName = "TETRAS";
else if (myNbNodes == 8)
elemName = "HEXAS"; elemName = "HEXAS";
else if (myElementType == SMDSAbs_Face){
elemName = "POLYGON";
myIsPoly = true;
} }
QString iconName = tr(QString("ICON_DLG_%1").arg(elemName)); QString iconName = tr(QString("ICON_DLG_%1").arg(elemName));
QString buttonGrTitle = tr(QString("SMESH_%1").arg(elemName)); QString buttonGrTitle = tr(QString("SMESH_%1").arg(elemName));
QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(elemName)); QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(elemName));
QString grBoxTitle = tr(QString("SMESH_ADD_%1").arg(elemName)); QString grBoxTitle = tr(QString("SMESH_ADD_%1").arg(elemName));
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", iconName )); QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", iconName));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr("ICON_SELECT"))); QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
if (!name) if (!name)
setName("SMESHGUI_AddMeshElementDlg"); setName("SMESHGUI_AddMeshElementDlg");
@ -329,6 +359,7 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const c
GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1); GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1);
LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1"); LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1");
// LineEditC1A1->setReadOnly(TRUE); // LineEditC1A1->setReadOnly(TRUE);
if (!myIsPoly)
LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator", myNbNodes)); LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator", myNbNodes));
GroupC1Layout->addWidget(LineEditC1A1, 0, 2); GroupC1Layout->addWidget(LineEditC1A1, 0, 2);
@ -342,7 +373,7 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const c
SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupC1, 1, 0); SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupC1, 1, 0);
Init(Sel) ; /* Initialisations */ Init(); /* Initialisations */
} }
//================================================================================= //=================================================================================
@ -355,22 +386,18 @@ SMESHGUI_AddMeshElementDlg::~SMESHGUI_AddMeshElementDlg()
delete mySimulation; delete mySimulation;
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_AddMeshElementDlg::Init( SALOME_Selection* Sel ) void SMESHGUI_AddMeshElementDlg::Init()
{ {
GroupC1->show(); GroupC1->show();
Constructor1->setChecked(TRUE); Constructor1->setChecked(TRUE);
myEditCurrentArgument = LineEditC1A1; myEditCurrentArgument = LineEditC1A1;
mySelection = Sel;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox((QDialog*)this); mySMESHGUI->SetActiveDialogBox((QDialog*)this);
myOkNodes = false ; myNbOkNodes = 0;
myActor = 0; myActor = 0;
/* signals and slots connections */ /* signals and slots connections */
@ -381,22 +408,23 @@ void SMESHGUI_AddMeshElementDlg::Init( SALOME_Selection* Sel )
connect(SelectButtonC1A1, SIGNAL(clicked()), SLOT(SetEditCurrentArgument())); connect(SelectButtonC1A1, SIGNAL(clicked()), SLOT(SetEditCurrentArgument()));
connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
connect(mySelection, SIGNAL( currentSelectionChanged() ), SLOT( SelectionIntoArgument() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
/* to close dialog if study frame change */ /* to close dialog if study frame change */
connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel())); connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel()));
if (Reverse) if (Reverse)
connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int))); connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)));
/* Move widget on the botton right corner of main widget */ // Move widget on the botton right corner of main widget
int x, y; int x, y;
mySMESHGUI->DefineDlgPosition(this, x, y); mySMESHGUI->DefineDlgPosition(this, x, y);
this->move(x, y); this->move(x, y);
this->show() ; /* displays Dialog */ this->show(); // displays Dialog
// set selection mode // set selection mode
SMESH::SetPointRepresentation(true); SMESH::SetPointRepresentation(true);
QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
myViewWindow->SetSelectionMode( NodeSelection );
myBusy = false; myBusy = false;
@ -409,8 +437,7 @@ void SMESHGUI_AddMeshElementDlg::Init( SALOME_Selection* Sel )
//================================================================================= //=================================================================================
void SMESHGUI_AddMeshElementDlg::ClickOnApply() void SMESHGUI_AddMeshElementDlg::ClickOnApply()
{ {
if ( myOkNodes && !mySMESHGUI->ActiveStudyLocked() ) { if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) {
myBusy = true; myBusy = true;
SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
anArrayOfIdeces->length(myNbNodes); anArrayOfIdeces->length(myNbNodes);
@ -433,8 +460,8 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply()
default:; default:;
} }
mySelection->ClearIObjects(); SALOME_ListIO aList; aList.Append( myActor->getIO() );
mySelection->AddIObject( myActor->getIO(), false ); mySelectionMgr->setSelectedObjects( aList, false );
SMESH::UpdateView(); SMESH::UpdateView();
mySimulation->SetVisibility(false); mySimulation->SetVisibility(false);
@ -465,27 +492,26 @@ void SMESHGUI_AddMeshElementDlg::ClickOnOk()
//================================================================================= //=================================================================================
void SMESHGUI_AddMeshElementDlg::ClickOnCancel() void SMESHGUI_AddMeshElementDlg::ClickOnCancel()
{ {
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
mySimulation->SetVisibility(false); mySimulation->SetVisibility(false);
SMESH::SetPointRepresentation(false); SMESH::SetPointRepresentation(false);
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); myViewWindow->SetSelectionMode( ActorSelection );
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
reject(); reject();
return; return;
} }
//======================================================================= //=================================================================================
//function : onTextChange // function : onTextChange()
// purpose : // purpose :
//======================================================================= //=================================================================================
void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText) void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText)
{ {
if (myBusy) return; if (myBusy) return;
myBusy = true; myBusy = true;
myOkNodes = false; myNbOkNodes = 0;
buttonOk->setEnabled(false); buttonOk->setEnabled(false);
buttonApply->setEnabled(false); buttonApply->setEnabled(false);
@ -496,32 +522,42 @@ void SMESHGUI_AddMeshElementDlg::onTextChange(const QString& theNewText)
SMDS_Mesh* aMesh = 0; SMDS_Mesh* aMesh = 0;
if (myActor) if (myActor)
aMesh = myActor->GetObject()->GetMesh(); aMesh = myActor->GetObject()->GetMesh();
if ( aMesh ) {
mySelection->ClearIObjects(); if (aMesh) {
mySelection->AddIObject( myActor->getIO() ); SALOME_ListIO aList; aList.Append( myActor->getIO() );
mySelectionMgr->setSelectedObjects( aList, false );
TColStd_IndexedMapOfInteger selectedIndices;
TColStd_MapOfInteger newIndices;
mySelector->GetIndex(myActor->getIO(), selectedIndices);
QStringList aListId = QStringList::split(" ", theNewText, false); QStringList aListId = QStringList::split(" ", theNewText, false);
bool allOk = true;
for (int i = 0; i < aListId.count(); i++) { for (int i = 0; i < aListId.count(); i++) {
const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
if ( n ) { {
if ( mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) if( selectedIndices.Add( n->GetID() ) )
allOk = false; newIndices.Add( n->GetID() );
else myNbOkNodes++;
mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true);
} }
else
allOk = false;
} }
myOkNodes = (allOk && myNbNodes == aListId.count() );
if ( myOkNodes ) { if( newIndices.Extent()>0 )
{
mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true );
myViewWindow->highlight( myActor->getIO(), true, true );
}
bool aNodesOK = false;
if (myIsPoly && myElementType == SMDSAbs_Face && aListId.count() >=3 ){
myNbOkNodes = aListId.count();
aNodesOK = true;
}
}
if(myNbOkNodes) {
buttonOk->setEnabled(true); buttonOk->setEnabled(true);
buttonApply->setEnabled(true); buttonApply->setEnabled(true);
displaySimulation(); displaySimulation();
} }
}
myBusy = false; myBusy = false;
} }
@ -535,8 +571,7 @@ void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
if (myBusy) return; if (myBusy) return;
// clear // clear
myNbOkNodes = 0;
myOkNodes = false;
myActor = 0; myActor = 0;
myBusy = true; myBusy = true;
@ -553,32 +588,35 @@ void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
// SMESH::SetPointRepresentation(true); // SMESH::SetPointRepresentation(true);
// get selected mesh // get selected mesh
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
int nbSel = mySelection->IObjectCount(); if (aList.Extent() != 1)
if(nbSel != 1)
return; return;
myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); Handle(SALOME_InteractiveObject) anIO = aList.First();
myMesh = SMESH::GetMeshByIO(anIO);
if (myMesh->_is_nil()) if (myMesh->_is_nil())
return; return;
myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); myActor = SMESH::FindActorByEntry(anIO->getEntry());
if (!myActor) if (!myActor)
return; return;
// get selected nodes // get selected nodes
QString aString = ""; QString aString = "";
int nbNodes = SMESH::GetNameOfSelectedNodes(mySelection, aString) ; int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString);
myBusy = true; myBusy = true;
myEditCurrentArgument->setText(aString); myEditCurrentArgument->setText(aString);
myBusy = false; myBusy = false;
if ( myNbNodes != nbNodes ) if (myIsPoly && myElementType == SMDSAbs_Face && nbNodes >= 3 ) {
myNbNodes = nbNodes;
} else if (myNbNodes != nbNodes) {
return; return;
}
// OK // OK
myNbOkNodes = nbNodes;
myOkNodes = true;
buttonOk->setEnabled(true); buttonOk->setEnabled(true);
buttonApply->setEnabled(true); buttonApply->setEnabled(true);
@ -586,15 +624,13 @@ void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
displaySimulation(); displaySimulation();
} }
//======================================================================= //=================================================================================
//function : displaySimulation // function : displaySimulation()
// purpose : // purpose :
//======================================================================= //=================================================================================
void SMESHGUI_AddMeshElementDlg::displaySimulation() void SMESHGUI_AddMeshElementDlg::displaySimulation()
{ {
if ( myOkNodes && GroupButtons->isEnabled() ) if (myNbOkNodes && GroupButtons->isEnabled()) {
{
SMESH::TElementSimulation::TVTKIds anIds; SMESH::TElementSimulation::TVTKIds anIds;
QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false); QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false);
for (int i = 0; i < aListId.count(); i++) for (int i = 0; i < aListId.count(); i++)
@ -604,6 +640,12 @@ void SMESHGUI_AddMeshElementDlg::displaySimulation()
reverse(anIds.begin(),anIds.end()); reverse(anIds.begin(),anIds.end());
vtkIdType aType = 0; vtkIdType aType = 0;
if (myIsPoly)
switch ( myElementType ) {
case SMDSAbs_Face : aType = VTK_POLYGON; break;
default: return;
}
else {
switch (myNbNodes) { switch (myNbNodes) {
case 2: aType = VTK_LINE; break; case 2: aType = VTK_LINE; break;
case 3: aType = VTK_TRIANGLE; break; case 3: aType = VTK_TRIANGLE; break;
@ -611,12 +653,12 @@ void SMESHGUI_AddMeshElementDlg::displaySimulation()
case 8: aType = VTK_HEXAHEDRON; break; case 8: aType = VTK_HEXAHEDRON; break;
default: return; default: return;
} }
}
mySimulation->SetPosition(myActor,aType,anIds); mySimulation->SetPosition(myActor,aType,anIds);
} }
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -645,10 +687,8 @@ void SMESHGUI_AddMeshElementDlg::DeactivateActiveDialog()
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
mySMESHGUI->SetActiveDialogBox(0); mySMESHGUI->SetActiveDialogBox(0);
} }
return ;
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -663,8 +703,8 @@ void SMESHGUI_AddMeshElementDlg::ActivateThisDialog()
GroupButtons->setEnabled(true); GroupButtons->setEnabled(true);
SMESH::SetPointRepresentation(true); SMESH::SetPointRepresentation(true);
QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
myViewWindow->SetSelectionMode( NodeSelection );
SelectionIntoArgument(); SelectionIntoArgument();
} }
@ -672,7 +712,7 @@ void SMESHGUI_AddMeshElementDlg::ActivateThisDialog()
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_AddMeshElementDlg::enterEvent(QEvent* e) void SMESHGUI_AddMeshElementDlg::enterEvent (QEvent*)
{ {
if (GroupConstructors->isEnabled()) if (GroupConstructors->isEnabled())
return; return;
@ -680,36 +720,34 @@ void SMESHGUI_AddMeshElementDlg::enterEvent(QEvent* e)
return; return;
} }
//================================================================================= //=================================================================================
// function : closeEvent() // function : closeEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_AddMeshElementDlg::closeEvent( QCloseEvent* e ) void SMESHGUI_AddMeshElementDlg::closeEvent (QCloseEvent*)
{ {
/* same than click on cancel button */ /* same than click on cancel button */
this->ClickOnCancel(); this->ClickOnCancel();
return; return;
} }
//=======================================================================
//function : hideEvent
//purpose : caused by ESC key
//=======================================================================
void SMESHGUI_AddMeshElementDlg::hideEvent ( QHideEvent * e ) //=================================================================================
// function : hideEvent()
// purpose : caused by ESC key
//=================================================================================
void SMESHGUI_AddMeshElementDlg::hideEvent (QHideEvent*)
{ {
if (!isMinimized()) if (!isMinimized())
ClickOnCancel(); ClickOnCancel();
} }
//======================================================================= //=================================================================================
//function : CheckBox // function : CheckBox()
// purpose : // purpose :
//======================================================================= //=================================================================================
void SMESHGUI_AddMeshElementDlg::CheckBox (int state) void SMESHGUI_AddMeshElementDlg::CheckBox (int state)
{ {
if ( !myOkNodes ) if (!myNbOkNodes)
return; return;
if (state >= 0) { if (state >= 0) {

View File

@ -29,7 +29,7 @@
#ifndef DIALOGBOX_ADD_FACE_H #ifndef DIALOGBOX_ADD_FACE_H
#define DIALOGBOX_ADD_FACE_H #define DIALOGBOX_ADD_FACE_H
#include "SALOME_Selection.h" #include "SalomeApp_SelectionMgr.h"
#include "SMDSAbs_ElementType.hxx" #include "SMDSAbs_ElementType.hxx"
@ -51,6 +51,8 @@ class QCheckBox;
class SMESHGUI; class SMESHGUI;
class SMESH_Actor; class SMESH_Actor;
class SMDS_Mesh; class SMDS_Mesh;
class SVTK_ViewWindow;
class SVTK_Selector;
namespace SMESH{ namespace SMESH{
struct TElementSimulation; struct TElementSimulation;
@ -69,29 +71,31 @@ class SMESHGUI_AddMeshElementDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_AddMeshElementDlg( QWidget* parent = 0, const char* name = 0, SMESHGUI_AddMeshElementDlg( SMESHGUI*,
SALOME_Selection* Sel = 0, const char* = 0,
SMDSAbs_ElementType ElementType = SMDSAbs_Edge, SMDSAbs_ElementType ElementType = SMDSAbs_Edge,
int nbNodes = 2, bool modal = FALSE, WFlags fl = 0 ); int nbNodes = 2, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_AddMeshElementDlg(); ~SMESHGUI_AddMeshElementDlg();
private: private:
void Init ();
void Init( SALOME_Selection* Sel ) ; void closeEvent (QCloseEvent*);
void closeEvent( QCloseEvent* e ) ;
void hideEvent (QHideEvent*); /* ESC key */ void hideEvent (QHideEvent*); /* ESC key */
void enterEvent (QEvent*); /* mouse enter the QWidget */ void enterEvent (QEvent*); /* mouse enter the QWidget */
void displaySimulation(); void displaySimulation();
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */ SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */
bool myOkNodes ; /* to check when arguments is defined */ int myNbOkNodes; /* to check when arguments is defined */
bool myBusy; bool myBusy;
SVTK_ViewWindow* myViewWindow;
SVTK_Selector* mySelector;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
int myElementType; int myElementType;
int myNbNodes; int myNbNodes;
bool myIsPoly;
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor; SMESH_Actor* myActor;

View File

@ -33,16 +33,24 @@
#include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_HypothesesUtils.h" #include "SMESHGUI_HypothesesUtils.h"
#include "SMESH_TypeFilter.hxx"
#include "SMESH_NumberFilter.hxx"
#include "GEOMBase.h" #include "GEOMBase.h"
#include "QAD_Application.h" #include "SUIT_Session.h"
#include "QAD_Desktop.h" #include "SUIT_MessageBox.h"
#include "QAD_MessageBox.h" #include "SUIT_OverrideCursor.h"
#include "QAD_WaitCursor.h" #include "SUIT_Operation.h"
#include "QAD_Operation.h" #include "SUIT_Desktop.h"
#include "SALOMEDSClient_Study.hxx"
#include "SALOMEDS_SObject.hxx"
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx"
#include "SALOMEGUI_QtCatchCorbaException.hxx" #include "SalomeApp_Tools.h"
#include "SVTK_ViewModel.h"
#include "utilities.h" #include "utilities.h"
@ -65,25 +73,28 @@ namespace SMESH{
try { try {
if (!theMesh->_is_nil() && !theShapeObject->_is_nil()) if (!theMesh->_is_nil() && !theShapeObject->_is_nil())
aSubMesh = theMesh->GetSubMesh(theShapeObject, theMeshName); aSubMesh = theMesh->GetSubMesh(theShapeObject, theMeshName);
} } catch (const SALOME::SALOME_Exception& S_ex) {
catch( const SALOME::SALOME_Exception& S_ex ) { SalomeApp_Tools::QtCatchCorbaException(S_ex);
QtCatchCorbaException( S_ex );
} }
return aSubMesh._retn(); return aSubMesh._retn();
} }
} }
//================================================================================= //=================================================================================
// class : SMESHGUI_AddSubMeshDlg() // function : SMESHGUI_AddSubMeshDlg()
// purpose : Constructs a SMESHGUI_AddSubMeshDlg which is a child of 'parent', with the // purpose : Constructs a SMESHGUI_AddSubMeshDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( SMESHGUI* theModule, const char* name,
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) bool modal, WFlags fl)
: QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu | WDestructiveClose),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
{ {
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
if (!name) if (!name)
setName("SMESHGUI_AddSubMeshDlg"); setName("SMESHGUI_AddSubMeshDlg");
setCaption(tr("SMESH_ADD_SUBMESH")); setCaption(tr("SMESH_ADD_SUBMESH"));
@ -175,10 +186,9 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* nam
SMESHGUI_AddSubMeshDlgLayout->addWidget(GroupButtons, 2, 0); SMESHGUI_AddSubMeshDlgLayout->addWidget(GroupButtons, 2, 0);
/***************************************************************/ /***************************************************************/
Init( Sel ) ; Init();
} }
//================================================================================= //=================================================================================
// function : ~SMESHGUI_AddSubMeshDlg() // function : ~SMESHGUI_AddSubMeshDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -188,18 +198,19 @@ SMESHGUI_AddSubMeshDlg::~SMESHGUI_AddSubMeshDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel ) void SMESHGUI_AddSubMeshDlg::Init ()
{ {
mySelection = Sel;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox((QDialog*)this); mySMESHGUI->SetActiveDialogBox((QDialog*)this);
myGeomFilter = new SALOME_TypeFilter( "GEOM" ); //myGeomFilter = new SALOME_TypeFilter("GEOM");
TColStd_MapOfInteger allTypesMap;
for (int i = 0; i < 10; i++)
allTypesMap.Add(i);
myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
myMeshFilter = new SMESH_TypeFilter (MESH); myMeshFilter = new SMESH_TypeFilter (MESH);
myAlgorithmFilter = new SMESH_TypeFilter (ALGORITHM); myAlgorithmFilter = new SMESH_TypeFilter (ALGORITHM);
myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS); myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS);
@ -214,7 +225,7 @@ void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel )
connect(SelectButtonC1A1Hyp, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectButtonC1A1Hyp, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(SelectButtonC1A1Algo, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectButtonC1A1Algo, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
@ -226,8 +237,8 @@ void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel )
LineEdit_NameMesh->setText(tr("SMESH_SUBMESH")); LineEdit_NameMesh->setText(tr("SMESH_SUBMESH"));
LineEdit_NameMesh->setFocus(); LineEdit_NameMesh->setFocus();
myEditCurrentArgument = LineEditC1A1; myEditCurrentArgument = LineEditC1A1;
mySelection->ClearFilters() ; mySelectionMgr->clearFilters();
mySelection->AddFilter( myMeshFilter ) ; mySelectionMgr->installFilter(myMeshFilter);
SelectionIntoArgument(); SelectionIntoArgument();
} }
@ -248,26 +259,29 @@ void SMESHGUI_AddSubMeshDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool SMESHGUI_AddSubMeshDlg::ClickOnApply() bool SMESHGUI_AddSubMeshDlg::ClickOnApply()
{ {
if (mySMESHGUI->ActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return false; return false;
QString myNameSubMesh = LineEdit_NameMesh->text().stripWhiteSpace(); QString myNameSubMesh = LineEdit_NameMesh->text().stripWhiteSpace();
if (myNameSubMesh.isEmpty()) { if (myNameSubMesh.isEmpty()) {
QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); SUIT_MessageBox::warn1(this, tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_EMPTY_NAME"), tr("SMESH_BUT_OK"));
return false; return false;
} }
if ( myMesh->_is_nil() || myGeomShape->_is_nil() || ( !HypoList.count() && !AlgoList.count() ) ) if (myMesh->_is_nil() || myGeomShape->_is_nil() ||
(!HypoList.count() && !AlgoList.count()))
return false; return false;
SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
GEOM::GEOM_Object_var myMainShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); GEOM::GEOM_Object_var myMainShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO);
if (myMainShape->_is_nil()) if (myMainShape->_is_nil())
return false; return false;
QAD_WaitCursor wc; SUIT_OverrideCursor wc;
QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() ); SUIT_Operation* op =
new SUIT_Operation (SUIT_Session::session()->activeApplication());
// start transaction // start transaction
op->start(); op->start();
@ -281,35 +295,33 @@ bool SMESHGUI_AddSubMeshDlg::ClickOnApply()
int nbAlgo = AlgoList.count(); int nbAlgo = AlgoList.count();
int nbHyps = HypoList.count() + nbAlgo; int nbHyps = HypoList.count() + nbAlgo;
for (int i = 0; i < nbHyps; i++) { for (int i = 0; i < nbHyps; i++) {
SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID _PTR(SObject) aHypSOClient =
( i < nbAlgo ? AlgoList[i] : HypoList[i-nbAlgo] ); SMESH::GetActiveStudyDocument()->FindObjectID
if ( !aHypSO->_is_nil() ) { (i < nbAlgo ? AlgoList[i].latin1() : HypoList[i-nbAlgo].latin1());
CORBA::Object_var anObject = aHypSO->GetObject(); if (aHypSOClient) {
CORBA::Object_var anObject = _CAST(SObject,aHypSOClient)->GetObject();
if (!CORBA::is_nil(anObject)) { if (!CORBA::is_nil(anObject)) {
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject); SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject);
if (!aHyp->_is_nil()) if (!aHyp->_is_nil())
if (SMESH::AddHypothesisOnSubMesh(aSubMesh, aHyp)) if (SMESH::AddHypothesisOnSubMesh(aSubMesh, aHyp))
nbSuccess++; nbSuccess++;
} } else {
else {
SCRUTE(CORBA::is_nil(anObject)); SCRUTE(CORBA::is_nil(anObject));
} }
} } else {
else { SCRUTE(!aHypSOClient);
SCRUTE( aHypSO->_is_nil() );
} }
} }
} } else {
else {
SCRUTE(aSubMesh->_is_nil()); SCRUTE(aSubMesh->_is_nil());
} }
// commit transaction // commit transaction
op->finish(); op->commit();
mySMESHGUI->updateObjBrowser();
return (nbSuccess > 0); return (nbSuccess > 0);
} }
//================================================================================= //=================================================================================
// function : ClickOnCancel() // function : ClickOnCancel()
// purpose : // purpose :
@ -319,16 +331,18 @@ void SMESHGUI_AddSubMeshDlg::ClickOnCancel()
close(); close();
} }
//======================================================================= //=================================================================================
//function : IsFatherOf // function : IsFatherOf()
// purpose : // purpose :
//======================================================================= //=================================================================================
static bool IsFatherOf (_PTR(SObject) SO, _PTR(SObject) fatherSO)
static bool IsFatherOf( SALOMEDS::SObject_ptr SO, SALOMEDS::SObject_ptr fatherSO ) { {
if ( !SO->_is_nil() && !fatherSO->_is_nil() ) { if (SO && fatherSO) {
SALOMEDS::SObject_var aSO = SO->GetFather(); _PTR(SObject) aSO = SO->GetFather();
while( strlen( aSO->GetID() ) >= strlen( fatherSO->GetID() ) ) { //while (strlen(aSO->GetID()) >= strlen(fatherSO->GetID())) {
if ( QString( aSO->GetID() ) == QString( fatherSO->GetID() ) ) while (aSO->GetID().length() >= fatherSO->GetID().length()) {
//if (QString(aSO->GetID()) == QString(fatherSO->GetID()))
if (aSO->GetID() == fatherSO->GetID())
return true; return true;
aSO = aSO->GetFather(); aSO = aSO->GetFather();
} }
@ -343,16 +357,18 @@ static bool IsFatherOf( SALOMEDS::SObject_ptr SO, SALOMEDS::SObject_ptr fatherSO
void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument() void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument()
{ {
QString aString = ""; QString aString = "";
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ;
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
if (myEditCurrentArgument == LineEditC1A1) { if (myEditCurrentArgument == LineEditC1A1) {
// mesh // mesh
if (nbSel != 1) { if (nbSel != 1) {
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_Mesh::_nil();
aString = ""; aString = "";
} } else {
else { Handle(SALOME_InteractiveObject) IO = aList.First();
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO); myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
if (myMesh->_is_nil()) { if (myMesh->_is_nil()) {
aString = ""; aString = "";
@ -360,69 +376,66 @@ void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument()
} }
myGeomShape = GEOM::GEOM_Object::_nil(); myGeomShape = GEOM::GEOM_Object::_nil();
LineEditC1A2->setText(""); LineEditC1A2->setText("");
}
else if ( myEditCurrentArgument == LineEditC1A2 ) { } else if (myEditCurrentArgument == LineEditC1A2) {
// geom shape // geom shape
if (nbSel != 1) { if (nbSel != 1) {
myGeomShape = GEOM::GEOM_Object::_nil(); myGeomShape = GEOM::GEOM_Object::_nil();
aString = ""; aString = "";
} } else {
else { Handle(SALOME_InteractiveObject) IO = aList.First();
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
myGeomShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO); myGeomShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO);
if( myGeomShape->_is_nil() || !GEOMBase::IsShape( myGeomShape ) ) if (myGeomShape->_is_nil() || !GEOMBase::IsShape(myGeomShape)) {
{
myGeomShape = GEOM::GEOM_Object::_nil(); myGeomShape = GEOM::GEOM_Object::_nil();
aString = ""; aString = "";
} }
if (!myMesh->_is_nil()) { if (!myMesh->_is_nil()) {
SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
GEOM::GEOM_Object_var aMainGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); GEOM::GEOM_Object_var aMainGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO);
SALOMEDS::SObject_var aMainGeomShapeSO = SMESH::FindSObject( aMainGeomShape ); _PTR(SObject) aMainGeomShapeSO = SMESH::FindSObject(aMainGeomShape);
if ( aMainGeomShapeSO->_is_nil() || !IsFatherOf( SMESH::GetActiveStudyDocument()->FindObjectID( IO->getEntry() ), aMainGeomShapeSO ) ) { if (!aMainGeomShapeSO ||
!IsFatherOf(SMESH::GetActiveStudyDocument()->FindObjectID
(IO->getEntry()), aMainGeomShapeSO)) {
myGeomShape = GEOM::GEOM_Object::_nil(); myGeomShape = GEOM::GEOM_Object::_nil();
aString = ""; aString = "";
} }
} }
} }
} } else if (myEditCurrentArgument == LineEditC1A1Hyp) {
else if ( myEditCurrentArgument == LineEditC1A1Hyp ) {
// hypotheses // hypotheses
HypoList.clear(); HypoList.clear();
if (nbSel >= 1) { if (nbSel >= 1) {
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); SALOME_ListIteratorOfListIO Itinit (aList);
for (; Itinit.More(); Itinit.Next()) { for (; Itinit.More(); Itinit.Next()) {
HypoList.append(Itinit.Value()->getEntry()); HypoList.append(Itinit.Value()->getEntry());
} }
if (nbSel > 1) if (nbSel > 1)
aString = tr("%1 Hypothesis").arg(nbSel); aString = tr("%1 Hypothesis").arg(nbSel);
} } else {
else {
aString = ""; aString = "";
} }
} } else if (myEditCurrentArgument == LineEditC1A1Algo) {
else if ( myEditCurrentArgument == LineEditC1A1Algo ) {
// algorithms // algorithms
AlgoList.clear(); AlgoList.clear();
if (nbSel >= 1) { if (nbSel >= 1) {
SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); SALOME_ListIteratorOfListIO Itinit (aList);
for (; Itinit.More(); Itinit.Next()) { for (; Itinit.More(); Itinit.Next()) {
AlgoList.append(Itinit.Value()->getEntry()); AlgoList.append(Itinit.Value()->getEntry());
} }
if (nbSel > 1) if (nbSel > 1)
aString = tr("%1 Algorithms").arg(nbSel); aString = tr("%1 Algorithms").arg(nbSel);
} } else {
else {
aString = ""; aString = "";
} }
} else {
} }
myEditCurrentArgument->setText(aString); myEditCurrentArgument->setText(aString);
myEditCurrentArgument->setCursorPosition( 0 );
UpdateControlState(); UpdateControlState();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -432,24 +445,24 @@ void SMESHGUI_AddSubMeshDlg::SetEditCurrentArgument()
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
if(send == SelectButtonC1A1) { if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus(); LineEditC1A1->setFocus();
mySelectionMgr->clearFilters();
mySelectionMgr->installFilter(myMeshFilter);
myEditCurrentArgument = LineEditC1A1; myEditCurrentArgument = LineEditC1A1;
mySelection->ClearFilters() ;
mySelection->AddFilter(myMeshFilter) ;
} else if (send == SelectButtonC1A2) { } else if (send == SelectButtonC1A2) {
LineEditC1A2->setFocus(); LineEditC1A2->setFocus();
mySelectionMgr->clearFilters();
mySelectionMgr->installFilter(myGeomFilter);
myEditCurrentArgument = LineEditC1A2; myEditCurrentArgument = LineEditC1A2;
mySelection->ClearFilters() ;
mySelection->AddFilter(myGeomFilter) ;
} else if(send == SelectButtonC1A1Hyp) { } else if(send == SelectButtonC1A1Hyp) {
LineEditC1A1Hyp->setFocus(); LineEditC1A1Hyp->setFocus();
mySelectionMgr->clearFilters();
mySelectionMgr->installFilter(myHypothesisFilter);
myEditCurrentArgument = LineEditC1A1Hyp; myEditCurrentArgument = LineEditC1A1Hyp;
mySelection->ClearFilters() ;
mySelection->AddFilter(myHypothesisFilter) ;
} else if(send == SelectButtonC1A1Algo) { } else if(send == SelectButtonC1A1Algo) {
LineEditC1A1Algo->setFocus(); LineEditC1A1Algo->setFocus();
mySelectionMgr->clearFilters();
mySelectionMgr->installFilter(myAlgorithmFilter);
myEditCurrentArgument = LineEditC1A1Algo; myEditCurrentArgument = LineEditC1A1Algo;
mySelection->ClearFilters() ;
mySelection->AddFilter(myAlgorithmFilter) ;
} }
SelectionIntoArgument(); SelectionIntoArgument();
} }
@ -461,13 +474,12 @@ void SMESHGUI_AddSubMeshDlg::SetEditCurrentArgument()
void SMESHGUI_AddSubMeshDlg::DeactivateActiveDialog() void SMESHGUI_AddSubMeshDlg::DeactivateActiveDialog()
{ {
if (GroupC1->isEnabled()) { if (GroupC1->isEnabled()) {
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
GroupC1->setEnabled(false); GroupC1->setEnabled(false);
GroupButtons->setEnabled(false); GroupButtons->setEnabled(false);
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -477,30 +489,28 @@ void SMESHGUI_AddSubMeshDlg::ActivateThisDialog()
mySMESHGUI->EmitSignalDeactivateDialog(); mySMESHGUI->EmitSignalDeactivateDialog();
GroupC1->setEnabled(true); GroupC1->setEnabled(true);
GroupButtons->setEnabled(true); GroupButtons->setEnabled(true);
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect (mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_AddSubMeshDlg::enterEvent(QEvent* e) void SMESHGUI_AddSubMeshDlg::enterEvent (QEvent*)
{ {
if (!GroupC1->isEnabled()) if (!GroupC1->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : closeEvent() // function : closeEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_AddSubMeshDlg::closeEvent (QCloseEvent* e) void SMESHGUI_AddSubMeshDlg::closeEvent (QCloseEvent* e)
{ {
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
mySelection->ClearFilters() ; mySelectionMgr->clearFilters();
QDialog::closeEvent(e); QDialog::closeEvent(e);
} }
@ -510,10 +520,12 @@ void SMESHGUI_AddSubMeshDlg::closeEvent( QCloseEvent* e )
//================================================================================= //=================================================================================
void SMESHGUI_AddSubMeshDlg::UpdateControlState() void SMESHGUI_AddSubMeshDlg::UpdateControlState()
{ {
bool isEnabled = ( !myMesh->_is_nil() && !myGeomShape->_is_nil() && ( HypoList.count() || AlgoList.count() ) ); bool isEnabled = (!myMesh->_is_nil() &&
!myGeomShape->_is_nil() &&
(HypoList.count() || AlgoList.count()));
bool isImportedMesh = false; bool isImportedMesh = false;
if (!myMesh->_is_nil()) { if (!myMesh->_is_nil()) {
SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO);
isImportedMesh = myGeomShape->_is_nil(); isImportedMesh = myGeomShape->_is_nil();
} }

View File

@ -29,9 +29,10 @@
#ifndef DIALOGBOX_ADD_SUBMESH_H #ifndef DIALOGBOX_ADD_SUBMESH_H
#define DIALOGBOX_ADD_SUBMESH_H #define DIALOGBOX_ADD_SUBMESH_H
#include "SALOME_Selection.h" //#include "SMESH_TypeFilter.hxx"
#include "SALOME_TypeFilter.hxx"
#include "SMESH_TypeFilter.hxx" #include "SUIT_SelectionFilter.h"
#include "SalomeApp_SelectionMgr.h"
// QT Includes // QT Includes
#include <qdialog.h> #include <qdialog.h>
@ -57,7 +58,10 @@ class SMESHGUI_AddSubMeshDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_AddSubMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); SMESHGUI_AddSubMeshDlg( SMESHGUI*,
const char* name = 0,
bool modal = FALSE,
WFlags fl = 0);
~SMESHGUI_AddSubMeshDlg(); ~SMESHGUI_AddSubMeshDlg();
protected: protected:
@ -65,22 +69,26 @@ protected:
void enterEvent (QEvent *) ; void enterEvent (QEvent *) ;
private: private:
void Init( SALOME_Selection* Sel ) ; void Init ();
void UpdateControlState(); void UpdateControlState();
private: private:
SMESHGUI* mySMESHGUI; SMESHGUI* mySMESHGUI;
SALOME_Selection* mySelection ; SalomeApp_SelectionMgr* mySelectionMgr;
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Mesh_var myMesh;
GEOM::GEOM_Object_var myGeomShape; GEOM::GEOM_Object_var myGeomShape;
QLineEdit* myEditCurrentArgument; QLineEdit* myEditCurrentArgument;
Handle(SALOME_TypeFilter) myGeomFilter; //Handle(SALOME_TypeFilter) myMeshFilter;
Handle(SMESH_TypeFilter) myMeshFilter; //Handle(SMESH_TypeFilter) myMeshFilter;
Handle(SMESH_TypeFilter) myHypothesisFilter; //Handle(SMESH_TypeFilter) myHypothesisFilter;
Handle(SMESH_TypeFilter) myAlgorithmFilter; //Handle(SMESH_TypeFilter) myAlgorithmFilter;
SUIT_SelectionFilter* myGeomFilter;
SUIT_SelectionFilter* myMeshFilter;
SUIT_SelectionFilter* myHypothesisFilter;
SUIT_SelectionFilter* myAlgorithmFilter;
QStringList HypoList; QStringList HypoList;
QStringList AlgoList; QStringList AlgoList;

View File

@ -32,7 +32,21 @@
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include <algorithm> #include "SMESH_Actor.h"
#include "SMESH_ActorUtils.h"
#include "SUIT_Session.h"
#include "SUIT_OverrideCursor.h"
#include "SALOME_ListIO.hxx"
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SalomeApp_Application.h"
#include "SalomeApp_SelectionMgr.h"
#include "SVTK_Selector.h"
#include "SVTK_ViewWindow.h"
// QT Includes // QT Includes
#include <qlabel.h> #include <qlabel.h>
@ -42,6 +56,7 @@
#include <qlayout.h> #include <qlayout.h>
#include <qgroupbox.h> #include <qgroupbox.h>
// VTK Includes
#include <vtkMath.h> #include <vtkMath.h>
#include <vtkCamera.h> #include <vtkCamera.h>
#include <vtkRenderer.h> #include <vtkRenderer.h>
@ -53,43 +68,31 @@
#include <vtkDataSetMapper.h> #include <vtkDataSetMapper.h>
#include <vtkPlaneSource.h> #include <vtkPlaneSource.h>
#include <vtkPolyData.h> #include <vtkPolyData.h>
#include "VTKViewer_ViewFrame.h"
#include "QAD_RightFrame.h"
#include "QAD_WaitCursor.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SMESH_Actor.h"
#include "SALOME_Selection.h"
#include "SALOME_InteractiveObject.hxx"
#include "SMESH_ActorUtils.h"
#include "VTKViewer_ViewFrame.h"
#include "VTKViewer_RenderWindow.h"
#include <vtkRenderer.h> #include <vtkRenderer.h>
// STL includes
#include <algorithm>
using namespace std; using namespace std;
class OrientedPlane: public vtkPlane class OrientedPlane: public vtkPlane
{ {
QAD_Study* myStudy; SVTK_ViewWindow* myViewWindow;
QAD_StudyFrame* myStudyFrame;
VTKViewer_ViewFrame* myViewFrame;
vtkDataSetMapper* myMapper; vtkDataSetMapper* myMapper;
public: public:
static OrientedPlane *New(){ static OrientedPlane *New()
{
return new OrientedPlane(); return new OrientedPlane();
} }
static OrientedPlane *New(QAD_Study* theStudy){ static OrientedPlane *New(SVTK_ViewWindow* theViewWindow)
return new OrientedPlane(theStudy); {
return new OrientedPlane(theViewWindow);
} }
vtkTypeMacro (OrientedPlane, vtkPlane); vtkTypeMacro (OrientedPlane, vtkPlane);
SMESH::Orientation myOrientation; SMESH::Orientation myOrientation;
float myDistance; float myDistance;
double myAngle[2]; double myAngle[2];
@ -103,7 +106,8 @@ public:
void SetDistance (float theDistance) { myDistance = theDistance; } void SetDistance (float theDistance) { myDistance = theDistance; }
float GetDistance() { return myDistance; } float GetDistance() { return myDistance; }
void ShallowCopy(OrientedPlane* theOrientedPlane){ void ShallowCopy (OrientedPlane* theOrientedPlane)
{
SetNormal(theOrientedPlane->GetNormal()); SetNormal(theOrientedPlane->GetNormal());
SetOrigin(theOrientedPlane->GetOrigin()); SetOrigin(theOrientedPlane->GetOrigin());
@ -120,28 +124,25 @@ public:
} }
protected: protected:
OrientedPlane(QAD_Study* theStudy): OrientedPlane(SVTK_ViewWindow* theViewWindow):
myViewWindow(theViewWindow),
myOrientation(SMESH::XY), myOrientation(SMESH::XY),
myDistance(0.5), myDistance(0.5)
myStudy(theStudy),
myStudyFrame(theStudy->getActiveStudyFrame()),
myViewFrame(SMESH::GetVtkViewFrame(theStudy->getActiveStudyFrame()))
{ {
Init(); Init();
myViewFrame->AddActor( myActor ); myViewWindow->AddActor(myActor);
} }
OrientedPlane(): OrientedPlane():
myOrientation(SMESH::XY), myOrientation(SMESH::XY),
myDistance(0.5), myViewWindow(NULL),
myStudy(NULL), myDistance(0.5)
myStudyFrame(NULL),
myViewFrame(NULL)
{ {
Init(); Init();
} }
void Init(){ void Init()
{
myPlaneSource = vtkPlaneSource::New(); myPlaneSource = vtkPlaneSource::New();
myAngle[0] = myAngle[1] = 0.0; myAngle[0] = myAngle[1] = 0.0;
@ -177,9 +178,7 @@ protected:
} }
~OrientedPlane(){ ~OrientedPlane(){
if(myStudy && SMESH::FindVtkViewFrame(myStudy,myStudyFrame)){ myViewWindow->RemoveActor(myActor);
myViewFrame->RemoveActor(myActor);
}
myActor->Delete(); myActor->Delete();
myMapper->RemoveAllInputs(); myMapper->RemoveAllInputs();
@ -204,17 +203,22 @@ struct TSetVisiblity{
int myIsVisible; int myIsVisible;
}; };
//================================================================================= //=================================================================================
// class : SMESHGUI_ClippingDlg() // class : SMESHGUI_ClippingDlg()
// purpose : // purpose :
// //
//================================================================================= //=================================================================================
SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( QWidget* parent, SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg (SMESHGUI* theModule,
const char* name, const char* name,
bool modal, bool modal,
WFlags fl ) WFlags fl):
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) QDialog(SMESH::GetDesktop(theModule),
name,
modal,
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
mySMESHGUI(theModule)
{ {
if (!name) if (!name)
setName("SMESHGUI_ClippingDlg"); setName("SMESHGUI_ClippingDlg");
@ -328,8 +332,6 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( QWidget* parent,
SMESHGUI_ClippingDlgLayout->addWidget(GroupParameters, 1, 0); SMESHGUI_ClippingDlgLayout->addWidget(GroupParameters, 1, 0);
SMESHGUI_ClippingDlgLayout->addWidget(GroupButtons, 2, 0); SMESHGUI_ClippingDlgLayout->addWidget(GroupButtons, 2, 0);
mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection());
// Initial state // Initial state
SpinBoxDistance->RangeStepAndValidator(0.0, 1.0, 0.01, 3); SpinBoxDistance->RangeStepAndValidator(0.0, 1.0, 0.01, 3);
SpinBoxRot1->RangeStepAndValidator(-180.0, 180.0, 1, 3); SpinBoxRot1->RangeStepAndValidator(-180.0, 180.0, 1, 3);
@ -358,19 +360,18 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( QWidget* parent,
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( SMESHGUI::GetSMESHGUI(), SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnOk() ) ) ; connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnOk()));
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged()));
/* to close dialog if study frame change */ /* to close dialog if study frame change */
connect( SMESHGUI::GetSMESHGUI(), SIGNAL ( SignalStudyFrameChanged() ), this, SLOT( ClickOnCancel() ) ) ; connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), this, SLOT(ClickOnCancel()));
/* Move widget on the botton right corner of main widget */ /* Move widget on the botton right corner of main widget */
int x, y; int x, y;
SMESHGUI::GetSMESHGUI()->DefineDlgPosition( this, x, y ) ; mySMESHGUI->DefineDlgPosition(this, x, y);
this->move(x, y); this->move(x, y);
this->show(); this->show();
} }
//================================================================================= //=================================================================================
// function : ~SMESHGUI_ClippingDlg() // function : ~SMESHGUI_ClippingDlg()
// purpose : // purpose :
@ -379,33 +380,35 @@ SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg()
{ {
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); SMESH::RenderViewWindow(SMESH::GetViewWindow(mySMESHGUI));
} }
//=======================================================================
// function : ClickOnApply()
// purpose :
//=======================================================================
void SMESHGUI_ClippingDlg::ClickOnApply() void SMESHGUI_ClippingDlg::ClickOnApply()
{ {
if (!myActor) if (!myActor)
return; return;
if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { if (SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI)) {
QAD_WaitCursor wc; SUIT_OverrideCursor wc;
myActor->RemoveAllClippingPlanes(); myActor->RemoveAllClippingPlanes();
SMESH::TPlanes::iterator anIter = myPlanes.begin(); SMESH::TPlanes::iterator anIter = myPlanes.begin();
for (; anIter != myPlanes.end(); anIter++) { for (; anIter != myPlanes.end(); anIter++) {
OrientedPlane* anOrientedPlane = OrientedPlane::New(); OrientedPlane* anOrientedPlane = OrientedPlane::New(aViewWindow);
anOrientedPlane->ShallowCopy(anIter->GetPointer()); anOrientedPlane->ShallowCopy(anIter->GetPointer());
myActor->AddClippingPlane(anOrientedPlane); myActor->AddClippingPlane(anOrientedPlane);
anOrientedPlane->Delete(); anOrientedPlane->Delete();
} }
SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); SMESH::RenderViewWindow(aViewWindow);
} }
} }
//======================================================================= //=======================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
@ -416,7 +419,6 @@ void SMESHGUI_ClippingDlg::ClickOnOk()
ClickOnCancel(); ClickOnCancel();
} }
//======================================================================= //=======================================================================
// function : ClickOnCancel() // function : ClickOnCancel()
// purpose : // purpose :
@ -426,16 +428,16 @@ void SMESHGUI_ClippingDlg::ClickOnCancel()
close(); close();
} }
//================================================================================= //=================================================================================
// function : onSelectionChanged() // function : onSelectionChanged()
// purpose : Called when selection is changed // purpose : Called when selection is changed
//================================================================================= //=================================================================================
void SMESHGUI_ClippingDlg::onSelectionChanged() void SMESHGUI_ClippingDlg::onSelectionChanged()
{ {
if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { if (SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI)) {
if ( mySelection->IObjectCount() ) { const SALOME_ListIO& aList = mySelector->StoredIObjects();
Handle(SALOME_InteractiveObject) IOS = mySelection->firstIObject(); if (aList.Extent() > 0) {
Handle(SALOME_InteractiveObject) IOS = aList.First();
myActor = SMESH::FindActorByEntry(IOS->getEntry()); myActor = SMESH::FindActorByEntry(IOS->getEntry());
if (myActor) { if (myActor) {
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
@ -445,7 +447,7 @@ void SMESHGUI_ClippingDlg::onSelectionChanged()
for (; anId < anEnd; anId++) { for (; anId < anEnd; anId++) {
if (vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)) { if (vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)) {
if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){ if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){
OrientedPlane* anOrientedPlane = OrientedPlane::New(SMESH::GetActiveStudy()); OrientedPlane* anOrientedPlane = OrientedPlane::New(aViewWindow);
SMESH::TVTKPlane aTVTKPlane(anOrientedPlane); SMESH::TVTKPlane aTVTKPlane(anOrientedPlane);
anOrientedPlane->Delete(); anOrientedPlane->Delete();
aTVTKPlane->ShallowCopy(aPlane); aTVTKPlane->ShallowCopy(aPlane);
@ -458,12 +460,11 @@ void SMESHGUI_ClippingDlg::onSelectionChanged()
TSetVisiblity(PreviewCheckBox->isChecked())); TSetVisiblity(PreviewCheckBox->isChecked()));
} }
} }
SMESH::RenderViewWindow(aViewWindow);
} }
Sinchronize(); Sinchronize();
SMESH::RenderViewFrame(SMESH::GetCurrentVtkView());
} }
//======================================================================= //=======================================================================
// function : onSelectPlane() // function : onSelectPlane()
// purpose : // purpose :
@ -502,7 +503,6 @@ void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex)
myIsSelectPlane = false; myIsSelectPlane = false;
} }
//======================================================================= //=======================================================================
// function : ClickOnNew() // function : ClickOnNew()
// purpose : // purpose :
@ -512,7 +512,8 @@ void SMESHGUI_ClippingDlg::ClickOnNew()
if (!myActor) if (!myActor)
return; return;
OrientedPlane* aPlane = OrientedPlane::New(SMESH::GetActiveStudy()); if(SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI)){
OrientedPlane* aPlane = OrientedPlane::New(aViewWindow);
SMESH::TVTKPlane aTVTKPlane(aPlane); SMESH::TVTKPlane aTVTKPlane(aPlane);
myPlanes.push_back(aTVTKPlane); myPlanes.push_back(aTVTKPlane);
@ -522,7 +523,7 @@ void SMESHGUI_ClippingDlg::ClickOnNew()
Sinchronize(); Sinchronize();
SetCurrentPlaneParam(); SetCurrentPlaneParam();
} }
}
//======================================================================= //=======================================================================
// function : ClickOnDelete() // function : ClickOnDelete()
@ -543,10 +544,9 @@ void SMESHGUI_ClippingDlg::ClickOnDelete()
ClickOnApply(); ClickOnApply();
Sinchronize(); Sinchronize();
SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); SMESH::RenderViewWindow(SMESH::GetCurrentVtkView());
} }
//======================================================================= //=======================================================================
// function : onSelectOrientation() // function : onSelectOrientation()
// purpose : // purpose :
@ -573,7 +573,6 @@ void SMESHGUI_ClippingDlg::onSelectOrientation(int theItem)
SetCurrentPlaneParam(); SetCurrentPlaneParam();
} }
//======================================================================= //=======================================================================
// function : Sinchronize() // function : Sinchronize()
// purpose : // purpose :
@ -612,7 +611,6 @@ void SMESHGUI_ClippingDlg::Sinchronize()
SpinBoxRot2->setEnabled(anIsControlsEnable); SpinBoxRot2->setEnabled(anIsControlsEnable);
} }
//======================================================================= //=======================================================================
// function : setRotation() // function : setRotation()
// purpose : // purpose :
@ -623,14 +621,11 @@ void SMESHGUI_ClippingDlg::setRotation( const double theRot1, const double theRo
SpinBoxRot2->SetValue(theRot2); SpinBoxRot2->SetValue(theRot2);
} }
//======================================================================= //=======================================================================
// function : SetCurrentPlaneParam // function : SetCurrentPlaneParam()
// purpose : // purpose :
//======================================================================= //=======================================================================
void void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
SMESHGUI_ClippingDlg::
SetCurrentPlaneParam()
{ {
if (myPlanes.empty() || myIsSelectPlane) if (myPlanes.empty() || myIsSelectPlane)
return; return;
@ -740,11 +735,15 @@ SetCurrentPlaneParam()
if(AutoApplyCheckBox->isChecked()) if(AutoApplyCheckBox->isChecked())
ClickOnApply(); ClickOnApply();
SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); SMESH::RenderViewWindow(SMESH::GetCurrentVtkView());
} }
//=======================================================================
void SMESHGUI_ClippingDlg::OnPreviewToggle(bool theIsToggled){ // function : OnPreviewToggle()
// purpose :
//=======================================================================
void SMESHGUI_ClippingDlg::OnPreviewToggle (bool theIsToggled)
{
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled));
SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); SMESH::RenderViewWindow(SMESH::GetCurrentVtkView());
} }

View File

@ -45,7 +45,11 @@ class QPushButton;
class QTable; class QTable;
class QCheckBox; class QCheckBox;
class QComboBox; class QComboBox;
class SALOME_Selection;
class SalomeApp_SelectionMgr;
class SVTK_Selector;
class SMESHGUI;
class SMESH_Actor; class SMESH_Actor;
class OrientedPlane; class OrientedPlane;
@ -69,7 +73,7 @@ class SMESHGUI_ClippingDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_ClippingDlg( QWidget* parent = 0, SMESHGUI_ClippingDlg (SMESHGUI* theModule,
const char* name = 0, const char* name = 0,
bool modal = false, bool modal = false,
WFlags fl = 0); WFlags fl = 0);
@ -85,7 +89,9 @@ public:
private: private:
SALOME_Selection* mySelection; SalomeApp_SelectionMgr* mySelectionMgr;
SVTK_Selector* mySelector;
SMESHGUI* mySMESHGUI;
SMESH_Actor* myActor; SMESH_Actor* myActor;
SMESH::TPlanes myPlanes; SMESH::TPlanes myPlanes;
@ -123,4 +129,3 @@ public slots:
}; };
#endif // DIALOGBOX_TRANSPARENCYDLG_H #endif // DIALOGBOX_TRANSPARENCYDLG_H

View File

@ -25,6 +25,20 @@
// Module : SMESH // Module : SMESH
// $Header$ // $Header$
#include "SMESHGUI_CreateHypothesesDlg.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI.h"
#include "SUIT_Desktop.h"
#include "SUIT_ResourceMgr.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "utilities.h"
// QT Includes // QT Includes
#include <qbuttongroup.h> #include <qbuttongroup.h>
#include <qgroupbox.h> #include <qgroupbox.h>
@ -33,37 +47,24 @@
#include <qlistview.h> #include <qlistview.h>
#include <qheader.h> #include <qheader.h>
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SMESHGUI_CreateHypothesesDlg.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI.h"
#include "utilities.h"
using namespace std; using namespace std;
//================================================================================= //=================================================================================
// class : SMESHGUI_CreateHypothesesDlg() // function : SMESHGUI_CreateHypothesesDlg()
// purpose : Constructs a SMESHGUI_CreateHypothesesDlg which is a child of 'parent', with the // purpose : Constructs a SMESHGUI_CreateHypothesesDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (QWidget* parent, SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (SMESHGUI* theModule,
const char* name, const char* name,
bool modal, bool modal,
bool isAlgo) bool isAlgo)
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
myIsAlgo( isAlgo ) WStyle_Title | WStyle_SysMenu | WDestructiveClose),
myIsAlgo(isAlgo),
mySMESHGUI( theModule )
{ {
MESSAGE("SMESHGUI_CreateHypothesesDlg");
if (!name) if (!name)
setName("SMESHGUI_CreateHypothesesDlg"); setName("SMESHGUI_CreateHypothesesDlg");
setCaption(isAlgo ? tr("SMESH_CREATE_ALGORITHMS" ) : tr("SMESH_CREATE_HYPOTHESES" )); setCaption(isAlgo ? tr("SMESH_CREATE_ALGORITHMS" ) : tr("SMESH_CREATE_HYPOTHESES" ));
@ -145,7 +146,6 @@ SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg()
//================================================================================= //=================================================================================
void SMESHGUI_CreateHypothesesDlg::Init() void SMESHGUI_CreateHypothesesDlg::Init()
{ {
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox((QDialog*)this); mySMESHGUI->SetActiveDialogBox((QDialog*)this);
InitAlgoDefinition(); InitAlgoDefinition();
@ -181,7 +181,7 @@ void SMESHGUI_CreateHypothesesDlg::ClickOnCancel()
//================================================================================= //=================================================================================
void SMESHGUI_CreateHypothesesDlg::ClickOnApply() void SMESHGUI_CreateHypothesesDlg::ClickOnApply()
{ {
if (mySMESHGUI->ActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return; return;
QListViewItem* item = ListAlgoDefinition->selectedItem(); QListViewItem* item = ListAlgoDefinition->selectedItem();
if (!item) if (!item)
@ -196,14 +196,11 @@ void SMESHGUI_CreateHypothesesDlg::ClickOnApply()
QString aClientLibName = aHypData->ClientLibName; QString aClientLibName = aHypData->ClientLibName;
MESSAGE("Client lib name = " << aClientLibName); MESSAGE("Client lib name = " << aClientLibName);
if (aClientLibName == "") if (aClientLibName == "") {
{
// Call hypothesis creation server method (without GUI) // Call hypothesis creation server method (without GUI)
QString aHypName = aHypData->Label; QString aHypName = aHypData->Label;
SMESH::CreateHypothesis(sHypType, aHypName, myIsAlgo); SMESH::CreateHypothesis(sHypType, aHypName, myIsAlgo);
} } else {
else
{
// Get hypotheses creator client (GUI) // Get hypotheses creator client (GUI)
SMESHGUI_GenericHypothesisCreator* aCreator = SMESHGUI_GenericHypothesisCreator* aCreator =
SMESH::GetHypothesisCreator(sHypType); SMESH::GetHypothesisCreator(sHypType);
@ -231,7 +228,7 @@ void SMESHGUI_CreateHypothesesDlg::ActivateThisDialog()
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_CreateHypothesesDlg::enterEvent(QEvent* e) void SMESHGUI_CreateHypothesesDlg::enterEvent (QEvent*)
{ {
ActivateThisDialog(); ActivateThisDialog();
return; return;
@ -290,8 +287,7 @@ void SMESHGUI_CreateHypothesesDlg::InitAlgoDefinition()
parentItem = new QListViewItem(ListAlgoDefinition, aHypData->PluginName); parentItem = new QListViewItem(ListAlgoDefinition, aHypData->PluginName);
parentItem->setOpen(true); parentItem->setOpen(true);
QListViewItem* aItem = new QListViewItem(parentItem, aHypData->Label, HypList[i]); QListViewItem* aItem = new QListViewItem(parentItem, aHypData->Label, HypList[i]);
QPixmap aPixMap (QAD_Desktop::getResourceManager()->loadPixmap QPixmap aPixMap (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr(aHypData->IconId)));
("SMESH", tr(aHypData->IconId)));
if (!aPixMap.isNull()) if (!aPixMap.isNull())
aItem->setPixmap(0, aPixMap); aItem->setPixmap(0, aPixMap);
} }

View File

@ -57,7 +57,7 @@ class SMESHGUI_CreateHypothesesDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_CreateHypothesesDlg (QWidget* parent = 0, SMESHGUI_CreateHypothesesDlg (SMESHGUI*,
const char* name = 0, const char* name = 0,
bool modal = FALSE, bool modal = FALSE,
bool isAlgo = FALSE); bool isAlgo = FALSE);

View File

@ -27,22 +27,37 @@
#include "SMESHGUI_CreatePatternDlg.h" #include "SMESHGUI_CreatePatternDlg.h"
#include "QAD_Desktop.h"
#include "QAD_FileDlg.h"
#include "SMESHGUI_PatternWidget.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SALOME_Selection.h" #include "SMESHGUI_SpinBox.h"
#include "SALOME_ListIteratorOfListOfFilter.hxx" #include "SMESHGUI_PatternWidget.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "SMESH_NumberFilter.hxx"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_PatternUtils.h" #include "SMESHGUI_PatternUtils.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include "SMESH_NumberFilter.hxx"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Desktop.h"
#include "SUIT_FileDlg.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_DataOwner.h"
#include "SalomeApp_SelectionMgr.h"
#include "SalomeApp_Tools.h"
#include "SALOMEDS_SObject.hxx"
#include "SALOME_ListIO.hxx"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_Selector.h"
#include "SVTK_Selection.h"
// OCCT Includes
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
// QT Includes
#include <qframe.h> #include <qframe.h>
#include <qlayout.h> #include <qlayout.h>
#include <qlineedit.h> #include <qlineedit.h>
@ -58,21 +73,24 @@
#define SPACING 5 #define SPACING 5
#define MARGIN 10 #define MARGIN 10
/* /*!
Class : SMESHGUI_CreatePatternDlg * Class : SMESHGUI_CreatePatternDlg
Description : Dialog to specify filters for VTK viewer * Description : Dialog to specify filters for VTK viewer
*/ */
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg // function : SMESHGUI_CreatePatternDlg()
// Purpose : Constructor // purpose : Constructor
//======================================================================= //=======================================================================
SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( QWidget* theParent, SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( SMESHGUI* theModule,
SALOME_Selection* theSelection,
const int theType, const int theType,
const char* theName) const char* theName)
: QDialog( theParent, theName, false, : QDialog( SMESH::GetDesktop( theModule ), theName, false,
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myViewWindow( SMESH::GetViewWindow( theModule ) ),
mySelector( myViewWindow->GetSelector() )
{ {
setCaption(tr("CAPTION")); setCaption(tr("CAPTION"));
@ -86,20 +104,19 @@ SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( QWidget* theParen
aDlgLay->setStretchFactor(aMainFrame, 1); aDlgLay->setStretchFactor(aMainFrame, 1);
Init( theSelection, theType ); Init(theType);
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::createMainFrame // function : createMainFrame()
// Purpose : Create frame containing dialog's input fields // purpose : Create frame containing dialog's input fields
//======================================================================= //=======================================================================
QFrame* SMESHGUI_CreatePatternDlg::createMainFrame (QWidget* theParent) QFrame* SMESHGUI_CreatePatternDlg::createMainFrame (QWidget* theParent)
{ {
QPixmap iconSlct( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); QPixmap iconSlct (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
QPixmap icon2d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) ); QPixmap icon2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_2d")));
QPixmap icon3d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) ); QPixmap icon3d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_3d")));
QPixmap iconSample2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D")));
QPixmap iconSample2d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) );
QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent); QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent);
aMainGrp->setFrameStyle(QFrame::NoFrame); aMainGrp->setFrameStyle(QFrame::NoFrame);
@ -156,8 +173,8 @@ QFrame* SMESHGUI_CreatePatternDlg::createMainFrame( QWidget* theParent )
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::createButtonFrame // function : createButtonFrame()
// Purpose : Create frame containing buttons // purpose : Create frame containing buttons
//======================================================================= //=======================================================================
QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame (QWidget* theParent) QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame (QWidget* theParent)
{ {
@ -185,16 +202,17 @@ QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame( QWidget* theParent )
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg // function : ~SMESHGUI_CreatePatternDlg()
// Purpose : Destructor // purpose : Destructor
//======================================================================= //=======================================================================
SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg() SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg()
{ {
// no need to delete child widgets, Qt does it all for us
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::onProject // function : onProject()
// Purpose : SLOT. Called when state of "Project nodes on ther face" // purpose : SLOT. Called when state of "Project nodes on ther face"
// checkbox is changed // checkbox is changed
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::onProject (bool) void SMESHGUI_CreatePatternDlg::onProject (bool)
@ -204,15 +222,14 @@ void SMESHGUI_CreatePatternDlg::onProject( bool )
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::Init // function : Init()
// Purpose : Init dialog fields, connect signals and slots, show dialog // purpose : Init dialog fields, connect signals and slots, show dialog
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::Init( SALOME_Selection* theSelection, const int theType ) void SMESHGUI_CreatePatternDlg::Init( const int theType )
{ {
myIsLoaded = false; myIsLoaded = false;
myType = -1; myType = -1;
myNbPoints = -1; myNbPoints = -1;
mySelection = theSelection;
mySubMesh = SMESH::SMESH_subMesh::_nil(); mySubMesh = SMESH::SMESH_subMesh::_nil();
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_Mesh::_nil();
myGeomObj = GEOM::GEOM_Object::_nil(); myGeomObj = GEOM::GEOM_Object::_nil();
@ -220,13 +237,12 @@ void SMESHGUI_CreatePatternDlg::Init( SALOME_Selection* theSelection, const int
erasePreview(); erasePreview();
SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); mySMESHGUI->SetActiveDialogBox((QDialog*)this);
aSMESHGUI->SetActiveDialogBox( ( QDialog* )this );
// selection and SMESHGUI // selection and SMESHGUI
connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
mySwitch2d->setEnabled(theType == Type_2d); mySwitch2d->setEnabled(theType == Type_2d);
mySwitch3d->setEnabled(theType == Type_3d); mySwitch3d->setEnabled(theType == Type_3d);
@ -253,14 +269,14 @@ void SMESHGUI_CreatePatternDlg::Init( SALOME_Selection* theSelection, const int
onSelectionDone(); onSelectionDone();
int x, y; int x, y;
aSMESHGUI->DefineDlgPosition( this, x, y ); mySMESHGUI->DefineDlgPosition(this, x, y);
this->move(x, y); this->move(x, y);
this->show(); this->show();
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::SetMesh // function : SetMesh()
// Purpose : Set mesh to dialog // purpose : Set mesh to dialog
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr) void SMESHGUI_CreatePatternDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr)
{ {
@ -270,62 +286,49 @@ void SMESHGUI_CreatePatternDlg::SetMesh( SMESH::SMESH_Mesh_ptr thePtr )
bool isValidMesh = false; bool isValidMesh = false;
if (!myMesh->_is_nil()) if (!myMesh->_is_nil())
{ {
SALOMEDS::SObject_var aSobj = SMESH::FindSObject( thePtr ); _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in());
CORBA::String_var anEntry = aSobj->GetID(); //Handle(SALOME_InteractiveObject) anIObj =
Handle(SALOME_InteractiveObject) anIObj = // new SALOME_InteractiveObject(aSobj->GetID().c_str(), "SMESH");
new SALOME_InteractiveObject( anEntry.in(), "SMESH" ); SUIT_DataOwnerPtr anIObj (new SalomeApp_DataOwner(aSobj->GetID().c_str()));
const SALOME_ListOfFilter& aList = mySelection->StoredFilters(); isValidMesh = mySelectionMgr->isOk(anIObj);
SALOME_ListIteratorOfListOfFilter anIter( aList );
for ( ; anIter.More(); anIter.Next() )
if ( !anIter.Value()->IsOk( anIObj ) )
break;
if ( !anIter.More() )
isValidMesh = true;
} }
if (isValidMesh) {
if ( isValidMesh ) _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in());
{ myMeshEdit->setText(aSO->GetName().c_str());
SALOMEDS::SObject_var aSO = SMESH::FindSObject( myMesh.in() ); myGeomObj = SMESH::GetGeom(aSO);
myMeshEdit->setText( aSO->GetName() ); } else {
myGeomObj = getGeom( aSO );
}
else
{
myMeshEdit->setText(""); myMeshEdit->setText("");
myGeomObj = GEOM::GEOM_Object::_nil(); myGeomObj = GEOM::GEOM_Object::_nil();
} }
if ( myType == Type_2d ) if (myType == Type_2d) {
{
loadFromObject(false); loadFromObject(false);
displayPreview(); displayPreview();
} }
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::isValid // function : isValid()
// Purpose : Verify validity of entry data // purpose : Verify validity of entry data
//======================================================================= //=======================================================================
bool SMESHGUI_CreatePatternDlg::isValid() bool SMESHGUI_CreatePatternDlg::isValid()
{ {
if ( myGeomObj->_is_nil() ) if (myGeomObj->_is_nil()) {
{ QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok ); tr("SMESHGUI_INVALID_PARAMETERS"),
QMessageBox::Ok);
return false; return false;
} }
else else
return true; return true;
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::getDefaultName // function : getDefaultName()
// Purpose : Get default pattern name // purpose : Get default pattern name
//======================================================================= //=======================================================================
QString SMESHGUI_CreatePatternDlg::getDefaultName() const QString SMESHGUI_CreatePatternDlg::getDefaultName() const
{ {
@ -333,15 +336,13 @@ QString SMESHGUI_CreatePatternDlg::getDefaultName() const
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::onSave // function : onSave()
// Purpose : SLOT called when "Save" button pressed. Build pattern and // purpose : SLOT called when "Save" button pressed. Build pattern and
// save it to disk // save it to disk
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::onSave() void SMESHGUI_CreatePatternDlg::onSave()
{ {
try try {
{
if (!isValid()) if (!isValid())
return; return;
@ -353,9 +354,9 @@ void SMESHGUI_CreatePatternDlg::onSave()
return; return;
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
QAD_FileDlg* aDlg = new QAD_FileDlg( this, false ); SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, false);
aDlg->setCaption(tr("SAVE_PATTERN")); aDlg->setCaption(tr("SAVE_PATTERN"));
aDlg->setMode( QFileDialogP::AnyFile ); aDlg->setMode(QFileDialog::AnyFile);
aDlg->setFilters(tr("PATTERN_FILT")); aDlg->setFilters(tr("PATTERN_FILT"));
if (myName->text() != "") if (myName->text() != "")
aDlg->setSelection(myName->text()); aDlg->setSelection(myName->text());
@ -380,33 +381,27 @@ void SMESHGUI_CreatePatternDlg::onSave()
long aWritten = aFile.writeBlock(aData, aLen); long aWritten = aFile.writeBlock(aData, aLen);
aFile.close(); aFile.close();
if ( aWritten != aLen ) if (aWritten != aLen) {
{ QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), tr("SMESH_ERROR"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("ERROR_OF_SAVING"), QMessageBox::Ok);
tr( "SMESH_ERROR" ), tr( "ERROR_OF_SAVING" ), QMessageBox::Ok ); } else {
} //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
else myViewWindow->SetSelectionMode(ActorSelection);
{ disconnect(mySelectionMgr, 0, this, 0);
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); disconnect(mySMESHGUI, 0, this, 0);
disconnect( mySelection, 0, this, 0 ); mySMESHGUI->ResetState();
disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 );
SMESHGUI::GetSMESHGUI()->ResetState();
accept(); accept();
emit NewPattern(); emit NewPattern();
} }
} } catch (const SALOME::SALOME_Exception& S_ex) {
catch( const SALOME::SALOME_Exception& S_ex ) SalomeApp_Tools::QtCatchCorbaException(S_ex);
{ } catch (...) {
QtCatchCorbaException( S_ex );
}
catch( ... )
{
} }
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::GetPatternName // function : GetPatternName()
// Purpose : Get name of pattern // purpose : Get name of pattern
//======================================================================= //=======================================================================
QString SMESHGUI_CreatePatternDlg::GetPatternName() const QString SMESHGUI_CreatePatternDlg::GetPatternName() const
{ {
@ -414,8 +409,8 @@ QString SMESHGUI_CreatePatternDlg::GetPatternName() const
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::GetPattern // function : GetPattern()
// Purpose : Get result pattern // purpose : Get result pattern
//======================================================================= //=======================================================================
SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern() SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern()
{ {
@ -423,13 +418,12 @@ SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern()
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::onOk // function : onOk()
// Purpose : SLOT called when "Ok" button pressed. // purpose : SLOT called when "Ok" button pressed.
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::onOk() void SMESHGUI_CreatePatternDlg::onOk()
{ {
try try {
{
if (!isValid()) if (!isValid())
return; return;
@ -437,49 +431,44 @@ void SMESHGUI_CreatePatternDlg::onOk()
loadFromObject(true); loadFromObject(true);
// Load pattern from object // Load pattern from object
if ( !myIsLoaded ) if (!myIsLoaded) {
return; return;
else } else {
{ //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); myViewWindow->SetSelectionMode(ActorSelection);
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); disconnect(mySMESHGUI, 0, this, 0);
SMESHGUI::GetSMESHGUI()->ResetState(); mySMESHGUI->ResetState();
accept(); accept();
emit NewPattern(); emit NewPattern();
} }
} } catch (const SALOME::SALOME_Exception& S_ex) {
catch( const SALOME::SALOME_Exception& S_ex ) SalomeApp_Tools::QtCatchCorbaException(S_ex);
{ } catch (...) {
QtCatchCorbaException( S_ex );
}
catch( ... )
{
} }
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::onClose // function : onClose()
// Purpose : SLOT called when "Close" button pressed. Close dialog // purpose : SLOT called when "Close" button pressed. Close dialog
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::onClose() void SMESHGUI_CreatePatternDlg::onClose()
{ {
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); myViewWindow->SetSelectionMode(ActorSelection);
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); disconnect(mySMESHGUI, 0, this, 0);
SMESHGUI::GetSMESHGUI()->ResetState(); mySMESHGUI->ResetState();
reject(); reject();
emit Close(); emit Close();
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::loadFromObject // function : loadFromObject()
// Purpose : Load pattern from geom object corresponding to the mesh/submesh // purpose : Load pattern from geom object corresponding to the mesh/submesh
//======================================================================= //=======================================================================
bool SMESHGUI_CreatePatternDlg::loadFromObject (const bool theMess) bool SMESHGUI_CreatePatternDlg::loadFromObject (const bool theMess)
{ {
try try {
{
myIsLoaded = false; myIsLoaded = false;
if (myPattern->_is_nil()) if (myPattern->_is_nil())
@ -494,8 +483,7 @@ bool SMESHGUI_CreatePatternDlg::loadFromObject( const bool theMess )
? myPattern->LoadFromFace(aMesh, myGeomObj, myProjectChk->isChecked()) ? myPattern->LoadFromFace(aMesh, myGeomObj, myProjectChk->isChecked())
: myPattern->LoadFrom3DBlock(aMesh, myGeomObj); : myPattern->LoadFrom3DBlock(aMesh, myGeomObj);
if ( !myIsLoaded && theMess ) if (!myIsLoaded && theMess) {
{
QString aMess; QString aMess;
SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode(); SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode();
@ -506,102 +494,66 @@ bool SMESHGUI_CreatePatternDlg::loadFromObject( const bool theMess )
else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS) aMess = tr("ERR_LOADV_COMPUTE_PARAMS"); else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS) aMess = tr("ERR_LOADV_COMPUTE_PARAMS");
else aMess = tr("ERROR_OF_CREATION"); else aMess = tr("ERROR_OF_CREATION");
QMessageBox::information( QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ),
SMESHGUI::GetSMESHGUI()->GetDesktop(), tr( "SMESH_ERROR" ), aMess, QMessageBox::Ok ); tr("SMESH_ERROR"), aMess, QMessageBox::Ok);
} }
} catch (const SALOME::SALOME_Exception& S_ex) {
} SalomeApp_Tools::QtCatchCorbaException(S_ex);
catch( const SALOME::SALOME_Exception& S_ex )
{
QtCatchCorbaException( S_ex );
} }
return myIsLoaded; return myIsLoaded;
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::getGeom // function : onSelectionDone()
// Purpose : Retrieve geom object from SObject // purpose : SLOT called when selection changed
//=======================================================================
GEOM::GEOM_Object_ptr SMESHGUI_CreatePatternDlg::getGeom( SALOMEDS::SObject_ptr theSO )
{
if ( theSO->_is_nil() )
return GEOM::GEOM_Object::_nil();
SALOMEDS::Study_var aStudy =
SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getStudyDocument();
SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theSO );
for( ; anIter->More(); anIter->Next() )
{
SALOMEDS::SObject_var aSO = anIter->Value();
SALOMEDS::SObject_var aRefSO;
GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow(
aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() );
if ( !aMeshShape->_is_nil() )
return aMeshShape._retn();
}
return GEOM::GEOM_Object::_nil();
}
//=======================================================================
// name : SMESHGUI_CreatePatternDlg::onSelectionDone
// Purpose : SLOT called when selection changed
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::onSelectionDone() void SMESHGUI_CreatePatternDlg::onSelectionDone()
{ {
try try {
{ SALOME_ListIO aList;
if ( mySelection->IObjectCount() != 1 ) mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
if (aList.Extent() != 1)
return; return;
// Get mesh or sub-mesh from selection // Get mesh or sub-mesh from selection
Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); Handle(SALOME_InteractiveObject) anIO = aList.First();
SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO); SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIO); SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIO);
if (aMesh->_is_nil() && aSubMesh->_is_nil()) if (aMesh->_is_nil() && aSubMesh->_is_nil())
return; return;
// Get geom object corresponding to the mesh // Get geom object corresponding to the mesh
SALOMEDS::SObject_var aSO; _PTR(SObject) aSO;
if (!aMesh->_is_nil()) if (!aMesh->_is_nil())
aSO = SMESH::FindSObject(aMesh.in()); aSO = SMESH::FindSObject(aMesh.in());
else else
aSO = SMESH::FindSObject(aSubMesh.in()); aSO = SMESH::FindSObject(aSubMesh.in());
GEOM::GEOM_Object_var aGeomObj = SMESH::GetGeom(aSO);
GEOM::GEOM_Object_var aGeomObj = getGeom( aSO );
if (aGeomObj->_is_nil()) if (aGeomObj->_is_nil())
return; return;
myGeomObj = aGeomObj; myGeomObj = aGeomObj;
// init class fields // init class fields
if ( !aMesh->_is_nil() ) if (!aMesh->_is_nil()) {
{
myMesh = aMesh; myMesh = aMesh;
mySubMesh = SMESH::SMESH_subMesh::_nil(); mySubMesh = SMESH::SMESH_subMesh::_nil();
} } else {
else
{
mySubMesh = aSubMesh; mySubMesh = aSubMesh;
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_Mesh::_nil();
} }
QString aName; QString aName;
SMESH::GetNameOfSelectedIObjects( mySelection, aName ); SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
myMeshEdit->setText(aName); myMeshEdit->setText(aName);
if ( myType == Type_2d ) if (myType == Type_2d) {
{
loadFromObject(true); loadFromObject(true);
displayPreview(); displayPreview();
} }
} } catch (...) {
catch( ... )
{
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_Mesh::_nil();
mySubMesh = SMESH::SMESH_subMesh::_nil(); mySubMesh = SMESH::SMESH_subMesh::_nil();
myGeomObj = GEOM::GEOM_Object::_nil(); myGeomObj = GEOM::GEOM_Object::_nil();
@ -610,40 +562,39 @@ void SMESHGUI_CreatePatternDlg::onSelectionDone()
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::onDeactivate // function : onDeactivate()
// Purpose : SLOT called when dialog must be deativated // purpose : SLOT called when dialog must be deativated
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::onDeactivate() void SMESHGUI_CreatePatternDlg::onDeactivate()
{ {
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
setEnabled(false); setEnabled(false);
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::enterEvent // function : enterEvent()
// Purpose : Event filter // purpose : Event filter
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::enterEvent (QEvent*) void SMESHGUI_CreatePatternDlg::enterEvent (QEvent*)
{ {
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); mySMESHGUI->EmitSignalDeactivateDialog();
setEnabled(true); setEnabled(true);
activateSelection(); activateSelection();
connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
} }
//================================================================================= //=================================================================================
// function : closeEvent() // function : closeEvent()
// purpose : Close dialog box // purpose : Close dialog box
//================================================================================= //=================================================================================
void SMESHGUI_CreatePatternDlg::closeEvent( QCloseEvent* e ) void SMESHGUI_CreatePatternDlg::closeEvent (QCloseEvent*)
{ {
onClose(); onClose();
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::onSelBtnClicked // function : onSelBtnClicked()
// Purpose : SLOT. Called when -> button clicked. // purpose : SLOT. Called when -> button clicked.
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::onSelBtnClicked() void SMESHGUI_CreatePatternDlg::onSelBtnClicked()
{ {
@ -651,8 +602,8 @@ void SMESHGUI_CreatePatternDlg::onSelBtnClicked()
} }
//================================================================ //================================================================
// Function : SMESHGUI_CreatePatternDlg::autoExtension // function : autoExtension()
// Purpose : Append extension to the file name // purpose : Append extension to the file name
//================================================================ //================================================================
QString SMESHGUI_CreatePatternDlg::autoExtension (const QString& theFileName) const QString SMESHGUI_CreatePatternDlg::autoExtension (const QString& theFileName) const
{ {
@ -661,28 +612,23 @@ QString SMESHGUI_CreatePatternDlg::autoExtension( const QString& theFileName ) c
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::displayPreview // function : displayPreview()
// Purpose : Display preview // purpose : Display preview
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::displayPreview() void SMESHGUI_CreatePatternDlg::displayPreview()
{ {
// Redisplay preview in dialog // Redisplay preview in dialog
try {
try if (!myIsLoaded) {
{
if ( !myIsLoaded )
erasePreview(); erasePreview();
else } else {
{
SMESH::point_array_var pnts = myPattern->GetPoints(); SMESH::point_array_var pnts = myPattern->GetPoints();
SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false); SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false);
if (pnts->length() == 0 || if (pnts->length() == 0 ||
keyPoints->length() == 0 || keyPoints->length() == 0 ||
elemPoints->length() == 0 ) elemPoints->length() == 0) {
{
myIsLoaded = false; myIsLoaded = false;
erasePreview(); erasePreview();
return; return;
@ -698,8 +644,7 @@ void SMESHGUI_CreatePatternDlg::displayPreview()
for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++) for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++)
aKeyPoints[ i2 ] = keyPoints[ i2 ]; aKeyPoints[ i2 ] = keyPoints[ i2 ];
for ( int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++ ) for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
{
QValueVector<int> aVec (elemPoints[ i3 ].length()); QValueVector<int> aVec (elemPoints[ i3 ].length());
for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++) for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
aVec[ i4 ] = elemPoints[ i3 ][ i4 ]; aVec[ i4 ] = elemPoints[ i3 ][ i4 ];
@ -711,55 +656,49 @@ void SMESHGUI_CreatePatternDlg::displayPreview()
} }
return; return;
}
catch( const SALOME::SALOME_Exception& S_ex ) } catch (const SALOME::SALOME_Exception& S_ex) {
{ SalomeApp_Tools::QtCatchCorbaException(S_ex);
QtCatchCorbaException( S_ex ); } catch (...) {
}
catch( ... )
{
} }
erasePreview(); erasePreview();
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::erasePreview // function : erasePreview()
// Purpose : Erase preview // purpose : Erase preview
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::erasePreview() void SMESHGUI_CreatePatternDlg::erasePreview()
{ {
// Erase preview in 2D viewer // Erase preview in 2D viewer
myPicture2d->SetPoints(PointVector(), QValueVector<int>(), ConnectivityVector()); myPicture2d->SetPoints(PointVector(), QValueVector<int>(), ConnectivityVector());
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::activateSelection // function : activateSelection()
// Purpose : Activate selection in accordance with current pattern type // purpose : Activate selection in accordance with current pattern type
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::activateSelection() void SMESHGUI_CreatePatternDlg::activateSelection()
{ {
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
myViewWindow->SetSelectionMode(ActorSelection);
if ( myType == Type_2d ) if (myType == Type_2d) {
{ mySelectionMgr->installFilter(new SMESH_NumberFilter
mySelection->AddFilter( ("SMESH", TopAbs_SHAPE, -1, TopAbs_FACE));
new SMESH_NumberFilter( "SMESH", TopAbs_SHAPE, -1, TopAbs_FACE ) ); } else {
}
else
{
TColStd_MapOfInteger aTypes; TColStd_MapOfInteger aTypes;
aTypes.Add(TopAbs_SHELL); aTypes.Add(TopAbs_SHELL);
aTypes.Add(TopAbs_SOLID); aTypes.Add(TopAbs_SOLID);
mySelection->AddFilter( new SMESH_NumberFilter( mySelectionMgr->installFilter(new SMESH_NumberFilter
"SMESH", TopAbs_FACE, 6, aTypes, GEOM::GEOM_Object::_nil(), true ) ); ("SMESH", TopAbs_FACE, 6, aTypes, GEOM::GEOM_Object::_nil(), true));
} }
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_CreatePatternDlg::onTypeChanged // function : onTypeChanged()
// Purpose : SLOT. Called when pattern type changed. // purpose : SLOT. Called when pattern type changed.
// Change dialog's look and feel // Change dialog's look and feel
//======================================================================= //=======================================================================
void SMESHGUI_CreatePatternDlg::onTypeChanged (int theType) void SMESHGUI_CreatePatternDlg::onTypeChanged (int theType)
@ -774,24 +713,3 @@ void SMESHGUI_CreatePatternDlg::onTypeChanged( int theType )
else else
myPicture2d->hide(); myPicture2d->hide();
} }

View File

@ -36,20 +36,25 @@
#include CORBA_SERVER_HEADER(SMESH_Pattern) #include CORBA_SERVER_HEADER(SMESH_Pattern)
class SMESHGUI_PatternWidget; class SMESHGUI_PatternWidget;
class SALOMEDSClient_SObject;
class QCloseEvent; class QCloseEvent;
class QFrame; class QFrame;
class QLineEdit; class QLineEdit;
class SMESHGUI_SpinBox; class SMESHGUI_SpinBox;
class QPushButton; class QPushButton;
class SALOME_Selection; class SalomeApp_SelectionMgr;
class QRadioButton; class QRadioButton;
class QCheckBox; class QCheckBox;
class QButtonGroup; class QButtonGroup;
class QLabel; class QLabel;
class SVTK_ViewWindow;
class SVTK_Selector;
class SMESHGUI;
/* /*!
Class : SMESHGUI_CreatePatternDlg * Class : SMESHGUI_CreatePatternDlg
Description : Dialog to specify filters for VTK viewer * Description : Dialog to specify filters for VTK viewer
*/ */
class SMESHGUI_CreatePatternDlg : public QDialog class SMESHGUI_CreatePatternDlg : public QDialog
@ -57,17 +62,15 @@ class SMESHGUI_CreatePatternDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
enum { Type_2d, Type_3d }; enum { Type_2d, Type_3d };
public: public:
SMESHGUI_CreatePatternDlg( QWidget*, SMESHGUI_CreatePatternDlg( SMESHGUI*,
SALOME_Selection*,
const int, const int,
const char* = 0); const char* = 0);
virtual ~SMESHGUI_CreatePatternDlg(); virtual ~SMESHGUI_CreatePatternDlg();
void Init( SALOME_Selection*, const int ); void Init(const int);
QString GetPatternName() const; QString GetPatternName() const;
SMESH::SMESH_Pattern_ptr GetPattern(); SMESH::SMESH_Pattern_ptr GetPattern();
void SetMesh (SMESH::SMESH_Mesh_ptr); void SetMesh (SMESH::SMESH_Mesh_ptr);
@ -106,7 +109,7 @@ private:
bool isValid(); bool isValid();
bool loadFromObject (const bool = true); bool loadFromObject (const bool = true);
QString getDefaultName() const; QString getDefaultName() const;
GEOM::GEOM_Object_ptr getGeom( SALOMEDS::SObject_ptr ); GEOM::GEOM_Object_ptr getGeom (SALOMEDSClient_SObject*) const;
private: private:
@ -126,7 +129,10 @@ private:
QCheckBox* myProjectChk; QCheckBox* myProjectChk;
SALOME_Selection* mySelection; SMESHGUI* mySMESHGUI;
SVTK_ViewWindow* myViewWindow;
SVTK_Selector* mySelector;
SalomeApp_SelectionMgr* mySelectionMgr;
int myNbPoints; int myNbPoints;
int myType; int myType;
@ -139,20 +145,3 @@ private:
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,135 @@
// SMESH SMESHGUI : GUI for SMESH component
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMESHGUI_CreatePolyhedralVolumeDlg.h
// Author : Michael ZORIN
// Module : SMESH
// $Header:
#ifndef DIALOGBOX_CREATEPOLYHEDRAL_H
#define DIALOGBOX_CREATEPOLYHEDRAL_H
// QT Includes
#include <qdialog.h>
class QGridLayout;
class QButtonGroup;
class QGroupBox;
class QListBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QCheckBox;
class SMESHGUI;
class SMESH_Actor;
class SVTK_Selector;
class SVTK_ViewWindow;
class SalomeApp_SelectionMgr;
namespace SMESH{
struct TPolySimulation;
}
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_CreatePolyhedralVolumeDlg
// purpose :
//=================================================================================
class SMESHGUI_CreatePolyhedralVolumeDlg : public QDialog
{
Q_OBJECT
public:
SMESHGUI_CreatePolyhedralVolumeDlg( SMESHGUI*, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_CreatePolyhedralVolumeDlg();
private:
void Init() ;
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */
void hideEvent ( QHideEvent * ); /* ESC key */
int GetConstructorId();
void displaySimulation();
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SalomeApp_SelectionMgr* mySelectionMgr ; /* User shape selection */
SVTK_ViewWindow* myViewWindow;
SVTK_Selector* mySelector;
QString myIDs;
int myNbOkElements ; /* to check when elements are defined */
QLineEdit* myEditCurrentArgument;
SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor;
SMESH::TPolySimulation* mySimulation;
QButtonGroup* GroupConstructors;
QRadioButton* RadioButton1;
QRadioButton* RadioButton2;
QCheckBox* Preview;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupContent;
QLabel* TextLabelIds;
QPushButton* SelectElementsButton;
QLineEdit* LineEditElements;
QListBox* myFacesByNodes;
QLabel* myFacesByNodesLabel;
QPushButton* AddButton;
QPushButton* RemoveButton;
public slots:
void onAdd();
void onRemove();
private slots:
void ConstructorsClicked(int constructorId);
void ClickOnPreview(bool theToggled);
void ClickOnOk();
void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ;
void DeactivateActiveDialog() ;
void ActivateThisDialog() ;
void onTextChange(const QString&);
void onListSelectionChanged();
protected:
QGridLayout* SMESHGUI_CreatePolyhedralVolumeDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupContentLayout;
};
#endif // DIALOGBOX_CREATEPOLYHEDRAL_H

View File

@ -28,14 +28,21 @@
#include "SMESHGUI_DeleteGroupDlg.h" #include "SMESHGUI_DeleteGroupDlg.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESH_TypeFilter.hxx"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "QAD_Desktop.h" #include "SMESH_TypeFilter.hxx"
#include "SALOME_Selection.h"
#include "SUIT_Desktop.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_SelectionMgr.h"
#include "SVTK_Selection.h"
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx"
// QT Includes
#include <qframe.h> #include <qframe.h>
#include <qlayout.h> #include <qlayout.h>
#include <qpushbutton.h> #include <qpushbutton.h>
@ -45,23 +52,24 @@
#include <qlist.h> #include <qlist.h>
#include <qmessagebox.h> #include <qmessagebox.h>
// IDL Headers
#include "SALOMEconfig.h" #include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#define SPACING 5 #define SPACING 5
#define MARGIN 10 #define MARGIN 10
/* /*!
Class : SMESHGUI_DeleteGroupDlg * Class : SMESHGUI_DeleteGroupDlg
Description : Delete groups and their contents * Description : Delete groups and their contents
*/ */
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg // function : SMESHGUI_DeleteGroupDlg()
// Purpose : Constructor // purpose : Constructor
//======================================================================= //=================================================================================
SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg (QWidget* theParent, SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg (QWidget* theParent,
SALOME_Selection* theSelection ) SalomeApp_SelectionMgr* theSelection)
: QDialog(theParent, "SMESHGUI_DeleteGroupDlg", false, : QDialog(theParent, "SMESHGUI_DeleteGroupDlg", false,
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
{ {
@ -80,13 +88,14 @@ SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg( QWidget* theParent,
Init(theSelection); Init(theSelection);
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::createMainFrame // function : createMainFrame()
// Purpose : Create frame containing dialog's input fields // purpose : Create frame containing dialog's input fields
//======================================================================= //=================================================================================
QFrame* SMESHGUI_DeleteGroupDlg::createMainFrame (QWidget* theParent) QFrame* SMESHGUI_DeleteGroupDlg::createMainFrame (QWidget* theParent)
{ {
QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, tr( "SELECTED_GROUPS" ), theParent ); QGroupBox* aMainGrp =
new QGroupBox(1, Qt::Horizontal, tr("SELECTED_GROUPS"), theParent);
myListBox = new QListBox(aMainGrp); myListBox = new QListBox(aMainGrp);
myListBox->setMinimumHeight(100); myListBox->setMinimumHeight(100);
@ -96,10 +105,10 @@ QFrame* SMESHGUI_DeleteGroupDlg::createMainFrame( QWidget* theParent )
return aMainGrp; return aMainGrp;
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::createButtonFrame // function : createButtonFrame()
// Purpose : Create frame containing buttons // purpose : Create frame containing buttons
//======================================================================= //=================================================================================
QFrame* SMESHGUI_DeleteGroupDlg::createButtonFrame (QWidget* theParent) QFrame* SMESHGUI_DeleteGroupDlg::createButtonFrame (QWidget* theParent)
{ {
QFrame* aFrame = new QFrame(theParent); QFrame* aFrame = new QFrame(theParent);
@ -126,27 +135,27 @@ QFrame* SMESHGUI_DeleteGroupDlg::createButtonFrame( QWidget* theParent )
return aFrame; return aFrame;
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::~SMESHGUI_DeleteGroupDlg // name : ~SMESHGUI_DeleteGroupDlg()
// Purpose : Destructor // Purpose : Destructor
//======================================================================= //=================================================================================
SMESHGUI_DeleteGroupDlg::~SMESHGUI_DeleteGroupDlg() SMESHGUI_DeleteGroupDlg::~SMESHGUI_DeleteGroupDlg()
{ {
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::Init // function : Init()
// Purpose : Init dialog fields, connect signals and slots, show dialog // purpose : Init dialog fields, connect signals and slots, show dialog
//======================================================================= //=================================================================================
void SMESHGUI_DeleteGroupDlg::Init( SALOME_Selection* theSelection ) void SMESHGUI_DeleteGroupDlg::Init (SalomeApp_SelectionMgr* theSelection)
{ {
myBlockSelection = false; myBlockSelection = false;
mySelection = theSelection; mySelectionMgr = theSelection;
SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI();
aSMESHGUI->SetActiveDialogBox((QDialog*)this); aSMESHGUI->SetActiveDialogBox((QDialog*)this);
// selection and SMESHGUI // selection and SMESHGUI
connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
connect(aSMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); connect(aSMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose()));
@ -156,33 +165,36 @@ void SMESHGUI_DeleteGroupDlg::Init( SALOME_Selection* theSelection )
this->show(); this->show();
// set selection mode // set selection mode
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); #ifdef NEW_GUI
mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); mySelectionMgr->setSelectionModes(ActorSelection, true);
#else
mySelectionMgr->setSelectionModes(ActorSelection);
#endif
mySelectionMgr->installFilter(new SMESH_TypeFilter(GROUP));
onSelectionDone(); onSelectionDone();
return; return;
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::isValid // function : isValid()
// Purpose : Verify validity of input data // purpose : Verify validity of input data
//======================================================================= //=================================================================================
bool SMESHGUI_DeleteGroupDlg::isValid() bool SMESHGUI_DeleteGroupDlg::isValid()
{ {
if ( myListBox->count() == 0 ) if (myListBox->count() == 0) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("NO_SELECTED_GROUPS"), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "NO_SELECTED_GROUPS" ), QMessageBox::Ok );
return false; return false;
} }
return !SMESHGUI::GetSMESHGUI()->ActiveStudyLocked(); return !SMESHGUI::GetSMESHGUI()->isActiveStudyLocked();
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::onApply // function : onApply()
// Purpose : SLOT called when "Apply" button pressed. // purpose : SLOT called when "Apply" button pressed.
//======================================================================= //=================================================================================
bool SMESHGUI_DeleteGroupDlg::onApply() bool SMESHGUI_DeleteGroupDlg::onApply()
{ {
if (!isValid()) if (!isValid())
@ -191,8 +203,7 @@ bool SMESHGUI_DeleteGroupDlg::onApply()
myBlockSelection = true; myBlockSelection = true;
QValueList<SMESH::SMESH_GroupBase_var>::iterator anIter; QValueList<SMESH::SMESH_GroupBase_var>::iterator anIter;
for ( anIter = myListGrp.begin(); anIter != myListGrp.end(); ++anIter ) for (anIter = myListGrp.begin(); anIter != myListGrp.end(); ++anIter) {
{
SMESH::SMESH_Mesh_ptr aMesh = (*anIter)->GetMesh(); SMESH::SMESH_Mesh_ptr aMesh = (*anIter)->GetMesh();
if (!aMesh->_is_nil()) if (!aMesh->_is_nil())
aMesh->RemoveGroupWithContents(*anIter); aMesh->RemoveGroupWithContents(*anIter);
@ -200,42 +211,42 @@ bool SMESHGUI_DeleteGroupDlg::onApply()
myListBox->clear(); myListBox->clear();
myListGrp.clear(); myListGrp.clear();
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
SMESH::UpdateView(); SMESH::UpdateView();
SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true ); SMESHGUI::GetSMESHGUI()->updateObjBrowser(true);
myBlockSelection = false; myBlockSelection = false;
return true; return true;
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::onOk // function : onOk()
// Purpose : SLOT called when "Ok" button pressed. // purpose : SLOT called when "Ok" button pressed.
//======================================================================= //=================================================================================
void SMESHGUI_DeleteGroupDlg::onOk() void SMESHGUI_DeleteGroupDlg::onOk()
{ {
if (onApply()) if (onApply())
onClose(); onClose();
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::onClose // function : onClose()
// Purpose : SLOT called when "Close" button pressed. Close dialog // purpose : SLOT called when "Close" button pressed. Close dialog
//======================================================================= //=================================================================================
void SMESHGUI_DeleteGroupDlg::onClose() void SMESHGUI_DeleteGroupDlg::onClose()
{ {
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); mySelectionMgr->setSelectionModes(ActorSelection);
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0);
SMESHGUI::GetSMESHGUI()->ResetState(); SMESHGUI::GetSMESHGUI()->ResetState();
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
reject(); reject();
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::onSelectionDone // function : onSelectionDone()
// Purpose : SLOT called when selection changed // purpose : SLOT called when selection changed
//======================================================================= //=================================================================================
void SMESHGUI_DeleteGroupDlg::onSelectionDone() void SMESHGUI_DeleteGroupDlg::onSelectionDone()
{ {
if (myBlockSelection) if (myBlockSelection)
@ -244,14 +255,13 @@ void SMESHGUI_DeleteGroupDlg::onSelectionDone()
myListGrp.clear(); myListGrp.clear();
QStringList aNames; QStringList aNames;
const SALOME_ListIO& aListIO = mySelection->StoredIObjects(); SALOME_ListIO aListIO;
mySelectionMgr->selectedObjects(aListIO);
SALOME_ListIteratorOfListIO anIter (aListIO); SALOME_ListIteratorOfListIO anIter (aListIO);
for( ; anIter.More(); anIter.Next() ) for (; anIter.More(); anIter.Next()) {
{
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value()); SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
if ( !aGroup->_is_nil() ) if (!aGroup->_is_nil()) {
{
aNames.append(aGroup->GetName()); aNames.append(aGroup->GetName());
myListGrp.append(aGroup); myListGrp.append(aGroup);
} }
@ -261,29 +271,32 @@ void SMESHGUI_DeleteGroupDlg::onSelectionDone()
myListBox->insertStringList(aNames); myListBox->insertStringList(aNames);
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::onDeactivate // function : onDeactivate()
// Purpose : SLOT called when dialog must be deativated // purpose : SLOT called when dialog must be deativated
//======================================================================= //=================================================================================
void SMESHGUI_DeleteGroupDlg::onDeactivate() void SMESHGUI_DeleteGroupDlg::onDeactivate()
{ {
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
setEnabled(false); setEnabled(false);
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_DeleteGroupDlg::enterEvent // function : enterEvent()
// Purpose : Event filter // purpose : Event filter
//======================================================================= //=================================================================================
void SMESHGUI_DeleteGroupDlg::enterEvent (QEvent*) void SMESHGUI_DeleteGroupDlg::enterEvent (QEvent*)
{ {
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
setEnabled(true); setEnabled(true);
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); #ifdef NEW_GUI
mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); mySelectionMgr->setSelectionModes(ActorSelection, true);
#else
mySelectionMgr->setSelectionModes(ActorSelection);
#endif
mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
} }
//================================================================================= //=================================================================================
// function : closeEvent() // function : closeEvent()
// purpose : // purpose :
@ -292,4 +305,3 @@ void SMESHGUI_DeleteGroupDlg::closeEvent( QCloseEvent* )
{ {
onClose(); onClose();
} }

View File

@ -36,12 +36,12 @@
class QCloseEvent; class QCloseEvent;
class QFrame; class QFrame;
class QPushButton; class QPushButton;
class SALOME_Selection; class SalomeApp_SelectionMgr;
class QListBox; class QListBox;
/* /*!
Class : SMESHGUI_DeleteGroupDlg * Class : SMESHGUI_DeleteGroupDlg
Description : Delete groups and their contents * Description : Delete groups and their contents
*/ */
class SMESHGUI_DeleteGroupDlg : public QDialog class SMESHGUI_DeleteGroupDlg : public QDialog
@ -49,14 +49,15 @@ class SMESHGUI_DeleteGroupDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_DeleteGroupDlg( QWidget*, SALOME_Selection* ); SMESHGUI_DeleteGroupDlg (QWidget*,
SalomeApp_SelectionMgr*);
virtual ~SMESHGUI_DeleteGroupDlg(); virtual ~SMESHGUI_DeleteGroupDlg();
void Init( SALOME_Selection* ) ; void Init (SalomeApp_SelectionMgr*);
private: private:
void closeEvent( QCloseEvent* e ) ; void closeEvent (QCloseEvent*);
void enterEvent (QEvent*); void enterEvent (QEvent*);
private slots: private slots:
@ -81,16 +82,10 @@ private:
QPushButton* myApplyBtn; QPushButton* myApplyBtn;
QPushButton* myCloseBtn; QPushButton* myCloseBtn;
QListBox* myListBox; QListBox* myListBox;
SALOME_Selection* mySelection; SalomeApp_SelectionMgr* mySelectionMgr;
QValueList<SMESH::SMESH_GroupBase_var> myListGrp; QValueList<SMESH::SMESH_GroupBase_var> myListGrp;
bool myBlockSelection; bool myBlockSelection;
}; };
#endif #endif

View File

@ -33,18 +33,25 @@
#include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_HypothesesUtils.h" #include "SMESHGUI_HypothesesUtils.h"
#include "SMESH_TypeFilter.hxx"
#include "SMESH_NumberFilter.hxx"
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx"
#include "QAD_Application.h" #include "SALOMEDSClient_Study.hxx"
#include "QAD_Desktop.h" #include "SALOMEDSClient_AttributeIOR.hxx"
#include "QAD_WaitCursor.h" #include "SALOMEDSClient_AttributeName.hxx"
#include "QAD_Operation.h"
#include "SALOMEconfig.h" #include "SUIT_Session.h"
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) #include "SUIT_OverrideCursor.h"
#include "SUIT_Operation.h"
#include "SUIT_Desktop.h"
#include "utilities.h" #include "utilities.h"
#include "SVTK_ViewModel.h"
// QT Includes // QT Includes
#include <qgroupbox.h> #include <qgroupbox.h>
#include <qlabel.h> #include <qlabel.h>
@ -94,17 +101,21 @@ int findItem( QListBox* listBox, const string& ior )
} }
//================================================================================= //=================================================================================
// class : SMESHGUI_EditHypothesesDlg() // function : SMESHGUI_EditHypothesesDlg()
// purpose : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the // purpose : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'. // name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to // The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg (SMESHGUI* theModule, const char* name,
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), bool modal, WFlags fl)
myImportedMesh( false ) : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu | WDestructiveClose),
myImportedMesh(false),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
{ {
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
if (!name) if (!name)
setName("SMESHGUI_EditHypothesesDlg"); setName("SMESHGUI_EditHypothesesDlg");
setCaption(tr("SMESH_EDIT_HYPOTHESES")); setCaption(tr("SMESH_EDIT_HYPOTHESES"));
@ -227,10 +238,9 @@ SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const c
SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupButtons, 4, 0); SMESHGUI_EditHypothesesDlgLayout->addWidget(GroupButtons, 4, 0);
/***************************************************************/ /***************************************************************/
Init(Sel) ; Init();
} }
//================================================================================= //=================================================================================
// function : ~SMESHGUI_EditHypothesesDlg() // function : ~SMESHGUI_EditHypothesesDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : Destroys the object and frees any allocated resources
@ -240,21 +250,22 @@ SMESHGUI_EditHypothesesDlg::~SMESHGUI_EditHypothesesDlg()
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel ) void SMESHGUI_EditHypothesesDlg::Init()
{ {
mySelection = Sel;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox((QDialog*)this); mySMESHGUI->SetActiveDialogBox((QDialog*)this);
InitHypDefinition(); InitHypDefinition();
InitAlgoDefinition(); InitAlgoDefinition();
myGeomFilter = new SALOME_TypeFilter( "GEOM" ); //myGeomFilter = new SALOME_TypeFilter ("GEOM");
TColStd_MapOfInteger allTypesMap;
for (int i = 0; i < 10; i++)
allTypesMap.Add(i);
myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
myGeomShape = GEOM::GEOM_Object::_nil(); myGeomShape = GEOM::GEOM_Object::_nil();
@ -269,7 +280,7 @@ void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel )
connect(SelectButtonC1A1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectButtonC1A1, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
connect(SelectButtonC1A2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectButtonC1A2, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
@ -286,15 +297,14 @@ void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel )
LineEditC1A1->setFocus(); LineEditC1A1->setFocus();
myEditCurrentArgument = LineEditC1A1; myEditCurrentArgument = LineEditC1A1;
mySelection->ClearFilters() ; mySelectionMgr->clearFilters();
mySelection->AddFilter(myMeshOrSubMeshFilter) ; mySelectionMgr->installFilter(myMeshOrSubMeshFilter);
SelectionIntoArgument(); SelectionIntoArgument();
UpdateControlState(); UpdateControlState();
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose :
@ -311,14 +321,15 @@ void SMESHGUI_EditHypothesesDlg::ClickOnOk()
//================================================================================= //=================================================================================
bool SMESHGUI_EditHypothesesDlg::ClickOnApply() bool SMESHGUI_EditHypothesesDlg::ClickOnApply()
{ {
if (mySMESHGUI->ActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return false; return false;
bool aRes = false; bool aRes = false;
QAD_WaitCursor wc; SUIT_OverrideCursor wc;
QAD_Operation* op = new QAD_Operation( mySMESHGUI->GetActiveStudy() ); SUIT_Operation* op = new SUIT_Operation
(SUIT_Session::session()->activeApplication());
// start transaction // start transaction
op->start(); op->start();
@ -328,23 +339,21 @@ bool SMESHGUI_EditHypothesesDlg::ClickOnApply()
else if (!mySubMesh->_is_nil()) else if (!mySubMesh->_is_nil())
aRes = StoreSubMesh(); aRes = StoreSubMesh();
if ( true/*aRes*/ ) // abort desynchronizes contents of a Study and a mesh on server if (true/*aRes*/) { // abort desynchronizes contents of a Study and a mesh on server
{
// commit transaction // commit transaction
op->finish(); op->commit();
InitHypAssignation(); InitHypAssignation();
InitAlgoAssignation(); InitAlgoAssignation();
} } else {
else
// abort transaction // abort transaction
op->abort(); op->abort();
}
UpdateControlState(); UpdateControlState();
return aRes; return aRes;
} }
//================================================================================= //=================================================================================
// function : ClickOnCancel() // function : ClickOnCancel()
// purpose : // purpose :
@ -354,7 +363,6 @@ void SMESHGUI_EditHypothesesDlg::ClickOnCancel()
close(); close();
} }
//================================================================================= //=================================================================================
// function : SelectionIntoArgument() // function : SelectionIntoArgument()
// purpose : Called when selection as changed or other case // purpose : Called when selection as changed or other case
@ -363,7 +371,10 @@ void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
{ {
QString aString = ""; QString aString = "";
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ; SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
if (myEditCurrentArgument == LineEditC1A1) { if (myEditCurrentArgument == LineEditC1A1) {
if (nbSel != 1) { if (nbSel != 1) {
@ -371,7 +382,7 @@ void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
mySubMesh = SMESH::SMESH_subMesh::_nil(); mySubMesh = SMESH::SMESH_subMesh::_nil();
aString = ""; aString = "";
} else { } else {
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; Handle(SALOME_InteractiveObject) IO = aList.First();
myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO); myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
if (myMesh->_is_nil()) { if (myMesh->_is_nil()) {
mySubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO); mySubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
@ -382,19 +393,20 @@ void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
} }
myEditCurrentArgument->setText(aString); myEditCurrentArgument->setText(aString);
myGeomShape = GEOM::GEOM_Object::_nil(); // InitGeom() will try to retrieve a shape from myMesh or mySubMesh // InitGeom() will try to retrieve a shape from myMesh or mySubMesh
myGeomShape = GEOM::GEOM_Object::_nil();
InitGeom(); InitGeom();
myImportedMesh = myGeomShape->_is_nil(); myImportedMesh = myGeomShape->_is_nil();
InitHypAssignation(); InitHypAssignation();
InitAlgoAssignation(); InitAlgoAssignation();
}
else if ( myEditCurrentArgument == LineEditC1A2 ) { } else if (myEditCurrentArgument == LineEditC1A2) {
if ( nbSel != 1 ) if (nbSel != 1) {
myGeomShape = GEOM::GEOM_Object::_nil(); myGeomShape = GEOM::GEOM_Object::_nil();
else { } else {
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; Handle(SALOME_InteractiveObject) IO = aList.First();
myGeomShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO); myGeomShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO);
} }
InitGeom(); InitGeom();
@ -403,7 +415,6 @@ void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument()
UpdateControlState(); UpdateControlState();
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -414,13 +425,13 @@ void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument()
if(send == SelectButtonC1A1) { if(send == SelectButtonC1A1) {
LineEditC1A1->setFocus(); LineEditC1A1->setFocus();
myEditCurrentArgument = LineEditC1A1; myEditCurrentArgument = LineEditC1A1;
mySelection->ClearFilters() ; mySelectionMgr->clearFilters();
mySelection->AddFilter(myMeshOrSubMeshFilter) ; mySelectionMgr->installFilter(myMeshOrSubMeshFilter);
} else if (send == SelectButtonC1A2) { } else if (send == SelectButtonC1A2) {
LineEditC1A2->setFocus(); LineEditC1A2->setFocus();
myEditCurrentArgument = LineEditC1A2; myEditCurrentArgument = LineEditC1A2;
mySelection->ClearFilters() ; mySelectionMgr->clearFilters();
mySelection->AddFilter(myGeomFilter) ; mySelectionMgr->installFilter(myGeomFilter);
} }
SelectionIntoArgument(); SelectionIntoArgument();
} }
@ -432,13 +443,12 @@ void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument()
void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog() void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog()
{ {
if (GroupC1->isEnabled()) { if (GroupC1->isEnabled()) {
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
GroupC1->setEnabled(false); GroupC1->setEnabled(false);
GroupButtons->setEnabled(false); GroupButtons->setEnabled(false);
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose :
@ -448,38 +458,35 @@ void SMESHGUI_EditHypothesesDlg::ActivateThisDialog()
mySMESHGUI->EmitSignalDeactivateDialog(); mySMESHGUI->EmitSignalDeactivateDialog();
GroupC1->setEnabled(true); GroupC1->setEnabled(true);
GroupButtons->setEnabled(true); GroupButtons->setEnabled(true);
connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect (mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_EditHypothesesDlg::enterEvent(QEvent* e) void SMESHGUI_EditHypothesesDlg::enterEvent (QEvent*)
{ {
if (!GroupC1->isEnabled()) if (!GroupC1->isEnabled())
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : closeEvent() // function : closeEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_EditHypothesesDlg::closeEvent (QCloseEvent* e) void SMESHGUI_EditHypothesesDlg::closeEvent (QCloseEvent* e)
{ {
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
mySelection->ClearFilters() ; mySelectionMgr->clearFilters();
QDialog::closeEvent(e); QDialog::closeEvent(e);
} }
//======================================================================= //=======================================================================
//function : IsOld // function : IsOld()
// purpose : // purpose :
//======================================================================= //=======================================================================
bool SMESHGUI_EditHypothesesDlg::IsOld (QListBoxItem* hypItem) bool SMESHGUI_EditHypothesesDlg::IsOld (QListBoxItem* hypItem)
{ {
if (hypItem->rtti() == ListBoxIOR::RTTI_IOR) { if (hypItem->rtti() == ListBoxIOR::RTTI_IOR) {
@ -510,11 +517,9 @@ void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* item)
ListAlgoAssignation->removeItem(ListAlgoAssignation->index(item)); ListAlgoAssignation->removeItem(ListAlgoAssignation->index(item));
} }
UpdateControlState(); UpdateControlState();
} }
//================================================================================= //=================================================================================
// function : addItem() // function : addItem()
// purpose : // purpose :
@ -532,29 +537,31 @@ void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* item)
bool isFound = false; bool isFound = false;
ListBoxIOR* anItem;
if (aSender == ListHypDefinition) { if (aSender == ListHypDefinition) {
for (int j = 0, n = ListHypAssignation->count(); !isFound && j < n; j++) { for (int j = 0, n = ListHypAssignation->count(); !isFound && j < n; j++) {
if (ListHypAssignation->item(j)->rtti() == ListBoxIOR::RTTI_IOR) { if (ListHypAssignation->item(j)->rtti() == ListBoxIOR::RTTI_IOR) {
ListBoxIOR* anItem = (ListBoxIOR*)ListHypAssignation->item( j ); anItem = (ListBoxIOR*)ListHypAssignation->item(j);
isFound = !strcmp(anItem->GetIOR(), i->GetIOR()); isFound = !strcmp(anItem->GetIOR(), i->GetIOR());
} }
} }
if (!isFound) if (!isFound)
ListBoxIOR* anItem = new ListBoxIOR( ListHypAssignation, anItem = new ListBoxIOR (ListHypAssignation,
CORBA::string_dup(i->GetIOR()), CORBA::string_dup(i->GetIOR()),
CORBA::string_dup(i->text().latin1())); CORBA::string_dup(i->text().latin1()));
}
else if ( aSender == ListAlgoDefinition ) { } else if (aSender == ListAlgoDefinition) {
for (int j = 0, n = ListAlgoAssignation->count(); !isFound && j < n; j++) { for (int j = 0, n = ListAlgoAssignation->count(); !isFound && j < n; j++) {
if (ListAlgoAssignation->item(j)->rtti() == ListBoxIOR::RTTI_IOR) { if (ListAlgoAssignation->item(j)->rtti() == ListBoxIOR::RTTI_IOR) {
ListBoxIOR* anItem = (ListBoxIOR*)ListAlgoAssignation->item( j ); anItem = (ListBoxIOR*)ListAlgoAssignation->item(j);
isFound = !strcmp(anItem->GetIOR(), i->GetIOR()); isFound = !strcmp(anItem->GetIOR(), i->GetIOR());
} }
} }
if (!isFound) if (!isFound)
ListBoxIOR* anItem = new ListBoxIOR( ListAlgoAssignation, anItem = new ListBoxIOR (ListAlgoAssignation,
CORBA::string_dup(i->GetIOR()), CORBA::string_dup(i->GetIOR()),
CORBA::string_dup(i->text().latin1())); CORBA::string_dup(i->text().latin1()));
} else {
} }
if (!isFound) if (!isFound)
@ -563,7 +570,6 @@ void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* item)
UpdateControlState(); UpdateControlState();
} }
//================================================================================= //=================================================================================
// function : InitHypDefinition() // function : InitHypDefinition()
// purpose : // purpose :
@ -572,27 +578,29 @@ void SMESHGUI_EditHypothesesDlg::InitHypDefinition()
{ {
ListHypDefinition->clear(); ListHypDefinition->clear();
SALOMEDS::SComponent_var father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); _PTR(SComponent) father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
if ( father->_is_nil() ) if (!father)
return; return;
SALOMEDS::SObject_var HypothesisRoot; _PTR(SObject) HypothesisRoot;
SALOMEDS::GenericAttribute_var anAttr; _PTR(GenericAttribute) anAttr;
SALOMEDS::AttributeName_var aName; _PTR(AttributeName) aName;
SALOMEDS::AttributeIOR_var anIOR; _PTR(AttributeIOR) anIOR;
int Tag_HypothesisRoot = 1; //int Tag_HypothesisRoot = 1;
if (father->FindSubObject(1, HypothesisRoot)) { if (father->FindSubObject(1, HypothesisRoot)) {
SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(HypothesisRoot); _PTR(ChildIterator) it =
SMESH::GetActiveStudyDocument()->NewChildIterator(HypothesisRoot);
ListBoxIOR* anItem;
for (; it->More();it->Next()) { for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value(); _PTR(SObject) Obj = it->Value();
if (Obj->FindAttribute(anAttr, "AttributeName")) { if (Obj->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr); aName = anAttr;
if (Obj->FindAttribute(anAttr, "AttributeIOR")) { if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); anIOR = anAttr;
ListBoxIOR* anItem = new ListBoxIOR( ListHypDefinition, anItem = new ListBoxIOR (ListHypDefinition,
anIOR->Value(), anIOR->Value().c_str(),
aName->Value() ); aName->Value().c_str());
} }
} }
} }
@ -606,36 +614,35 @@ void SMESHGUI_EditHypothesesDlg::InitHypDefinition()
void SMESHGUI_EditHypothesesDlg::InitHypAssignation() void SMESHGUI_EditHypothesesDlg::InitHypAssignation()
{ {
myNbModification = 0; myNbModification = 0;
// MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() )
// MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() )
myMapOldHypos.clear(); myMapOldHypos.clear();
ListHypAssignation->clear(); ListHypAssignation->clear();
if (myImportedMesh) if (myImportedMesh)
return; return;
SALOMEDS::SObject_var aMorSM, AHR, aRef; _PTR(SObject) aMorSM, AHR, aRef;
SALOMEDS::GenericAttribute_var anAttr; _PTR(GenericAttribute) anAttr;
SALOMEDS::AttributeName_var aName; _PTR(AttributeName) aName;
SALOMEDS::AttributeIOR_var anIOR; _PTR(AttributeIOR) anIOR;
if (!myMesh->_is_nil()) if (!myMesh->_is_nil())
aMorSM = SMESH::FindSObject(myMesh); aMorSM = SMESH::FindSObject(myMesh);
else if (!mySubMesh->_is_nil()) else if (!mySubMesh->_is_nil())
aMorSM = SMESH::FindSObject(mySubMesh); aMorSM = SMESH::FindSObject(mySubMesh);
if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (2, AHR)) { if (aMorSM && aMorSM->FindSubObject(2, AHR)) {
SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); _PTR(ChildIterator) it =
SMESH::GetActiveStudyDocument()->NewChildIterator(AHR);
for (; it->More();it->Next()) { for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value(); _PTR(SObject) Obj = it->Value();
if (Obj->ReferencedObject(aRef)) { if (Obj->ReferencedObject(aRef)) {
if (aRef->FindAttribute(anAttr, "AttributeName")) { if (aRef->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr); aName = anAttr;
if (aRef->FindAttribute(anAttr, "AttributeIOR")) { if (aRef->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); anIOR = anAttr;
ListBoxIOR* anItem = new ListBoxIOR (ListHypAssignation, ListBoxIOR* anItem = new ListBoxIOR (ListHypAssignation,
anIOR->Value(), anIOR->Value().c_str(),
aName->Value() ); aName->Value().c_str());
myMapOldHypos[ anIOR->Value() ] = ListHypAssignation->index(anItem); myMapOldHypos[ anIOR->Value() ] = ListHypAssignation->index(anItem);
} }
} }
@ -652,69 +659,68 @@ void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition()
{ {
ListAlgoDefinition->clear(); ListAlgoDefinition->clear();
SALOMEDS::SComponent_var father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); _PTR(SComponent) father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
if ( father->_is_nil() ) if (!father)
return; return;
SALOMEDS::SObject_var AlgorithmsRoot; _PTR(SObject) AlgorithmsRoot;
SALOMEDS::GenericAttribute_var anAttr; _PTR(GenericAttribute) anAttr;
SALOMEDS::AttributeName_var aName; _PTR(AttributeName) aName;
SALOMEDS::AttributeIOR_var anIOR; _PTR(AttributeIOR) anIOR;
if (father->FindSubObject (2, AlgorithmsRoot)) { if (father->FindSubObject (2, AlgorithmsRoot)) {
SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AlgorithmsRoot); _PTR(ChildIterator) it =
SMESH::GetActiveStudyDocument()->NewChildIterator(AlgorithmsRoot);
ListBoxIOR* anItem;
for (; it->More();it->Next()) { for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value(); _PTR(SObject) Obj = it->Value();
if (Obj->FindAttribute(anAttr, "AttributeName")) { if (Obj->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr); aName = anAttr;
if (Obj->FindAttribute(anAttr, "AttributeIOR")) { if (Obj->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); anIOR = anAttr;
ListBoxIOR* anItem = new ListBoxIOR( ListAlgoDefinition, anItem = new ListBoxIOR (ListAlgoDefinition,
anIOR->Value(), anIOR->Value().c_str(),
aName->Value() ); aName->Value().c_str());
} }
} }
} }
} }
} }
//================================================================================= //=================================================================================
// function : InitAlgoAssignation() // function : InitAlgoAssignation()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation() void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation()
{ {
MESSAGE ( " InitAlgoAssignation " << myMesh->_is_nil() )
MESSAGE ( " InitAlgoAssignation " << mySubMesh->_is_nil() )
myMapOldAlgos.clear(); myMapOldAlgos.clear();
ListAlgoAssignation->clear(); ListAlgoAssignation->clear();
if (myImportedMesh) if (myImportedMesh)
return; return;
SALOMEDS::SObject_var aMorSM, AHR, aRef; _PTR(SObject) aMorSM, AHR, aRef;
SALOMEDS::GenericAttribute_var anAttr; _PTR(GenericAttribute) anAttr;
SALOMEDS::AttributeName_var aName; _PTR(AttributeName) aName;
SALOMEDS::AttributeIOR_var anIOR; _PTR(AttributeIOR) anIOR;
if (!myMesh->_is_nil()) if (!myMesh->_is_nil())
aMorSM = SMESH::FindSObject(myMesh); aMorSM = SMESH::FindSObject(myMesh);
else if (!mySubMesh->_is_nil()) else if (!mySubMesh->_is_nil())
aMorSM = SMESH::FindSObject(mySubMesh); aMorSM = SMESH::FindSObject(mySubMesh);
if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (3, AHR)) { if (aMorSM && aMorSM->FindSubObject(3, AHR)) {
SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); _PTR(ChildIterator) it =
SMESH::GetActiveStudyDocument()->NewChildIterator(AHR);
for (; it->More();it->Next()) { for (; it->More();it->Next()) {
SALOMEDS::SObject_var Obj = it->Value(); _PTR(SObject) Obj = it->Value();
if (Obj->ReferencedObject(aRef)) { if (Obj->ReferencedObject(aRef)) {
if (aRef->FindAttribute(anAttr, "AttributeName")) { if (aRef->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr); aName = anAttr;
if (aRef->FindAttribute(anAttr, "AttributeIOR")) { if (aRef->FindAttribute(anAttr, "AttributeIOR")) {
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); anIOR = anAttr;
ListBoxIOR* anItem = new ListBoxIOR (ListAlgoAssignation, ListBoxIOR* anItem = new ListBoxIOR (ListAlgoAssignation,
anIOR->Value(), anIOR->Value().c_str(),
aName->Value() ); aName->Value().c_str());
myMapOldAlgos[ anIOR->Value() ] = ListAlgoAssignation->index(anItem); myMapOldAlgos[ anIOR->Value() ] = ListAlgoAssignation->index(anItem);
} }
} }
@ -732,25 +738,26 @@ void SMESHGUI_EditHypothesesDlg::InitGeom()
LineEditC1A2->setText(""); LineEditC1A2->setText("");
if (myGeomShape->_is_nil() && !myMesh->_is_nil()) { if (myGeomShape->_is_nil() && !myMesh->_is_nil()) {
SALOMEDS::SObject_var aMesh = SMESH::FindSObject( myMesh ); _PTR(SObject) aMesh = SMESH::FindSObject(myMesh);
if ( !aMesh->_is_nil() ) if (aMesh)
myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMesh); myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMesh);
} }
if (myGeomShape->_is_nil() && !mySubMesh->_is_nil()) { if (myGeomShape->_is_nil() && !mySubMesh->_is_nil()) {
SALOMEDS::SObject_var aSubMesh = SMESH::FindSObject( mySubMesh ); _PTR(SObject) aSubMesh = SMESH::FindSObject(mySubMesh);
if ( !aSubMesh->_is_nil() ) if (aSubMesh)
myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMesh); myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMesh);
} }
SALOMEDS::GenericAttribute_var anAttr; _PTR(GenericAttribute) anAttr;
SALOMEDS::AttributeName_var aName; _PTR(AttributeName) aName;
if (!myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil())) { if (!myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil())) {
SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myGeomShape) ); //_PTR(SObject) aSO = aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomShape));
if ( !aSO->_is_nil() ) { _PTR(SObject) aSO = aStudy->FindObjectID(myGeomShape->GetStudyEntry());
if (aSO) {
if (aSO->FindAttribute(anAttr, "AttributeName")) { if (aSO->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr); aName = anAttr;
LineEditC1A2->setText( QString(aName->Value()) ) ; LineEditC1A2->setText(QString(aName->Value().c_str()));
} }
} }
} }
@ -762,8 +769,11 @@ void SMESHGUI_EditHypothesesDlg::InitGeom()
//================================================================================= //=================================================================================
void SMESHGUI_EditHypothesesDlg::UpdateControlState() void SMESHGUI_EditHypothesesDlg::UpdateControlState()
{ {
bool isEnabled = ( !myMesh ->_is_nil() && !myGeomShape->_is_nil() && ListHypAssignation->count() && ListAlgoAssignation->count() ) || bool isEnabled = (!myMesh->_is_nil() && !myGeomShape->_is_nil() &&
( !mySubMesh->_is_nil() && !myGeomShape->_is_nil() && ( ListHypAssignation->count() || ListAlgoAssignation->count() ) ); ListHypAssignation->count() && ListAlgoAssignation->count())
||
(!mySubMesh->_is_nil() && !myGeomShape->_is_nil() &&
(ListHypAssignation->count() || ListAlgoAssignation->count()));
buttonOk ->setEnabled(myNbModification && isEnabled && !myImportedMesh); buttonOk ->setEnabled(myNbModification && isEnabled && !myImportedMesh);
buttonApply->setEnabled(myNbModification && isEnabled && !myImportedMesh); buttonApply->setEnabled(myNbModification && isEnabled && !myImportedMesh);
@ -785,10 +795,12 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh()
MapIOR anOldHypos, aNewHypos; MapIOR anOldHypos, aNewHypos;
if (myGeomShape->_is_nil()) if (myGeomShape->_is_nil())
return false; return false;
// 1. Check whether the geometric shape has changed // 1. Check whether the geometric shape has changed
SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO); GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMeshSO);
bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape ); bool bShapeChanged = aIniGeomShape->_is_nil() ||
!aIniGeomShape->_is_equivalent(myGeomShape);
if (bShapeChanged) { if (bShapeChanged) {
// VSR : TODO : Set new shape - not supported yet by SMESH engine // VSR : TODO : Set new shape - not supported yet by SMESH engine
// 1. remove all old hypotheses and algorithms and also submeshes // 1. remove all old hypotheses and algorithms and also submeshes
@ -797,30 +809,35 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh()
int nbFail = 0; int nbFail = 0;
MapIOR::iterator it; MapIOR::iterator it;
// 2. remove not used hypotheses from the mesh // 2. remove not used hypotheses from the mesh
for (it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it) { for (it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it) {
string ior = it->first; string ior = it->first;
int index = findItem(ListHypAssignation, ior); int index = findItem(ListHypAssignation, ior);
if (index < 0) { if (index < 0) {
SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str()); SMESH::SMESH_Hypothesis_var aHyp =
SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
if (!aHyp->_is_nil()) { if (!aHyp->_is_nil()) {
if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aMeshSO, aHyp)) if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aMeshSO, aHyp))
nbFail++; nbFail++;
} }
} }
} }
// 3. remove not used algorithms from the mesh // 3. remove not used algorithms from the mesh
for (it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it) { for (it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it) {
string ior = it->first; string ior = it->first;
int index = findItem(ListAlgoAssignation, ior); int index = findItem(ListAlgoAssignation, ior);
if (index < 0) { if (index < 0) {
SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str()); SMESH::SMESH_Hypothesis_var aHyp =
SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
if (!aHyp->_is_nil()) { if (!aHyp->_is_nil()) {
if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aMeshSO, aHyp)) if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh(aMeshSO, aHyp))
nbFail++; nbFail++;
} }
} }
} }
// 4. Add new algorithms // 4. Add new algorithms
for (int i = 0; i < ListAlgoAssignation->count(); i++) { for (int i = 0; i < ListAlgoAssignation->count(); i++) {
if (ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { if (ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) {
@ -828,7 +845,8 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh()
if (anItem) { if (anItem) {
string ior = anItem->GetIOR(); string ior = anItem->GetIOR();
if (myMapOldAlgos.find(ior) == myMapOldAlgos.end()) { if (myMapOldAlgos.find(ior) == myMapOldAlgos.end()) {
SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str()); SMESH::SMESH_Hypothesis_var aHyp =
SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
if (!aHyp->_is_nil()) { if (!aHyp->_is_nil()) {
if (!SMESH::AddHypothesisOnMesh(myMesh, aHyp)) if (!SMESH::AddHypothesisOnMesh(myMesh, aHyp))
nbFail++; nbFail++;
@ -837,6 +855,7 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh()
} }
} }
} }
// 5. Add new hypotheses // 5. Add new hypotheses
for (int i = 0; i < ListHypAssignation->count(); i++) { for (int i = 0; i < ListHypAssignation->count(); i++) {
if (ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { if (ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) {
@ -844,7 +863,8 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh()
if (anItem) { if (anItem) {
string ior = anItem->GetIOR(); string ior = anItem->GetIOR();
if (myMapOldHypos.find(ior) == myMapOldHypos.end()) { if (myMapOldHypos.find(ior) == myMapOldHypos.end()) {
SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str()); SMESH::SMESH_Hypothesis_var aHyp =
SMESH::IORToInterface<SMESH::SMESH_Hypothesis>(ior.c_str());
if (!aHyp->_is_nil()) { if (!aHyp->_is_nil()) {
if (!SMESH::AddHypothesisOnMesh(myMesh, aHyp)) if (!SMESH::AddHypothesisOnMesh(myMesh, aHyp))
nbFail++; nbFail++;
@ -865,8 +885,9 @@ bool SMESHGUI_EditHypothesesDlg::StoreSubMesh()
MapIOR anOldHypos, aNewHypos; MapIOR anOldHypos, aNewHypos;
if (myGeomShape->_is_nil()) if (myGeomShape->_is_nil())
return false; return false;
// 1. Check whether the geometric shape has changed // 1. Check whether the geometric shape has changed
SALOMEDS::SObject_var aSubMeshSO = SMESH::FindSObject( mySubMesh ); _PTR(SObject) aSubMeshSO = SMESH::FindSObject(mySubMesh);
GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMeshSO); GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMeshSO);
bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent(myGeomShape); bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent(myGeomShape);
if (bShapeChanged) { if (bShapeChanged) {
@ -876,6 +897,7 @@ bool SMESHGUI_EditHypothesesDlg::StoreSubMesh()
} }
int nbFail = 0; int nbFail = 0;
MapIOR::iterator it; MapIOR::iterator it;
// 2. remove not used hypotheses from the submesh // 2. remove not used hypotheses from the submesh
for (it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it) { for (it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it) {
string ior = it->first; string ior = it->first;
@ -888,6 +910,7 @@ bool SMESHGUI_EditHypothesesDlg::StoreSubMesh()
} }
} }
} }
// 3. remove not used algorithms from the submesh // 3. remove not used algorithms from the submesh
for (it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it) { for (it = myMapOldAlgos.begin(); it != myMapOldAlgos.end(); ++it) {
string ior = it->first; string ior = it->first;
@ -900,6 +923,7 @@ bool SMESHGUI_EditHypothesesDlg::StoreSubMesh()
} }
} }
} }
// 4. Add new algorithms // 4. Add new algorithms
for (int i = 0; i < ListAlgoAssignation->count(); i++) { for (int i = 0; i < ListAlgoAssignation->count(); i++) {
if (ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { if (ListAlgoAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) {
@ -916,6 +940,7 @@ bool SMESHGUI_EditHypothesesDlg::StoreSubMesh()
} }
} }
} }
// 5. Add new hypotheses // 5. Add new hypotheses
for (int i = 0; i < ListHypAssignation->count(); i++) { for (int i = 0; i < ListHypAssignation->count(); i++) {
if (ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) { if (ListHypAssignation->item(i)->rtti() == ListBoxIOR::RTTI_IOR) {

View File

@ -29,9 +29,9 @@
#ifndef DIALOGBOX_EDIT_HYPOTHESES_H #ifndef DIALOGBOX_EDIT_HYPOTHESES_H
#define DIALOGBOX_EDIT_HYPOTHESES_H #define DIALOGBOX_EDIT_HYPOTHESES_H
#include "SALOME_Selection.h" //#include "SMESH_TypeFilter.hxx"
#include "SALOME_TypeFilter.hxx" #include "SUIT_SelectionFilter.h"
#include "SMESH_TypeFilter.hxx" #include "SalomeApp_SelectionMgr.h"
// QT Includes // QT Includes
#include <qdialog.h> #include <qdialog.h>
@ -52,7 +52,7 @@ class QListBox;
class QListBoxItem; class QListBoxItem;
class SMESHGUI; class SMESHGUI;
typedef map<string, int> MapIOR; typedef map<std::string, int> MapIOR;
//================================================================================= //=================================================================================
// class : SMESHGUI_EditHypothesesDlg // class : SMESHGUI_EditHypothesesDlg
@ -63,15 +63,18 @@ class SMESHGUI_EditHypothesesDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_EditHypothesesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); SMESHGUI_EditHypothesesDlg (SMESHGUI*,
const char* name = 0,
bool modal = FALSE,
WFlags fl = 0);
~SMESHGUI_EditHypothesesDlg(); ~SMESHGUI_EditHypothesesDlg();
protected: protected:
virtual void closeEvent( QCloseEvent* e ); virtual void closeEvent (QCloseEvent*);
virtual void enterEvent (QEvent*); virtual void enterEvent (QEvent*);
private: private:
void Init( SALOME_Selection* Sel ) ; void Init();
void InitHypDefinition(); void InitHypDefinition();
void InitAlgoDefinition(); void InitAlgoDefinition();
@ -89,7 +92,7 @@ private:
private: private:
SMESHGUI* mySMESHGUI; SMESHGUI* mySMESHGUI;
SALOME_Selection* mySelection ; SalomeApp_SelectionMgr* mySelectionMgr;
GEOM::GEOM_Object_var myGeomShape; GEOM::GEOM_Object_var myGeomShape;
QLineEdit* myEditCurrentArgument; QLineEdit* myEditCurrentArgument;
@ -97,8 +100,10 @@ private:
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Mesh_var myMesh;
SMESH::SMESH_subMesh_var mySubMesh; SMESH::SMESH_subMesh_var mySubMesh;
Handle(SALOME_TypeFilter) myGeomFilter; //Handle(SALOME_TypeFilter) myGeomFilter;
Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; //Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter;
SUIT_SelectionFilter* myGeomFilter;
SUIT_SelectionFilter* myMeshOrSubMeshFilter;
MapIOR myMapOldHypos, myMapOldAlgos; MapIOR myMapOldHypos, myMapOldAlgos;
int myNbModification; int myNbModification;

File diff suppressed because it is too large Load Diff

View File

@ -29,9 +29,9 @@
#ifndef DIALOGBOX_EXTRUSION_PATH_H #ifndef DIALOGBOX_EXTRUSION_PATH_H
#define DIALOGBOX_EXTRUSION_PATH_H #define DIALOGBOX_EXTRUSION_PATH_H
#include "SALOME_Selection.h" #include "SalomeApp_SelectionMgr.h"
#include "SMESH_LogicalFilter.hxx" #include "SUIT_SelectionFilter.h"
#include "SMESH_TypeFilter.hxx"
// QT Includes // QT Includes
#include <qdialog.h> #include <qdialog.h>
@ -44,9 +44,13 @@ class QLineEdit;
class QCheckBox; class QCheckBox;
class QListBox; class QListBox;
class QPushButton; class QPushButton;
class SMESHGUI_SpinBox;
class SMESHGUI; class SMESHGUI;
class SMESH_Actor; class SMESH_Actor;
class SMESHGUI_SpinBox;
class SVTK_ViewWindow;
class SVTK_Selector;
// IDL Headers // IDL Headers
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
@ -70,14 +74,12 @@ class SMESHGUI_ExtrusionAlongPathDlg : public QDialog
friend class SetBusy; friend class SetBusy;
public: public:
SMESHGUI_ExtrusionAlongPathDlg( QWidget* parent = 0, SALOME_Selection* Sel = 0, bool modal = FALSE ); SMESHGUI_ExtrusionAlongPathDlg (SMESHGUI*,
bool modal = FALSE);
~SMESHGUI_ExtrusionAlongPathDlg(); ~SMESHGUI_ExtrusionAlongPathDlg();
bool eventFilter (QObject* object, QEvent* event); bool eventFilter (QObject* object, QEvent* event);
protected slots:
void reject();
private: private:
void Init (bool ResetControls = true); void Init (bool ResetControls = true);
void enterEvent (QEvent*); /* mouse enter the QWidget */ void enterEvent (QEvent*); /* mouse enter the QWidget */
@ -85,24 +87,28 @@ private:
void SetEditCurrentArgument (QToolButton* button); void SetEditCurrentArgument (QToolButton* button);
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */ SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SVTK_ViewWindow* myViewWindow;
SVTK_Selector* mySelector;
QWidget* myEditCurrentArgument; /* Current argument */ QWidget* myEditCurrentArgument; /* Current argument */
bool myBusy; bool myBusy;
SMESH::SMESH_IDSource_var myIDSource;
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myMeshActor; SMESH_Actor* myMeshActor;
SMESH::SMESH_IDSource_var myIDSource;
SMESH::SMESH_Mesh_var myPathMesh; SMESH::SMESH_Mesh_var myPathMesh;
GEOM::GEOM_Object_var myPathShape; GEOM::GEOM_Object_var myPathShape;
Handle(SMESH_LogicalFilter) myElementsFilter; SUIT_SelectionFilter* myElementsFilter;
Handle(SMESH_TypeFilter) myPathMeshFilter; SUIT_SelectionFilter* myPathMeshFilter;
int myType; int myType;
// widgets // widgets
QButtonGroup* ElementsTypeGrp; QButtonGroup* GroupConstructors;
QRadioButton* Elements1dRB; QRadioButton* Elements1dRB;
QRadioButton* Elements2dRB; QRadioButton* Elements2dRB;
QGroupBox* ArgumentsGrp;
QGroupBox* GroupArguments;
QLabel* ElementsLab; QLabel* ElementsLab;
QToolButton* SelectElementsButton; QToolButton* SelectElementsButton;
QLineEdit* ElementsLineEdit; QLineEdit* ElementsLineEdit;
@ -132,13 +138,17 @@ private:
SMESHGUI_SpinBox* YSpin; SMESHGUI_SpinBox* YSpin;
QLabel* ZLab; QLabel* ZLab;
SMESHGUI_SpinBox* ZSpin; SMESHGUI_SpinBox* ZSpin;
QGroupBox* ButtonsGrp;
QGroupBox* GroupButtons;
QPushButton* OkButton; QPushButton* OkButton;
QPushButton* ApplyButton; QPushButton* ApplyButton;
QPushButton* CloseButton; QPushButton* CloseButton;
protected slots:
void reject();
private slots: private slots:
void TypeChanged( int type ); void ConstructorsClicked (int);
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void SetEditCurrentArgument(); void SetEditCurrentArgument();

View File

@ -27,21 +27,38 @@
// $Header: // $Header:
#include "SMESHGUI_ExtrusionDlg.h" #include "SMESHGUI_ExtrusionDlg.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_IdValidator.h" #include "SMESHGUI_IdValidator.h"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_TypeFilter.hxx" #include "SMESH_TypeFilter.hxx"
#include "SMESH_NumberFilter.hxx"
#include "SMESH_LogicalFilter.hxx"
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "QAD_Application.h" #include "SUIT_ResourceMgr.h"
#include "QAD_Desktop.h" #include "SUIT_OverrideCursor.h"
#include "QAD_MessageBox.h" #include "SUIT_Desktop.h"
#include "SUIT_MessageBox.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_Selector.h"
#include "SVTK_Selection.h"
#include "SALOME_ListIO.hxx"
#include "utilities.h" #include "utilities.h"
// OCCT Includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
// QT Includes // QT Includes
#include <qapplication.h> #include <qapplication.h>
#include <qbuttongroup.h> #include <qbuttongroup.h>
@ -51,8 +68,8 @@
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qradiobutton.h> #include <qradiobutton.h>
#include <qcheckbox.h> #include <qcheckbox.h>
#include <qlayout.h>
#include <qspinbox.h> #include <qspinbox.h>
#include <qlayout.h>
#include <qvalidator.h> #include <qvalidator.h>
#include <qpixmap.h> #include <qpixmap.h>
@ -63,35 +80,38 @@
using namespace std; using namespace std;
//================================================================================= //=================================================================================
// class : SMESHGUI_ExtrusionDlg() // function : SMESHGUI_ExtrusionDlg()
// purpose : // purpose : constructor
//================================================================================= //=================================================================================
SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule,
bool modal, WFlags fl ) bool modal)
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_ExtrusionDlg", modal, WStyle_Customize |
Qt::WDestructiveClose) WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myViewWindow( SMESH::GetViewWindow( theModule ) ),
mySelector( myViewWindow->GetSelector() )
{ {
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE"))); QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_EDGE")));
QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE"))); QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE")));
QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
if ( !name )
setName( "SMESHGUI_ExtrusionDlg" );
resize(303, 185); resize(303, 185);
setCaption(tr("EXTRUSION_ALONG_LINE")); setCaption(tr("EXTRUSION_ALONG_LINE"));
setSizeGripEnabled(TRUE); setSizeGripEnabled(TRUE);
SMESHGUI_ExtrusionDlgLayout = new QGridLayout( this );
QGridLayout* SMESHGUI_ExtrusionDlgLayout = new QGridLayout(this);
SMESHGUI_ExtrusionDlgLayout->setSpacing(6); SMESHGUI_ExtrusionDlgLayout->setSpacing(6);
SMESHGUI_ExtrusionDlgLayout->setMargin(11); SMESHGUI_ExtrusionDlgLayout->setMargin(11);
/***************************************************************/ /***************************************************************/
GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); GroupConstructors = new QButtonGroup("GroupConstructors", this);
GroupConstructors->setTitle(tr("SMESH_EXTRUSION")); GroupConstructors->setTitle(tr("SMESH_EXTRUSION"));
GroupConstructors->setExclusive(TRUE); GroupConstructors->setExclusive(TRUE);
GroupConstructors->setColumnLayout(0, Qt::Vertical); GroupConstructors->setColumnLayout(0, Qt::Vertical);
GroupConstructors->layout()->setSpacing(0); GroupConstructors->layout()->setSpacing(0);
GroupConstructors->layout()->setMargin(0); GroupConstructors->layout()->setMargin(0);
GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
GroupConstructorsLayout->setAlignment(Qt::AlignTop); GroupConstructorsLayout->setAlignment(Qt::AlignTop);
GroupConstructorsLayout->setSpacing(6); GroupConstructorsLayout->setSpacing(6);
GroupConstructorsLayout->setMargin(11); GroupConstructorsLayout->setMargin(11);
@ -112,7 +132,7 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg( QWidget* parent, const char* name,
GroupButtons->setColumnLayout(0, Qt::Vertical); GroupButtons->setColumnLayout(0, Qt::Vertical);
GroupButtons->layout()->setSpacing(0); GroupButtons->layout()->setSpacing(0);
GroupButtons->layout()->setMargin(0); GroupButtons->layout()->setMargin(0);
GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
GroupButtonsLayout->setAlignment(Qt::AlignTop); GroupButtonsLayout->setAlignment(Qt::AlignTop);
GroupButtonsLayout->setSpacing(6); GroupButtonsLayout->setSpacing(6);
GroupButtonsLayout->setMargin(11); GroupButtonsLayout->setMargin(11);
@ -139,7 +159,7 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg( QWidget* parent, const char* name,
GroupArguments->setColumnLayout(0, Qt::Vertical); GroupArguments->setColumnLayout(0, Qt::Vertical);
GroupArguments->layout()->setSpacing(0); GroupArguments->layout()->setSpacing(0);
GroupArguments->layout()->setMargin(0); GroupArguments->layout()->setMargin(0);
GroupArgumentsLayout = new QGridLayout( GroupArguments->layout()); QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
GroupArgumentsLayout->setAlignment(Qt::AlignTop); GroupArgumentsLayout->setAlignment(Qt::AlignTop);
GroupArgumentsLayout->setSpacing(6); GroupArgumentsLayout->setSpacing(6);
GroupArgumentsLayout->setMargin(11); GroupArgumentsLayout->setMargin(11);
@ -212,24 +232,24 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg( QWidget* parent, const char* name,
GroupArguments->show(); GroupArguments->show();
RadioButton1->setChecked(TRUE); RadioButton1->setChecked(TRUE);
mySelection = Sel;
mySMESHGUI = SMESHGUI::GetSMESHGUI() ; mySMESHGUI->SetActiveDialogBox(this);
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
// Costruction of the logical filter // Costruction of the logical filter for the elements: mesh/sub-mesh/group
SMESH_ListOfFilter aListOfFilters; SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
if ( !aMeshOrSubMeshFilter.IsNull() )
aListOfFilters.Append( aMeshOrSubMeshFilter );
Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
if ( !aSmeshGroupFilter.IsNull() )
aListOfFilters.Append( aSmeshGroupFilter );
myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); QPtrList<SUIT_SelectionFilter> aListOfFilters;
if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
myMeshOrSubMeshOrGroupFilter =
new SMESH_LogicalFilter (aListOfFilters, SMESH_LogicalFilter::LO_OR);
Init(); Init();
/* signals and slots connections */
/***************************************************************/
// signals and slots connections
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
@ -237,36 +257,34 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg( QWidget* parent, const char* name,
connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument())); connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
/* to close dialog if study change */ /* to close dialog if study change */
connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel())); connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
connect( LineEditElements, SIGNAL( textChanged( const QString& )), connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
SLOT( onTextChange( const QString& ))); connect(CheckBoxMesh, SIGNAL(toggled(bool)), SLOT(onSelectMesh(bool)));
connect( CheckBoxMesh, SIGNAL( toggled( bool )),
SLOT( onSelectMesh( bool )));
/***************************************************************/
/* Move widget on the botton right corner of main widget */ /* Move widget on the botton right corner of main widget */
int x, y; int x, y;
mySMESHGUI->DefineDlgPosition(this, x, y); mySMESHGUI->DefineDlgPosition(this, x, y);
this->move(x, y); this->move(x, y);
this->show() ; /* displays Dialog */ this->show(); // displays Dialog
ConstructorsClicked(0); ConstructorsClicked(0);
} }
//================================================================================= //=================================================================================
// function : ~SMESHGUI_ExtrusionDlg() // function : ~SMESHGUI_ExtrusionDlg()
// purpose : Destroys the object and frees any allocated resources // purpose : destructor
//================================================================================= //=================================================================================
SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg() SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg()
{ {
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose : initialization
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::Init (bool ResetControls) void SMESHGUI_ExtrusionDlg::Init (bool ResetControls)
{ {
@ -282,8 +300,7 @@ void SMESHGUI_ExtrusionDlg::Init( bool ResetControls )
myActor = 0; myActor = 0;
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_Mesh::_nil();
if( ResetControls ) if (ResetControls) {
{
SpinBox_NbSteps->setValue(1); SpinBox_NbSteps->setValue(1);
SpinBox_Dx->SetValue(0); SpinBox_Dx->SetValue(0);
SpinBox_Dy->SetValue(0); SpinBox_Dy->SetValue(0);
@ -294,29 +311,27 @@ void SMESHGUI_ExtrusionDlg::Init( bool ResetControls )
} }
} }
//================================================================================= //=================================================================================
// function : ConstructorsClicked() // function : ConstructorsClicked()
// purpose : Radio button management // purpose : Radio button management
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId) void SMESHGUI_ExtrusionDlg::ConstructorsClicked (int constructorId)
{ {
disconnect(mySelection, 0, this, 0); disconnect(mySelectionMgr, 0, this, 0);
switch(constructorId) switch (constructorId) {
{
case 0: case 0:
{ {
GroupArguments->setTitle(tr("EXTRUSION_1D")); GroupArguments->setTitle(tr("EXTRUSION_1D"));
if (!CheckBoxMesh->isChecked()) if (!CheckBoxMesh->isChecked())
QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); myViewWindow->SetSelectionMode(EdgeSelection);
break; break;
} }
case 1: case 1:
{ {
GroupArguments->setTitle(tr("EXTRUSION_2D")); GroupArguments->setTitle(tr("EXTRUSION_2D"));
if (!CheckBoxMesh->isChecked()) if (!CheckBoxMesh->isChecked())
QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); myViewWindow->SetSelectionMode(FaceSelection);
break; break;
} }
} }
@ -327,21 +342,19 @@ void SMESHGUI_ExtrusionDlg::ConstructorsClicked(int constructorId)
if (CheckBoxMesh->isChecked()) if (CheckBoxMesh->isChecked())
onSelectMesh(true); onSelectMesh(true);
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
} }
//================================================================================= //=================================================================================
// function : ClickOnApply() // function : ClickOnApply()
// purpose : // purpose : Called when user presses <Apply> button
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::ClickOnApply() bool SMESHGUI_ExtrusionDlg::ClickOnApply()
{ {
if (mySMESHGUI->ActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return; return false;
if ( myNbOkElements) if (myNbOkElements) {
{
QStringList aListElementsId = QStringList::split(" ", myElementsId, false); QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
SMESH::long_array_var anElementsId = new SMESH::long_array; SMESH::long_array_var anElementsId = new SMESH::long_array;
@ -357,59 +370,60 @@ void SMESHGUI_ExtrusionDlg::ClickOnApply()
long aNbSteps = (long)SpinBox_NbSteps->value(); long aNbSteps = (long)SpinBox_NbSteps->value();
try try {
{
SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
QApplication::setOverrideCursor(Qt::waitCursor); QApplication::setOverrideCursor(Qt::waitCursor);
aMeshEditor->ExtrusionSweep(anElementsId.inout(), aVector, aNbSteps); aMeshEditor->ExtrusionSweep(anElementsId.inout(), aVector, aNbSteps);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} } catch (...) {
catch( ... )
{
} }
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
SMESH::UpdateView(); SMESH::UpdateView();
Init(false); Init(false);
ConstructorsClicked(GetConstructorId()); ConstructorsClicked(GetConstructorId());
} }
return true;
} }
//================================================================================= //=================================================================================
// function : ClickOnOk() // function : ClickOnOk()
// purpose : // purpose : Called when user presses <OK> button
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::ClickOnOk() void SMESHGUI_ExtrusionDlg::ClickOnOk()
{ {
ClickOnApply(); if (ClickOnApply())
ClickOnCancel(); ClickOnCancel();
} }
//================================================================================= //=================================================================================
// function : ClickOnCancel() // function : ClickOnCancel()
// purpose : // purpose : Called when dialog box is closed
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::ClickOnCancel() void SMESHGUI_ExtrusionDlg::ClickOnCancel()
{ {
mySelection->ClearFilters(); disconnect(mySelectionMgr, 0, this, 0);
mySelection->ClearIObjects(); mySelectionMgr->clearFilters();
mySelectionMgr->clearSelected();
SMESH::SetPickable(); // ???
SMESH::SetPointRepresentation(false); SMESH::SetPointRepresentation(false);
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); myViewWindow->SetSelectionMode(ActorSelection);
disconnect( mySelection, 0, this, 0 );
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
reject(); reject();
} }
//======================================================================= //=================================================================================
//function : onTextChange // function : onTextChange()
// purpose : // purpose :
//======================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText) void SMESHGUI_ExtrusionDlg::onTextChange (const QString& theNewText)
{ {
QLineEdit* send = (QLineEdit*)sender(); QLineEdit* send = (QLineEdit*)sender();
// return if busy
if (myBusy) return; if (myBusy) return;
// set busy flag
myBusy = true; myBusy = true;
if (send == LineEditElements) if (send == LineEditElements)
@ -424,20 +438,34 @@ void SMESHGUI_ExtrusionDlg::onTextChange(const QString& theNewText)
aMesh = myActor->GetObject()->GetMesh(); aMesh = myActor->GetObject()->GetMesh();
if (aMesh) { if (aMesh) {
mySelection->ClearIObjects(); //mySelectionMgr->clearSelected();
mySelection->AddIObject( myActor->getIO() ); //mySelectionMgr->AddIObject(myActor->getIO());
SALOME_ListIO aList;
aList.Append(myActor->getIO());
mySelectionMgr->setSelectedObjects(aList, false);
QStringList aListId = QStringList::split(" ", theNewText, false); QStringList aListId = QStringList::split(" ", theNewText, false);
if (send == LineEditElements) { if (send == LineEditElements) {
const Handle(SALOME_InteractiveObject)& anIO = myActor->getIO();
TColStd_IndexedMapOfInteger selectedIndices;
TColStd_MapOfInteger newIndices;
mySelector->GetIndex(anIO, selectedIndices);
for (int i = 0; i < aListId.count(); i++) { for (int i = 0; i < aListId.count(); i++) {
const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
if (e) { if (e) {
if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) //if (!mySelectionMgr->IsIndexSelected(myActor->getIO(), e->GetID())) {
mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); if (selectedIndices.Add(e->GetID())) {
//mySelectionMgr->AddOrRemoveIndex(myActor->getIO(), e->GetID(), true);
newIndices.Add(e->GetID());
}
myNbOkElements++; myNbOkElements++;
} }
} }
if (newIndices.Extent() > 0) {
mySelector->AddOrRemoveIndex(anIO, newIndices, true);
myViewWindow->highlight( anIO, true, true );
}
myElementsId = theNewText; myElementsId = theNewText;
} }
} }
@ -458,73 +486,67 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
{ {
if (myBusy) return; if (myBusy) return;
// return if dialog box is inactive
if (!GroupButtons->isEnabled())
return;
// clear // clear
myActor = 0; myActor = 0;
QString aString = ""; QString aString = "";
// set busy flag
myBusy = true; myBusy = true;
myEditCurrentArgument->setText(aString); myEditCurrentArgument->setText(aString);
myNbOkElements = 0; myNbOkElements = 0;
buttonOk->setEnabled(false); buttonOk->setEnabled(false);
buttonApply->setEnabled(false); buttonApply->setEnabled(false);
myBusy = false; myBusy = false;
if ( !GroupButtons->isEnabled() ) // inactive
return;
buttonOk->setEnabled( false );
buttonApply->setEnabled( false );
// get selected mesh // get selected mesh
SALOME_ListIO aList;
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString); mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
if (nbSel != 1) if (nbSel != 1)
return; return;
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); Handle(SALOME_InteractiveObject) IO = aList.First();
myMesh = SMESH::GetMeshByIO(IO); myMesh = SMESH::GetMeshByIO(IO);
if (myMesh->_is_nil()) if (myMesh->_is_nil())
return; return;
myActor = SMESH::FindActorByObject(myMesh); myActor = SMESH::FindActorByObject(myMesh);
if (!myActor) if (!myActor)
return; return;
if (myEditCurrentArgument == LineEditElements) if (myEditCurrentArgument == LineEditElements) {
{
int aNbElements = 0; int aNbElements = 0;
myElementsId = ""; myElementsId = "";
if (CheckBoxMesh->isChecked()) if (CheckBoxMesh->isChecked()) {
{
SMESH::GetNameOfSelectedIObjects(mySelection, aString);
int aConstructorId = GetConstructorId(); int aConstructorId = GetConstructorId();
if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) //MESH SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
{
if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
// get IDs from mesh // get IDs from mesh
SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
if (!aSMDSMesh) if (!aSMDSMesh)
return; return;
if (aConstructorId == 0) if (aConstructorId == 0) {
{
SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator();
while ( anIter->more() ) while (anIter->more()) {
{
const SMDS_MeshEdge * edge = anIter->next(); const SMDS_MeshEdge * edge = anIter->next();
if (edge) { if (edge) {
myElementsId += QString(" %1").arg(edge->GetID()); myElementsId += QString(" %1").arg(edge->GetID());
aNbElements++; aNbElements++;
} }
} }
} } else if (aConstructorId == 1) {
else if (aConstructorId == 1)
{
SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator();
while ( anIter->more() ) while (anIter->more()) {
{
const SMDS_MeshFace * face = anIter->next(); const SMDS_MeshFace * face = anIter->next();
if (face) { if (face) {
myElementsId += QString(" %1").arg(face->GetID()); myElementsId += QString(" %1").arg(face->GetID());
@ -532,9 +554,7 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
} }
} }
} }
} } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) //SUBMESH
{
// get submesh // get submesh
SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO); SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
@ -548,9 +568,7 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
for (int i = 0; i < anElementsIds->length(); i++) for (int i = 0; i < anElementsIds->length(); i++)
myElementsId += QString(" %1").arg(anElementsIds[i]); myElementsId += QString(" %1").arg(anElementsIds[i]);
aNbElements = anElementsIds->length(); aNbElements = anElementsIds->length();
} } else { // GROUP
else // GROUP
{
// get smesh group // get smesh group
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO); SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
@ -568,10 +586,8 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
myElementsId += QString(" %1").arg(anElementsIds[i]); myElementsId += QString(" %1").arg(anElementsIds[i]);
aNbElements = anElementsIds->length(); aNbElements = anElementsIds->length();
} }
} } else {
else aNbElements = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aString);
{
aNbElements = SMESH::GetNameOfSelectedElements(mySelection, aString) ;
myElementsId = aString; myElementsId = aString;
} }
@ -586,15 +602,12 @@ void SMESHGUI_ExtrusionDlg::SelectionIntoArgument()
myBusy = false; myBusy = false;
// OK // OK
if (myNbOkElements) {
if(myNbOkElements)
{
buttonOk->setEnabled(true); buttonOk->setEnabled(true);
buttonApply->setEnabled(true); buttonApply->setEnabled(true);
} }
} }
//================================================================================= //=================================================================================
// function : SetEditCurrentArgument() // function : SetEditCurrentArgument()
// purpose : // purpose :
@ -603,35 +616,32 @@ void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument()
{ {
QPushButton* send = (QPushButton*)sender(); QPushButton* send = (QPushButton*)sender();
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
if (send == SelectElementsButton) { if (send == SelectElementsButton) {
myEditCurrentArgument = LineEditElements; myEditCurrentArgument = LineEditElements;
if (CheckBoxMesh->isChecked()) if (CheckBoxMesh->isChecked()) {
{ myViewWindow->SetSelectionMode(ActorSelection);
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); } else {
}
else
{
int aConstructorId = GetConstructorId(); int aConstructorId = GetConstructorId();
if (aConstructorId == 0) if (aConstructorId == 0)
QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); myViewWindow->SetSelectionMode(EdgeSelection);
else if (aConstructorId == 1) else if (aConstructorId == 1)
QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); myViewWindow->SetSelectionMode(FaceSelection);
} }
} }
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
SelectionIntoArgument(); SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : DeactivateActiveDialog() // function : DeactivateActiveDialog()
// purpose : // purpose : Deactivates this dialog
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog() void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog()
{ {
@ -644,65 +654,58 @@ void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog()
} }
} }
//================================================================================= //=================================================================================
// function : ActivateThisDialog() // function : ActivateThisDialog()
// purpose : // purpose : Activates this dialog
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::ActivateThisDialog() void SMESHGUI_ExtrusionDlg::ActivateThisDialog()
{ {
/* Emit a signal to deactivate the active dialog */ // Emit a signal to deactivate the active dialog
mySMESHGUI->EmitSignalDeactivateDialog(); mySMESHGUI->EmitSignalDeactivateDialog();
GroupConstructors->setEnabled(true); GroupConstructors->setEnabled(true);
GroupArguments->setEnabled(true); GroupArguments->setEnabled(true);
GroupButtons->setEnabled(true); GroupButtons->setEnabled(true);
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; mySMESHGUI->SetActiveDialogBox(this);
ConstructorsClicked(GetConstructorId()); ConstructorsClicked(GetConstructorId());
SelectionIntoArgument(); SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose : Mouse enter event
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::enterEvent(QEvent* e) void SMESHGUI_ExtrusionDlg::enterEvent (QEvent*)
{ {
if ( GroupConstructors->isEnabled() ) if (!GroupConstructors->isEnabled())
return ;
ActivateThisDialog(); ActivateThisDialog();
} }
//================================================================================= //=================================================================================
// function : closeEvent() // function : closeEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::closeEvent( QCloseEvent* e ) //void SMESHGUI_ExtrusionDlg::closeEvent (QCloseEvent*)
{ //{
/* same than click on cancel button */ // /* same than click on cancel button */
this->ClickOnCancel() ; // this->ClickOnCancel();
} //}
//
//=================================================================================
//======================================================================= // function : hideEvent()
//function : hideEvent
// purpose : caused by ESC key // purpose : caused by ESC key
//======================================================================= //=================================================================================
//void SMESHGUI_ExtrusionDlg::hideEvent (QHideEvent*)
//{
// if (!isMinimized())
// ClickOnCancel();
//}
void SMESHGUI_ExtrusionDlg::hideEvent ( QHideEvent * e ) //=================================================================================
{ // function : onSelectMesh()
if ( !isMinimized() )
ClickOnCancel();
}
//=======================================================================
//function : onSelectMesh
// purpose : // purpose :
//======================================================================= //=================================================================================
void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh) void SMESHGUI_ExtrusionDlg::onSelectMesh (bool toSelectMesh)
{ {
if (toSelectMesh) if (toSelectMesh)
@ -710,27 +713,23 @@ void SMESHGUI_ExtrusionDlg::onSelectMesh ( bool toSelectMesh )
else else
TextLabelElements->setText(tr("SMESH_ID_ELEMENTS")); TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
if (myEditCurrentArgument != LineEditElements) if (myEditCurrentArgument != LineEditElements) {
{
LineEditElements->clear(); LineEditElements->clear();
return; return;
} }
mySelection->ClearFilters() ; mySelectionMgr->clearFilters();
if (toSelectMesh) if (toSelectMesh) {
{ myViewWindow->SetSelectionMode(ActorSelection);
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter);
LineEditElements->setReadOnly(true); LineEditElements->setReadOnly(true);
} } else {
else
{
int aConstructorId = GetConstructorId(); int aConstructorId = GetConstructorId();
if (aConstructorId == 0) if (aConstructorId == 0)
QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); myViewWindow->SetSelectionMode(EdgeSelection);
else if (aConstructorId == 0) else if (aConstructorId == 0)
QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); myViewWindow->SetSelectionMode(FaceSelection);
LineEditElements->setReadOnly(false); LineEditElements->setReadOnly(false);
onTextChange(LineEditElements->text()); onTextChange(LineEditElements->text());
@ -739,7 +738,6 @@ void SMESHGUI_ExtrusionDlg::onSelectMesh ( bool toSelectMesh )
SelectionIntoArgument(); SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
// function : GetConstructorId() // function : GetConstructorId()
// purpose : // purpose :

View File

@ -29,30 +29,32 @@
#ifndef DIALOGBOX_EXTRUSION_H #ifndef DIALOGBOX_EXTRUSION_H
#define DIALOGBOX_EXTRUSION_H #define DIALOGBOX_EXTRUSION_H
#include "SALOME_Selection.h" #include "SalomeApp_SelectionMgr.h"
#include "SMESH_LogicalFilter.hxx" #include "SUIT_SelectionFilter.h"
// QT Includes // QT Includes
#include <qdialog.h> #include <qdialog.h>
class QGridLayout; class QGridLayout;
class QButtonGroup; class QButtonGroup;
class QRadioButton;
class QGroupBox; class QGroupBox;
class QLabel; class QLabel;
class QLineEdit; class QLineEdit;
class QPushButton;
class QRadioButton;
class QCheckBox; class QCheckBox;
class QSpinBox; class QSpinBox;
class SMESHGUI_SpinBox; class QPushButton;
class SMESHGUI; class SMESHGUI;
class SMESH_Actor; class SMESH_Actor;
class SMESHGUI_SpinBox;
class SVTK_ViewWindow;
class SVTK_Selector;
// IDL Headers // IDL Headers
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
//================================================================================= //=================================================================================
// class : SMESHGUI_ExtrusionDlg // class : SMESHGUI_ExtrusionDlg
// purpose : // purpose :
@ -62,36 +64,35 @@ class SMESHGUI_ExtrusionDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_ExtrusionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); SMESHGUI_ExtrusionDlg (SMESHGUI*,
bool modal = FALSE);
~SMESHGUI_ExtrusionDlg(); ~SMESHGUI_ExtrusionDlg();
private: private:
void Init (bool ResetControls = true); void Init (bool ResetControls = true);
void closeEvent( QCloseEvent* e ) ;
void enterEvent (QEvent*); /* mouse enter the QWidget */ void enterEvent (QEvent*); /* mouse enter the QWidget */
void hideEvent ( QHideEvent * ); /* ESC key */
int GetConstructorId(); int GetConstructorId();
//void closeEvent (QCloseEvent*);
//void hideEvent (QHideEvent*); /* ESC key */
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */ SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
QString myElementsId; QString myElementsId;
int myNbOkElements; /* to check when elements are defined */ int myNbOkElements; /* to check when elements are defined */
SVTK_ViewWindow* myViewWindow;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */ SVTK_Selector* mySelector;
bool myBusy; bool myBusy;
SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Mesh_var myMesh;
SMESH_Actor* myActor; SMESH_Actor* myActor;
Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; SUIT_SelectionFilter* myMeshOrSubMeshOrGroupFilter;
// widgets
QButtonGroup* GroupConstructors; QButtonGroup* GroupConstructors;
QRadioButton* RadioButton1; QRadioButton* RadioButton1;
QRadioButton* RadioButton2; QRadioButton* RadioButton2;
QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupArguments; QGroupBox* GroupArguments;
QLabel* TextLabelElements; QLabel* TextLabelElements;
QPushButton* SelectElementsButton; QPushButton* SelectElementsButton;
@ -107,24 +108,22 @@ private:
QLabel* TextLabelNbSteps; QLabel* TextLabelNbSteps;
QSpinBox* SpinBox_NbSteps; QSpinBox* SpinBox_NbSteps;
private slots: QGroupBox* GroupButtons;
QPushButton* buttonOk;
QPushButton* buttonCancel;
QPushButton* buttonApply;
void ConstructorsClicked(int constructorId); private slots:
void ConstructorsClicked (int);
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply();
void ClickOnCancel(); void ClickOnCancel();
void ClickOnApply();
void SetEditCurrentArgument(); void SetEditCurrentArgument();
void SelectionIntoArgument(); void SelectionIntoArgument();
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void ActivateThisDialog(); void ActivateThisDialog();
void onTextChange (const QString&); void onTextChange (const QString&);
void onSelectMesh (bool toSelectMesh); void onSelectMesh (bool toSelectMesh);
protected:
QGridLayout* SMESHGUI_ExtrusionDlgLayout;
QGridLayout* GroupConstructorsLayout;
QGridLayout* GroupButtonsLayout;
QGridLayout* GroupArgumentsLayout;
}; };
#endif // DIALOGBOX_EXTRUSION_H #endif // DIALOGBOX_EXTRUSION_H

View File

@ -26,17 +26,21 @@
// Module : SMESH // Module : SMESH
#include "SMESHGUI_Filter.h" #include "SMESHGUI_Filter.h"
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESH_Actor.h"
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDSAbs_ElementType.hxx" #include "SMDSAbs_ElementType.hxx"
#include <vtkCell.h> // OCCT Includes
#include <gp_Vec.hxx> #include <gp_Vec.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include "SMESH_Actor.h"
#include "SMESHGUI.h" // VTK Includes
#include <vtkCell.h>
IMPLEMENT_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) IMPLEMENT_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter)
IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_Filter, VTKViewer_Filter) IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_Filter, VTKViewer_Filter)
@ -158,7 +162,10 @@ void SMESHGUI_PredicateFilter::SetActor( SALOME_Actor* theActor )
if ( myActor != 0 && !myPred->_is_nil() ) if ( myActor != 0 && !myPred->_is_nil() )
{ {
Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); SALOME_Actor* sActor = dynamic_cast<SALOME_Actor*>( myActor );
Handle(SALOME_InteractiveObject) anIO;
if( sActor )
anIO = sActor->getIO();
if ( !anIO.IsNull() ) if ( !anIO.IsNull() )
{ {
SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO); SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
@ -488,14 +495,3 @@ bool SMESHGUI_VolumesFilter::IsNodeFilter() const
{ {
return false; return false;
} }

View File

@ -30,35 +30,47 @@
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_Filter.h" #include "SMESHGUI_Filter.h"
#include "SMESH_Actor.h" #include "SMESHGUI_FilterUtils.h"
#include "VTKViewer_ViewFrame.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "QAD_RightFrame.h"
#include "QAD_Config.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "SMESHGUI_FilterLibraryDlg.h" #include "SMESHGUI_FilterLibraryDlg.h"
#include "SALOME_TypeFilter.hxx"
#include "SMESH_Actor.h"
#include "SMESH_NumberFilter.hxx"
#include "SMESH_TypeFilter.hxx"
#include "GEOMBase.h" #include "GEOMBase.h"
#include "GEOM_FaceFilter.hxx" #include "GEOM_FaceFilter.h"
#include "GEOM_TypeFilter.h"
#include "SUIT_Desktop.h"
#include "SUIT_ResourceMgr.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Tools.h"
#include "SalomeApp_Study.h"
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx"
#include "SALOMEDSClient_Study.hxx"
#include "SVTK_ViewWindow.h"
#include "SVTK_Selector.h"
// OCCT Includes
#include <StdSelect_TypeOfFace.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <Geom_Plane.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Precision.hxx>
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx> #include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <Precision.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <Geom_Plane.hxx>
#include <Geom_CylindricalSurface.hxx>
// QT Includes
#include <qframe.h> #include <qframe.h>
#include <qlayout.h> #include <qlayout.h>
#include <qlineedit.h> #include <qlineedit.h>
@ -161,6 +173,7 @@ SMESHGUI_FilterTable::AdditionalWidget::AdditionalWidget( QWidget* theParent )
QString aText = QString("%1").arg(Precision::Confusion()); QString aText = QString("%1").arg(Precision::Confusion());
myLineEdits[ Tolerance ]->setText(aText); myLineEdits[ Tolerance ]->setText(aText);
} }
SMESHGUI_FilterTable::AdditionalWidget::~AdditionalWidget() SMESHGUI_FilterTable::AdditionalWidget::~AdditionalWidget()
{ {
} }
@ -179,16 +192,14 @@ bool SMESHGUI_FilterTable::AdditionalWidget::IsValid( const bool theMsg ) const
QValueList<int> aParams; QValueList<int> aParams;
GetParameters(aParams); GetParameters(aParams);
QValueList<int>::const_iterator anIter; QValueList<int>::const_iterator anIter;
for ( anIter = aParams.begin(); anIter != aParams.end(); ++anIter ) for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter) {
{
const QLineEdit* aWg = myLineEdits[ *anIter ]; const QLineEdit* aWg = myLineEdits[ *anIter ];
int p = 0; int p = 0;
QString aText = aWg->text(); QString aText = aWg->text();
if ( aWg->isEnabled() && aWg->validator()->validate( aText, p ) != QValidator::Acceptable ) if (aWg->isEnabled() && aWg->validator()->validate(aText, p) != QValidator::Acceptable) {
{
if (theMsg) if (theMsg)
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok ); tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok);
return false; return false;
} }
} }
@ -250,7 +261,6 @@ void SMESHGUI_FilterTable::AdditionalWidget::SetEditable( const bool isEditable
*/ */
class SMESHGUI_FilterTable::ComboItem : public QComboTableItem class SMESHGUI_FilterTable::ComboItem : public QComboTableItem
{ {
public: public:
ComboItem(QTable*, const QMap<int, QString>&); ComboItem(QTable*, const QMap<int, QString>&);
@ -285,8 +295,7 @@ void SMESHGUI_FilterTable::ComboItem::setStringList( const QMap<int, QString>& t
int i = 0; int i = 0;
QStringList aList; QStringList aList;
QMap<int, QString>::const_iterator anIter; QMap<int, QString>::const_iterator anIter;
for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
{
myNumToId[ i ] = anIter.key(); myNumToId[ i ] = anIter.key();
myIdToNum[ anIter.key() ] = i; myIdToNum[ anIter.key() ] = i;
aList.append(anIter.data()); aList.append(anIter.data());
@ -352,7 +361,8 @@ SMESHGUI_FilterTable::Table::~Table()
// name : SMESHGUI_FilterTable::Table::SetEditable // name : SMESHGUI_FilterTable::Table::SetEditable
// Purpose : Set editable of specified cell // Purpose : Set editable of specified cell
//======================================================================= //=======================================================================
void SMESHGUI_FilterTable::Table::SetEditable( const bool isEditable, const int row, const int col ) void SMESHGUI_FilterTable::Table::SetEditable (const bool isEditable,
const int row, const int col)
{ {
QTableItem* anItem = item(row, col); QTableItem* anItem = item(row, col);
if(anItem) if(anItem)
@ -405,7 +415,6 @@ QString SMESHGUI_FilterTable::Table::text( int row, int col ) const
} }
/* /*
Class : SMESHGUI_FilterTable Class : SMESHGUI_FilterTable
Description : Frame containig Description : Frame containig
@ -572,7 +581,7 @@ void SMESHGUI_FilterTable::Init( const QValueList<int>& theTypes )
//======================================================================= //=======================================================================
// name : SMESHGUI_FilterTable::GetTableGrp // name : SMESHGUI_FilterTable::GetTableGrp
// Purpose : Get group box containing table. May be used for adding new widgets in it // Purpose : Get group box containing table. May be used for adding new widgets in it
////======================================================================= //=======================================================================
QWidget* SMESHGUI_FilterTable::createAdditionalFrame (QWidget* theParent) QWidget* SMESHGUI_FilterTable::createAdditionalFrame (QWidget* theParent)
{ {
QFrame* aFrame = new QFrame(theParent); QFrame* aFrame = new QFrame(theParent);
@ -600,7 +609,7 @@ QWidget* SMESHGUI_FilterTable::createAdditionalFrame( QWidget* theParent )
//======================================================================= //=======================================================================
// name : SMESHGUI_FilterTable::GetTableGrp // name : SMESHGUI_FilterTable::GetTableGrp
// Purpose : Get group box containing table. May be used for adding new widgets in it // Purpose : Get group box containing table. May be used for adding new widgets in it
////======================================================================= //=======================================================================
QGroupBox* SMESHGUI_FilterTable::GetTableGrp() QGroupBox* SMESHGUI_FilterTable::GetTableGrp()
{ {
return myTableGrp; return myTableGrp;
@ -659,28 +668,23 @@ bool SMESHGUI_FilterTable::IsValid( const bool theMess, const int theEntityType
aCriterion == FT_BelongToGeom || aCriterion == FT_BelongToGeom ||
aCriterion == FT_BelongToPlane || aCriterion == FT_BelongToPlane ||
aCriterion == FT_BelongToCylinder || aCriterion == FT_BelongToCylinder ||
aCriterion == FT_LyingOnGeom) aCriterion == FT_LyingOnGeom) {
{ if (aTable->text(i, 2).isEmpty()) {
if ( aTable->text( i, 2 ).isEmpty() )
{
if (theMess) if (theMess)
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR" ), QMessageBox::Ok ); tr("ERROR"), QMessageBox::Ok);
return false; return false;
} }
} } else {
else
{
bool aRes = false; bool aRes = false;
aTable->blockSignals(true); aTable->blockSignals(true);
double aThreshold = (int)aTable->text(i, 2).toDouble(&aRes); double aThreshold = (int)aTable->text(i, 2).toDouble(&aRes);
aTable->blockSignals(false); aTable->blockSignals(false);
if ( !aRes && aTable->IsEditable( i, 2 ) ) if (!aRes && aTable->IsEditable(i, 2)) {
{
if (theMess) if (theMess)
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR" ), QMessageBox::Ok ); tr("ERROR"), QMessageBox::Ok);
return false; return false;
} }
else if (aType == SMESH::EDGE && else if (aType == SMESH::EDGE &&
@ -688,8 +692,8 @@ bool SMESHGUI_FilterTable::IsValid( const bool theMess, const int theEntityType
aThreshold == 1) aThreshold == 1)
{ {
if (theMess) if (theMess)
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "MULTIEDGES_ERROR" ), QMessageBox::Ok ); tr("MULTIEDGES_ERROR"), QMessageBox::Ok);
return false; return false;
} }
} }
@ -1585,11 +1589,15 @@ bool SMESHGUI_FilterTable::GetThreshold( const int theRow,
// name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
// Purpose : Constructor // Purpose : Constructor
//======================================================================= //=======================================================================
SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent, SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
const QValueList<int>& theTypes, const QValueList<int>& theTypes,
const char* theName) const char* theName)
: QDialog( theParent, theName, false, : QDialog( SMESH::GetDesktop( theModule ), theName, false,
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myViewWindow( SMESH::GetViewWindow( theModule ) ),
mySelector( myViewWindow->GetSelector() )
{ {
construct(theTypes); construct(theTypes);
} }
@ -1598,11 +1606,15 @@ SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent,
// name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg // name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg
// Purpose : Constructor // Purpose : Constructor
//======================================================================= //=======================================================================
SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent, SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( SMESHGUI* theModule,
const int theType, const int theType,
const char* theName) const char* theName)
: QDialog( theParent, theName, false, : QDialog( SMESH::GetDesktop( theModule ), theName, false,
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myViewWindow( SMESH::GetViewWindow( theModule ) ),
mySelector( myViewWindow->GetSelector() )
{ {
QValueList<int> aTypes; QValueList<int> aTypes;
aTypes.append(theType); aTypes.append(theType);
@ -1761,7 +1773,6 @@ void SMESHGUI_FilterDlg::Init( const int type )
void SMESHGUI_FilterDlg::Init (const QValueList<int>& theTypes) void SMESHGUI_FilterDlg::Init (const QValueList<int>& theTypes)
{ {
mySourceWg = 0; mySourceWg = 0;
mySelection = 0;
myTypes = theTypes; myTypes = theTypes;
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_Mesh::_nil();
myIObjects.Clear(); myIObjects.Clear();
@ -1786,7 +1797,6 @@ void SMESHGUI_FilterDlg::Init( const QValueList<int>& theTypes )
adjustSize(); adjustSize();
setEnabled(true); setEnabled(true);
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox((QDialog*)this); mySMESHGUI->SetActiveDialogBox((QDialog*)this);
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
@ -1834,9 +1844,9 @@ void SMESHGUI_FilterDlg::onOk()
{ {
if (onApply()) if (onApply())
{ {
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
disconnect(mySMESHGUI, 0, this, 0); disconnect(mySMESHGUI, 0, this, 0);
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
accept(); accept();
emit Accepted(); emit Accepted();
@ -1850,26 +1860,29 @@ void SMESHGUI_FilterDlg::onOk()
void SMESHGUI_FilterDlg::onClose() void SMESHGUI_FilterDlg::onClose()
{ {
// Restore previously selected object // Restore previously selected object
if ( mySelection ) if (mySelectionMgr)
{ {
mySelection->ClearFilters(); SALOME_ListIO aList;
mySelection->Clear(); mySelectionMgr->clearFilters();
mySelectionMgr->clearSelected();
SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter (myIObjects); SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter (myIObjects);
for (; anIter.More(); anIter.Next()) for (; anIter.More(); anIter.Next())
{ {
mySelection->AddIObject( anIter.Key() ); aList.Append(anIter.Key());
TColStd_MapOfInteger aResMap; TColStd_MapOfInteger aResMap;
const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value(); const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value();
for (int i = 1, n = anIndMap.Extent(); i <= n; i++) for (int i = 1, n = anIndMap.Extent(); i <= n; i++)
aResMap.Add(anIndMap(i)); aResMap.Add(anIndMap(i));
mySelection->AddOrRemoveIndex( anIter.Key(), aResMap, false ); mySelector->AddOrRemoveIndex( anIter.Key(), aResMap, false);
myViewWindow->highlight( anIter.Key(), true, true );
} }
mySelectionMgr->setSelectedObjects(aList, false);
} }
disconnect(mySMESHGUI, 0, this, 0); disconnect(mySMESHGUI, 0, this, 0);
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
reject(); reject();
return; return;
@ -1896,12 +1909,11 @@ void SMESHGUI_FilterDlg::enterEvent( QEvent* )
setEnabled(true); setEnabled(true);
} }
//=======================================================================
//================================================================================= // name : closeEvent()
// function : closeEvent() // Purpose :
// purpose : //=======================================================================
//================================================================================= void SMESHGUI_FilterDlg::closeEvent (QCloseEvent*)
void SMESHGUI_FilterDlg::closeEvent( QCloseEvent* e )
{ {
onClose(); onClose();
} }
@ -2017,55 +2029,48 @@ bool SMESHGUI_FilterDlg::isValid() const
if (aType == FT_BelongToGeom || if (aType == FT_BelongToGeom ||
aType == FT_BelongToPlane || aType == FT_BelongToPlane ||
aType == FT_BelongToCylinder || aType == FT_BelongToCylinder ||
aType == FT_LyingOnGeom) aType == FT_LyingOnGeom) {
{
QString aName; QString aName;
myTable->GetThreshold(i, aName); myTable->GetThreshold(i, aName);
SALOMEDS::Study::ListOfSObject_var aList = SMESHGUI::GetSMESHGUI()->GetActiveStudy()-> std::vector<_PTR(SObject)> aList =
getStudyDocument()->FindObjectByName( aName.latin1(), "GEOM" ); SMESH::GetActiveStudyDocument()->FindObjectByName(aName.latin1(), "GEOM");
if ( aList->length() == 0 ) if (aList.size() == 0) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("BAD_SHAPE_NAME").arg(aName), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "BAD_SHAPE_NAME" ).arg( aName ), QMessageBox::Ok );
return false; return false;
} }
if ( aType == FT_BelongToCylinder || aType == FT_BelongToPlane ) if (aType == FT_BelongToCylinder || aType == FT_BelongToPlane) {
{ CORBA::Object_var anObject = SMESH::SObjectToObject(aList[ 0 ]);
GEOM::GEOM_Object_var aGeomObj = //GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(aList[ 0 ]->GetObject());
GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() ); GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow(anObject);
if ( !aGeomObj->_is_nil() ) if (!aGeomObj->_is_nil()) {
{
TopoDS_Shape aFace; TopoDS_Shape aFace;
if (!GEOMBase::GetShape(aGeomObj, aFace) || if (!GEOMBase::GetShape(aGeomObj, aFace) ||
aFace.IsNull() || aFace.IsNull() ||
aFace.ShapeType() != TopAbs_FACE ) aFace.ShapeType() != TopAbs_FACE) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("SHAPE_IS_NOT_A_FACE").arg(aName), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_FACE" ).arg( aName ), QMessageBox::Ok );
return false; return false;
} }
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace)); Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace));
if ( aSurf.IsNull() ) if (aSurf.IsNull()) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("SHAPE_IS_NOT_A_FACE").arg(aName), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_FACE" ).arg( aName ), QMessageBox::Ok );
return false; return false;
} }
if ( aType == FT_BelongToPlane && !aSurf->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) if (aType == FT_BelongToPlane && !aSurf->IsKind(STANDARD_TYPE(Geom_Plane))) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("SHAPE_IS_NOT_A_PLANE").arg(aName), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_PLANE" ).arg( aName ), QMessageBox::Ok );
return false; return false;
} }
if ( aType == FT_BelongToCylinder && !aSurf->IsKind( STANDARD_TYPE( Geom_CylindricalSurface ) ) ) if (aType == FT_BelongToCylinder && !aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("SHAPE_IS_NOT_A_CYLINDER").arg(aName), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_CYLINDER" ).arg( aName ), QMessageBox::Ok );
return false; return false;
} }
} }
@ -2099,26 +2104,22 @@ void SMESHGUI_FilterDlg::SetMesh( SMESH::SMESH_Mesh_ptr theMesh )
// name : SMESHGUI_FilterDlg::SetSelection // name : SMESHGUI_FilterDlg::SetSelection
// Purpose : Get filtered ids // Purpose : Get filtered ids
//======================================================================= //=======================================================================
void SMESHGUI_FilterDlg::SetSelection( SALOME_Selection* theSel ) void SMESHGUI_FilterDlg::SetSelection()
{ {
if ( mySelection ) if (mySelectionMgr)
disconnect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); disconnect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionDone()));
mySelection = theSel; if (mySelectionMgr) {
if ( mySelection )
{
myIObjects.Clear(); myIObjects.Clear();
const SALOME_ListIO& anObjs = mySelection->StoredIObjects(); const SALOME_ListIO& anObjs = mySelector->StoredIObjects();
SALOME_ListIteratorOfListIO anIter (anObjs); SALOME_ListIteratorOfListIO anIter (anObjs);
for ( ;anIter.More(); anIter.Next() ) for (; anIter.More(); anIter.Next()) {
{
TColStd_IndexedMapOfInteger aMap; TColStd_IndexedMapOfInteger aMap;
mySelection->GetIndex( anIter.Value(), aMap ); mySelector->GetIndex(anIter.Value(), aMap);
myIObjects.Bind(anIter.Value(), aMap); myIObjects.Bind(anIter.Value(), aMap);
} }
connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
updateSelection(); updateSelection();
} }
@ -2136,8 +2137,7 @@ bool SMESHGUI_FilterDlg::onApply()
if (!isValid()) if (!isValid())
return false; return false;
try try {
{
int aCurrType = myTable->GetType(); int aCurrType = myTable->GetType();
if (!createFilter(aCurrType)) if (!createFilter(aCurrType))
@ -2145,8 +2145,7 @@ bool SMESHGUI_FilterDlg::onApply()
insertFilterInViewer(); insertFilterInViewer();
if ( !myFilter[ aCurrType ]->GetPredicate()->_is_nil() ) if (!myFilter[ aCurrType ]->GetPredicate()->_is_nil()) {
{
QValueList<int> aResultIds; QValueList<int> aResultIds;
filterSource(aCurrType, aResultIds); filterSource(aCurrType, aResultIds);
selectInViewer(aCurrType, aResultIds); selectInViewer(aCurrType, aResultIds);
@ -2154,11 +2153,10 @@ bool SMESHGUI_FilterDlg::onApply()
myInsertState[ aCurrType ] = mySetInViewer->isChecked(); myInsertState[ aCurrType ] = mySetInViewer->isChecked();
myApplyToState[ aCurrType ] = mySourceGrp->id(mySourceGrp->selected()); myApplyToState[ aCurrType ] = mySourceGrp->id(mySourceGrp->selected());
} }
catch(const SALOME::SALOME_Exception& S_ex) catch(const SALOME::SALOME_Exception& S_ex)
{ {
QtCatchCorbaException( S_ex ); SalomeApp_Tools::QtCatchCorbaException(S_ex);
} }
catch(...) catch(...)
{ {
@ -2183,17 +2181,17 @@ bool SMESHGUI_FilterDlg::createFilter( const int theType )
aCriteria->length(n); aCriteria->length(n);
long aPrecision = -1; long aPrecision = -1;
if ( QAD_CONFIG->hasSetting( "SMESH:ControlsPrecision" ) ) SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr();
{
QString aStr = QAD_CONFIG->getSetting( "SMESH:ControlsPrecision" ); if (mgr && mgr->hasValue("SMESH", "ControlsPrecision")) {
QString aStr = mgr->stringValue("SMESH", "ControlsPrecision");
bool isOk = false; bool isOk = false;
int aVal = aStr.toInt(&isOk); int aVal = aStr.toInt(&isOk);
if (isOk) if (isOk)
aPrecision = aVal; aPrecision = aVal;
} }
for ( CORBA::ULong i = 0; i < n; i++ ) for (CORBA::ULong i = 0; i < n; i++) {
{
SMESH::Filter::Criterion aCriterion = createCriterion(); SMESH::Filter::Criterion aCriterion = createCriterion();
myTable->GetCriterion(i, aCriterion); myTable->GetCriterion(i, aCriterion);
aCriterion.Precision = aPrecision; aCriterion.Precision = aPrecision;
@ -2212,16 +2210,14 @@ bool SMESHGUI_FilterDlg::createFilter( const int theType )
//======================================================================= //=======================================================================
void SMESHGUI_FilterDlg::insertFilterInViewer() void SMESHGUI_FilterDlg::insertFilterInViewer()
{ {
if ( VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle() ) if (SVTK_InteractorStyle* aStyle = SMESH::GetInteractorStyle()) {
{
SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType(); SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType();
if (myFilter[ myTable->GetType() ]->_is_nil() || if (myFilter[ myTable->GetType() ]->_is_nil() ||
myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() || myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() ||
!mySetInViewer->isChecked() ) !mySetInViewer->isChecked()) {
SMESH::RemoveFilter(getFilterId(anEntType), aStyle); SMESH::RemoveFilter(getFilterId(anEntType), aStyle);
else } else {
{
Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter(); Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter();
aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate()); aFilter->SetPredicate(myFilter[ myTable->GetType() ]->GetPredicate());
SMESH::SetFilter(aFilter, aStyle); SMESH::SetFilter(aFilter, aStyle);
@ -2287,7 +2283,7 @@ void SMESHGUI_FilterDlg::filterSelectionSource( const int theType,
QValueList<int>& theResIds) QValueList<int>& theResIds)
{ {
theResIds.clear(); theResIds.clear();
if ( myMesh->_is_nil() || mySelection == 0 ) if (myMesh->_is_nil() || mySelectionMgr == 0)
return; return;
// Create map of entities to be filtered // Create map of entities to be filtered
@ -2354,20 +2350,19 @@ void SMESHGUI_FilterDlg::filterSelectionSource( const int theType,
//======================================================================= //=======================================================================
void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QValueList<int>& theIds) void SMESHGUI_FilterDlg::selectInViewer (const int theType, const QValueList<int>& theIds)
{ {
if ( mySelection == 0 || myMesh->_is_nil() ) if (mySelectionMgr == 0 || myMesh->_is_nil())
return; return;
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
// Set new selection mode if necessary // Set new selection mode if necessary
Selection_Mode aSelMode = getSelMode(theType); Selection_Mode aSelMode = getSelMode(theType);
if ( aSelMode != mySelection->SelectionMode() ) if (myViewWindow->SelectionMode()!=aSelMode) {
{ mySelectionMgr->clearSelected();
mySelection->ClearIObjects(); mySelectionMgr->clearFilters();
mySelection->ClearFilters();
if (aSelMode == NodeSelection) if (aSelMode == NodeSelection)
SMESH::SetPointRepresentation(true); SMESH::SetPointRepresentation(true);
QAD_Application::getDesktop()->SetSelectionMode( aSelMode ); myViewWindow->SetSelectionMode(aSelMode);
} }
// Clear selection // Clear selection
@ -2376,8 +2371,11 @@ void SMESHGUI_FilterDlg::selectInViewer( const int theType, const QValueList<int
return; return;
Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
mySelection->ClearIObjects(); //mySelectionMgr->clearSelected();
mySelection->AddIObject( anIO, false ); //mySelectionMgr->AddIObject(anIO, false);
SALOME_ListIO aList;
aList.Append(anIO);
mySelectionMgr->setSelectedObjects(aList, false);
// Remove filter corresponding to the current type from viewer // Remove filter corresponding to the current type from viewer
int aType = myTable->GetType(); int aType = myTable->GetType();
@ -2391,13 +2389,13 @@ void SMESHGUI_FilterDlg::selectInViewer( const int theType, const QValueList<int
// get vtk ids // get vtk ids
TColStd_MapOfInteger aMap; TColStd_MapOfInteger aMap;
QValueList<int>::const_iterator anIter; QValueList<int>::const_iterator anIter;
for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
{
aMap.Add(*anIter); aMap.Add(*anIter);
} }
// Set new selection // Set new selection
mySelection->AddOrRemoveIndex( anIO, aMap, false, true ); mySelector->AddOrRemoveIndex(anIO, aMap, false);
myViewWindow->highlight( anIO, true, true );
// insert previously stored filter in viewer if necessary // insert previously stored filter in viewer if necessary
if (!aFilter.IsNull()) if (!aFilter.IsNull())
@ -2432,7 +2430,9 @@ SMESH::Filter::Criterion SMESHGUI_FilterDlg::createCriterion()
void SMESHGUI_FilterDlg::onSelectionDone() void SMESHGUI_FilterDlg::onSelectionDone()
{ {
int aRow, aCol; int aRow, aCol;
if ( mySelection->IObjectCount() != 1 || const SALOME_ListIO& aList = mySelector->StoredIObjects();
if (aList.Extent() != 1 ||
!myTable->CurrentCell(aRow, aCol) || !myTable->CurrentCell(aRow, aCol) ||
myTable->GetCriterionType(aRow) != FT_BelongToGeom && myTable->GetCriterionType(aRow) != FT_BelongToGeom &&
myTable->GetCriterionType(aRow) != FT_BelongToPlane && myTable->GetCriterionType(aRow) != FT_BelongToPlane &&
@ -2440,7 +2440,7 @@ void SMESHGUI_FilterDlg::onSelectionDone()
myTable->GetCriterionType(aRow) != FT_LyingOnGeom) myTable->GetCriterionType(aRow) != FT_LyingOnGeom)
return; return;
Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject() ; Handle(SALOME_InteractiveObject) anIO = aList.First();
GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO); GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(anIO);
if (!anObj->_is_nil()) if (!anObj->_is_nil())
myTable->SetThreshold(aRow, GEOMBase::GetName(anObj)); myTable->SetThreshold(aRow, GEOMBase::GetName(anObj));
@ -2470,10 +2470,18 @@ void SMESHGUI_FilterDlg::onCurrentChanged( int, int )
//======================================================================= //=======================================================================
void SMESHGUI_FilterDlg::updateSelection() void SMESHGUI_FilterDlg::updateSelection()
{ {
if ( mySelection == 0 ) if (mySelectionMgr == 0)
return; return;
mySelection->ClearFilters(); TColStd_MapOfInteger allTypes;
for( int i=0; i<10; i++ )
allTypes.Add( i );
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
if( !aStudy )
return;
mySelectionMgr->clearFilters();
int aRow, aCol; int aRow, aCol;
@ -2481,44 +2489,24 @@ void SMESHGUI_FilterDlg::updateSelection()
(myTable->GetCriterionType(aRow) == FT_BelongToGeom || (myTable->GetCriterionType(aRow) == FT_BelongToGeom ||
myTable->GetCriterionType(aRow) == FT_BelongToPlane || myTable->GetCriterionType(aRow) == FT_BelongToPlane ||
myTable->GetCriterionType(aRow) == FT_BelongToCylinder || myTable->GetCriterionType(aRow) == FT_BelongToCylinder ||
myTable->GetCriterionType( aRow ) == FT_LyingOnGeom) ) myTable->GetCriterionType(aRow) == FT_LyingOnGeom)) {
{
if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom || myTable->GetCriterionType( aRow ) == FT_LyingOnGeom )
mySelection->AddFilter( new SALOME_TypeFilter( "GEOM" ) );
else if ( myTable->GetCriterionType( aRow ) == FT_BelongToPlane )
mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Plane ) );
else if ( myTable->GetCriterionType( aRow ) == FT_BelongToCylinder )
mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Cylinder ) );
if (myTable->GetCriterionType(aRow) == FT_BelongToGeom ||
myTable->GetCriterionType(aRow) == FT_LyingOnGeom) {
mySelectionMgr->installFilter(new SMESH_NumberFilter("GEOM",TopAbs_SHAPE,0,allTypes));
} else if (myTable->GetCriterionType(aRow) == FT_BelongToPlane) {
mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Plane ) );
} else if (myTable->GetCriterionType(aRow) == FT_BelongToCylinder) {
mySelectionMgr->installFilter(new GEOM_FaceFilter( aStudy, StdSelect_Cylinder ) );
}
myIsSelectionChanged = true; myIsSelectionChanged = true;
}
else } else {
{ if (myIsSelectionChanged) {
if ( myIsSelectionChanged ) mySelectionMgr->installFilter(new SMESH_NumberFilter ("This filter deactivates selection",TopAbs_SHAPE,0,allTypes));
mySelection->AddFilter( new SALOME_TypeFilter( "This filter deactivate selection" ) ); }
} }
} }

View File

@ -34,9 +34,10 @@
#include <qmap.h> #include <qmap.h>
#include <qvaluelist.h> #include <qvaluelist.h>
#include "SALOME_Selection.h" #include "SalomeApp_SelectionMgr.h"
#include "SALOME_InteractiveObject.hxx" #include "SALOME_InteractiveObject.hxx"
#include "SALOME_DataMapOfIOMapOfInteger.hxx" #include "SALOME_DataMapOfIOMapOfInteger.hxx"
#include "SVTK_Selection.h"
#include <TColStd_IndexedMapOfInteger.hxx> #include <TColStd_IndexedMapOfInteger.hxx>
@ -55,16 +56,18 @@ class QStringList;
class QTable; class QTable;
class QTableItem; class QTableItem;
class QWidgetStack; class QWidgetStack;
class SALOME_Selection; class SalomeApp_SelectionMgr;
class SMESHGUI; class SMESHGUI;
class SMESHGUI_FilterLibraryDlg; class SMESHGUI_FilterLibraryDlg;
class SVTK_Selector;
class SVTK_ViewWindow;
/* /*!
Class : SMESHGUI_FilterTable * Class : SMESHGUI_FilterTable
Description : Frame containig * Description : Frame containig
- Button group for switching entity type * - Button group for switching entity type
- Table for displaying filter criterions * - Table for displaying filter criterions
- Buttons for editing table * - Buttons for editing table
*/ */
class SMESHGUI_FilterTable : public QFrame class SMESHGUI_FilterTable : public QFrame
@ -78,7 +81,6 @@ class SMESHGUI_FilterTable : public QFrame
typedef QMap<int, Table*> TableMap; typedef QMap<int, Table*> TableMap;
public: public:
SMESHGUI_FilterTable (QWidget* parent, SMESHGUI_FilterTable (QWidget* parent,
const int type); const int type);
SMESHGUI_FilterTable (QWidget* parent, SMESHGUI_FilterTable (QWidget* parent,
@ -128,7 +130,6 @@ public:
void Update(); void Update();
signals: signals:
void CopyFromClicked(); void CopyFromClicked();
@ -190,13 +191,14 @@ private:
SMESHGUI_FilterLibraryDlg* myLibDlg; SMESHGUI_FilterLibraryDlg* myLibDlg;
QWidgetStack* myWgStack; QWidgetStack* myWgStack;
QMap<QTableItem*, AdditionalWidget*> myAddWidgets; QMap<QTableItem*, AdditionalWidget*> myAddWidgets;
}; };
/* /*!
Class : SMESHGUI_FilterDlg * Class : SMESHGUI_FilterDlg
Description : Dialog to specify filters for VTK viewer * Description : Dialog to specify filters for VTK viewer
*/ */
class SMESHGUI_FilterDlg : public QDialog class SMESHGUI_FilterDlg : public QDialog
@ -210,11 +212,11 @@ class SMESHGUI_FilterDlg : public QDialog
enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close }; enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close };
public: public:
SMESHGUI_FilterDlg( QWidget* parent, SMESHGUI_FilterDlg( SMESHGUI*,
const QValueList<int>& types, const QValueList<int>& types,
const char* name = 0); const char* name = 0);
SMESHGUI_FilterDlg( QWidget* parent, SMESHGUI_FilterDlg( SMESHGUI*,
const int type, const int type,
const char* name = 0); const char* name = 0);
virtual ~SMESHGUI_FilterDlg(); virtual ~SMESHGUI_FilterDlg();
@ -222,7 +224,7 @@ public:
void Init (const QValueList<int>& types); void Init (const QValueList<int>& types);
void Init (const int type); void Init (const int type);
void SetSelection( SALOME_Selection* ); void SetSelection();
void SetMesh (SMESH::SMESH_Mesh_ptr); void SetMesh (SMESH::SMESH_Mesh_ptr);
void SetSourceWg (QWidget*); void SetSourceWg (QWidget*);
@ -246,7 +248,7 @@ private:
void construct (const QValueList<int>& types); void construct (const QValueList<int>& types);
void closeEvent( QCloseEvent* e ); void closeEvent (QCloseEvent*);
void enterEvent (QEvent*); void enterEvent (QEvent*);
// dialog creation // dialog creation
@ -285,7 +287,9 @@ private:
// initial fields // initial fields
QValueList<int> myTypes; QValueList<int> myTypes;
SMESHGUI* mySMESHGUI; SMESHGUI* mySMESHGUI;
SALOME_Selection* mySelection; SalomeApp_SelectionMgr* mySelectionMgr;
SVTK_Selector* mySelector;
SVTK_ViewWindow* myViewWindow;
SMESH::SMESH_Mesh_ptr myMesh; SMESH::SMESH_Mesh_ptr myMesh;
QWidget* mySourceWg; QWidget* mySourceWg;
@ -297,23 +301,3 @@ private:
}; };
#endif #endif

View File

@ -26,13 +26,16 @@
// Module : SMESH // Module : SMESH
#include "SMESHGUI_FilterLibraryDlg.h" #include "SMESHGUI_FilterLibraryDlg.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_FilterUtils.h" #include "SMESHGUI_FilterUtils.h"
#include <QAD_Desktop.h> #include "SUIT_Session.h"
#include <QAD_FileDlg.h> #include "SUIT_Desktop.h"
#include "SUIT_FileDlg.h"
// QT Includes
#include <qapplication.h> #include <qapplication.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include <qframe.h> #include <qframe.h>
@ -49,12 +52,12 @@
#define SPACING 5 #define SPACING 5
#define MARGIN 10 #define MARGIN 10
/* /*!
Class : SMESHGUI_FilterLibraryDlg::Dialog * Class : SMESHGUI_FilterLibraryDlg::Dialog
Description : Dialog for opening filter library * Description : Dialog for opening filter library
*/ */
class SMESHGUI_FilterLibraryDlg::Dialog : public QAD_FileDlg class SMESHGUI_FilterLibraryDlg::Dialog : public SUIT_FileDlg
{ {
public: public:
Dialog(QWidget* theParent, const bool theToOpen); Dialog(QWidget* theParent, const bool theToOpen);
@ -66,7 +69,7 @@ protected:
SMESHGUI_FilterLibraryDlg::Dialog::Dialog (QWidget* theParent, SMESHGUI_FilterLibraryDlg::Dialog::Dialog (QWidget* theParent,
const bool theToOpen) const bool theToOpen)
: QAD_FileDlg( theParent, theToOpen ) : SUIT_FileDlg(theParent, theToOpen)
{ {
} }
@ -76,16 +79,17 @@ SMESHGUI_FilterLibraryDlg::Dialog::~Dialog()
bool SMESHGUI_FilterLibraryDlg::Dialog::acceptData() bool SMESHGUI_FilterLibraryDlg::Dialog::acceptData()
{ {
#ifdef NEW_GUI
if (mode() != QFileDialogP::AnyFile) if (mode() != QFileDialogP::AnyFile)
return QAD_FileDlg::acceptData(); return SUIT_FileDlg::acceptData();
else #endif
return true; return true;
} }
/*!
/* * Class : SMESHGUI_FilterLibraryDlg
Class : SMESHGUI_FilterLibraryDlg * Description : Dialog to specify filters for VTK viewer
Description : Dialog to specify filters for VTK viewer
*/ */
//======================================================================= //=======================================================================
@ -96,8 +100,8 @@ SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg( QWidget* the
const QValueList<int>& theTypes, const QValueList<int>& theTypes,
const int theMode, const int theMode,
const char* theName) const char* theName)
: QDialog( theParent, theName, true, : QDialog(theParent, theName, true, WStyle_Customize |
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
{ {
construct(theTypes, theMode); construct(theTypes, theMode);
} }
@ -110,8 +114,8 @@ SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg( QWidget* theParent,
const int theType, const int theType,
const int theMode, const int theMode,
const char* theName) const char* theName)
: QDialog( theParent, theName, true, : QDialog(theParent, theName, true, WStyle_Customize |
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
{ {
QValueList<int> aTypes; QValueList<int> aTypes;
aTypes.append(theType); aTypes.append(theType);
@ -122,7 +126,8 @@ SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg( QWidget* theParent,
// name : SMESHGUI_FilterLibraryDlg::construct // name : SMESHGUI_FilterLibraryDlg::construct
// Purpose : Construct dialog (called by constructor) // Purpose : Construct dialog (called by constructor)
//======================================================================= //=======================================================================
void SMESHGUI_FilterLibraryDlg::construct( const QValueList<int>& theTypes, const int theMode ) void SMESHGUI_FilterLibraryDlg::construct (const QValueList<int>& theTypes,
const int theMode)
{ {
myTypes = theTypes; myTypes = theTypes;
myMode = theMode; myMode = theMode;
@ -159,8 +164,8 @@ QFrame* SMESHGUI_FilterLibraryDlg::createMainFrame( QWidget* theParent )
new QLabel(tr("LIBRARY_FILE"), aGrp); new QLabel(tr("LIBRARY_FILE"), aGrp);
myFileName = new QLineEdit(aGrp); myFileName = new QLineEdit(aGrp);
myOpenBtn = new QPushButton(aGrp); myOpenBtn = new QPushButton(aGrp);
myOpenBtn->setPixmap( QAD_Desktop::getResourceManager()->loadPixmap( myOpenBtn->setPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap(
"QAD", tr("ICON_FILE_OPEN") ) ); "SUIT", tr("ICON_FILE_OPEN")));
// filters list box // filters list box
@ -258,14 +263,11 @@ QFrame* SMESHGUI_FilterLibraryDlg::createButtonFrame( QWidget* theParent )
//======================================================================= //=======================================================================
void SMESHGUI_FilterLibraryDlg::updateMainButtons() void SMESHGUI_FilterLibraryDlg::updateMainButtons()
{ {
if ( myTypes.count() == 1 ) if (myTypes.count() == 1) {
{
myButtons[ BTN_Cancel ]->show(); myButtons[ BTN_Cancel ]->show();
myButtons[ BTN_Apply ]->hide(); myButtons[ BTN_Apply ]->hide();
myButtons[ BTN_Close ]->hide(); myButtons[ BTN_Close ]->hide();
} } else {
else
{
myButtons[ BTN_Cancel ]->hide(); myButtons[ BTN_Cancel ]->hide();
myButtons[ BTN_Apply ]->show(); myButtons[ BTN_Apply ]->show();
myButtons[ BTN_Close ]->show(); myButtons[ BTN_Close ]->show();
@ -295,7 +297,8 @@ void SMESHGUI_FilterLibraryDlg::Init( const int type, const int theMode )
// name : SMESHGUI_FilterLibraryDlg::Init // name : SMESHGUI_FilterLibraryDlg::Init
// Purpose : Init dialog fields, connect signals and slots, show dialog // Purpose : Init dialog fields, connect signals and slots, show dialog
//======================================================================= //=======================================================================
void SMESHGUI_FilterLibraryDlg::Init( const QValueList<int>& theTypes, const int theMode ) void SMESHGUI_FilterLibraryDlg::Init (const QValueList<int>& theTypes,
const int theMode)
{ {
myMode = theMode; myMode = theMode;
myTypes = theTypes; myTypes = theTypes;
@ -395,10 +398,9 @@ bool SMESHGUI_FilterLibraryDlg::onApply()
if (!isValid(true) || !isPermissionValid(false)) if (!isValid(true) || !isPermissionValid(false))
return false; return false;
if ( myLibrary->_is_nil() ) if (myLibrary->_is_nil()) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("LIBRARY_IS_NOT_LOADED"), QMessageBox::Ok);
tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok );
return false; return false;
} }
@ -408,17 +410,13 @@ bool SMESHGUI_FilterLibraryDlg::onApply()
bool aResult = false; bool aResult = false;
if ( myMode == COPY_FROM || myListBox->count() == 0 ) if (myMode == COPY_FROM || myListBox->count() == 0) {
{
aResult = true; aResult = true;
} } else if (myMode == EDIT || myMode == ADD_TO) {
else if ( myMode == EDIT || myMode == ADD_TO )
{
SMESH::Filter_var aFilter = createFilter(); SMESH::Filter_var aFilter = createFilter();
if ( !myLibrary->Replace( myCurrFilterName, myName->text(), aFilter.in() ) ) if (!myLibrary->Replace(myCurrFilterName, myName->text(), aFilter.in())) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("ERROR_OF_EDITING"), QMessageBox::Ok);
tr( "SMESH_ERROR" ), tr( "ERROR_OF_EDITING" ), QMessageBox::Ok );
aResult = false; aResult = false;
} }
else else
@ -428,16 +426,15 @@ bool SMESHGUI_FilterLibraryDlg::onApply()
if (aResult && myMode != COPY_FROM) if (aResult && myMode != COPY_FROM)
aResult = myLibrary->Save(); aResult = myLibrary->Save();
if ( aResult ) if (aResult) {
{
char* aFileName = myLibrary->GetFileName(); char* aFileName = myLibrary->GetFileName();
getDefaultLibraryName() = QString(aFileName); getDefaultLibraryName() = QString(aFileName);
delete aFileName; delete aFileName;
} else if (myMode != COPY_FROM) {
QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
tr("ERROR_OF_SAVING"), QMessageBox::Ok);
} else {
} }
else if ( myMode != COPY_FROM )
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
tr( "SMESH_ERROR" ), tr( "ERROR_OF_SAVING" ), QMessageBox::Ok );
return aResult; return aResult;
} }
@ -571,7 +568,8 @@ void SMESHGUI_FilterLibraryDlg::onBrowse()
Dialog* aDlg = new Dialog(this, true); Dialog* aDlg = new Dialog(this, true);
aDlg->setCaption(tr("OPEN_LIBRARY")); aDlg->setCaption(tr("OPEN_LIBRARY"));
aDlg->setMode( myMode == COPY_FROM ? QFileDialogP::ExistingFile : QFileDialogP::AnyFile ); //aDlg->setMode(myMode == COPY_FROM ? QFileDialogP::ExistingFile : QFileDialogP::AnyFile);
aDlg->setMode(myMode == COPY_FROM ? QFileDialog::ExistingFile : QFileDialog::AnyFile);
aDlg->setFilters(prepareFilters()); aDlg->setFilters(prepareFilters());
aDlg->setSelection(getFileName()); aDlg->setSelection(getFileName());
@ -623,16 +621,12 @@ void SMESHGUI_FilterLibraryDlg::processNewLibrary()
return; return;
myLibrary = aFilterMgr->LoadLibrary(autoExtension(getFileName())); myLibrary = aFilterMgr->LoadLibrary(autoExtension(getFileName()));
if ( myLibrary->_is_nil() ) if (myLibrary->_is_nil()) {
{ if (myMode == COPY_FROM) {
if ( myMode == COPY_FROM ) QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
{ tr("ERROR_LOAD"), QMessageBox::Ok);
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(),
tr( "SMESH_ERROR" ), tr( "ERROR_LOAD" ), QMessageBox::Ok );
return; return;
} } else {
else
{
myLibrary = aFilterMgr->CreateLibrary(); myLibrary = aFilterMgr->CreateLibrary();
myLibrary->SetFileName(getFileName().latin1()); myLibrary->SetFileName(getFileName().latin1());
} }
@ -679,25 +673,21 @@ void SMESHGUI_FilterLibraryDlg::updateList()
bool SMESHGUI_FilterLibraryDlg::isNameValid(const bool theMess) const bool SMESHGUI_FilterLibraryDlg::isNameValid(const bool theMess) const
{ {
// verify validity of filter name // verify validity of filter name
if ( myName->isEnabled() && !myCurrFilterName.isEmpty() ) if (myName->isEnabled() && !myCurrFilterName.isEmpty()) {
{
QString aCurrName = myName->text(); QString aCurrName = myName->text();
if ( aCurrName.isEmpty() ) if (aCurrName.isEmpty()) {
{
if (theMess) if (theMess)
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "EMPTY_FILTER_NAME" ), QMessageBox::Ok ); tr("EMPTY_FILTER_NAME"), QMessageBox::Ok);
return false; return false;
} }
SMESH::string_array_var aNames = myLibrary->GetAllNames(); SMESH::string_array_var aNames = myLibrary->GetAllNames();
for ( int f = 0, n = aNames->length(); f < n; f++ ) for (int f = 0, n = aNames->length(); f < n; f++) {
{ if (aNames[ f ] == aCurrName && aNames[ f ] != myCurrFilterName) {
if ( aNames[ f ] == aCurrName && aNames[ f ] != myCurrFilterName )
{
if (theMess) if (theMess)
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR_FILTER_NAME" ), QMessageBox::Ok ); tr("ERROR_FILTER_NAME"), QMessageBox::Ok);
return false; return false;
} }
} }
@ -724,10 +714,9 @@ bool SMESHGUI_FilterLibraryDlg::isPermissionValid( const bool theIsExistingOnly
fName = QDir::convertSeparators(fName); fName = QDir::convertSeparators(fName);
if ( QFileInfo( fName ).exists() ) if (QFileInfo(fName).exists()) {
isWritable = QFileInfo(fName).isWritable(); isWritable = QFileInfo(fName).isWritable();
else if ( !theIsExistingOnly ) } else if (!theIsExistingOnly) {
{
QFileInfo aDirInfo(QFileInfo(fName).dirPath(true)); QFileInfo aDirInfo(QFileInfo(fName).dirPath(true));
isWritable = aDirInfo.isWritable(); isWritable = aDirInfo.isWritable();
/*if (QDir(QFileInfo(fName).dirPath(true)).exists() || /*if (QDir(QFileInfo(fName).dirPath(true)).exists() ||
@ -740,14 +729,13 @@ bool SMESHGUI_FilterLibraryDlg::isPermissionValid( const bool theIsExistingOnly
aFile.close(); aFile.close();
} }
*/ */
} } else {
else
isWritable = true; isWritable = true;
}
if ( !isWritable ) if (!isWritable) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("NO_PERMISSION"), QMessageBox::Ok);
tr( "SMESH_WRN_WARNING" ), tr( "NO_PERMISSION" ), QMessageBox::Ok );
return false; return false;
} }
@ -899,16 +887,15 @@ void SMESHGUI_FilterLibraryDlg::onAddBtnPressed()
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_FilterLibraryDlg::onAddBtnPressed // name : onAddBtnPressed()
// Purpose : SLOT. Called when "Add" button pressed // Purpose : SLOT. Called when "Add" button pressed
// Add new filter to the end of library // Add new filter to the end of library
//======================================================================= //=======================================================================
void SMESHGUI_FilterLibraryDlg::addFilterToLib (const QString& theName) void SMESHGUI_FilterLibraryDlg::addFilterToLib (const QString& theName)
{ {
if ( myLibrary->_is_nil() ) if (myLibrary->_is_nil()) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("LIBRARY_IS_NOT_LOADED"), QMessageBox::Ok);
tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok );
return; return;
} }
@ -930,10 +917,9 @@ void SMESHGUI_FilterLibraryDlg::addFilterToLib( const QString& theName )
? myLibrary->Add(aName.latin1(), aFilter) ? myLibrary->Add(aName.latin1(), aFilter)
: myLibrary->AddEmpty(aName.latin1(), (SMESH::ElementType)myTable->GetType()); : myLibrary->AddEmpty(aName.latin1(), (SMESH::ElementType)myTable->GetType());
if ( !aResult ) if (!aResult) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("ERROR_OF_ADDING"), QMessageBox::Ok);
tr( "SMESH_ERROR" ), tr( "ERROR_OF_ADDING" ), QMessageBox::Ok );
} }
updateList(); updateList();
@ -942,7 +928,7 @@ void SMESHGUI_FilterLibraryDlg::addFilterToLib( const QString& theName )
setSelected(aName); setSelected(aName);
if (theName != aName) if (theName != aName)
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr( "SMESH_WARNING" ), QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WARNING"),
tr("ASSIGN_NEW_NAME").arg(theName).arg(aName), QMessageBox::Ok); tr("ASSIGN_NEW_NAME").arg(theName).arg(aName), QMessageBox::Ok);
} }
@ -1041,22 +1027,18 @@ int SMESHGUI_FilterLibraryDlg::getIndex( const QString& theName ) const
//======================================================================= //=======================================================================
void SMESHGUI_FilterLibraryDlg::onDeleteBtnPressed() void SMESHGUI_FilterLibraryDlg::onDeleteBtnPressed()
{ {
if ( myLibrary->_is_nil() ) if (myLibrary->_is_nil()) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_WRN_WARNING"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("LIBRARY_IS_NOT_LOADED"), QMessageBox::Ok);
tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok );
return; return;
} }
int anIndex = getIndex(myCurrFilterName); int anIndex = getIndex(myCurrFilterName);
if ( anIndex == -1 || !myLibrary->Delete( myCurrFilterName.latin1() ) ) if (anIndex == -1 || !myLibrary->Delete(myCurrFilterName.latin1())) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("ERROR_OF_DELETING"), QMessageBox::Ok);
tr( "SMESH_ERROR" ), tr( "ERROR_OF_DELETING" ), QMessageBox::Ok ); } else {
}
else
{
myCurrFilterName = ""; myCurrFilterName = "";
myCurrFilterName = -1; myCurrFilterName = -1;
myListBox->removeItem(anIndex); myListBox->removeItem(anIndex);
@ -1070,15 +1052,14 @@ void SMESHGUI_FilterLibraryDlg::onDeleteBtnPressed()
} }
myTable->SetEnabled(myListBox->count() > 0); myTable->SetEnabled(myListBox->count() > 0);
if ( myListBox->count() == 0 ) if (myListBox->count() == 0) {
{
myName->setText(""); myName->setText("");
myName->setEnabled(false); myName->setEnabled(false);
} }
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_FilterLibraryDlg::onFilterNameChanged // name : onFilterNameChanged()
// Purpose : SLOT. Called when name of filter changed // Purpose : SLOT. Called when name of filter changed
// Change filter name in list box // Change filter name in list box
//======================================================================= //=======================================================================
@ -1150,10 +1131,3 @@ void SMESHGUI_FilterLibraryDlg::onNeedValidation()
} }
} }
} }

View File

@ -19,19 +19,13 @@
#include "SMESHGUI_FilterUtils.h" #include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_SMESHGenUtils.h"
#include "SMESHGUI.h"
namespace SMESH namespace SMESH
{ {
SMESH::FilterManager_var GetFilterManager() SMESH::FilterManager_var GetFilterManager()
{ {
static SMESH::FilterManager_var aFilterManager; return SMESHGUI::GetSMESHGen()->CreateFilterManager(); // DumpPython
if(CORBA::is_nil(aFilterManager)){
aFilterManager = GetSMESHGen()->CreateFilterManager();
} }
return aFilterManager;
}
} }

View File

@ -17,32 +17,36 @@
// //
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include <boost/shared_ptr.hpp>
#include "QAD_Desktop.h"
#include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include <GeometryGUI.h>
#include <SALOMEDSClient_SObject.hxx>
#include <SALOMEDSClient_ChildIterator.hxx>
#include <SALOMEDS_SObject.hxx>
#include CORBA_CLIENT_HEADER(SMESH_Mesh) #include CORBA_CLIENT_HEADER(SMESH_Mesh)
namespace SMESH { namespace SMESH {
GEOM::GEOM_Gen_var GetGEOMGen() GEOM::GEOM_Gen_var GetGEOMGen()
{ {
static GEOM::GEOM_Gen_var aGEOMGen; static GEOM::GEOM_Gen_var aGEOMGen;
if(CORBA::is_nil(aGEOMGen)){
if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){ if(CORBA::is_nil(aGEOMGen))
Engines::Component_var aComponent = aDesktop->getEngine("FactoryServer","GEOM"); aGEOMGen = GeometryGUI::GetGeomGen();
aGEOMGen = GEOM::GEOM_Gen::_narrow(aComponent);
}
}
return aGEOMGen; return aGEOMGen;
} }
GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh)
GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr theMeshOrSubmesh)
{ {
if(!theMeshOrSubmesh->_is_nil()) { SALOMEDS_SObject* aMeshOrSubmesh = _CAST(SObject,theMeshOrSubmesh);
CORBA::Object_var Obj = theMeshOrSubmesh->GetObject(); if(aMeshOrSubmesh) {
CORBA::Object_var Obj = aMeshOrSubmesh->GetObject();
if ( !CORBA::is_nil( Obj ) ) { if ( !CORBA::is_nil( Obj ) ) {
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh_var aMesh =
SObjectToInterface<SMESH::SMESH_Mesh>( theMeshOrSubmesh ); SObjectToInterface<SMESH::SMESH_Mesh>( theMeshOrSubmesh );
@ -57,4 +61,32 @@ namespace SMESH{
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
} }
GEOM::GEOM_Object_ptr GetGeom (_PTR(SObject) theSO)
{
if (!theSO)
return GEOM::GEOM_Object::_nil();
_PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
if (!aStudy)
return GEOM::GEOM_Object::_nil();
_PTR(ChildIterator) anIter (aStudy->NewChildIterator(theSO));
for (; anIter->More(); anIter->Next()) {
_PTR(SObject) aSObject = anIter->Value();
_PTR(SObject) aRefSOClient;
GEOM::GEOM_Object_var aMeshShape;
if (aSObject->ReferencedObject(aRefSOClient)) {
SALOMEDS_SObject* aRefSO = _CAST(SObject,aRefSOClient);
aMeshShape = GEOM::GEOM_Object::_narrow(aRefSO->GetObject());
} else {
SALOMEDS_SObject* aSO = _CAST(SObject,aSObject);
aMeshShape = GEOM::GEOM_Object::_narrow(aSO->GetObject());
}
if (!aMeshShape->_is_nil())
return aMeshShape._retn();
}
return GEOM::GEOM_Object::_nil();
}
} }

View File

@ -22,17 +22,18 @@
#include "SALOMEconfig.h" #include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(GEOM_Gen) #include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_CLIENT_HEADER(SALOMEDS)
#include "SALOMEDSClient_definitions.hxx"
class SALOMEDSClient_SObject;
namespace SMESH namespace SMESH
{ {
GEOM::GEOM_Gen_var GetGEOMGen(); GEOM::GEOM_Gen_var GetGEOMGen();
GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr theSObject); GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh (_PTR(SObject) theSObject);
GEOM::GEOM_Object_ptr GetGeom (_PTR(SObject) theSO);
} }
#endif #endif

View File

@ -28,7 +28,6 @@
#include "SMESHGUI_GroupDlg.h" #include "SMESHGUI_GroupDlg.h"
#include "SMESHGUI_FilterDlg.h" #include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_Filter.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
@ -38,18 +37,25 @@
#include "SMESHGUI_FilterUtils.h" #include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_GEOMGenUtils.h" #include "SMESHGUI_GEOMGenUtils.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx" #include "SMESH_TypeFilter.hxx"
#include "SMESH_Actor.h"
#include "GEOMBase.h"
#include "SUIT_Desktop.h"
#include "SUIT_ResourceMgr.h"
#include "SalomeApp_Tools.h"
#include "SALOMEDSClient_Study.hxx"
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx"
#include "VTKViewer_ViewFrame.h"
#include "QAD_Application.h" #include "SVTK_ViewWindow.h"
#include "QAD_Desktop.h" #include "SVTK_Selector.h"
#include "QAD_MessageBox.h"
#include "QAD_RightFrame.h"
#include "utilities.h" #include "utilities.h"
#include "SMESH_Actor.h" // OCCT Includes
#include <TColStd_MapOfInteger.hxx>
#include "GEOMBase.h"
// QT Includes // QT Includes
#include <qbuttongroup.h> #include <qbuttongroup.h>
@ -74,15 +80,20 @@
using namespace std; using namespace std;
//================================================================================= //=================================================================================
// class : SMESHGUI_GroupDlg() // function : SMESHGUI_GroupDlg()
// purpose : // purpose :
//================================================================================= //=================================================================================
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl) SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl)
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu | WDestructiveClose),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myViewWindow( SMESH::GetViewWindow( theModule ) ),
mySelector( myViewWindow->GetSelector() )
{ {
if (!name) setName("SMESHGUI_GroupDlg"); if (!name) setName("SMESHGUI_GroupDlg");
initDialog(theSel, true); initDialog(true);
if (!theMesh->_is_nil()) if (!theMesh->_is_nil())
init(theMesh); init(theMesh);
else { else {
@ -98,12 +109,21 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_
this->move(x, y); this->move(x, y);
} }
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, //=================================================================================
// function : SMESHGUI_GroupDlg()
// purpose :
//=================================================================================
SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl) SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl)
: QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu | WDestructiveClose),
mySMESHGUI( theModule ),
mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
myViewWindow( SMESH::GetViewWindow( theModule ) ),
mySelector( myViewWindow->GetSelector() )
{ {
if (!name) setName("SMESHGUI_GroupDlg"); if (!name) setName("SMESHGUI_GroupDlg");
initDialog(theSel, false); initDialog(false);
if (!theGroup->_is_nil()) if (!theGroup->_is_nil())
init(theGroup); init(theGroup);
else { else {
@ -117,13 +137,17 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_
this->move(x, y); this->move(x, y);
} }
void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) //=================================================================================
// function : SMESHGUI_GroupDlg()
// purpose :
//=================================================================================
void SMESHGUI_GroupDlg::initDialog(bool create)
{ {
myFilterDlg = 0; myFilterDlg = 0;
myCreate = create; myCreate = create;
myCurrentLineEdit = 0; myCurrentLineEdit = 0;
QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
if (create) if (create)
setCaption(tr("SMESH_CREATE_GROUP_TITLE")); setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
@ -331,8 +355,6 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create)
connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
/* Init selection */ /* Init selection */
mySelection = theSel;
mySMESHGUI = SMESHGUI::GetSMESHGUI();
mySMESHGUI->SetActiveDialogBox(this); mySMESHGUI->SetActiveDialogBox(this);
mySMESHGUI->SetState(800); mySMESHGUI->SetState(800);
@ -343,7 +365,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create)
connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate())); connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose())); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!! myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!! onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
@ -368,7 +390,6 @@ SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
} }
} }
//================================================================================= //=================================================================================
// function : Init() // function : Init()
// purpose : // purpose :
@ -382,7 +403,9 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh)
myActor = SMESH::FindActorByObject(myMesh); myActor = SMESH::FindActorByObject(myMesh);
SMESH::SetPickable(myActor); SMESH::SetPickable(myActor);
QString aName = mySelection->firstIObject()->getName(); const SALOME_ListIO& aList = mySelector->StoredIObjects();
QString aName = aList.First()->getName();
myMeshGroupLine->setText(aName) ; myMeshGroupLine->setText(aName) ;
myMeshGroupLine->home( false ); myMeshGroupLine->home( false );
@ -436,7 +459,6 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup)
} }
} }
//================================================================================= //=================================================================================
// function : updateButtons() // function : updateButtons()
// purpose : // purpose :
@ -503,8 +525,8 @@ void SMESHGUI_GroupDlg::setSelectionMode(int theMode)
return; return;
if (mySelectionMode != theMode) { if (mySelectionMode != theMode) {
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
SMESH::SetPointRepresentation(false); SMESH::SetPointRepresentation(false);
if (theMode < 4) { if (theMode < 4) {
switch (theMode) { switch (theMode) {
@ -513,26 +535,25 @@ void SMESHGUI_GroupDlg::setSelectionMode(int theMode)
myActor->SetPointRepresentation(true); myActor->SetPointRepresentation(true);
else else
SMESH::SetPointRepresentation(true); SMESH::SetPointRepresentation(true);
QAD_Application::getDesktop()->SetSelectionMode(NodeSelection, true); myViewWindow->SetSelectionMode(NodeSelection);
break; break;
case 1: case 1:
QAD_Application::getDesktop()->SetSelectionMode(EdgeSelection, true); myViewWindow->SetSelectionMode(EdgeSelection);
break; break;
case 2: case 2:
QAD_Application::getDesktop()->SetSelectionMode(FaceSelection, true); myViewWindow->SetSelectionMode(FaceSelection);
break; break;
default: default:
QAD_Application::getDesktop()->SetSelectionMode(VolumeSelection, true); myViewWindow->SetSelectionMode(VolumeSelection);
} }
} } else {
else { myViewWindow->SetSelectionMode(ActorSelection);
QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true);
if (theMode == 4) if (theMode == 4)
mySelection->AddFilter(mySubMeshFilter); mySelectionMgr->installFilter(mySubMeshFilter);
else if (theMode == 5) else if (theMode == 5)
mySelection->AddFilter(myGroupFilter); mySelectionMgr->installFilter(myGroupFilter);
else if (theMode == 6) else if (theMode == 6)
mySelection->AddFilter(myMeshFilter); mySelectionMgr->installFilter(myMeshFilter);
} }
mySelectionMode = theMode; mySelectionMode = theMode;
} }
@ -544,11 +565,13 @@ void SMESHGUI_GroupDlg::setSelectionMode(int theMode)
//================================================================================= //=================================================================================
bool SMESHGUI_GroupDlg::onApply() bool SMESHGUI_GroupDlg::onApply()
{ {
if (mySMESHGUI->ActiveStudyLocked()) if (mySMESHGUI->isActiveStudyLocked())
return false; return false;
if ( myGrpTypeId == 0 && !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0) { if (myGrpTypeId == 0 &&
mySelection->ClearIObjects(); !myName->text().stripWhiteSpace().isEmpty() &&
myElements->count() > 0) {
mySelectionMgr->clearSelected();
if (myGroup->_is_nil()) { if (myGroup->_is_nil()) {
SMESH::ElementType aType = SMESH::ALL; SMESH::ElementType aType = SMESH::ALL;
switch(myTypeId) { switch(myTypeId) {
@ -572,8 +595,8 @@ bool SMESHGUI_GroupDlg::onApply()
myName->setText(""); myName->setText("");
myElements->clear(); myElements->clear();
myGroup = SMESH::SMESH_Group::_nil(); myGroup = SMESH::SMESH_Group::_nil();
}
else { } else {
myGroup->SetName(myName->text()); myGroup->SetName(myName->text());
QValueList<int> aAddList; QValueList<int> aAddList;
@ -609,12 +632,13 @@ bool SMESHGUI_GroupDlg::onApply()
myIdList.append(anItem->text().toInt()); myIdList.append(anItem->text().toInt());
} }
mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); mySMESHGUI->updateObjBrowser(true);
SMESH::UpdateView(); // asv: fix of BUG PAL5515 SMESH::UpdateView(); // asv: fix of BUG PAL5515
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
return true; return true;
} } else if (myGrpTypeId == 1 &&
else if (myGrpTypeId == 1 && !myName->text().stripWhiteSpace().isEmpty() && !CORBA::is_nil( myGeomGroup )) !myName->text().stripWhiteSpace().isEmpty() &&
!CORBA::is_nil(myGeomGroup))
{ {
SMESH::ElementType aType = SMESH::ALL; SMESH::ElementType aType = SMESH::ALL;
switch (myTypeId) { switch (myTypeId) {
@ -624,13 +648,15 @@ bool SMESHGUI_GroupDlg::onApply()
case 3: aType = SMESH::VOLUME; break; case 3: aType = SMESH::VOLUME; break;
} }
SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); GEOM::GEOM_IGroupOperations_var aGroupOp =
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup); SMESH::SMESH_GroupOnGeom_var aGroupOnGeom =
myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup);
mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); mySMESHGUI->updateObjBrowser(true);
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
/* init for next operation */ /* init for next operation */
myName->setText(""); myName->setText("");
return true; return true;
@ -661,7 +687,7 @@ void SMESHGUI_GroupDlg::onListSelectionChanged()
busy = true; busy = true;
if (myCurrentLineEdit == 0) { if (myCurrentLineEdit == 0) {
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
TColStd_MapOfInteger aIndexes; TColStd_MapOfInteger aIndexes;
QListBoxItem* anItem; QListBoxItem* anItem;
for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
@ -670,8 +696,11 @@ void SMESHGUI_GroupDlg::onListSelectionChanged()
aIndexes.Add(anId); aIndexes.Add(anId);
} }
} }
mySelection->AddOrRemoveIndex(myActor->getIO(), aIndexes, false, false); mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
mySelection->AddIObject(myActor->getIO()); SALOME_ListIO aList;
aList.Append(myActor->getIO());
mySelectionMgr->setSelectedObjects(aList,false);
myViewWindow->highlight( myActor->getIO(), true, true );
} }
busy = false; busy = false;
} }
@ -685,15 +714,16 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
if (busy || !isEnabled()) return; if (busy || !isEnabled()) return;
busy = true; busy = true;
int aNbSel = mySelection->IObjectCount(); const SALOME_ListIO& aList = mySelector->StoredIObjects();
int aNbSel = aList.Extent();
myElements->clearSelection(); myElements->clearSelection();
if (myCurrentLineEdit) { if (myCurrentLineEdit) {
myCurrentLineEdit->setText(""); myCurrentLineEdit->setText("");
QString aString = ""; QString aString = "";
if (myCurrentLineEdit == myMeshGroupLine) if (myCurrentLineEdit == myMeshGroupLine) {
{
mySelectSubMesh->setEnabled(false); mySelectSubMesh->setEnabled(false);
mySelectGroup->setEnabled(false); mySelectGroup->setEnabled(false);
myGroupLine->setText(""); myGroupLine->setText("");
@ -707,26 +737,27 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
myElements->clear(); myElements->clear();
if(aNbSel != 1) if (aNbSel != 1) {
{
myGroup = SMESH::SMESH_Group::_nil(); myGroup = SMESH::SMESH_Group::_nil();
myMesh = SMESH::SMESH_Mesh::_nil(); myMesh = SMESH::SMESH_Mesh::_nil();
busy = false; busy = false;
return; return;
} }
Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); Handle(SALOME_InteractiveObject) IO = aList.First();
if (myCreate) if (myCreate) {
{
myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO); myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
if (myMesh->_is_nil()) if (myMesh->_is_nil())
{
busy = false;
return; return;
}
myGroup = SMESH::SMESH_Group::_nil(); myGroup = SMESH::SMESH_Group::_nil();
myActor = SMESH::FindActorByObject(myMesh); myActor = SMESH::FindActorByObject(myMesh);
SMESH::SetPickable(myActor); SMESH::SetPickable(myActor);
aString = mySelection->firstIObject()->getName(); aString = aList.First()->getName();
myMeshGroupLine->setText(aString) ; myMeshGroupLine->setText(aString) ;
myMeshGroupLine->home( false ); myMeshGroupLine->home( false );
@ -735,12 +766,13 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
myGeomGroupBtn->setEnabled(true); myGeomGroupBtn->setEnabled(true);
myGeomGroupLine->setEnabled(true); myGeomGroupLine->setEnabled(true);
updateButtons(); updateButtons();
} } else {
else
{
SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(IO); SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(IO);
if (aGroup->_is_nil()) if (aGroup->_is_nil())
{
busy = false;
return; return;
}
busy = false; busy = false;
myCurrentLineEdit = 0; myCurrentLineEdit = 0;
init(aGroup); init(aGroup);
@ -753,75 +785,79 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
myCurrentLineEdit = 0; myCurrentLineEdit = 0;
busy = false; busy = false;
if (!myCreate) if (!myCreate)
{
busy = false;
return; return;
}
if (myTypeId == -1) if (myTypeId == -1)
onTypeChanged(0); onTypeChanged(0);
else else {
{
myElements->clear(); myElements->clear();
setSelectionMode(myTypeId); setSelectionMode(myTypeId);
} }
busy = false;
return; return;
}
else if (myCurrentLineEdit == myGeomGroupLine)
{
if(aNbSel != 1) } else if (myCurrentLineEdit == myGeomGroupLine) {
{ if (aNbSel != 1) {
myGeomGroup = GEOM::GEOM_Object::_nil(); myGeomGroup = GEOM::GEOM_Object::_nil();
busy = false; busy = false;
return; return;
} }
Standard_Boolean testResult = Standard_False; Standard_Boolean testResult = Standard_False;
myGeomGroup = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); myGeomGroup = GEOMBase::ConvertIOinGEOMObject(aList.First(), testResult);
// Check if the object is a geometry group // Check if the object is a geometry group
if(!testResult || CORBA::is_nil( myGeomGroup )) if (!testResult || CORBA::is_nil(myGeomGroup)) {
{
myGeomGroup = GEOM::GEOM_Object::_nil(); myGeomGroup = GEOM::GEOM_Object::_nil();
busy = false; busy = false;
return; return;
} }
// Check if group constructed on the same shape as a mesh or on its child // Check if group constructed on the same shape as a mesh or on its child
SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
GEOM::GEOM_IGroupOperations_var anOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); GEOM::GEOM_IGroupOperations_var anOp =
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
// The main shape of the group // The main shape of the group
GEOM::GEOM_Object_var aGroupMainShape; GEOM::GEOM_Object_var aGroupMainShape;
if (myGeomGroup->GetType() == 37) if (myGeomGroup->GetType() == 37)
aGroupMainShape = anOp->GetMainShape(myGeomGroup); aGroupMainShape = anOp->GetMainShape(myGeomGroup);
else else
aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup); aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup);
SALOMEDS::SObject_var aGroupMainShapeSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(aGroupMainShape) ); _PTR(SObject) aGroupMainShapeSO =
//aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
aStudy->FindObjectIOR(aGroupMainShape->GetStudyEntry());
// The mesh SObject // The mesh SObject
SALOMEDS::SObject_var aMeshSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myMesh) ); _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
if ( aMeshSO->_is_nil() ) { if (!aMeshSO) {
myGeomGroup = GEOM::GEOM_Object::_nil(); myGeomGroup = GEOM::GEOM_Object::_nil();
busy = false; busy = false;
return; return;
} }
SALOMEDS::SObject_var anObj, aRef; _PTR(SObject) anObj, aRef;
bool isRefOrSubShape = false; bool isRefOrSubShape = false;
if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) { if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
if ( strcmp( aRef->GetID(), aGroupMainShapeSO->GetID() ) == 0 ) //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
isRefOrSubShape = true; isRefOrSubShape = true;
else } else {
{ _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
SALOMEDS::SObject_var aFather = aGroupMainShapeSO->GetFather(); _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
SALOMEDS::SComponent_var aComponent = aGroupMainShapeSO->GetFatherComponent(); //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
while ( !isRefOrSubShape && strcmp( aFather->GetID(), aComponent->GetID() ) != 0 ) while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
{ //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
if (strcmp( aRef->GetID(), aFather->GetID() ) == 0) if (aRef->GetID() == aFather->GetID())
isRefOrSubShape = true; isRefOrSubShape = true;
else else
aFather = aFather->GetFather(); aFather = aFather->GetFather();
} }
} }
} }
if ( !isRefOrSubShape ) if (!isRefOrSubShape) {
{
myGeomGroup = GEOM::GEOM_Object::_nil(); myGeomGroup = GEOM::GEOM_Object::_nil();
busy = false; busy = false;
return; return;
@ -834,9 +870,8 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel); aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
else if (myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine) else if (myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine)
aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel); aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
} } else {
else { aString = aList.First()->getName();
aString = mySelection->firstIObject()->getName();
} }
} }
@ -844,16 +879,15 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
myCurrentLineEdit->home(false); myCurrentLineEdit->home(false);
updateButtons(); updateButtons();
}
else { } else {
if (aNbSel == 1) { if (aNbSel == 1) {
QString aListStr = ""; QString aListStr = "";
int aNbItems = 0; int aNbItems = 0;
if (myTypeId == 0) { if (myTypeId == 0) {
aNbItems = SMESH::GetNameOfSelectedNodes(mySelection, aListStr); aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
} } else {
else { aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
aNbItems = SMESH::GetNameOfSelectedElements(mySelection, aListStr);
} }
if (aNbItems > 0) { if (aNbItems > 0) {
QStringList anElements = QStringList::split(" ", aListStr); QStringList anElements = QStringList::split(" ", aListStr);
@ -876,7 +910,6 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
busy = false; busy = false;
} }
//================================================================================= //=================================================================================
// function : onSelectSubMesh() // function : onSelectSubMesh()
// purpose : Called when selection in 3D view or ObjectBrowser is changed // purpose : Called when selection in 3D view or ObjectBrowser is changed
@ -1003,13 +1036,13 @@ void SMESHGUI_GroupDlg::setFilters()
if ( myFilterDlg == 0 ) if ( myFilterDlg == 0 )
{ {
myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), aType ); myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
} }
else else
myFilterDlg->Init( aType ); myFilterDlg->Init( aType );
myFilterDlg->SetSelection( mySelection ); myFilterDlg->SetSelection();
myFilterDlg->SetMesh( myMesh ); myFilterDlg->SetMesh( myMesh );
myFilterDlg->SetSourceWg( myElements ); myFilterDlg->SetSourceWg( myElements );
@ -1037,7 +1070,9 @@ void SMESHGUI_GroupDlg::onFilterAccepted()
//================================================================================= //=================================================================================
void SMESHGUI_GroupDlg::onAdd() void SMESHGUI_GroupDlg::onAdd()
{ {
int aNbSel = mySelection->IObjectCount(); const SALOME_ListIO& aList = mySelector->StoredIObjects();
int aNbSel = aList.Extent();
if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
busy = true; busy = true;
@ -1055,10 +1090,10 @@ void SMESHGUI_GroupDlg::onAdd()
QString aListStr = ""; QString aListStr = "";
int aNbItems = 0; int aNbItems = 0;
if (myTypeId == 0) { if (myTypeId == 0) {
aNbItems = SMESH::GetNameOfSelectedNodes(mySelection, myActor->getIO(), aListStr); aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
} }
else { else {
aNbItems = SMESH::GetNameOfSelectedElements(mySelection, myActor->getIO(), aListStr); aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
} }
if (aNbItems > 0) { if (aNbItems > 0) {
QStringList anElements = QStringList::split(" ", aListStr); QStringList anElements = QStringList::split(" ", aListStr);
@ -1072,11 +1107,13 @@ void SMESHGUI_GroupDlg::onAdd()
myElements->setSelected(anItem, true); myElements->setSelected(anItem, true);
} }
} }
} } else if (myCurrentLineEdit == mySubMeshLine) {
else if (myCurrentLineEdit == mySubMeshLine) { //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); const SALOME_ListIO& aList = mySelector->StoredIObjects();
SALOME_ListIteratorOfListIO anIt (aList);
for (; anIt.More(); anIt.Next()) { for (; anIt.More(); anIt.Next()) {
SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value()); SMESH::SMESH_subMesh_var aSubMesh =
SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
if (!aSubMesh->_is_nil()) { if (!aSubMesh->_is_nil()) {
// check if mesh is the same // check if mesh is the same
if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
@ -1095,7 +1132,7 @@ void SMESHGUI_GroupDlg::onAdd()
} }
} }
catch (const SALOME::SALOME_Exception& ex) { catch (const SALOME::SALOME_Exception& ex) {
QtCatchCorbaException(ex); SalomeApp_Tools::QtCatchCorbaException(ex);
} }
} }
} }
@ -1103,11 +1140,14 @@ void SMESHGUI_GroupDlg::onAdd()
mySelectSubMesh->setChecked(false); mySelectSubMesh->setChecked(false);
busy = false; busy = false;
onListSelectionChanged(); onListSelectionChanged();
}
else if (myCurrentLineEdit == myGroupLine) { } else if (myCurrentLineEdit == myGroupLine) {
SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
const SALOME_ListIO& aList = mySelector->StoredIObjects();
SALOME_ListIteratorOfListIO anIt (aList);
for (; anIt.More(); anIt.Next()) { for (; anIt.More(); anIt.Next()) {
SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value()); SMESH::SMESH_Group_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
if (!aGroup->_is_nil()) { if (!aGroup->_is_nil()) {
// check if mesh is the same // check if mesh is the same
if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
@ -1129,11 +1169,11 @@ void SMESHGUI_GroupDlg::onAdd()
mySelectGroup->setChecked(false); mySelectGroup->setChecked(false);
busy = false; busy = false;
onListSelectionChanged(); onListSelectionChanged();
}
else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) {
SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) {
GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
GEOM::GEOM_IGroupOperations_var aGroupOp =
SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
SMESH::ElementType aGroupType = SMESH::ALL; SMESH::ElementType aGroupType = SMESH::ALL;
switch(aGroupOp->GetType(myGeomGroup)) { switch(aGroupOp->GetType(myGeomGroup)) {
@ -1141,17 +1181,19 @@ void SMESHGUI_GroupDlg::onAdd()
case 6: aGroupType = SMESH::EDGE; break; case 6: aGroupType = SMESH::EDGE; break;
case 4: aGroupType = SMESH::FACE; break; case 4: aGroupType = SMESH::FACE; break;
case 2: aGroupType = SMESH::VOLUME; break; case 2: aGroupType = SMESH::VOLUME; break;
default: return; default: busy = false; return;
} }
if (aGroupType == aType) { if (aGroupType == aType) {
SALOMEDS::SObject_var aGroupSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myGeomGroup) ); _PTR(SObject) aGroupSO =
//aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
aStudy->FindObjectIOR(myGeomGroup->GetStudyEntry());
// Construct filter // Construct filter
SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();; SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
aBelongToGeom->SetGeom(myGeomGroup); aBelongToGeom->SetGeom(myGeomGroup);
aBelongToGeom->SetShapeName(aGroupSO->GetName()); aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
aBelongToGeom->SetElementType(aType); aBelongToGeom->SetElementType(aType);
aFilter->SetPredicate(aBelongToGeom); aFilter->SetPredicate(aBelongToGeom);
@ -1175,7 +1217,7 @@ void SMESHGUI_GroupDlg::onAdd()
onListSelectionChanged(); onListSelectionChanged();
} }
busy = false; busy = false;
// mySelection->ClearIObjects(); // mySelectionMgr->clearSelected();
updateButtons(); updateButtons();
} }
@ -1192,9 +1234,10 @@ void SMESHGUI_GroupDlg::onRemove()
myElements->removeItem(i-1); myElements->removeItem(i-1);
} }
} }
} } else {
else { const SALOME_ListIO& aList = mySelector->StoredIObjects();
int aNbSel = mySelection->IObjectCount(); int aNbSel = aList.Extent();
if (aNbSel == 0) { busy = false; return; } if (aNbSel == 0) { busy = false; return; }
SMESH::ElementType aType = SMESH::ALL; SMESH::ElementType aType = SMESH::ALL;
@ -1206,7 +1249,9 @@ void SMESHGUI_GroupDlg::onRemove()
} }
if (myCurrentLineEdit == mySubMeshLine) { if (myCurrentLineEdit == mySubMeshLine) {
SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
const SALOME_ListIO& aList = mySelector->StoredIObjects();
SALOME_ListIteratorOfListIO anIt (aList);
for (; anIt.More(); anIt.Next()) { for (; anIt.More(); anIt.Next()) {
SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value()); SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
if (!aSubMesh->_is_nil()) { if (!aSubMesh->_is_nil()) {
@ -1223,7 +1268,7 @@ void SMESHGUI_GroupDlg::onRemove()
} }
} }
catch (const SALOME::SALOME_Exception& ex) { catch (const SALOME::SALOME_Exception& ex) {
QtCatchCorbaException(ex); SalomeApp_Tools::QtCatchCorbaException(ex);
} }
} }
else { else {
@ -1237,7 +1282,7 @@ void SMESHGUI_GroupDlg::onRemove()
} }
} }
catch (const SALOME::SALOME_Exception& ex) { catch (const SALOME::SALOME_Exception& ex) {
QtCatchCorbaException(ex); SalomeApp_Tools::QtCatchCorbaException(ex);
} }
} }
} }
@ -1246,7 +1291,9 @@ void SMESHGUI_GroupDlg::onRemove()
} }
else if (myCurrentLineEdit == myGroupLine) { else if (myCurrentLineEdit == myGroupLine) {
Standard_Boolean aRes; Standard_Boolean aRes;
SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
const SALOME_ListIO& aList = mySelector->StoredIObjects();
SALOME_ListIteratorOfListIO anIt (aList);
for (; anIt.More(); anIt.Next()) { for (; anIt.More(); anIt.Next()) {
SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value()); SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
if (aRes && !aGroup->_is_nil()) { if (aRes && !aGroup->_is_nil()) {
@ -1309,64 +1356,63 @@ void SMESHGUI_GroupDlg::onSort()
// function : closeEvent() // function : closeEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_GroupDlg::closeEvent( QCloseEvent* e ) void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
{ {
onClose(); onClose();
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_GroupDlg::onClose // function : SMESHGUI_GroupDlg::onClose
// Purpose : SLOT called when "Close" button pressed. Close dialog // purpose : SLOT called when "Close" button pressed. Close dialog
//======================================================================= //=================================================================================
void SMESHGUI_GroupDlg::onClose() void SMESHGUI_GroupDlg::onClose()
{ {
QAD_StudyFrame* aStudyFrame = mySMESHGUI->GetActiveStudy()->getActiveStudyFrame(); if (SMESH::GetCurrentVtkView()) {
if (aStudyFrame->getTypeView() == VIEW_VTK) {
SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
SMESH::SetPointRepresentation(false); SMESH::SetPointRepresentation(false);
SMESH::SetPickable(); SMESH::SetPickable();
} }
mySelection->ClearIObjects(); mySelectionMgr->clearSelected();
QAD_Application::getDesktop()->SetSelectionMode(ActorSelection); myViewWindow->SetSelectionMode(ActorSelection);
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
reject(); reject();
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_GroupDlg::onDeactivate // function : SMESHGUI_GroupDlg::onDeactivate
// Purpose : SLOT called when dialog must be deativated // purpose : SLOT called when dialog must be deativated
//======================================================================= //=================================================================================
void SMESHGUI_GroupDlg::onDeactivate() void SMESHGUI_GroupDlg::onDeactivate()
{ {
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
setEnabled(false); setEnabled(false);
} }
//======================================================================= //=================================================================================
// name : SMESHGUI_GroupDlg::enterEvent // function : SMESHGUI_GroupDlg::enterEvent
// Purpose : Event filter // purpose : Event filter
//======================================================================= //=================================================================================
void SMESHGUI_GroupDlg::enterEvent (QEvent*) void SMESHGUI_GroupDlg::enterEvent (QEvent*)
{ {
if (!isEnabled()) { if (!isEnabled()) {
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); mySMESHGUI->EmitSignalDeactivateDialog();
setEnabled(true); setEnabled(true);
mySelectionMode = -1; mySelectionMode = -1;
setSelectionMode(myTypeId); setSelectionMode(myTypeId);
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
mySMESHGUI->SetActiveDialogBox(this);
mySMESHGUI->SetState(800); mySMESHGUI->SetState(800);
} }
} }
//======================================================================= //=================================================================================
// function : hideEvent // function : hideEvent
// purpose : caused by ESC key // purpose : caused by ESC key
//======================================================================= //=================================================================================
void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)
void SMESHGUI_GroupDlg::hideEvent ( QHideEvent * e )
{ {
if (!isMinimized()) if (!isMinimized())
onClose(); onClose();

View File

@ -28,8 +28,9 @@
#ifndef DIALOGBOX_GROUP_H #ifndef DIALOGBOX_GROUP_H
#define DIALOGBOX_GROUP_H #define DIALOGBOX_GROUP_H
#include "SALOME_Selection.h" #include "SalomeApp_SelectionMgr.h"
#include "SMESH_TypeFilter.hxx" //#include "SMESH_TypeFilter.hxx"
#include "SUIT_SelectionFilter.h"
// QT Includes // QT Includes
#include <qdialog.h> #include <qdialog.h>
@ -50,6 +51,8 @@ class QWidgetStack;
class SMESHGUI; class SMESHGUI;
class SMESH_Actor; class SMESH_Actor;
class SMESHGUI_FilterDlg; class SMESHGUI_FilterDlg;
class SVTK_Selector;
class SVTK_ViewWindow;
//================================================================================= //=================================================================================
// class : SMESHGUI_GroupDlg // class : SMESHGUI_GroupDlg
@ -60,11 +63,14 @@ class SMESHGUI_GroupDlg : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_GroupDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* theSel = 0, SMESHGUI_GroupDlg( SMESHGUI*,
const char* name = 0,
SMESH::SMESH_Mesh_ptr theMesh = SMESH::SMESH_Mesh::_nil(), SMESH::SMESH_Mesh_ptr theMesh = SMESH::SMESH_Mesh::_nil(),
bool modal = FALSE, WFlags fl = 0 ); bool modal = FALSE, WFlags fl = 0 );
SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, SMESHGUI_GroupDlg( SMESHGUI*,
SMESH::SMESH_Group_ptr theGroup, bool modal = FALSE, WFlags fl = 0 ); const char* name,
SMESH::SMESH_Group_ptr theGroup,
bool modal = FALSE, WFlags fl = 0 );
~SMESHGUI_GroupDlg(); ~SMESHGUI_GroupDlg();
public slots: public slots:
@ -98,7 +104,7 @@ private slots:
void onFilterAccepted(); void onFilterAccepted();
private: private:
void initDialog(SALOME_Selection* theSel, bool create); void initDialog(bool create);
void init(SMESH::SMESH_Mesh_ptr theMesh); void init(SMESH::SMESH_Mesh_ptr theMesh);
void init(SMESH::SMESH_Group_ptr theGroup); void init(SMESH::SMESH_Group_ptr theGroup);
void closeEvent(QCloseEvent* e); void closeEvent(QCloseEvent* e);
@ -108,11 +114,13 @@ private:
void updateButtons(); void updateButtons();
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */ SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SMESH_Actor* myActor; /* Current mesh actor */ SMESH_Actor* myActor; /* Current mesh actor */
int myGrpTypeId; /* Current group type id : standalone or group on geometry */ int myGrpTypeId; /* Current group type id : standalone or group on geometry */
int myTypeId; /* Current type id = radio button id */ int myTypeId; /* Current type id = radio button id */
QLineEdit* myCurrentLineEdit; /* Current LineEdit */ QLineEdit* myCurrentLineEdit; /* Current LineEdit */
SVTK_ViewWindow* myViewWindow;
SVTK_Selector* mySelector;
QPushButton* myMeshGroupBtn; QPushButton* myMeshGroupBtn;
QLineEdit* myMeshGroupLine; QLineEdit* myMeshGroupLine;
@ -144,9 +152,12 @@ private:
GEOM::GEOM_Object_var myGeomGroup; GEOM::GEOM_Object_var myGeomGroup;
int mySelectionMode; int mySelectionMode;
Handle(SMESH_TypeFilter) myMeshFilter; //Handle(SMESH_TypeFilter) myMeshFilter;
Handle(SMESH_TypeFilter) mySubMeshFilter; //Handle(SMESH_TypeFilter) mySubMeshFilter;
Handle(SMESH_TypeFilter) myGroupFilter; //Handle(SMESH_TypeFilter) myGroupFilter;
SUIT_SelectionFilter* myMeshFilter;
SUIT_SelectionFilter* mySubMeshFilter;
SUIT_SelectionFilter* myGroupFilter;
SMESHGUI_FilterDlg* myFilterDlg; SMESHGUI_FilterDlg* myFilterDlg;

View File

@ -27,13 +27,19 @@
#include "SMESHGUI_GroupOpDlg.h" #include "SMESHGUI_GroupOpDlg.h"
#include "QAD_Desktop.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SALOME_Selection.h"
#include "SMESH_TypeFilter.hxx" #include "SMESH_TypeFilter.hxx"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Desktop.h"
#include "SalomeApp_SelectionMgr.h"
#include "SVTK_Selection.h"
#include "SALOME_ListIO.hxx"
// QT Includes
#include <qframe.h> #include <qframe.h>
#include <qlayout.h> #include <qlayout.h>
#include <qpushbutton.h> #include <qpushbutton.h>
@ -46,9 +52,9 @@
#define SPACING 5 #define SPACING 5
#define MARGIN 10 #define MARGIN 10
/* /*!
Class : SMESHGUI_GroupOpDlg * Class : SMESHGUI_GroupOpDlg
Description : Perform boolean operations on groups * Description : Perform boolean operations on groups
*/ */
//======================================================================= //=======================================================================
@ -56,7 +62,7 @@
// Purpose : Constructor // Purpose : Constructor
//======================================================================= //=======================================================================
SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg (QWidget* theParent, SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg (QWidget* theParent,
SALOME_Selection* theSelection, SalomeApp_SelectionMgr* theSelection,
const int theMode) const int theMode)
: QDialog(theParent, "SMESHGUI_GroupOpDlg", false, : QDialog(theParent, "SMESHGUI_GroupOpDlg", false,
WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
@ -99,15 +105,17 @@ QFrame* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent )
new QLabel(myMode == CUT ? tr("MAIN_OBJECT") :tr("OBJECT_1"), anArgGrp); new QLabel(myMode == CUT ? tr("MAIN_OBJECT") :tr("OBJECT_1"), anArgGrp);
myBtn1 = new QPushButton(anArgGrp); myBtn1 = new QPushButton(anArgGrp);
myEdit1 = new QLineEdit(anArgGrp); myEdit1 = new QLineEdit(anArgGrp);
myEdit1->setAlignment( Qt::AlignLeft );
new QLabel(myMode == CUT ? tr("TOOL_OBJECT") :tr("OBJECT_2"), anArgGrp); new QLabel(myMode == CUT ? tr("TOOL_OBJECT") :tr("OBJECT_2"), anArgGrp);
myBtn2 = new QPushButton(anArgGrp); myBtn2 = new QPushButton(anArgGrp);
myEdit2 = new QLineEdit(anArgGrp); myEdit2 = new QLineEdit(anArgGrp);
myEdit2->setAlignment( Qt::AlignLeft );
myEdit1->setReadOnly(true); myEdit1->setReadOnly(true);
myEdit2->setReadOnly(true); myEdit2->setReadOnly(true);
QPixmap aPix( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); QPixmap aPix (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
myBtn1->setPixmap(aPix); myBtn1->setPixmap(aPix);
myBtn2->setPixmap(aPix); myBtn2->setPixmap(aPix);
@ -156,9 +164,9 @@ SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg()
// name : SMESHGUI_GroupOpDlg::Init // name : SMESHGUI_GroupOpDlg::Init
// Purpose : Init dialog fields, connect signals and slots, show dialog // Purpose : Init dialog fields, connect signals and slots, show dialog
//======================================================================= //=======================================================================
void SMESHGUI_GroupOpDlg::Init( SALOME_Selection* theSelection ) void SMESHGUI_GroupOpDlg::Init (SalomeApp_SelectionMgr* theSelection)
{ {
mySelection = theSelection; mySelectionMgr = theSelection;
SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI();
aSMESHGUI->SetActiveDialogBox((QDialog*)this); aSMESHGUI->SetActiveDialogBox((QDialog*)this);
myFocusWg = myEdit1; myFocusWg = myEdit1;
@ -167,7 +175,7 @@ void SMESHGUI_GroupOpDlg::Init( SALOME_Selection* theSelection )
myGroup2 = SMESH::SMESH_GroupBase::_nil(); myGroup2 = SMESH::SMESH_GroupBase::_nil();
// selection and SMESHGUI // selection and SMESHGUI
connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
connect(aSMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); connect(aSMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose())); connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose()));
@ -180,8 +188,12 @@ void SMESHGUI_GroupOpDlg::Init( SALOME_Selection* theSelection )
this->show(); this->show();
// set selection mode // set selection mode
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); #ifdef NEW_GUI
mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); mySelectionMgr->setSelectionModes(ActorSelection, true);
#else
mySelectionMgr->setSelectionModes(ActorSelection);
#endif
mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
return; return;
} }
@ -193,18 +205,16 @@ void SMESHGUI_GroupOpDlg::Init( SALOME_Selection* theSelection )
bool SMESHGUI_GroupOpDlg::isValid() bool SMESHGUI_GroupOpDlg::isValid()
{ {
// Verify validity of group name // Verify validity of group name
if ( myNameEdit->text() == "" ) if (myNameEdit->text() == "") {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("EMPTY_NAME"), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "EMPTY_NAME" ), QMessageBox::Ok );
return false; return false;
} }
// Verufy wheter arguments speciffiyed // Verufy wheter arguments speciffiyed
if ( myGroup1->_is_nil() || myGroup2->_is_nil() ) if (myGroup1->_is_nil() || myGroup2->_is_nil()) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("INCORRECT_ARGUMENTS"), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "INCORRECT_ARGUMENTS" ), QMessageBox::Ok );
return false; return false;
} }
@ -215,22 +225,19 @@ bool SMESHGUI_GroupOpDlg::isValid()
int aMeshId1 = !aMesh1->_is_nil() ? aMesh1->GetId() : -1; int aMeshId1 = !aMesh1->_is_nil() ? aMesh1->GetId() : -1;
int aMeshId2 = !aMesh2->_is_nil() ? aMesh2->GetId() : -1; int aMeshId2 = !aMesh2->_is_nil() ? aMesh2->GetId() : -1;
if ( aMeshId1 != aMeshId2 || aMeshId1 == -1 ) if (aMeshId1 != aMeshId2 || aMeshId1 == -1) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("DIFF_MESHES"), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "DIFF_MESHES" ), QMessageBox::Ok );
return false; return false;
} }
// Verify whether groups have same types of entities // Verify whether groups have same types of entities
if ( myGroup1->GetType() != myGroup2->GetType() ) if (myGroup1->GetType() != myGroup2->GetType()) {
{ QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr("DIFF_TYPES"), QMessageBox::Ok);
tr( "SMESH_INSUFFICIENT_DATA" ), tr( "DIFF_TYPES" ), QMessageBox::Ok );
return false; return false;
} }
return true; return true;
} }
@ -240,7 +247,7 @@ bool SMESHGUI_GroupOpDlg::isValid()
//======================================================================= //=======================================================================
bool SMESHGUI_GroupOpDlg::onApply() bool SMESHGUI_GroupOpDlg::onApply()
{ {
if ( !isValid() || SMESHGUI::GetSMESHGUI()->ActiveStudyLocked() ) if (!isValid() || SMESHGUI::GetSMESHGUI()->isActiveStudyLocked())
return false; return false;
SMESH::SMESH_Mesh_ptr aMesh = myGroup1->GetMesh(); SMESH::SMESH_Mesh_ptr aMesh = myGroup1->GetMesh();
@ -251,16 +258,13 @@ bool SMESHGUI_GroupOpDlg::onApply()
else if (myMode == INTERSECT) aNewGrp = aMesh->IntersectGroups(myGroup1, myGroup2, aName.latin1()); else if (myMode == INTERSECT) aNewGrp = aMesh->IntersectGroups(myGroup1, myGroup2, aName.latin1());
else aNewGrp = aMesh->CutGroups(myGroup1, myGroup2, aName.latin1()); else aNewGrp = aMesh->CutGroups(myGroup1, myGroup2, aName.latin1());
if ( !aNewGrp->_is_nil() ) if (!aNewGrp->_is_nil()) {
{ SMESHGUI::GetSMESHGUI()->updateObjBrowser(true);
SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true );
reset(); reset();
return true; return true;
} } else {
else QMessageBox::critical(SMESHGUI::desktop(), tr("SMESH_ERROR"),
{ tr("SMESH_OPERATION_FAILED"), "OK");
QMessageBox::critical( SMESHGUI::GetSMESHGUI()->GetDesktop(),
tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ), "OK" );
return false; return false;
} }
} }
@ -281,11 +285,11 @@ void SMESHGUI_GroupOpDlg::onOk()
//======================================================================= //=======================================================================
void SMESHGUI_GroupOpDlg::onClose() void SMESHGUI_GroupOpDlg::onClose()
{ {
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); mySelectionMgr->setSelectionModes(ActorSelection);
disconnect( mySelection, 0, this, 0 ); disconnect(mySelectionMgr, 0, this, 0);
disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0);
SMESHGUI::GetSMESHGUI()->ResetState(); SMESHGUI::GetSMESHGUI()->ResetState();
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
reject(); reject();
} }
@ -302,14 +306,17 @@ void SMESHGUI_GroupOpDlg::onSelectionDone()
myFocusWg->setText(""); myFocusWg->setText("");
if ( mySelection->IObjectCount() == 1 ) SALOME_ListIO aList;
{ mySelectionMgr->selectedObjects(aList);
if (aList.Extent() == 1) {
SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>( mySelection->firstIObject() ); SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(aList.First());
if (!aGroup->_is_nil()) if (!aGroup->_is_nil())
{ {
myFocusWg->setText(aGroup->GetName()); myFocusWg->setText(aGroup->GetName());
myFocusWg->setCursorPosition( 0 );
if (myFocusWg == myEdit1) if (myFocusWg == myEdit1)
myGroup1 = aGroup; myGroup1 = aGroup;
@ -326,7 +333,7 @@ void SMESHGUI_GroupOpDlg::onSelectionDone()
void SMESHGUI_GroupOpDlg::onDeactivate() void SMESHGUI_GroupOpDlg::onDeactivate()
{ {
setEnabled(false); setEnabled(false);
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
} }
//======================================================================= //=======================================================================
@ -337,15 +344,18 @@ void SMESHGUI_GroupOpDlg::enterEvent( QEvent* )
{ {
SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
setEnabled(true); setEnabled(true);
QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); #ifdef NEW_GUI
mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); mySelectionMgr->setSelectionModes(ActorSelection, true);
#else
mySelectionMgr->setSelectionModes(ActorSelection);
#endif
mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
} }
//=======================================================================
//================================================================================= // name : SMESHGUI_GroupOpDlg::closeEvent
// function : closeEvent()
// purpose : // purpose :
//================================================================================= //=======================================================================
void SMESHGUI_GroupOpDlg::closeEvent (QCloseEvent*) void SMESHGUI_GroupOpDlg::closeEvent (QCloseEvent*)
{ {
onClose(); onClose();
@ -374,28 +384,3 @@ void SMESHGUI_GroupOpDlg::reset()
myFocusWg = myEdit1; myFocusWg = myEdit1;
myNameEdit->setFocus(); myNameEdit->setFocus();
} }

View File

@ -36,7 +36,7 @@ class QCloseEvent;
class QLabel; class QLabel;
class QFrame; class QFrame;
class QPushButton; class QPushButton;
class SALOME_Selection; class SalomeApp_SelectionMgr;
class QLineEdit; class QLineEdit;
/* /*
@ -52,10 +52,10 @@ public:
enum { UNION, INTERSECT, CUT }; enum { UNION, INTERSECT, CUT };
public: public:
SMESHGUI_GroupOpDlg( QWidget*, SALOME_Selection*, const int ); SMESHGUI_GroupOpDlg( QWidget*, SalomeApp_SelectionMgr*, const int );
virtual ~SMESHGUI_GroupOpDlg(); virtual ~SMESHGUI_GroupOpDlg();
void Init( SALOME_Selection* ) ; void Init( SalomeApp_SelectionMgr* ) ;
private: private:
@ -91,7 +91,7 @@ private:
QPushButton* myBtn1; QPushButton* myBtn1;
QPushButton* myBtn2; QPushButton* myBtn2;
SALOME_Selection* mySelection; SalomeApp_SelectionMgr* mySelectionMgr;
int myMode; int myMode;
QLineEdit* myFocusWg; QLineEdit* myFocusWg;
@ -102,8 +102,3 @@ private:
}; };
#endif #endif

View File

@ -18,12 +18,17 @@
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "QAD_Study.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "SMESHGUI_GroupUtils.h" #include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SUIT_Session.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Tools.h"
#include "OB_Browser.h"
namespace SMESH namespace SMESH
{ {
@ -37,10 +42,12 @@ namespace SMESH
aGroup = theMesh->CreateGroup( theType, theGroupName ); aGroup = theMesh->CreateGroup( theType, theGroupName );
} }
catch( const SALOME::SALOME_Exception& S_ex ) { catch( const SALOME::SALOME_Exception& S_ex ) {
QtCatchCorbaException( S_ex ); SalomeApp_Tools::QtCatchCorbaException( S_ex );
} }
GetActiveStudy()->updateObjBrowser( true ); //SalomeApp_Application* app =
// dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
//if (app) app->objectBrowser()->updateTree();
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
return aGroup._retn(); return aGroup._retn();
} }
} }

View File

@ -17,33 +17,38 @@
// //
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_XmlHandler.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include "SUIT_Tools.h"
#include "SUIT_Desktop.h"
#include "SUIT_MessageBox.h"
#include "SUIT_OverrideCursor.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Session.h"
#include "OB_Browser.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_Tools.h"
#include "SalomeApp_Application.h"
#include <SALOMEDSClient_Study.hxx>
#include <SALOMEDSClient_SObject.hxx>
#include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
#include <map> #include <map>
#include <string> #include <string>
#include <dlfcn.h> #include <dlfcn.h>
#include "QAD.h"
#include "QAD_Tools.h"
#include "QAD_Config.h"
#include "QAD_Desktop.h"
#include "QAD_MessageBox.h"
#include "QAD_WaitCursor.h"
#include "QAD_ResourceMgr.h"
#include "SALOMEGUI_QtCatchCorbaException.hxx"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_XmlHandler.h"
#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_SMESHGenUtils.h"
#include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
#ifdef _DEBUG_ #ifdef _DEBUG_
static int MYDEBUG = 0; static int MYDEBUG = 0;
#else #else
@ -79,10 +84,10 @@ namespace SMESH{
// get Hyp name // get Hyp name
QString aHypName ("NULL Hypothesis"); QString aHypName ("NULL Hypothesis");
if (!CORBA::is_nil(theHyp)) { if (!CORBA::is_nil(theHyp)) {
SALOMEDS::SObject_var Shyp = SMESH::FindSObject( theHyp ); _PTR(SObject) Shyp = SMESH::FindSObject(theHyp);
if ( !CORBA::is_nil( Shyp )) if (Shyp)
// name in study // name in study
aHypName = Shyp->GetName(); aHypName = Shyp->GetName().c_str();
else else
// label in xml file // label in xml file
aHypName = GetHypothesisData(theHyp->GetName())->Label; aHypName = GetHypothesisData(theHyp->GetName())->Label;
@ -99,7 +104,7 @@ namespace SMESH{
aMsg = QObject::tr(aMsg).arg(aHypName) + aMsg = QObject::tr(aMsg).arg(aHypName) +
QObject::tr(QString("SMESH_HYP_%1").arg(theHypStatus)); QObject::tr(QString("SMESH_HYP_%1").arg(theHypStatus));
QAD_MessageBox::warn1(QAD_Application::getDesktop(), SUIT_MessageBox::warn1(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"), QObject::tr("SMESH_WRN_WARNING"),
aMsg, aMsg,
QObject::tr("SMESH_BUT_OK")); QObject::tr("SMESH_BUT_OK"));
@ -109,10 +114,10 @@ namespace SMESH{
void InitAvailableHypotheses() void InitAvailableHypotheses()
{ {
QAD_WaitCursor wc; SUIT_OverrideCursor wc;
if (myHypothesesMap.empty() && myAlgorithmsMap.empty()) { if (myHypothesesMap.empty() && myAlgorithmsMap.empty()) {
// Resource manager // Resource manager
QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); SUIT_ResourceMgr* resMgr = SMESHGUI::resourceMgr();
if (!resMgr) return; if (!resMgr) return;
// Find name of a resource XML file ("SMESH_Meshers.xml"); // Find name of a resource XML file ("SMESH_Meshers.xml");
@ -124,7 +129,7 @@ namespace SMESH{
QStringList HypsXmlList = QStringList::split(":", HypsXml, false); QStringList HypsXmlList = QStringList::split(":", HypsXml, false);
if (HypsXmlList.count() == 0) if (HypsXmlList.count() == 0)
{ {
QAD_MessageBox::error1(QAD_Application::getDesktop(), SUIT_MessageBox::error1(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"), QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("MESHERS_FILE_NO_VARIABLE"), QObject::tr("MESHERS_FILE_NO_VARIABLE"),
QObject::tr("SMESH_BUT_OK")); QObject::tr("SMESH_BUT_OK"));
@ -138,9 +143,9 @@ namespace SMESH{
// Find full path to the resource XML file // Find full path to the resource XML file
QString xmlFile = HypsXml + ".xml"; QString xmlFile = HypsXml + ".xml";
xmlFile = QAD_Tools::addSlash(resMgr->findFile(xmlFile, HypsXml)) + xmlFile; xmlFile = resMgr->path("resources", "SMESH", xmlFile);
QFile file (QAD_Tools::unix2win(xmlFile)); QFile file (xmlFile);
if (file.exists() && file.open(IO_ReadOnly)) { if (file.exists() && file.open(IO_ReadOnly)) {
file.close(); file.close();
@ -158,7 +163,7 @@ namespace SMESH{
addMap(aXmlHandler->myAlgorithmsMap, myAlgorithmsMap); addMap(aXmlHandler->myAlgorithmsMap, myAlgorithmsMap);
} }
else { else {
QAD_MessageBox::error1(QAD_Application::getDesktop(), SUIT_MessageBox::error1(SMESHGUI::desktop(),
QObject::tr("INF_PARSE_ERROR"), QObject::tr("INF_PARSE_ERROR"),
QObject::tr(aXmlHandler->errorProtocol()), QObject::tr(aXmlHandler->errorProtocol()),
QObject::tr("SMESH_BUT_OK")); QObject::tr("SMESH_BUT_OK"));
@ -176,12 +181,12 @@ namespace SMESH{
if (!aNoAccessFiles.isEmpty()) { if (!aNoAccessFiles.isEmpty()) {
QString aMess = QObject::tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n"; QString aMess = QObject::tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n";
aMess += QObject::tr("MESHERS_FILE_CHECK_VARIABLE"); aMess += QObject::tr("MESHERS_FILE_CHECK_VARIABLE");
wc.stop(); wc.suspend();
QAD_MessageBox::warn1(QAD_Application::getDesktop(), SUIT_MessageBox::warn1(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"), QObject::tr("SMESH_WRN_WARNING"),
aMess, aMess,
QObject::tr("SMESH_BUT_OK")); QObject::tr("SMESH_BUT_OK"));
wc.start(); wc.resume();
} }
} }
} }
@ -290,7 +295,7 @@ namespace SMESH{
} }
} }
catch (const SALOME::SALOME_Exception& S_ex) { catch (const SALOME::SALOME_Exception& S_ex) {
QtCatchCorbaException(S_ex); SalomeApp_Tools::QtCatchCorbaException(S_ex);
} }
} }
@ -310,19 +315,24 @@ namespace SMESH{
QString aServLib = aHypData->ServerLibName; QString aServLib = aHypData->ServerLibName;
try { try {
Hyp = SMESH::GetSMESHGen()->CreateHypothesis(aHypType, aServLib); Hyp = SMESHGUI::GetSMESHGen()->CreateHypothesis(aHypType, aServLib);
if (!Hyp->_is_nil()) { if (!Hyp->_is_nil()) {
SALOMEDS::SObject_var SHyp = SMESH::FindSObject(Hyp.in()); _PTR(SObject) SHyp = SMESH::FindSObject(Hyp.in());
if (!SHyp->_is_nil()) { if (SHyp) {
if ( strcmp(aHypName,"") != 0 ) //if (strcmp(aHypName,"") != 0)
if (strlen(aHypName) > 0)
SMESH::SetName(SHyp, aHypName); SMESH::SetName(SHyp, aHypName);
GetActiveStudy()->updateObjBrowser(true); //SalomeApp_Application* app =
// dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
//if (app)
// app->objectBrowser()->updateTree();
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
return Hyp._retn(); return Hyp._retn();
} }
} }
} }
catch (const SALOME::SALOME_Exception & S_ex) { catch (const SALOME::SALOME_Exception & S_ex) {
QtCatchCorbaException(S_ex); SalomeApp_Tools::QtCatchCorbaException(S_ex);
} }
return SMESH::SMESH_Hypothesis::_nil(); return SMESH::SMESH_Hypothesis::_nil();
@ -333,28 +343,28 @@ namespace SMESH{
{ {
if(MYDEBUG) MESSAGE ("SMESHGUI::AddHypothesisOnMesh"); if(MYDEBUG) MESSAGE ("SMESHGUI::AddHypothesisOnMesh");
int res = SMESH::HYP_UNKNOWN_FATAL; int res = SMESH::HYP_UNKNOWN_FATAL;
QAD_WaitCursor wc; SUIT_OverrideCursor wc;
if (!aMesh->_is_nil()) { if (!aMesh->_is_nil()) {
SALOMEDS::SObject_var SM = SMESH::FindSObject( aMesh ); _PTR(SObject) SM = SMESH::FindSObject(aMesh);
GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SM); GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SM);
try { try {
res = aMesh->AddHypothesis(aShapeObject, aHyp); res = aMesh->AddHypothesis(aShapeObject, aHyp);
if (res < SMESH::HYP_UNKNOWN_FATAL) { if (res < SMESH::HYP_UNKNOWN_FATAL) {
SALOMEDS::SObject_var SH = SMESH::FindSObject(aHyp); _PTR(SObject) SH = SMESH::FindSObject(aHyp);
if ( !SM->_is_nil() && !SH->_is_nil() ) { if (SM && SH) {
SMESH::ModifiedMesh(SM, false); SMESH::ModifiedMesh(SM, false);
} }
} }
if (res > SMESH::HYP_OK) { if (res > SMESH::HYP_OK) {
wc.stop(); wc.suspend();
processHypothesisStatus(res, aHyp, true); processHypothesisStatus(res, aHyp, true);
wc.start(); wc.resume();
} }
} }
catch(const SALOME::SALOME_Exception& S_ex) { catch(const SALOME::SALOME_Exception& S_ex) {
wc.stop(); wc.suspend();
QtCatchCorbaException( S_ex ); SalomeApp_Tools::QtCatchCorbaException(S_ex);
res = SMESH::HYP_UNKNOWN_FATAL; res = SMESH::HYP_UNKNOWN_FATAL;
} }
} }
@ -366,36 +376,36 @@ namespace SMESH{
{ {
if(MYDEBUG) MESSAGE("SMESHGUI::AddHypothesisOnSubMesh() "); if(MYDEBUG) MESSAGE("SMESHGUI::AddHypothesisOnSubMesh() ");
int res = SMESH::HYP_UNKNOWN_FATAL; int res = SMESH::HYP_UNKNOWN_FATAL;
QAD_WaitCursor wc; SUIT_OverrideCursor wc;
if (!aSubMesh->_is_nil() && ! aHyp->_is_nil()) { if (!aSubMesh->_is_nil() && ! aHyp->_is_nil()) {
try { try {
SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
SALOMEDS::SObject_var SsubM = SMESH::FindSObject( aSubMesh ); _PTR(SObject) SsubM = SMESH::FindSObject(aSubMesh);
GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SsubM); GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SsubM);
if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShapeObject->_is_nil() ) { if (!aMesh->_is_nil() && SsubM && !aShapeObject->_is_nil()) {
res = aMesh->AddHypothesis(aShapeObject, aHyp); res = aMesh->AddHypothesis(aShapeObject, aHyp);
if (res < SMESH::HYP_UNKNOWN_FATAL) { if (res < SMESH::HYP_UNKNOWN_FATAL) {
SALOMEDS::SObject_var meshSO = SMESH::FindSObject( aMesh ); _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
if ( !meshSO->_is_nil() ) if (meshSO)
SMESH::ModifiedMesh(meshSO, false); SMESH::ModifiedMesh(meshSO, false);
} }
if (res > SMESH::HYP_OK) { if (res > SMESH::HYP_OK) {
wc.stop(); wc.suspend();
processHypothesisStatus(res, aHyp, true); processHypothesisStatus(res, aHyp, true);
wc.start(); wc.resume();
} }
} }
else { else {
SCRUTE(aHyp->_is_nil()); SCRUTE(aHyp->_is_nil());
SCRUTE(aMesh->_is_nil()); SCRUTE(aMesh->_is_nil());
SCRUTE( SsubM->_is_nil() ); SCRUTE(!SsubM);
SCRUTE(aShapeObject->_is_nil()); SCRUTE(aShapeObject->_is_nil());
} }
} }
catch(const SALOME::SALOME_Exception& S_ex) { catch(const SALOME::SALOME_Exception& S_ex) {
wc.stop(); wc.suspend();
QtCatchCorbaException( S_ex ); SalomeApp_Tools::QtCatchCorbaException(S_ex);
res = SMESH::HYP_UNKNOWN_FATAL; res = SMESH::HYP_UNKNOWN_FATAL;
} }
} }
@ -409,16 +419,16 @@ namespace SMESH{
bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject) bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject)
{ {
int res = SMESH::HYP_UNKNOWN_FATAL; int res = SMESH::HYP_UNKNOWN_FATAL;
QAD_WaitCursor wc; SUIT_OverrideCursor wc;
if (IObject->hasReference()) { if (IObject->hasReference()) {
try { try {
SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); _PTR(Study) aStudy = GetActiveStudyDocument();
SMESH_Hypothesis_var anHyp = IObjectToInterface<SMESH_Hypothesis>(IObject); SMESH_Hypothesis_var anHyp = IObjectToInterface<SMESH_Hypothesis>(IObject);
SALOMEDS::SObject_var aHypSObj = aStudy->FindObjectID(IObject->getReference()); _PTR(SObject) aHypSObj = aStudy->FindObjectID(IObject->getReference());
if (!aHypSObj->_is_nil()) { if (aHypSObj) {
SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(aHypSObj); _PTR(SObject) MorSM = SMESH::GetMeshOrSubmesh(aHypSObj);
if (!MorSM->_is_nil()) { if (MorSM) {
GEOM::GEOM_Object_var aShape = SMESH::GetShapeOnMeshOrSubMesh(MorSM); GEOM::GEOM_Object_var aShape = SMESH::GetShapeOnMeshOrSubMesh(MorSM);
if (!aShape->_is_nil()){ if (!aShape->_is_nil()){
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh_var aMesh =
@ -432,14 +442,14 @@ namespace SMESH{
if (!aMesh->_is_nil()) { if (!aMesh->_is_nil()) {
res = aMesh->RemoveHypothesis(aShape, anHyp); res = aMesh->RemoveHypothesis(aShape, anHyp);
if (res < SMESH::HYP_UNKNOWN_FATAL) { if (res < SMESH::HYP_UNKNOWN_FATAL) {
SALOMEDS::SObject_var meshSO = SMESH::FindSObject( aMesh ); _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
if ( !meshSO->_is_nil() ) if (meshSO)
SMESH::ModifiedMesh(meshSO, false); SMESH::ModifiedMesh(meshSO, false);
} }
if (res > SMESH::HYP_OK) { if (res > SMESH::HYP_OK) {
wc.stop(); wc.suspend();
processHypothesisStatus(res, anHyp, false); processHypothesisStatus(res, anHyp, false);
wc.start(); wc.resume();
} }
} }
} }
@ -447,8 +457,8 @@ namespace SMESH{
} }
} }
catch(const SALOME::SALOME_Exception& S_ex) { catch(const SALOME::SALOME_Exception& S_ex) {
wc.stop(); wc.suspend();
QtCatchCorbaException( S_ex ); SalomeApp_Tools::QtCatchCorbaException(S_ex);
res = SMESH::HYP_UNKNOWN_FATAL; res = SMESH::HYP_UNKNOWN_FATAL;
} }
} }
@ -458,16 +468,15 @@ namespace SMESH{
return res < SMESH::HYP_UNKNOWN_FATAL; return res < SMESH::HYP_UNKNOWN_FATAL;
} }
bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM, bool RemoveHypothesisOrAlgorithmOnMesh (_PTR(SObject) MorSM,
SMESH::SMESH_Hypothesis_ptr anHyp) SMESH::SMESH_Hypothesis_ptr anHyp)
{ {
SALOMEDS::SObject_var AHR, aRef;
SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR; SALOMEDS::AttributeIOR_var anIOR;
int res = SMESH::HYP_UNKNOWN_FATAL; int res = SMESH::HYP_UNKNOWN_FATAL;
QAD_WaitCursor wc; SUIT_OverrideCursor wc;
if (!MorSM->_is_nil()) { if (MorSM) {
try { try {
GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM); GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM);
if (!aShapeObject->_is_nil()) { if (!aShapeObject->_is_nil()) {
@ -480,48 +489,49 @@ namespace SMESH{
if (!aMesh->_is_nil()) { if (!aMesh->_is_nil()) {
res = aMesh->RemoveHypothesis(aShapeObject, anHyp); res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
if (res < SMESH::HYP_UNKNOWN_FATAL) { if (res < SMESH::HYP_UNKNOWN_FATAL) {
SALOMEDS::SObject_var meshSO = SMESH::FindSObject( aMesh ); _PTR(SObject) meshSO = SMESH::FindSObject(aMesh);
if ( !meshSO->_is_nil() ) if (meshSO)
SMESH::ModifiedMesh(meshSO, false); SMESH::ModifiedMesh(meshSO, false);
} }
if (res > SMESH::HYP_OK) { if (res > SMESH::HYP_OK) {
wc.stop(); wc.suspend();
processHypothesisStatus(res, anHyp, false); processHypothesisStatus(res, anHyp, false);
wc.start(); wc.resume();
} }
} }
} }
} catch(const SALOME::SALOME_Exception& S_ex) { } catch(const SALOME::SALOME_Exception& S_ex) {
wc.stop(); wc.suspend();
QtCatchCorbaException( S_ex ); SalomeApp_Tools::QtCatchCorbaException(S_ex);
res = SMESH::HYP_UNKNOWN_FATAL; res = SMESH::HYP_UNKNOWN_FATAL;
} }
} }
return res < SMESH::HYP_UNKNOWN_FATAL; return res < SMESH::HYP_UNKNOWN_FATAL;
} }
SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp)
{ {
SALOMEDS::Study::ListOfSObject_var listSOmesh = SObjectList listSOmesh;
new SALOMEDS::Study::ListOfSObject; listSOmesh.resize(0);
listSOmesh->length(0);
unsigned int index = 0; unsigned int index = 0;
if (!AlgoOrHyp->_is_nil()) { if (!AlgoOrHyp->_is_nil()) {
SALOMEDS::SObject_var SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp); _PTR(SObject) SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp);
if (!SO_Hypothesis->_is_nil()) { if (SO_Hypothesis) {
SALOMEDS::Study::ListOfSObject_var listSO = SObjectList listSO =
GetActiveStudyDocument()->FindDependances(SO_Hypothesis); SMESHGUI::activeStudy()->studyDS()->FindDependances(SO_Hypothesis);
if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<<listSO->length());
for (unsigned int i = 0; i < listSO->length(); i++) { if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<<listSO.size());
SALOMEDS::SObject_ptr SO = listSO[i]; for (unsigned int i = 0; i < listSO.size(); i++) {
if (!SO->_is_nil()) { _PTR(SObject) SO = listSO[i];
SALOMEDS::SObject_var aFather = SO->GetFather(); if (!SO) {
if (!aFather->_is_nil()) { _PTR(SObject) aFather = SO->GetFather();
SALOMEDS::SObject_var SOfatherFather = aFather->GetFather(); if (aFather) {
if (!SOfatherFather->_is_nil()) { _PTR(SObject) SOfatherFather = aFather->GetFather();
if (SOfatherFather) {
if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list"); if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list");
index++; index++;
listSOmesh->length(index); listSOmesh.resize(index);
listSOmesh[index - 1] = SOfatherFather; listSOmesh[index - 1] = SOfatherFather;
} }
} }
@ -530,7 +540,6 @@ namespace SMESH{
} }
} }
if (MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed"); if (MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed");
return listSOmesh._retn(); return listSOmesh;
} }
} }

View File

@ -32,14 +32,18 @@
#include <qstringlist.h> #include <qstringlist.h>
#include "SALOME_InteractiveObject.hxx" #include "SALOME_InteractiveObject.hxx"
#include "SALOMEDSClient_definitions.hxx"
#include "SALOMEconfig.h" #include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(SALOMEDS) #include CORBA_CLIENT_HEADER(SALOMEDS)
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Hypothesis) #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
#include <vector>
class HypothesisData; class HypothesisData;
class SMESHGUI_GenericHypothesisCreator; class SMESHGUI_GenericHypothesisCreator;
class SALOMEDSClient_SObject;
namespace SMESH{ namespace SMESH{
@ -61,10 +65,11 @@ namespace SMESH{
bool RemoveHypothesisOrAlgorithmOnMesh(const Handle(SALOME_InteractiveObject)& IObject); bool RemoveHypothesisOrAlgorithmOnMesh(const Handle(SALOME_InteractiveObject)& IObject);
bool RemoveHypothesisOrAlgorithmOnMesh(SALOMEDS::SObject_ptr MorSM, bool RemoveHypothesisOrAlgorithmOnMesh(_PTR(SObject) MorSM,
SMESH::SMESH_Hypothesis_ptr anHyp); SMESH::SMESH_Hypothesis_ptr anHyp);
SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ; typedef std::vector<_PTR(SObject)> SObjectList;
SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
} }

Some files were not shown because too many files have changed in this diff Show More