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,11 +1761,10 @@ 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)
{ {
if ( theIterator ) { if ( theIterator ) {
while( theIterator->more() ) { while( theIterator->more() ) {
@ -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;
case SMDSAbs_Edge:
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_Face:
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_Volume:
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break;
case SMDSAbs_All:
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),thePredicate,theSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),thePredicate,theSequence);
break; break;
} }
case SMDSAbs_Edge:{ }
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
break; void
} Filter::GetElementsId( const SMDS_Mesh* theMesh,
case SMDSAbs_Face:{ Filter::TIdSequence& theSequence )
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence); {
break; GetElementsId(theMesh,myPredicate,theSequence);
}
case SMDSAbs_Volume:{
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
break;
}
case SMDSAbs_All:{
FillSequence<const SMDS_MeshElement*>(theMesh->edgesIterator(),myPredicate,aSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->facesIterator(),myPredicate,aSequence);
FillSequence<const SMDS_MeshElement*>(theMesh->volumesIterator(),myPredicate,aSequence);
break;
}
}
return aSequence;
} }
/* /*
@ -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,9 +615,20 @@ 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:
@ -586,7 +756,7 @@ void DriverMED_R_SMESHDS_Mesh::GetGroup(SMESHDS_Group* theGroup)
for (; anElemsIter != anElements.end(); anElemsIter++) for (; anElemsIter != anElements.end(); anElemsIter++)
{ {
element = *anElemsIter; element = *anElemsIter;
theGroup->SMDSGroup().Add(element); theGroup->SMDSGroup().Add(element);
} }
if ( element ) if ( element )
theGroup->SetType( element->GetType() ); theGroup->SetType( element->GetType() );

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,41 +460,42 @@ 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;
switch(aNbNodes){ if (anElem->IsPoly()) {
case 3: aNbConnectivity = aNbNodes;
aNbConnectivity = aNbTriaConn; anElemNums = &aPolygoneElemNums;
anElemNums = &anTriaElemNums; aFamilyNums = &aPolygoneFamilyNums;
aFamilyNums = &aTriaFamilyNums; aConnectivity = &aPolygoneConn;
aConnectivity = &aTriaConn; } else {
break; switch(aNbNodes){
case 4: case 3:
aNbConnectivity = aNbQuadConn; aNbConnectivity = aNbTriaConn;
anElemNums = &aQuadElemNums; anElemNums = &anTriaElemNums;
aFamilyNums = &aQuadFamilyNums; aFamilyNums = &aTriaFamilyNums;
aConnectivity = &aQuadConn; aConnectivity = &aTriaConn;
break; break;
} case 4:
aNbConnectivity = aNbQuadConn;
anElemNums = &aQuadElemNums;
aFamilyNums = &aQuadFamilyNums;
aConnectivity = &aQuadConn;
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,74 +598,111 @@ 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();
TInt aNbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
TInt aNbConnectivity;
MED::TIntVector* anElemNums;
MED::TIntVector* aFamilyNums;
MED::TIntVector* aConnectivity;
switch(aNbNodes){
case 4:
aNbConnectivity = aNbTetraConn;
anElemNums = &anTetraElemNums;
aFamilyNums = &aTetraFamilyNums;
aConnectivity = &aTetraConn;
break;
case 5:
aNbConnectivity = aNbPyraConn;
anElemNums = &anPyraElemNums;
aFamilyNums = &aPyraFamilyNums;
aConnectivity = &aPyraConn;
break;
case 6:
aNbConnectivity = aNbPentaConn;
anElemNums = &anPentaElemNums;
aFamilyNums = &aPentaFamilyNums;
aConnectivity = &aPentaConn;
break;
case 8:
aNbConnectivity = aNbHexaConn;
anElemNums = &aHexaElemNums;
aFamilyNums = &aHexaFamilyNums;
aConnectivity = &aHexaConn;
}
MED::TIntVector aVector(aNbNodes); MED::TIntVector* anElemNums;
for(TInt iNode = 0; aNodesIter->more(); iNode++){ MED::TIntVector* aFamilyNums;
const SMDS_MeshElement* aNode = aNodesIter->next();
aVector[iNode] = aNode->GetID(); if (anElem->IsPoly()) {
} const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
TInt aSize = aConnectivity->size(); (const SMDS_PolyhedralVolumeOfNodes*) anElem;
aConnectivity->resize(aSize+aNbConnectivity); if (!aPolyedre) {
// There is some difference between SMDS and MED in cells mapping 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_ #ifdef _EDF_NODE_IDS_
switch(aNbNodes){ aPolyedreConn.push_back(aNodeIdMap[aNodeId]);
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
switch(aNbNodes){ aPolyedreConn.push_back(aNodeId);
case 5:
(*aConnectivity)[aSize+0] = aVector[0];
(*aConnectivity)[aSize+1] = aVector[3];
(*aConnectivity)[aSize+2] = aVector[2];
(*aConnectivity)[aSize+3] = aVector[1];
(*aConnectivity)[aSize+4] = aVector[4];
default:
for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aVector[iNode];
}
#endif #endif
anElemNums->push_back(anElem->GetID()); }
TInt aPrevPos = aPolyedreFaces.back();
aPolyedreFaces.push_back(aPrevPos + aNbFaceNodes);
}
TInt aPrevPos = aPolyedreInds.back();
aPolyedreInds.push_back(aPrevPos + aNbFaces);
} else {
TInt aNbNodes = anElem->NbNodes();
SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
TInt aNbConnectivity;
MED::TIntVector* aConnectivity;
switch(aNbNodes){
case 4:
aNbConnectivity = aNbTetraConn;
anElemNums = &anTetraElemNums;
aFamilyNums = &aTetraFamilyNums;
aConnectivity = &aTetraConn;
break;
case 5:
aNbConnectivity = aNbPyraConn;
anElemNums = &anPyraElemNums;
aFamilyNums = &aPyraFamilyNums;
aConnectivity = &aPyraConn;
break;
case 6:
aNbConnectivity = aNbPentaConn;
anElemNums = &anPentaElemNums;
aFamilyNums = &aPentaFamilyNums;
aConnectivity = &aPentaConn;
break;
case 8:
aNbConnectivity = aNbHexaConn;
anElemNums = &aHexaElemNums;
aFamilyNums = &aHexaFamilyNums;
aConnectivity = &aHexaConn;
}
TInt aSize = aConnectivity->size();
aConnectivity->resize(aSize + aNbConnectivity);
MED::TIntVector aVector(aNbNodes);
for(TInt iNode = 0; aNodesIter->more(); iNode++){
const SMDS_MeshElement* aNode = aNodesIter->next();
#ifdef _EDF_NODE_IDS_
aVector[iNode] = aNodeIdMap[aNode->GetID()];
#else
aVector[iNode] = aNode->GetID();
#endif
}
// There is some difference between SMDS and MED in cells mapping
switch(aNbNodes){
case 5:
(*aConnectivity)[aSize+0] = aVector[0];
(*aConnectivity)[aSize+1] = aVector[3];
(*aConnectivity)[aSize+2] = aVector[2];
(*aConnectivity)[aSize+3] = aVector[1];
(*aConnectivity)[aSize+4] = aVector[4];
default:
for(TInt iNode = 0; iNode < aNbNodes; iNode++)
(*aConnectivity)[aSize+iNode] = aVector[iNode];
}
}
anElemNums->push_back(anElem->GetID());
if (anElemFamMap.find(anElem) != anElemFamMap.end()) if (anElemFamMap.find(anElem) != anElemFamMap.end())
aFamilyNums->push_back(anElemFamMap[anElem]); aFamilyNums->push_back(anElemFamMap[anElem]);
@ -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);
@ -405,7 +405,7 @@ SMESH_ActorDef::SMESH_ActorDef()
myPtsMaskPoints = vtkMaskPoints::New(); myPtsMaskPoints = vtkMaskPoints::New();
myPtsMaskPoints->SetInput(myPointsNumDataSet); myPtsMaskPoints->SetInput(myPointsNumDataSet);
myPtsMaskPoints->SetOnRatio(1); myPtsMaskPoints->SetOnRatio(1);
myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New(); myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput()); myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
myPtsSelectVisiblePoints->SelectInvisibleOff(); myPtsSelectVisiblePoints->SelectInvisibleOff();
@ -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 )
@ -265,17 +352,19 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
case SMDSAbs_Edge: case SMDSAbs_Edge:
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 == 4 ) return VTK_QUAD; else if ( theNbNodes == 3 ) return VTK_TRIANGLE;
else return VTK_EMPTY_CELL; else if ( theNbNodes == 4 ) return VTK_QUAD;
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 == 5 ) return VTK_PYRAMID; else if ( theNbNodes == 4 ) return VTK_TETRA;
else if ( theNbNodes == 6 ) return VTK_WEDGE; else if ( theNbNodes == 5 ) return VTK_PYRAMID;
else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON; else if ( theNbNodes == 6 ) return VTK_WEDGE;
else return VTK_EMPTY_CELL; else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
else return VTK_EMPTY_CELL;
default: return VTK_EMPTY_CELL; default: return VTK_EMPTY_CELL;
} }
@ -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) {
for( vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++ ) 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++)
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
{ {
@ -697,25 +785,27 @@ void SMESH_MeshObj::Update( int theIsClear )
if( !aLength ) if( !aLength )
return; return;
for ( CORBA::Long anId = 0; anId < aLength; anId++) for ( CORBA::Long anId = 0; anId < aLength; anId++)
{ {
const SMESH::double_array& aCoords = aSeq[anId].coords; const SMESH::double_array& aCoords = aSeq[anId].coords;
const SMESH::long_array& anIndexes = aSeq[anId].indexes; const SMESH::long_array& anIndexes = aSeq[anId].indexes;
CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number; CORBA::Long anElemId = 0, aNbElems = aSeq[anId].number;
CORBA::Long aCommand = aSeq[anId].commandType; CORBA::Long aCommand = aSeq[anId].commandType;
switch(aCommand) switch(aCommand)
{ {
case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_NODE : AddNodesWithID ( myMesh, aSeq, anId ); break;
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_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_POLYGON : AddPolygonsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_PYRAMID : AddPiramidsWithID( myMesh, aSeq, anId ); break; case SMESH::ADD_TETRAHEDRON: AddTetrasWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_PRISM : AddPrismsWithID ( myMesh, aSeq, anId ); break; case SMESH::ADD_PYRAMID : AddPiramidsWithID ( myMesh, aSeq, anId ); break;
case SMESH::ADD_HEXAHEDRON : AddHexasWithID ( 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_POLYHEDRON : AddPolyhedronsWithID( myMesh, aSeq, anId ); break;
case SMESH::REMOVE_NODE: case SMESH::REMOVE_NODE:
for( ; anElemId < aNbElems; anElemId++ ) for( ; anElemId < aNbElems; anElemId++ )
myMesh->RemoveNode( FindNode( myMesh, anIndexes[anElemId] ) ); myMesh->RemoveNode( FindNode( myMesh, anIndexes[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,58 +263,75 @@ 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();
switch ( myVolumeNbNodes ) {
case 4:
case 5:
case 6:
case 8:
{
myVolume = theVolume;
myNbFaces = theVolume->NbFaces();
// set volume nodes // set volume nodes
int iNode = 0; int iNode = 0;
SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator(); myVolumeNodes = new const SMDS_MeshNode* [myVolumeNbNodes];
while ( nodeIt->more() ) SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator();
myVolumeNodes[ iNode++ ] = static_cast<const SMDS_MeshNode*>( nodeIt->next() ); 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
XYZ botNormal;
GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z );
const SMDS_MeshNode* topNode = myVolumeNodes[ myVolumeNbNodes - 1 ];
const SMDS_MeshNode* botNode = myVolumeNodes[ 0 ];
XYZ upDir (topNode->X() - botNode->X(),
topNode->Y() - botNode->Y(),
topNode->Z() - botNode->Z() );
myVolForward = ( botNormal.Dot( upDir ) < 0 );
break;
} }
default: myVolume = 0;
if (myVolume->IsPoly()) {
myPolyedre = static_cast<const SMDS_PolyhedralVolumeOfNodes*>( myVolume );
if (!myPolyedre) {
MESSAGE("Warning: bad volumic element");
return false;
}
} else {
switch ( myVolumeNbNodes ) {
case 4:
case 5:
case 6:
case 8: {
// define volume orientation
XYZ botNormal;
GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z );
const SMDS_MeshNode* topNode = myVolumeNodes[ myVolumeNbNodes - 1 ];
const SMDS_MeshNode* botNode = myVolumeNodes[ 0 ];
XYZ upDir (topNode->X() - botNode->X(),
topNode->Y() - botNode->Y(),
topNode->Z() - botNode->Z() );
myVolForward = ( botNormal.Dot( upDir ) < 0 );
break;
}
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;
@ -372,9 +423,9 @@ void SMDS_VolumeTool::SetExternalNormal ()
int SMDS_VolumeTool::NbFaceNodes( int faceIndex ) 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,10 +474,10 @@ 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 ]);
return true; return true;
} }
@ -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,12 +585,17 @@ 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:
if ( faceIndex == 0 || faceIndex == 1 ) if ( faceIndex == 0 || faceIndex == 1 )
ind = 1 - faceIndex; ind = 1 - faceIndex;
break; break;
case 8: case 8:
ind = faceIndex + ( faceIndex % 2 ? -1 : 1 ); ind = faceIndex + ( faceIndex % 2 ? -1 : 1 );
break; break;
@ -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;
// choose face node indices if (myFaceNodes != NULL) {
switch ( myVolumeNbNodes ) { delete [] myFaceNodes;
case 4: myFaceNodes = NULL;
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ];
break;
case 5:
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ];
break;
case 6:
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ];
break;
case 8:
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ];
else
myFaceNodeIndices = Hexa_F[ faceIndex ];
break;
default: return false;
} }
// set face nodes if (myVolume->IsPoly()) {
int iNode, nbNode = myFaceNbNodes[ faceIndex ]; if (!myPolyedre) {
for ( iNode = 0; iNode <= nbNode; iNode++ ) MESSAGE("Warning: bad volumic element");
myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]]; 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
switch ( myVolumeNbNodes ) {
case 4:
myFaceNbNodes = Tetra_nbN[ faceIndex ];
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ];
break;
case 5:
myFaceNbNodes = Pyramid_nbN[ faceIndex ];
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? Pyramid_F[ faceIndex ] : Pyramid_R[ faceIndex ];
break;
case 6:
myFaceNbNodes = Penta_nbN[ faceIndex ];
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ];
else
myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ];
break;
case 8:
myFaceNbNodes = Hexa_nbN[ faceIndex ];
if ( myExternalFaces )
myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ];
else
myFaceNodeIndices = Hexa_F[ faceIndex ];
break;
default:
return false;
}
// set face nodes
myFaceNodes = new const SMDS_MeshNode* [myFaceNbNodes + 1];
for ( int iNode = 0; iNode <= myFaceNbNodes; 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);
@ -165,6 +168,8 @@ public:
int NbTriangles() throw(SALOME_Exception); int NbTriangles() throw(SALOME_Exception);
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);
@ -173,9 +178,11 @@ public:
int NbHexas() throw(SALOME_Exception); int NbHexas() throw(SALOME_Exception);
int NbPyramids() throw(SALOME_Exception); int NbPyramids() throw(SALOME_Exception);
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
@ -226,20 +237,27 @@ 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, const SMDS_MeshNode* theBetweenNode2,
std::list<const SMDS_MeshNode*>& theNodesToInsert); std::list<const SMDS_MeshNode*>& theNodesToInsert,
// insert theNodesToInsert into theFace between theBetweenNode1 const bool toCreatePoly = false);
// and theBetweenNode2 and split theElement. // insert theNodesToInsert into theFace between theBetweenNode1 and theBetweenNode2.
// If toCreatePoly is true, replace theFace by polygon, else split theFace.
static int SortQuadNodes (const SMDS_Mesh * theMesh, void UpdateVolumes (const SMDS_MeshNode* theBetweenNode1,
int theNodeIds[] ); const SMDS_MeshNode* theBetweenNode2,
// Set 4 nodes of a quadrangle face in a good order. std::list<const SMDS_MeshNode*>& theNodesToInsert);
// Swap 1<->2 or 2<->3 nodes and correspondingly return // insert theNodesToInsert into all volumes, containing link
// 1 or 2 else 0. // theBetweenNode1 - theBetweenNode2, between theBetweenNode1 and theBetweenNode2.
static bool SortHexaNodes (const SMDS_Mesh * theMesh, // static int SortQuadNodes (const SMDS_Mesh * theMesh,
int theNodeIds[] ); // int theNodeIds[] );
// Set 8 nodes of a hexahedron in a good order. // // Set 4 nodes of a quadrangle face in a good order.
// Return success status // // Swap 1<->2 or 2<->3 nodes and correspondingly return
// // 1 or 2 else 0.
//
// static bool SortHexaNodes (const SMDS_Mesh * theMesh,
// int theNodeIds[] );
// // Set 8 nodes of a hexahedron in a good order.
// // 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,9 +100,9 @@ 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
// the loaded pattern to <theFaces>. The first key-point // the loaded pattern to <theFaces>. The first key-point
// will be mapped into <theNodeIndexOnKeyPoint1>-th node // will be mapped into <theNodeIndexOnKeyPoint1>-th node
@ -116,9 +116,9 @@ 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
// the loaded pattern to <theVolumes>. The (0,0,0) key-point // the loaded pattern to <theVolumes>. The (0,0,0) key-point
// will be mapped into <theNode000Index>-th node. The // will be mapped into <theNode000Index>-th node. The
@ -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,41 +273,80 @@ 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);
// Look for coincident points between myXYZs indexed with
// list<int> of each element of xyzIndGroups. Coincident indices
// are merged in myElemXYZIDs using reverseConnectivity.
void mergePoints (const bool uniteGroups);
// Merge XYZ on edges and/or faces.
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
bool myIs2D; typedef std::list< int > TElemDef; // element definition is its nodes ids
std::vector< TPoint > myPoints;
std::list< int > myKeyPointIDs;
std::list< std::list< int > > myElemPointIDs;
ErrorCode myErrorCode; bool myIs2D;
bool myIsComputed; std::vector< TPoint > myPoints;
bool myIsBoundaryPointsFound; std::list< int > myKeyPointIDs;
std::list< TElemDef > myElemPointIDs;
TopoDS_Shape myShape; ErrorCode myErrorCode;
bool myIsComputed;
bool myIsBoundaryPointsFound;
TopoDS_Shape myShape;
// 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::vector<const SMDS_MeshElement*> myElements; // refined elements std::map< int, const SMDS_MeshNode*> myXYZIdToNodeMap; // map XYZ id to node of a refined element
std::vector<const SMDS_MeshNode*> myOrderedNodes; std::vector<const SMDS_MeshElement*> myElements; // refined elements
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 ))
// is there the same local hyp or maybe a new father algo applied? SetAlgoState(HYP_OK);
if ( !GetSimilarAttached( _subShape, anHyp ) )
modifiedHyp = true;
}
else else
SetAlgoState(MISSING_HYP); SetAlgoState(MISSING_HYP);
// is there the same local hyp or maybe a new father algo applied?
if ( !GetSimilarAttached( _subShape, anHyp ) )
modifiedHyp = true;
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;
} }
@ -1047,7 +1035,7 @@ void SMESH_subMesh::CleanDependsOn()
for (its = dependson.begin(); its != dependson.end(); its++) for (its = dependson.begin(); its != dependson.end(); its++)
{ {
SMESH_subMesh *sm = (*its).second; SMESH_subMesh *sm = (*its).second;
//SCRUTE((*its).first); // SCRUTE((*its).first);
sm->ComputeStateEngine(CLEAN); sm->ComputeStateEngine(CLEAN);
} }
} }
@ -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 SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor);
if ( ancestor.ShapeType() >= TopAbs_SOLID ) { if (aSubMesh)
SMESH_subMesh *aSubMesh = _father->GetSubMeshContaining(ancestor); aSubMesh->ComputeStateEngine(CLEANDEP);
if (aSubMesh)
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 MoveNode(int NewNodeID, double x, double y, double z);
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 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() ) return true;
{ if (myOperation == LO_AND && !filter->isOk(owner))
if ( myLogOp == LO_OR && anIter.Value()->IsOk( theIO ) ) return false;
return true; if (myOperation == LO_NOT)
if ( myLogOp == LO_AND && !anIter.Value()->IsOk( theIO ) ) return !filter->isOk(owner);
return false;
}
} }
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:
SMESH_LogicalFilter (const QPtrList<SUIT_SelectionFilter>&,
const int);
virtual ~SMESH_LogicalFilter();
public: virtual bool isOk (const SUIT_DataOwner*) const;
SMESH_LogicalFilter( const SMESH_ListOfFilter&, const int ); void setFilters (const QPtrList<SUIT_SelectionFilter>&);
void setOperation (const int);
const QPtrList<SUIT_SelectionFilter> getFilters() const;
virtual ~SMESH_LogicalFilter(); int getOperation() const;
virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const;
void SetFilters( const SMESH_ListOfFilter& );
void SetLogOp( const int );
const SMESH_ListOfFilter& GetFilters() const;
int GetLogOp() 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,84 +1,65 @@
// 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
//======================================================================= //=======================================================================
SMESH_NumberFilter::SMESH_NumberFilter( const char* theKind, SMESH_NumberFilter::SMESH_NumberFilter (const char* theKind,
const TopAbs_ShapeEnum theSubShapeType, const TopAbs_ShapeEnum theSubShapeType,
const int theNumber, const int theNumber,
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;
myShapeTypes.Add( theShapeType ); myShapeTypes.Add(theShapeType);
myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj);
} }
//======================================================================= //=======================================================================
// name : SMESH_NumberFilter::SMESH_NumberFilter // name : SMESH_NumberFilter::SMESH_NumberFilter
// Purpose : Constructor // Purpose : Constructor
//======================================================================= //=======================================================================
SMESH_NumberFilter::SMESH_NumberFilter( const char* theKind, SMESH_NumberFilter::SMESH_NumberFilter (const char* theKind,
const TopAbs_ShapeEnum theSubShapeType, const TopAbs_ShapeEnum theSubShapeType,
const int theNumber, const int theNumber,
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;
myShapeTypes = theShapeTypes; myShapeTypes = theShapeTypes;
myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj);
} }
SMESH_NumberFilter::~SMESH_NumberFilter() SMESH_NumberFilter::~SMESH_NumberFilter()
@ -89,52 +70,53 @@ 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;
// Get shape from geom object and verify its parameters // Get shape from geom object and verify its parameters
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; return false;
if (myIsClosedOnly && aShape.ShapeType() == TopAbs_SHELL && !aShape.Closed())
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;
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())
aMap.Add( anExp2.Current() ); aMap.Add(anExp2.Current());
return myNumber == aMap.Extent(); return myNumber == aMap.Extent();
} }
@ -143,83 +125,76 @@ 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();
}
else
{
// 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();
SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO ); GEOM::GEOM_Object_var anObj;
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();
}
if (!owner || !appStudy)
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
_PTR(Study) study = appStudy->studyDS();
QString entry = owner->entry();
_PTR(SObject) aSO(study->FindObjectID(entry.latin1()));
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())
return aMeshShape._retn();
} }
return GEOM::GEOM_Object::_nil();
} }
void SMESH_NumberFilter::SetSubShapeType (const TopAbs_ShapeEnum theSubShapeType)
void SMESH_NumberFilter::SetSubShapeType( const TopAbs_ShapeEnum theSubShapeType )
{ {
mySubShapeType = theSubShapeType; mySubShapeType = theSubShapeType;
} }
void SMESH_NumberFilter::SetNumber( const int theNumber ) void SMESH_NumberFilter::SetNumber (const int theNumber)
{ {
myNumber = theNumber; myNumber = theNumber;
} }
void SMESH_NumberFilter::SetClosedOnly( const bool theIsClosedOnly ) void SMESH_NumberFilter::SetClosedOnly (const bool theIsClosedOnly)
{ {
myIsClosedOnly = theIsClosedOnly; myIsClosedOnly = theIsClosedOnly;
} }
void SMESH_NumberFilter::SetShapeType( const TopAbs_ShapeEnum theShapeType ) void SMESH_NumberFilter::SetShapeType (const TopAbs_ShapeEnum theShapeType)
{ {
myShapeTypes.Add( theShapeType ); myShapeTypes.Add( theShapeType );
} }
void SMESH_NumberFilter::SetMainShape( GEOM::GEOM_Object_ptr theMainObj ) void SMESH_NumberFilter::SetMainShape (GEOM::GEOM_Object_ptr theMainObj)
{ {
myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); myMainObj = GEOM::GEOM_Object::_duplicate(theMainObj);
} }

View File

@ -1,124 +1,69 @@
// 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:
SMESH_NumberFilter (const char* theKind,
const TopAbs_ShapeEnum theSubShapeType,
const int theNumber,
const TopAbs_ShapeEnum theShapeType = TopAbs_SHAPE,
GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(),
const bool theIsClosedOnly = false );
public: SMESH_NumberFilter (const char* theKind,
const TopAbs_ShapeEnum theSubShapeType,
const int theNumber,
const TColStd_MapOfInteger& theShapeTypes,
GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(),
const bool theIsClosedOnly = false );
SMESH_NumberFilter( const char* theKind, virtual ~SMESH_NumberFilter();
const TopAbs_ShapeEnum theSubShapeType,
const int theNumber,
const TopAbs_ShapeEnum theShapeType = TopAbs_SHAPE,
GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(),
const bool theIsClosedOnly = false );
SMESH_NumberFilter( const char* theKind, virtual bool isOk (const SUIT_DataOwner*) const;
const TopAbs_ShapeEnum theSubShapeType,
const int theNumber,
const TColStd_MapOfInteger& theShapeTypes,
GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(),
const bool theIsClosedOnly = false );
virtual ~SMESH_NumberFilter();
virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const;
void SetSubShapeType( const TopAbs_ShapeEnum );
void SetNumber( const int );
void SetClosedOnly( const bool );
void SetShapeType( const TopAbs_ShapeEnum );
void SetShapeTypes( const TColStd_MapOfInteger& );
void SetMainShape( GEOM::GEOM_Object_ptr );
private: void SetSubShapeType (const TopAbs_ShapeEnum);
GEOM::GEOM_Object_ptr getGeom( const Handle(SALOME_InteractiveObject)& theObj ) const; void SetNumber (const int);
void SetClosedOnly (const bool);
void SetShapeType (const TopAbs_ShapeEnum);
void SetShapeTypes (const TColStd_MapOfInteger&);
void SetMainShape (GEOM::GEOM_Object_ptr);
private:
private: GEOM::GEOM_Object_ptr getGeom (const SUIT_DataOwner*) const;
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,44 +1,38 @@
// 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());
if (owner && appStudy) {
_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();
SALOMEDS::SObject_var objFather = obj->GetFather();
SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent();
int aLevel = obj->Depth() - objComponent->Depth(); int aLevel = obj->Depth() - objComponent->Depth();
// Max level under the component is 4: // Max level under the component is 4:
@ -55,10 +49,10 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)&
// 4 | |- Applied algorithms ( selectable in Use Case Browser ) // 4 | |- Applied algorithms ( selectable in Use Case Browser )
// |- Group Of Nodes // |- Group Of Nodes
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

@ -11,7 +11,7 @@
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
@ -30,71 +30,96 @@
#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();
QDialog* GetActiveDialogBox() ; virtual QString engineIOR() const;
void SetActiveDialogBox(QDialog* aDlg) ; virtual void initialize( CAM_Application* );
virtual void windows( QMap<int, int>& ) const;
virtual void viewManagers( QStringList& ) const;
void ResetState() ; QDialog* GetActiveDialogBox() ;
void SetActiveDialogBox(QDialog* aDlg) ;
void ResetState() ;
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;
}; };

File diff suppressed because it is too large Load Diff

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,33 +71,35 @@ 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;
SMESH::TElementSimulation* mySimulation; SMESH::TElementSimulation* mySimulation;
QButtonGroup* GroupConstructors; QButtonGroup* GroupConstructors;
QRadioButton* Constructor1; QRadioButton* Constructor1;

View File

@ -1,23 +1,23 @@
// SMESH SMESHGUI : GUI for SMESH component // SMESH SMESHGUI : GUI for SMESH component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
// //
// //
// //
@ -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"
@ -56,178 +64,181 @@
using namespace std; using namespace std;
namespace SMESH{ namespace SMESH {
SMESH::SMESH_subMesh_var AddSubMesh(SMESH::SMESH_Mesh_ptr theMesh, SMESH::SMESH_subMesh_var AddSubMesh (SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject, GEOM::GEOM_Object_ptr theShapeObject,
const char* theMeshName ) const char* theMeshName)
{ {
SMESH::SMESH_subMesh_var aSubMesh; SMESH::SMESH_subMesh_var aSubMesh;
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"));
setSizeGripEnabled( TRUE ); setSizeGripEnabled(TRUE);
QGridLayout* SMESHGUI_AddSubMeshDlgLayout = new QGridLayout( this ); QGridLayout* SMESHGUI_AddSubMeshDlgLayout = new QGridLayout(this);
SMESHGUI_AddSubMeshDlgLayout->setSpacing( 6 ); SMESHGUI_AddSubMeshDlgLayout->setSpacing(6);
SMESHGUI_AddSubMeshDlgLayout->setMargin( 11 ); SMESHGUI_AddSubMeshDlgLayout->setMargin(11);
/***************************************************************/
GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), this, "GroupC1" );
GroupC1->setColumnLayout(0, Qt::Vertical );
GroupC1->layout()->setSpacing( 0 );
GroupC1->layout()->setMargin( 0 );
QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
GroupC1Layout->setAlignment( Qt::AlignTop );
GroupC1Layout->setSpacing( 6 );
GroupC1Layout->setMargin( 11 );
TextLabel_NameMesh = new QLabel( tr( "SMESH_NAME" ), GroupC1, "TextLabel_NameMesh" );
GroupC1Layout->addWidget( TextLabel_NameMesh, 0, 0 );
LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" );
GroupC1Layout->addWidget( LineEdit_NameMesh, 0, 2 );
TextLabelC1A1 = new QLabel( tr( "SMESH_OBJECT_MESH" ), GroupC1, "TextLabelC1A1" );
GroupC1Layout->addWidget( TextLabelC1A1, 1, 0 );
SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
SelectButtonC1A1->setPixmap( image0 );
SelectButtonC1A1->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A1, 1, 1 );
LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
LineEditC1A1->setReadOnly( true );
GroupC1Layout->addWidget( LineEditC1A1, 1, 2 );
TextLabelC1A2 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A2" );
GroupC1Layout->addWidget( TextLabelC1A2, 2, 0 );
SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" );
SelectButtonC1A2->setPixmap( image0 );
SelectButtonC1A2->setToggleButton( FALSE );
GroupC1Layout->addWidget( SelectButtonC1A2, 2, 1 );
LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
LineEditC1A2->setReadOnly( true );
GroupC1Layout->addWidget( LineEditC1A2, 2, 2 );
TextLabelC1A1Hyp = new QLabel( tr( "SMESH_OBJECT_HYPOTHESIS" ), GroupC1, "TextLabelC1A1Hyp" );
GroupC1Layout->addWidget( TextLabelC1A1Hyp, 3, 0 );
SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" );
SelectButtonC1A1Hyp->setPixmap( image0 );
GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 3, 1 );
LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" );
LineEditC1A1Hyp->setReadOnly( true );
GroupC1Layout->addWidget( LineEditC1A1Hyp, 3, 2 );
TextLabelC1A1Algo = new QLabel( tr( "SMESH_OBJECT_ALGORITHM" ), GroupC1, "TextLabelC1A1Algo" );
GroupC1Layout->addWidget( TextLabelC1A1Algo, 4, 0 );
SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" );
SelectButtonC1A1Algo->setPixmap( image0 );
GroupC1Layout->addWidget( SelectButtonC1A1Algo, 4, 1 );
LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" );
LineEditC1A1Algo->setReadOnly( true );
GroupC1Layout->addWidget( LineEditC1A1Algo, 4, 2 );
SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupC1, 1, 0 );
/***************************************************************/ /***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" ); GroupC1 = new QGroupBox (tr("SMESH_ARGUMENTS"), this, "GroupC1");
GroupButtons->setColumnLayout(0, Qt::Vertical ); GroupC1->setColumnLayout(0, Qt::Vertical);
GroupButtons->layout()->setSpacing( 0 ); GroupC1->layout()->setSpacing(0);
GroupButtons->layout()->setMargin( 0 ); GroupC1->layout()->setMargin(0);
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); QGridLayout* GroupC1Layout = new QGridLayout (GroupC1->layout());
GroupButtonsLayout->setAlignment( Qt::AlignTop ); GroupC1Layout->setAlignment(Qt::AlignTop);
GroupButtonsLayout->setSpacing( 6 ); GroupC1Layout->setSpacing(6);
GroupButtonsLayout->setMargin( 11 ); GroupC1Layout->setMargin(11);
buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons, "buttonOk" ); TextLabel_NameMesh = new QLabel (tr("SMESH_NAME"), GroupC1, "TextLabel_NameMesh");
buttonOk->setAutoDefault( TRUE ); GroupC1Layout->addWidget(TextLabel_NameMesh, 0, 0);
buttonOk->setDefault( TRUE ); LineEdit_NameMesh = new QLineEdit (GroupC1, "LineEdit_NameMesh");
GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); GroupC1Layout->addWidget(LineEdit_NameMesh, 0, 2);
buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons, "buttonApply" ); TextLabelC1A1 = new QLabel (tr("SMESH_OBJECT_MESH"), GroupC1, "TextLabelC1A1");
buttonApply->setAutoDefault( TRUE ); GroupC1Layout->addWidget(TextLabelC1A1, 1, 0);
GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); SelectButtonC1A1 = new QPushButton (GroupC1, "SelectButtonC1A1");
SelectButtonC1A1->setPixmap(image0);
SelectButtonC1A1->setToggleButton(FALSE);
GroupC1Layout->addWidget(SelectButtonC1A1, 1, 1);
LineEditC1A1 = new QLineEdit (GroupC1, "LineEditC1A1");
LineEditC1A1->setReadOnly(true);
GroupC1Layout->addWidget(LineEditC1A1, 1, 2);
GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); TextLabelC1A2 = new QLabel(tr("SMESH_OBJECT_GEOM"), GroupC1, "TextLabelC1A2");
GroupC1Layout->addWidget(TextLabelC1A2, 2, 0);
SelectButtonC1A2 = new QPushButton(GroupC1, "SelectButtonC1A2");
SelectButtonC1A2->setPixmap(image0);
SelectButtonC1A2->setToggleButton(FALSE);
GroupC1Layout->addWidget(SelectButtonC1A2, 2, 1);
LineEditC1A2 = new QLineEdit(GroupC1, "LineEditC1A2");
LineEditC1A2->setReadOnly(true);
GroupC1Layout->addWidget(LineEditC1A2, 2, 2);
buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons, "buttonCancel" ); TextLabelC1A1Hyp = new QLabel(tr("SMESH_OBJECT_HYPOTHESIS"), GroupC1, "TextLabelC1A1Hyp");
buttonCancel->setAutoDefault( TRUE ); GroupC1Layout->addWidget(TextLabelC1A1Hyp, 3, 0);
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); SelectButtonC1A1Hyp = new QPushButton(GroupC1, "SelectButtonC1A1Hyp");
SelectButtonC1A1Hyp->setPixmap(image0);
GroupC1Layout->addWidget(SelectButtonC1A1Hyp, 3, 1);
LineEditC1A1Hyp = new QLineEdit(GroupC1, "LineEditC1A1Hyp");
LineEditC1A1Hyp->setReadOnly(true);
GroupC1Layout->addWidget(LineEditC1A1Hyp, 3, 2);
SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupButtons, 2, 0 ); TextLabelC1A1Algo = new QLabel(tr("SMESH_OBJECT_ALGORITHM"), GroupC1, "TextLabelC1A1Algo");
GroupC1Layout->addWidget(TextLabelC1A1Algo, 4, 0);
SelectButtonC1A1Algo = new QPushButton(GroupC1, "SelectButtonC1A1Algo");
SelectButtonC1A1Algo->setPixmap(image0);
GroupC1Layout->addWidget(SelectButtonC1A1Algo, 4, 1);
LineEditC1A1Algo = new QLineEdit(GroupC1, "LineEditC1A1Algo");
LineEditC1A1Algo->setReadOnly(true);
GroupC1Layout->addWidget(LineEditC1A1Algo, 4, 2);
SMESHGUI_AddSubMeshDlgLayout->addWidget(GroupC1, 1, 0);
/***************************************************************/ /***************************************************************/
Init( Sel ) ; GroupButtons = new QGroupBox(this, "GroupButtons");
GroupButtons->setColumnLayout(0, Qt::Vertical);
GroupButtons->layout()->setSpacing(0);
GroupButtons->layout()->setMargin(0);
QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
GroupButtonsLayout->setAlignment(Qt::AlignTop);
GroupButtonsLayout->setSpacing(6);
GroupButtonsLayout->setMargin(11);
buttonOk = new QPushButton(tr("SMESH_BUT_OK"), GroupButtons, "buttonOk");
buttonOk->setAutoDefault(TRUE);
buttonOk->setDefault(TRUE);
GroupButtonsLayout->addWidget(buttonOk, 0, 0);
buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons, "buttonApply");
buttonApply->setAutoDefault(TRUE);
GroupButtonsLayout->addWidget(buttonApply, 0, 1);
GroupButtonsLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2);
buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons, "buttonCancel");
buttonCancel->setAutoDefault(TRUE);
GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
SMESHGUI_AddSubMeshDlgLayout->addWidget(GroupButtons, 2, 0);
/***************************************************************/
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
//================================================================================= //=================================================================================
SMESHGUI_AddSubMeshDlg::~SMESHGUI_AddSubMeshDlg() 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->SetActiveDialogBox((QDialog*)this);
mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ;
myGeomFilter = new SALOME_TypeFilter( "GEOM" ); //myGeomFilter = new SALOME_TypeFilter("GEOM");
myMeshFilter = new SMESH_TypeFilter( MESH ); TColStd_MapOfInteger allTypesMap;
myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM ); for (int i = 0; i < 10; i++)
myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS ); allTypesMap.Add(i);
myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
myMeshFilter = new SMESH_TypeFilter (MESH);
myAlgorithmFilter = new SMESH_TypeFilter (ALGORITHM);
myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS);
/* signals and slots connections */ /* signals and slots connections */
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
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( 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()));
int x, y ;
mySMESHGUI->DefineDlgPosition( this, x, y ) ;
this->move( x, y ) ;
this->show() ;
LineEdit_NameMesh->setText( tr( "SMESH_SUBMESH" ) ); int x, y;
LineEdit_NameMesh->setFocus() ; mySMESHGUI->DefineDlgPosition(this, x, y);
myEditCurrentArgument = LineEditC1A1 ; this->move(x, y);
mySelection->ClearFilters() ; this->show();
mySelection->AddFilter( myMeshFilter ) ;
LineEdit_NameMesh->setText(tr("SMESH_SUBMESH"));
LineEdit_NameMesh->setFocus();
myEditCurrentArgument = LineEditC1A1;
mySelectionMgr->clearFilters();
mySelectionMgr->installFilter(myMeshFilter);
SelectionIntoArgument(); SelectionIntoArgument();
} }
@ -238,8 +249,8 @@ void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel )
//================================================================================= //=================================================================================
void SMESHGUI_AddSubMeshDlg::ClickOnOk() void SMESHGUI_AddSubMeshDlg::ClickOnOk()
{ {
if ( this->ClickOnApply() ) if (this->ClickOnApply())
this->ClickOnCancel() ; this->ClickOnCancel();
} }
//================================================================================= //=================================================================================
@ -248,67 +259,68 @@ 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();
// create submesh // create submesh
SMESH::SMESH_subMesh_var aSubMesh = SMESH::AddSubMesh( myMesh, myGeomShape, myNameSubMesh ) ; SMESH::SMESH_subMesh_var aSubMesh = SMESH::AddSubMesh(myMesh, myGeomShape, myNameSubMesh);
int nbSuccess = 0; int nbSuccess = 0;
if ( !aSubMesh->_is_nil() ) { if (!aSubMesh->_is_nil()) {
// assign hypotheses // assign hypotheses
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) {
if ( !CORBA::is_nil( anObject ) ) { CORBA::Object_var anObject = _CAST(SObject,aHypSOClient)->GetObject();
SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); if (!CORBA::is_nil(anObject)) {
if ( !aHyp->_is_nil() ) SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(anObject);
if ( SMESH::AddHypothesisOnSubMesh( aSubMesh, aHyp ) ) if (!aHyp->_is_nil())
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 {
SCRUTE(aSubMesh->_is_nil());
} }
else {
SCRUTE( aSubMesh->_is_nil() );
}
// commit transaction
op->finish();
return ( nbSuccess > 0 );
}
// commit transaction
op->commit();
mySMESHGUI->updateObjBrowser();
return (nbSuccess > 0);
}
//================================================================================= //=================================================================================
// function : ClickOnCancel() // function : ClickOnCancel()
@ -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();
} }
@ -342,87 +356,86 @@ 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) ;
if ( myEditCurrentArgument == LineEditC1A1 ) { SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type());
int nbSel = SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
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 = "";
} }
} }
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 :
@ -431,27 +444,27 @@ 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() ; } else if(send == SelectButtonC1A1Hyp) {
mySelection->AddFilter(myGeomFilter) ; LineEditC1A1Hyp->setFocus();
} else if( send == SelectButtonC1A1Hyp ) { mySelectionMgr->clearFilters();
LineEditC1A1Hyp->setFocus() ; mySelectionMgr->installFilter(myHypothesisFilter);
myEditCurrentArgument = LineEditC1A1Hyp ; myEditCurrentArgument = LineEditC1A1Hyp;
mySelection->ClearFilters() ; } else if(send == SelectButtonC1A1Algo) {
mySelection->AddFilter(myHypothesisFilter) ; LineEditC1A1Algo->setFocus();
} else if( send == SelectButtonC1A1Algo ) { mySelectionMgr->clearFilters();
LineEditC1A1Algo->setFocus() ; mySelectionMgr->installFilter(myAlgorithmFilter);
myEditCurrentArgument = LineEditC1A1Algo ; myEditCurrentArgument = LineEditC1A1Algo;
mySelection->ClearFilters() ;
mySelection->AddFilter(myAlgorithmFilter) ;
} }
SelectionIntoArgument() ; SelectionIntoArgument();
} }
//================================================================================= //=================================================================================
@ -460,48 +473,45 @@ 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 :
//================================================================================= //=================================================================================
void SMESHGUI_AddSubMeshDlg::ActivateThisDialog() 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,14 +520,16 @@ 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();
} }
buttonOk ->setEnabled( isEnabled && !isImportedMesh ); buttonOk ->setEnabled(isEnabled && !isImportedMesh);
buttonApply->setEnabled( isEnabled && !isImportedMesh ); buttonApply->setEnabled(isEnabled && !isImportedMesh);
} }

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,33 +58,40 @@ 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:
void closeEvent( QCloseEvent* e ) ; void closeEvent (QCloseEvent* e);
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;
GEOM::GEOM_Object_var myGeomShape ;
QLineEdit* myEditCurrentArgument;
Handle(SALOME_TypeFilter) myGeomFilter; SMESH::SMESH_Mesh_var myMesh;
Handle(SMESH_TypeFilter) myMeshFilter; GEOM::GEOM_Object_var myGeomShape;
Handle(SMESH_TypeFilter) myHypothesisFilter; QLineEdit* myEditCurrentArgument;
Handle(SMESH_TypeFilter) myAlgorithmFilter;
QStringList HypoList; //Handle(SALOME_TypeFilter) myMeshFilter;
QStringList AlgoList; //Handle(SMESH_TypeFilter) myMeshFilter;
//Handle(SMESH_TypeFilter) myHypothesisFilter;
//Handle(SMESH_TypeFilter) myAlgorithmFilter;
SUIT_SelectionFilter* myGeomFilter;
SUIT_SelectionFilter* myMeshFilter;
SUIT_SelectionFilter* myHypothesisFilter;
SUIT_SelectionFilter* myAlgorithmFilter;
QStringList HypoList;
QStringList AlgoList;
QGroupBox* GroupButtons; QGroupBox* GroupButtons;
QPushButton* buttonOk; QPushButton* buttonOk;
@ -91,8 +99,8 @@ private:
QPushButton* buttonCancel; QPushButton* buttonCancel;
QGroupBox* GroupC1; QGroupBox* GroupC1;
QLabel* TextLabel_NameMesh ; QLabel* TextLabel_NameMesh;
QLineEdit* LineEdit_NameMesh ; QLineEdit* LineEdit_NameMesh;
QLabel* TextLabelC1A1; QLabel* TextLabelC1A1;
QPushButton* SelectButtonC1A1; QPushButton* SelectButtonC1A1;
QLineEdit* LineEditC1A1; QLineEdit* LineEditC1A1;
@ -112,10 +120,10 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ClickOnCancel(); void ClickOnCancel();
void SetEditCurrentArgument() ; void SetEditCurrentArgument();
void SelectionIntoArgument() ; void SelectionIntoArgument();
void DeactivateActiveDialog() ; void DeactivateActiveDialog();
void ActivateThisDialog() ; void ActivateThisDialog();
}; };
#endif // DIALOGBOX_ADD_SUBMESH_H #endif // DIALOGBOX_ADD_SUBMESH_H

View File

@ -1,23 +1,23 @@
// SMESH SMESHGUI : GUI for SMESH component // SMESH SMESHGUI : GUI for SMESH component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
// //
// //
// //
@ -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,57 +68,46 @@
#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];
vtkPlaneSource* myPlaneSource; vtkPlaneSource* myPlaneSource;
SALOME_Actor *myActor; SALOME_Actor *myActor;
void SetOrientation(SMESH::Orientation theOrientation) {myOrientation = theOrientation;}
SMESH::Orientation GetOrientation() {return myOrientation;}
void SetDistance(float theDistance) {myDistance = theDistance;} void SetOrientation (SMESH::Orientation theOrientation) { myOrientation = theOrientation; }
float GetDistance() {return myDistance;} SMESH::Orientation GetOrientation() { return myOrientation; }
void ShallowCopy(OrientedPlane* theOrientedPlane){ void SetDistance (float theDistance) { myDistance = theDistance; }
float GetDistance() { return myDistance; }
void ShallowCopy (OrientedPlane* theOrientedPlane)
{
SetNormal(theOrientedPlane->GetNormal()); SetNormal(theOrientedPlane->GetNormal());
SetOrigin(theOrientedPlane->GetOrigin()); SetOrigin(theOrientedPlane->GetOrigin());
@ -120,41 +124,38 @@ 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;
// Create and display actor // Create and display actor
myMapper = vtkDataSetMapper::New(); myMapper = vtkDataSetMapper::New();
myMapper->SetInput( myPlaneSource->GetOutput() ); myMapper->SetInput(myPlaneSource->GetOutput());
myActor = SALOME_Actor::New(); myActor = SALOME_Actor::New();
myActor->VisibilityOff(); myActor->VisibilityOff();
myActor->PickableOff(); myActor->PickableOff();
myActor->SetInfinitive(true); myActor->SetInfinitive(true);
myActor->SetMapper( myMapper ); myActor->SetMapper(myMapper);
vtkProperty* aProp = vtkProperty::New(); vtkProperty* aProp = vtkProperty::New();
float anRGB[3]; float anRGB[3];
@ -163,40 +164,38 @@ protected:
anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.;
aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
aProp->SetOpacity(0.75); aProp->SetOpacity(0.75);
myActor->SetProperty( aProp ); myActor->SetProperty(aProp);
aProp->Delete(); aProp->Delete();
vtkProperty* aBackProp = vtkProperty::New(); vtkProperty* aBackProp = vtkProperty::New();
anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.;
aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
aBackProp->SetOpacity(0.75); aBackProp->SetOpacity(0.75);
myActor->SetBackfaceProperty( aBackProp ); myActor->SetBackfaceProperty(aBackProp);
aBackProp->Delete(); aBackProp->Delete();
} }
~OrientedPlane(){ ~OrientedPlane(){
if(myStudy && SMESH::FindVtkViewFrame(myStudy,myStudyFrame)){ myViewWindow->RemoveActor(myActor);
myViewFrame->RemoveActor(myActor);
}
myActor->Delete(); myActor->Delete();
myMapper->RemoveAllInputs(); myMapper->RemoveAllInputs();
myMapper->Delete(); myMapper->Delete();
myPlaneSource->UnRegisterAllOutputs(); myPlaneSource->UnRegisterAllOutputs();
myPlaneSource->Delete(); myPlaneSource->Delete();
}; };
private: private:
// Not implemented. // Not implemented.
OrientedPlane(const OrientedPlane&); OrientedPlane (const OrientedPlane&);
void operator=(const OrientedPlane&); void operator= (const OrientedPlane&);
}; };
struct TSetVisiblity{ struct TSetVisiblity {
TSetVisiblity(int theIsVisible): myIsVisible(theIsVisible){} TSetVisiblity(int theIsVisible): myIsVisible(theIsVisible){}
void operator()(SMESH::TVTKPlane& theOrientedPlane){ void operator()(SMESH::TVTKPlane& theOrientedPlane){
theOrientedPlane->myActor->SetVisibility(myIsVisible); theOrientedPlane->myActor->SetVisibility(myIsVisible);
@ -204,173 +203,175 @@ 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");
setCaption( tr( "SMESH_CLIPPING_TITLE" ) ); setCaption(tr("SMESH_CLIPPING_TITLE"));
setSizeGripEnabled( TRUE ); setSizeGripEnabled(TRUE);
QGridLayout* SMESHGUI_ClippingDlgLayout = new QGridLayout( this ); QGridLayout* SMESHGUI_ClippingDlgLayout = new QGridLayout(this);
SMESHGUI_ClippingDlgLayout->setSpacing( 6 ); SMESHGUI_ClippingDlgLayout->setSpacing(6);
SMESHGUI_ClippingDlgLayout->setMargin( 11 ); SMESHGUI_ClippingDlgLayout->setMargin(11);
// Controls for selecting, creating, deleting planes // Controls for selecting, creating, deleting planes
QGroupBox* GroupPlanes = new QGroupBox( this, "GroupPlanes" ); QGroupBox* GroupPlanes = new QGroupBox (this, "GroupPlanes");
GroupPlanes->setTitle( tr("Clipping planes") ); GroupPlanes->setTitle(tr("Clipping planes"));
GroupPlanes->setColumnLayout(0, Qt::Vertical); GroupPlanes->setColumnLayout(0, Qt::Vertical);
GroupPlanes->layout()->setSpacing( 0 ); GroupPlanes->layout()->setSpacing(0);
GroupPlanes->layout()->setMargin( 0 ); GroupPlanes->layout()->setMargin(0);
QGridLayout* GroupPlanesLayout = new QGridLayout( GroupPlanes->layout() ); QGridLayout* GroupPlanesLayout = new QGridLayout (GroupPlanes->layout());
GroupPlanesLayout->setAlignment( Qt::AlignTop ); GroupPlanesLayout->setAlignment(Qt::AlignTop);
GroupPlanesLayout->setSpacing( 6 ); GroupPlanesLayout->setSpacing(6);
GroupPlanesLayout->setMargin( 11 ); GroupPlanesLayout->setMargin(11);
ComboBoxPlanes = new QComboBox(GroupPlanes, "ComboBoxPlanes"); ComboBoxPlanes = new QComboBox(GroupPlanes, "ComboBoxPlanes");
GroupPlanesLayout->addWidget( ComboBoxPlanes, 0, 0 ); GroupPlanesLayout->addWidget(ComboBoxPlanes, 0, 0);
QSpacerItem* spacerGP = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); QSpacerItem* spacerGP = new QSpacerItem (20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
GroupPlanesLayout->addItem( spacerGP, 0, 1 ); GroupPlanesLayout->addItem(spacerGP, 0, 1);
buttonNew = new QPushButton( GroupPlanes, "buttonNew" ); buttonNew = new QPushButton (GroupPlanes, "buttonNew");
buttonNew->setText( tr( "SMESH_BUT_NEW" ) ); buttonNew->setText(tr("SMESH_BUT_NEW"));
GroupPlanesLayout->addWidget( buttonNew, 0, 2 ); GroupPlanesLayout->addWidget(buttonNew, 0, 2);
buttonDelete = new QPushButton( GroupPlanes, "buttonDelete" ); buttonDelete = new QPushButton (GroupPlanes, "buttonDelete");
buttonDelete->setText( tr( "SMESH_BUT_DELETE" ) ); buttonDelete->setText(tr("SMESH_BUT_DELETE"));
GroupPlanesLayout->addWidget( buttonDelete, 0, 3 ); GroupPlanesLayout->addWidget(buttonDelete, 0, 3);
// Controls for defining plane parameters // Controls for defining plane parameters
QGroupBox* GroupParameters = new QGroupBox( this, "GroupParameters" ); QGroupBox* GroupParameters = new QGroupBox (this, "GroupParameters");
GroupParameters->setTitle( tr("SMESH_PARAMETERS") ); GroupParameters->setTitle(tr("SMESH_PARAMETERS"));
GroupParameters->setColumnLayout(0, Qt::Vertical); GroupParameters->setColumnLayout(0, Qt::Vertical);
GroupParameters->layout()->setSpacing( 0 ); GroupParameters->layout()->setSpacing(0);
GroupParameters->layout()->setMargin( 0 ); GroupParameters->layout()->setMargin(0);
QGridLayout* GroupParametersLayout = new QGridLayout( GroupParameters->layout() ); QGridLayout* GroupParametersLayout = new QGridLayout (GroupParameters->layout());
GroupParametersLayout->setAlignment( Qt::AlignTop ); GroupParametersLayout->setAlignment(Qt::AlignTop);
GroupParametersLayout->setSpacing( 6 ); GroupParametersLayout->setSpacing(6);
GroupParametersLayout->setMargin( 11 ); GroupParametersLayout->setMargin(11);
TextLabelOrientation = new QLabel( GroupParameters, "TextLabelOrientation" ); TextLabelOrientation = new QLabel(GroupParameters, "TextLabelOrientation");
TextLabelOrientation->setText( tr("SMESH_ORIENTATION") ); TextLabelOrientation->setText(tr("SMESH_ORIENTATION"));
GroupParametersLayout->addWidget( TextLabelOrientation, 0, 0 ); GroupParametersLayout->addWidget(TextLabelOrientation, 0, 0);
ComboBoxOrientation = new QComboBox(GroupParameters, "ComboBoxOrientation"); ComboBoxOrientation = new QComboBox(GroupParameters, "ComboBoxOrientation");
GroupParametersLayout->addWidget( ComboBoxOrientation, 0, 1 ); GroupParametersLayout->addWidget(ComboBoxOrientation, 0, 1);
TextLabelDistance = new QLabel( GroupParameters, "TextLabelDistance" );
TextLabelDistance->setText( tr("SMESH_DISTANCE") );
GroupParametersLayout->addWidget( TextLabelDistance, 1, 0 );
SpinBoxDistance = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxDistance" ); TextLabelDistance = new QLabel(GroupParameters, "TextLabelDistance");
GroupParametersLayout->addWidget( SpinBoxDistance, 1, 1 ); TextLabelDistance->setText(tr("SMESH_DISTANCE"));
GroupParametersLayout->addWidget(TextLabelDistance, 1, 0);
TextLabelRot1 = new QLabel( GroupParameters, "TextLabelRot1" ); SpinBoxDistance = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxDistance");
TextLabelRot1->setText( tr("Rotation around X (Y to Z):") ); GroupParametersLayout->addWidget(SpinBoxDistance, 1, 1);
GroupParametersLayout->addWidget( TextLabelRot1, 2, 0 );
SpinBoxRot1 = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxRot1" ); TextLabelRot1 = new QLabel(GroupParameters, "TextLabelRot1");
GroupParametersLayout->addWidget( SpinBoxRot1, 2, 1 ); TextLabelRot1->setText(tr("Rotation around X (Y to Z):"));
GroupParametersLayout->addWidget(TextLabelRot1, 2, 0);
TextLabelRot2 = new QLabel( GroupParameters, "TextLabelRot2" );
TextLabelRot2->setText( tr("Rotation around Y (X to Z):") ); SpinBoxRot1 = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxRot1");
GroupParametersLayout->addWidget( TextLabelRot2, 3, 0 ); GroupParametersLayout->addWidget(SpinBoxRot1, 2, 1);
SpinBoxRot2 = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxRot2" ); TextLabelRot2 = new QLabel(GroupParameters, "TextLabelRot2");
GroupParametersLayout->addWidget( SpinBoxRot2, 3, 1 ); TextLabelRot2->setText(tr("Rotation around Y (X to Z):"));
GroupParametersLayout->addWidget(TextLabelRot2, 3, 0);
SpinBoxRot2 = new SMESHGUI_SpinBox(GroupParameters, "SpinBoxRot2");
GroupParametersLayout->addWidget(SpinBoxRot2, 3, 1);
PreviewCheckBox = new QCheckBox(tr("Show preview"), GroupParameters); PreviewCheckBox = new QCheckBox(tr("Show preview"), GroupParameters);
PreviewCheckBox->setChecked(true); PreviewCheckBox->setChecked(true);
GroupParametersLayout->addWidget( PreviewCheckBox, 4, 0 ); GroupParametersLayout->addWidget(PreviewCheckBox, 4, 0);
AutoApplyCheckBox = new QCheckBox(tr("Auto Apply"), GroupParameters); AutoApplyCheckBox = new QCheckBox(tr("Auto Apply"), GroupParameters);
AutoApplyCheckBox->setChecked(false); AutoApplyCheckBox->setChecked(false);
GroupParametersLayout->addWidget( AutoApplyCheckBox, 4, 1 ); GroupParametersLayout->addWidget(AutoApplyCheckBox, 4, 1);
// Controls for "Ok", "Apply" and "Close" button
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
GroupButtons->layout()->setMargin( 0 );
QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
buttonApply = new QPushButton( GroupButtons, "buttonApply" );
buttonApply->setText( tr( "SMESH_BUT_APPLY" ) );
buttonApply->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupButtonsLayout->addItem( spacer_9, 0, 2 );
buttonOk = new QPushButton( GroupButtons, "buttonOk" );
buttonOk->setText( tr( "SMESH_BUT_OK" ) );
buttonOk->setAutoDefault( TRUE );
buttonOk->setDefault( TRUE );
GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
SMESHGUI_ClippingDlgLayout->addWidget( GroupPlanes, 0, 0 ); // Controls for "Ok", "Apply" and "Close" button
SMESHGUI_ClippingDlgLayout->addWidget( GroupParameters, 1, 0 ); QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
SMESHGUI_ClippingDlgLayout->addWidget( GroupButtons, 2, 0 ); GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth()));
GroupButtons->setGeometry(QRect(10, 10, 281, 48));
mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection()); GroupButtons->setTitle(tr("" ));
GroupButtons->setColumnLayout(0, Qt::Vertical);
GroupButtons->layout()->setSpacing(0);
GroupButtons->layout()->setMargin(0);
QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
GroupButtonsLayout->setAlignment(Qt::AlignTop);
GroupButtonsLayout->setSpacing(6);
GroupButtonsLayout->setMargin(11);
buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
buttonCancel->setAutoDefault(TRUE);
GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
buttonApply = new QPushButton(GroupButtons, "buttonApply");
buttonApply->setText(tr("SMESH_BUT_APPLY" ));
buttonApply->setAutoDefault(TRUE);
GroupButtonsLayout->addWidget(buttonApply, 0, 1);
QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
GroupButtonsLayout->addItem(spacer_9, 0, 2);
buttonOk = new QPushButton(GroupButtons, "buttonOk");
buttonOk->setText(tr("SMESH_BUT_OK" ));
buttonOk->setAutoDefault(TRUE);
buttonOk->setDefault(TRUE);
GroupButtonsLayout->addWidget(buttonOk, 0, 0);
SMESHGUI_ClippingDlgLayout->addWidget(GroupPlanes, 0, 0);
SMESHGUI_ClippingDlgLayout->addWidget(GroupParameters, 1, 0);
SMESHGUI_ClippingDlgLayout->addWidget(GroupButtons, 2, 0);
// 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);
SpinBoxRot2->RangeStepAndValidator( -180.0, 180.0, 1, 3 ); SpinBoxRot2->RangeStepAndValidator(-180.0, 180.0, 1, 3);
ComboBoxOrientation->insertItem( tr("|| X-Y") ); ComboBoxOrientation->insertItem(tr("|| X-Y"));
ComboBoxOrientation->insertItem( tr("|| Y-Z") ); ComboBoxOrientation->insertItem(tr("|| Y-Z"));
ComboBoxOrientation->insertItem( tr("|| Z-X") ); ComboBoxOrientation->insertItem(tr("|| Z-X"));
SpinBoxDistance->SetValue(0.5); SpinBoxDistance->SetValue(0.5);
myActor = 0; myActor = 0;
myIsSelectPlane = false; myIsSelectPlane = false;
onSelectionChanged(); onSelectionChanged();
// signals and slots connections : // signals and slots connections :
connect( ComboBoxPlanes, SIGNAL( activated( int )), this, SLOT( onSelectPlane( int ) ) ); connect(ComboBoxPlanes, SIGNAL(activated(int)), this, SLOT(onSelectPlane(int)));
connect( buttonNew, SIGNAL( clicked() ), this, SLOT( ClickOnNew() ) ); connect(buttonNew, SIGNAL(clicked()), this, SLOT(ClickOnNew()));
connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( ClickOnDelete() ) ); connect(buttonDelete, SIGNAL(clicked()), this, SLOT(ClickOnDelete()));
connect( ComboBoxOrientation, SIGNAL( activated( int )), this, SLOT( onSelectOrientation( int ) ) ); connect(ComboBoxOrientation, SIGNAL(activated(int)), this, SLOT(onSelectOrientation(int)));
connect( SpinBoxDistance, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); connect(SpinBoxDistance, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam()));
connect( SpinBoxRot1, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); connect(SpinBoxRot1, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam()));
connect( SpinBoxRot2, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); connect(SpinBoxRot2, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam()));
connect( PreviewCheckBox, SIGNAL( toggled( bool )), this, SLOT( OnPreviewToggle( bool ) ) ); connect(PreviewCheckBox, SIGNAL(toggled(bool)), this, SLOT(OnPreviewToggle(bool)));
connect( AutoApplyCheckBox, SIGNAL( toggled( bool )), this, SLOT( ClickOnApply() ) ); connect(AutoApplyCheckBox, SIGNAL(toggled(bool)), this, SLOT(ClickOnApply()));
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,44 +380,45 @@ 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 :
//======================================================================= //=======================================================================
void SMESHGUI_ClippingDlg::ClickOnOk() void SMESHGUI_ClippingDlg::ClickOnOk()
{ {
ClickOnApply() ; ClickOnApply();
ClickOnCancel() ; ClickOnCancel();
} }
//======================================================================= //=======================================================================
// function : ClickOnCancel() // function : ClickOnCancel()
// purpose : // purpose :
@ -426,26 +428,26 @@ 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));
myPlanes.clear(); myPlanes.clear();
vtkIdType anId = 0, anEnd = myActor->GetNumberOfClippingPlanes(); vtkIdType anId = 0, anEnd = myActor->GetNumberOfClippingPlanes();
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,26 +460,25 @@ 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 :
//======================================================================= //=======================================================================
void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex) void SMESHGUI_ClippingDlg::onSelectPlane (int theIndex)
{ {
if (!myActor || myPlanes.empty()) if (!myActor || myPlanes.empty())
return; return;
OrientedPlane* aPlane = myPlanes[theIndex].GetPointer(); OrientedPlane* aPlane = myPlanes[theIndex].GetPointer();
// Orientation // Orientation
SMESH::Orientation anOrientation = aPlane->GetOrientation(); SMESH::Orientation anOrientation = aPlane->GetOrientation();
// Rotations // Rotations
double aRot[2] = {aPlane->myAngle[0], aPlane->myAngle[1]}; double aRot[2] = {aPlane->myAngle[0], aPlane->myAngle[1]};
@ -486,15 +487,15 @@ void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex)
setDistance(aPlane->GetDistance()); setDistance(aPlane->GetDistance());
setRotation(aRot[0], aRot[1]); setRotation(aRot[0], aRot[1]);
switch (anOrientation) { switch (anOrientation) {
case SMESH::XY: case SMESH::XY:
ComboBoxOrientation->setCurrentItem(0); ComboBoxOrientation->setCurrentItem(0);
onSelectOrientation(0); onSelectOrientation(0);
break; break;
case SMESH::YZ: case SMESH::YZ:
ComboBoxOrientation->setCurrentItem(1); ComboBoxOrientation->setCurrentItem(1);
onSelectOrientation(1); onSelectOrientation(1);
break; break;
case SMESH::ZX: case SMESH::ZX:
ComboBoxOrientation->setCurrentItem(2); ComboBoxOrientation->setCurrentItem(2);
onSelectOrientation(2); onSelectOrientation(2);
break; break;
@ -502,7 +503,6 @@ void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex)
myIsSelectPlane = false; myIsSelectPlane = false;
} }
//======================================================================= //=======================================================================
// function : ClickOnNew() // function : ClickOnNew()
// purpose : // purpose :
@ -511,19 +511,20 @@ void SMESHGUI_ClippingDlg::ClickOnNew()
{ {
if (!myActor) if (!myActor)
return; return;
OrientedPlane* aPlane = OrientedPlane::New(SMESH::GetActiveStudy());
SMESH::TVTKPlane aTVTKPlane(aPlane);
myPlanes.push_back(aTVTKPlane);
if(PreviewCheckBox->isChecked()) if(SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI)){
aTVTKPlane->myActor->VisibilityOn(); OrientedPlane* aPlane = OrientedPlane::New(aViewWindow);
SMESH::TVTKPlane aTVTKPlane(aPlane);
myPlanes.push_back(aTVTKPlane);
Sinchronize(); if (PreviewCheckBox->isChecked())
SetCurrentPlaneParam(); aTVTKPlane->myActor->VisibilityOn();
Sinchronize();
SetCurrentPlaneParam();
}
} }
//======================================================================= //=======================================================================
// function : ClickOnDelete() // function : ClickOnDelete()
// purpose : // purpose :
@ -532,48 +533,46 @@ void SMESHGUI_ClippingDlg::ClickOnDelete()
{ {
if (!myActor || myPlanes.empty()) if (!myActor || myPlanes.empty())
return; return;
int aPlaneIndex = ComboBoxPlanes->currentItem(); int aPlaneIndex = ComboBoxPlanes->currentItem();
SMESH::TPlanes::iterator anIter = myPlanes.begin() + aPlaneIndex; SMESH::TPlanes::iterator anIter = myPlanes.begin() + aPlaneIndex;
anIter->GetPointer()->myActor->SetVisibility(false); anIter->GetPointer()->myActor->SetVisibility(false);
myPlanes.erase(anIter); myPlanes.erase(anIter);
if(AutoApplyCheckBox->isChecked()) if(AutoApplyCheckBox->isChecked())
ClickOnApply(); ClickOnApply();
Sinchronize(); Sinchronize();
SMESH::RenderViewFrame(SMESH::GetCurrentVtkView()); SMESH::RenderViewWindow(SMESH::GetCurrentVtkView());
} }
//======================================================================= //=======================================================================
// function : onSelectOrientation() // function : onSelectOrientation()
// purpose : // purpose :
//======================================================================= //=======================================================================
void SMESHGUI_ClippingDlg::onSelectOrientation(int theItem) void SMESHGUI_ClippingDlg::onSelectOrientation (int theItem)
{ {
if (myPlanes.empty()) if (myPlanes.empty())
return; return;
if (theItem == 0) { if (theItem == 0) {
TextLabelRot1->setText( tr( "Rotation around X (Y to Z):") ); TextLabelRot1->setText(tr("Rotation around X (Y to Z):"));
TextLabelRot2->setText( tr( "Rotation around Y (X to Z):" ) ); TextLabelRot2->setText(tr("Rotation around Y (X to Z):"));
} }
else if (theItem == 1) { else if (theItem == 1) {
TextLabelRot1->setText( tr( "Rotation around Y (Z to X):" ) ); TextLabelRot1->setText(tr("Rotation around Y (Z to X):"));
TextLabelRot2->setText( tr( "Rotation around Z (Y to X):" ) ); TextLabelRot2->setText(tr("Rotation around Z (Y to X):"));
} }
else if (theItem == 2) { else if (theItem == 2) {
TextLabelRot1->setText( tr( "Rotation around Z (X to Y):" ) ); TextLabelRot1->setText(tr("Rotation around Z (X to Y):"));
TextLabelRot2->setText( tr( "Rotation around X (Z to Y):" ) ); TextLabelRot2->setText(tr("Rotation around X (Z to Y):"));
} }
if((QComboBox*)sender() == ComboBoxOrientation) if((QComboBox*)sender() == ComboBoxOrientation)
SetCurrentPlaneParam(); SetCurrentPlaneParam();
} }
//======================================================================= //=======================================================================
// function : Sinchronize() // function : Sinchronize()
// purpose : // purpose :
@ -582,21 +581,21 @@ void SMESHGUI_ClippingDlg::Sinchronize()
{ {
int aNbPlanes = myPlanes.size(); int aNbPlanes = myPlanes.size();
ComboBoxPlanes->clear(); ComboBoxPlanes->clear();
QString aName; QString aName;
for(int i = 1; i<=aNbPlanes ; i++){ for(int i = 1; i<=aNbPlanes; i++) {
aName = QString(tr("Plane# %1")).arg(i); aName = QString(tr("Plane# %1")).arg(i);
ComboBoxPlanes->insertItem(aName); ComboBoxPlanes->insertItem(aName);
} }
int aPos = ComboBoxPlanes->count() - 1; int aPos = ComboBoxPlanes->count() - 1;
ComboBoxPlanes->setCurrentItem(aPos); ComboBoxPlanes->setCurrentItem(aPos);
bool anIsControlsEnable = (aPos >= 0); bool anIsControlsEnable = (aPos >= 0);
if(anIsControlsEnable){ if (anIsControlsEnable) {
onSelectPlane(aPos); onSelectPlane(aPos);
}else{ } else {
ComboBoxPlanes->insertItem( tr("No planes") ); ComboBoxPlanes->insertItem(tr("No planes"));
SpinBoxRot1->SetValue(0.0); SpinBoxRot1->SetValue(0.0);
SpinBoxRot2->SetValue(0.0); SpinBoxRot2->SetValue(0.0);
SpinBoxDistance->SetValue(0.5); SpinBoxDistance->SetValue(0.5);
@ -612,37 +611,33 @@ void SMESHGUI_ClippingDlg::Sinchronize()
SpinBoxRot2->setEnabled(anIsControlsEnable); SpinBoxRot2->setEnabled(anIsControlsEnable);
} }
//======================================================================= //=======================================================================
// function : setRotation() // function : setRotation()
// purpose : // purpose :
//======================================================================= //=======================================================================
void SMESHGUI_ClippingDlg::setRotation( const double theRot1, const double theRot2 ) void SMESHGUI_ClippingDlg::setRotation (const double theRot1, const double theRot2)
{ {
SpinBoxRot1->SetValue(theRot1); SpinBoxRot1->SetValue(theRot1);
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;
int aCurPlaneIndex = ComboBoxPlanes->currentItem(); int aCurPlaneIndex = ComboBoxPlanes->currentItem();
OrientedPlane* aPlane = myPlanes[aCurPlaneIndex].GetPointer(); OrientedPlane* aPlane = myPlanes[aCurPlaneIndex].GetPointer();
float aNormal[3]; float aNormal[3];
SMESH::Orientation anOrientation; SMESH::Orientation anOrientation;
float aDir[3][3] = {{0, 0, 0}, {0, 0, 0}}; float aDir[3][3] = {{0, 0, 0}, {0, 0, 0}};
{ {
static double aCoeff = vtkMath::Pi()/180.0; static double aCoeff = vtkMath::Pi()/180.0;
float aRot[2] = {getRotation1(), getRotation2()}; float aRot[2] = {getRotation1(), getRotation2()};
@ -653,10 +648,10 @@ SetCurrentPlaneParam()
float aV[2] = {sqrt(1.0-anU[0]*anU[0]), sqrt(1.0-anU[1]*anU[1])}; float aV[2] = {sqrt(1.0-anU[0]*anU[0]), sqrt(1.0-anU[1]*anU[1])};
aV[0] = aRot[0] > 0? aV[0]: -aV[0]; aV[0] = aRot[0] > 0? aV[0]: -aV[0];
aV[1] = aRot[1] > 0? aV[1]: -aV[1]; aV[1] = aRot[1] > 0? aV[1]: -aV[1];
switch (ComboBoxOrientation->currentItem()) { switch (ComboBoxOrientation->currentItem()) {
case 0: case 0:
anOrientation = SMESH::XY; anOrientation = SMESH::XY;
aDir[0][1] = anU[0]; aDir[0][1] = anU[0];
aDir[0][2] = aV[0]; aDir[0][2] = aV[0];
@ -665,8 +660,8 @@ SetCurrentPlaneParam()
aDir[1][2] = aV[1]; aDir[1][2] = aV[1];
break; break;
case 1: case 1:
anOrientation = SMESH::YZ; anOrientation = SMESH::YZ;
aDir[0][2] = anU[0]; aDir[0][2] = anU[0];
aDir[0][0] = aV[0]; aDir[0][0] = aV[0];
@ -675,8 +670,8 @@ SetCurrentPlaneParam()
aDir[1][0] = aV[1]; aDir[1][0] = aV[1];
break; break;
case 2: case 2:
anOrientation = SMESH::ZX; anOrientation = SMESH::ZX;
aDir[0][0] = anU[0]; aDir[0][0] = anU[0];
aDir[0][1] = aV[0]; aDir[0][1] = aV[0];
@ -691,10 +686,10 @@ SetCurrentPlaneParam()
vtkMath::Normalize(aNormal); vtkMath::Normalize(aNormal);
vtkMath::Cross(aNormal,aDir[1],aDir[0]); vtkMath::Cross(aNormal,aDir[1],aDir[0]);
} }
aPlane->SetOrientation(anOrientation); aPlane->SetOrientation(anOrientation);
aPlane->SetDistance(getDistance()); aPlane->SetDistance(getDistance());
myActor->SetPlaneParam(aNormal, getDistance(), aPlane); myActor->SetPlaneParam(aNormal, getDistance(), aPlane);
vtkDataSet* aDataSet = myActor->GetInput(); vtkDataSet* aDataSet = myActor->GetInput();
@ -707,44 +702,48 @@ SetCurrentPlaneParam()
{aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}}; {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}};
float aParam, aPnt0[3], aPnt1[3], aPnt2[3]; float aParam, aPnt0[3], aPnt1[3], aPnt2[3];
float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0], float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0],
aPnt[1] - aDelta[0][1] - aDelta[1][1], aPnt[1] - aDelta[0][1] - aDelta[1][1],
aPnt[2] - aDelta[0][2] - aDelta[1][2]}; aPnt[2] - aDelta[0][2] - aDelta[1][2]};
float aPnt02[3] = {aPnt01[0] + aNormal[0], float aPnt02[3] = {aPnt01[0] + aNormal[0],
aPnt01[1] + aNormal[1], aPnt01[1] + aNormal[1],
aPnt01[2] + aNormal[2]}; aPnt01[2] + aNormal[2]};
vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0); vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0);
float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0], float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0],
aPnt[1] - aDelta[0][1] + aDelta[1][1], aPnt[1] - aDelta[0][1] + aDelta[1][1],
aPnt[2] - aDelta[0][2] + aDelta[1][2]}; aPnt[2] - aDelta[0][2] + aDelta[1][2]};
float aPnt12[3] = {aPnt11[0] + aNormal[0], float aPnt12[3] = {aPnt11[0] + aNormal[0],
aPnt11[1] + aNormal[1], aPnt11[1] + aNormal[1],
aPnt11[2] + aNormal[2]}; aPnt11[2] + aNormal[2]};
vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1); vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1);
float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0], float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0],
aPnt[1] + aDelta[0][1] - aDelta[1][1], aPnt[1] + aDelta[0][1] - aDelta[1][1],
aPnt[2] + aDelta[0][2] - aDelta[1][2]}; aPnt[2] + aDelta[0][2] - aDelta[1][2]};
float aPnt22[3] = {aPnt21[0] + aNormal[0], float aPnt22[3] = {aPnt21[0] + aNormal[0],
aPnt21[1] + aNormal[1], aPnt21[1] + aNormal[1],
aPnt21[2] + aNormal[2]}; aPnt21[2] + aNormal[2]};
vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2); vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2);
vtkPlaneSource* aPlaneSource = aPlane->myPlaneSource; vtkPlaneSource* aPlaneSource = aPlane->myPlaneSource;
aPlaneSource->SetNormal(aNormal[0],aNormal[1],aNormal[2]); aPlaneSource->SetNormal(aNormal[0],aNormal[1],aNormal[2]);
aPlaneSource->SetOrigin(aPnt0[0],aPnt0[1],aPnt0[2]); aPlaneSource->SetOrigin(aPnt0[0],aPnt0[1],aPnt0[2]);
aPlaneSource->SetPoint1(aPnt1[0],aPnt1[1],aPnt1[2]); aPlaneSource->SetPoint1(aPnt1[0],aPnt1[1],aPnt1[2]);
aPlaneSource->SetPoint2(aPnt2[0],aPnt2[1],aPnt2[2]); aPlaneSource->SetPoint2(aPnt2[0],aPnt2[1],aPnt2[2]);
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,18 +45,22 @@ 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;
namespace SMESH{ namespace SMESH {
typedef vtkSmartPointer<OrientedPlane> TVTKPlane; typedef vtkSmartPointer<OrientedPlane> TVTKPlane;
typedef std::vector<TVTKPlane> TPlanes; typedef std::vector<TVTKPlane> TPlanes;
enum Orientation {XY, YZ, ZX}; enum Orientation {XY, YZ, ZX};
}; };
@ -65,30 +69,32 @@ namespace SMESH{
// purpose : // purpose :
//================================================================================= //=================================================================================
class SMESHGUI_ClippingDlg : public QDialog 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);
float getDistance() { return (float)SpinBoxDistance->GetValue(); }
void setDistance (const float theDistance) { SpinBoxDistance->SetValue(theDistance); }
double getRotation1() { return SpinBoxRot1->GetValue(); }
double getRotation2() { return SpinBoxRot2->GetValue(); }
void setRotation (const double theRot1, const double theRot2);
void Sinchronize();
float getDistance() {return (float)SpinBoxDistance->GetValue();}
void setDistance( const float theDistance) {SpinBoxDistance->SetValue(theDistance);}
double getRotation1() {return SpinBoxRot1->GetValue();}
double getRotation2() {return SpinBoxRot2->GetValue();}
void setRotation( const double theRot1, const double theRot2 );
void Sinchronize();
~SMESHGUI_ClippingDlg(); ~SMESHGUI_ClippingDlg();
private: private:
SALOME_Selection* mySelection; SalomeApp_SelectionMgr* mySelectionMgr;
SMESH_Actor* myActor; SVTK_Selector* mySelector;
SMESH::TPlanes myPlanes; SMESHGUI* mySMESHGUI;
SMESH_Actor* myActor;
SMESH::TPlanes myPlanes;
QComboBox* ComboBoxPlanes; QComboBox* ComboBoxPlanes;
QPushButton* buttonNew; QPushButton* buttonNew;
QPushButton* buttonDelete; QPushButton* buttonDelete;
@ -107,20 +113,19 @@ private:
QPushButton* buttonApply; QPushButton* buttonApply;
bool myIsSelectPlane; bool myIsSelectPlane;
public slots: public slots:
void onSelectPlane(int theIndex); void onSelectPlane (int theIndex);
void ClickOnNew(); void ClickOnNew();
void ClickOnDelete(); void ClickOnDelete();
void onSelectOrientation(int theItem); void onSelectOrientation (int theItem);
void SetCurrentPlaneParam(); void SetCurrentPlaneParam();
void onSelectionChanged(); void onSelectionChanged();
void OnPreviewToggle(bool theIsToggled); void OnPreviewToggle (bool theIsToggled);
void ClickOnOk(); void ClickOnOk();
void ClickOnCancel(); void ClickOnCancel();
void ClickOnApply(); void ClickOnApply();
}; };
#endif // DIALOGBOX_TRANSPARENCYDLG_H #endif // DIALOGBOX_TRANSPARENCYDLG_H

View File

@ -1,21 +1,21 @@
// SMESH SMESHGUI : GUI for SMESH component // SMESH SMESHGUI : GUI for SMESH component
// //
// Copyright (C) 2003 CEA // Copyright (C) 2003 CEA
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org // See http://www.salome-platform.org or email : webmaster.salome@opencascade.org
// //
// //
@ -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,98 +47,85 @@
#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)
setName("SMESHGUI_CreateHypothesesDlg");
setCaption(isAlgo ? tr("SMESH_CREATE_ALGORITHMS" ) : tr("SMESH_CREATE_HYPOTHESES" ));
setSizeGripEnabled(TRUE);
if ( !name ) QGridLayout* SMESHGUI_CreateHypothesesDlgLayout = new QGridLayout(this);
setName( "SMESHGUI_CreateHypothesesDlg" ); SMESHGUI_CreateHypothesesDlgLayout->setSpacing(6);
setCaption( isAlgo ? tr( "SMESH_CREATE_ALGORITHMS" ) : tr( "SMESH_CREATE_HYPOTHESES" ) ); SMESHGUI_CreateHypothesesDlgLayout->setMargin(11);
setSizeGripEnabled( TRUE );
QGridLayout* SMESHGUI_CreateHypothesesDlgLayout = new QGridLayout( this );
SMESHGUI_CreateHypothesesDlgLayout->setSpacing( 6 );
SMESHGUI_CreateHypothesesDlgLayout->setMargin( 11 );
/***************************************************************/ /***************************************************************/
GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" ); GroupAlgorithms = new QGroupBox(this, "GroupAlgorithms");
GroupAlgorithms->setTitle( isAlgo ? tr("SMESH_AVAILABLE_ALGORITHMS") : tr("SMESH_AVAILABLE_HYPOTHESES") ); GroupAlgorithms->setTitle(isAlgo ? tr("SMESH_AVAILABLE_ALGORITHMS") : tr("SMESH_AVAILABLE_HYPOTHESES"));
GroupAlgorithms->setColumnLayout(0, Qt::Vertical ); GroupAlgorithms->setColumnLayout(0, Qt::Vertical);
GroupAlgorithms->layout()->setSpacing( 0 ); GroupAlgorithms->layout()->setSpacing(0);
GroupAlgorithms->layout()->setMargin( 0 ); GroupAlgorithms->layout()->setMargin(0);
QGridLayout* hypLayout = new QGridLayout( GroupAlgorithms->layout() ); QGridLayout* hypLayout = new QGridLayout(GroupAlgorithms->layout());
hypLayout->setGeometry( QRect( 12, 18, 139, 250 ) ); hypLayout->setGeometry(QRect(12, 18, 139, 250));
hypLayout->setAlignment( Qt::AlignTop ); hypLayout->setAlignment(Qt::AlignTop);
hypLayout->setSpacing( 6 ); hypLayout->setSpacing(6);
hypLayout->setMargin( 11 ); hypLayout->setMargin(11);
ListAlgoDefinition = new QListView( GroupAlgorithms, "ListAlgoDefinition" ); ListAlgoDefinition = new QListView(GroupAlgorithms, "ListAlgoDefinition");
ListAlgoDefinition->setMinimumSize( 400, 200 ); ListAlgoDefinition->setMinimumSize(400, 200);
ListAlgoDefinition->addColumn(""); ListAlgoDefinition->addColumn("");
ListAlgoDefinition->header()->hide(); ListAlgoDefinition->header()->hide();
ListAlgoDefinition->setSelectionMode(QListView::Single); ListAlgoDefinition->setSelectionMode(QListView::Single);
ListAlgoDefinition->setResizeMode(QListView::AllColumns); ListAlgoDefinition->setResizeMode(QListView::AllColumns);
ListAlgoDefinition->setRootIsDecorated( true ); ListAlgoDefinition->setRootIsDecorated(true);
hypLayout->addWidget( ListAlgoDefinition, 0, 0 ); hypLayout->addWidget(ListAlgoDefinition, 0, 0);
SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupAlgorithms, 0, 0 ); SMESHGUI_CreateHypothesesDlgLayout->addWidget(GroupAlgorithms, 0, 0);
/***************************************************************/ /***************************************************************/
GroupButtons = new QGroupBox( this, "GroupButtons" ); GroupButtons = new QGroupBox(this, "GroupButtons");
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);
QGridLayout* 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);
buttonApply = new QPushButton( GroupButtons, "buttonApply" ); buttonApply = new QPushButton(GroupButtons, "buttonApply");
buttonApply->setText( tr( "SMESH_BUT_CREATE" ) ); buttonApply->setText(tr("SMESH_BUT_CREATE" ));
buttonApply->setAutoDefault( TRUE ); buttonApply->setAutoDefault(TRUE);
buttonApply->setDefault( FALSE ); buttonApply->setDefault(FALSE);
buttonApply->setEnabled( FALSE ) ; buttonApply->setEnabled(FALSE);
GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); GroupButtonsLayout->addWidget(buttonApply, 0, 1);
QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
GroupButtonsLayout->addItem( spacer_9, 0, 2 ); GroupButtonsLayout->addItem(spacer_9, 0, 2);
buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
buttonCancel->setAutoDefault( TRUE ); buttonCancel->setAutoDefault(TRUE);
buttonCancel->setDefault( TRUE ); buttonCancel->setDefault(TRUE);
buttonCancel->setEnabled( TRUE ) ; buttonCancel->setEnabled(TRUE);
GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupButtons, 1, 0 ); SMESHGUI_CreateHypothesesDlgLayout->addWidget(GroupButtons, 1, 0);
/***************************************************************/ /***************************************************************/
Init(); Init();
@ -136,7 +137,7 @@ SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (QWidget* parent,
//================================================================================= //=================================================================================
SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg() SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg()
{ {
// no need to delete child widgets, Qt does it all for us // no need to delete child widgets, Qt does it all for us
} }
//================================================================================= //=================================================================================
@ -145,25 +146,24 @@ 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();
/* signals and slots connections */ /* signals and slots connections */
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( 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()));
connect( ListAlgoDefinition, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
connect( ListAlgoDefinition, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( onDoubleClicked(QListViewItem*) ) );
int x, y ; connect(ListAlgoDefinition, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
mySMESHGUI->DefineDlgPosition( this, x, y ) ; connect(ListAlgoDefinition, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(onDoubleClicked(QListViewItem*)));
this->move( x, y ) ;
this->show() ; int x, y;
mySMESHGUI->DefineDlgPosition(this, x, y);
this->move(x, y);
this->show();
} }
//================================================================================= //=================================================================================
@ -172,7 +172,7 @@ void SMESHGUI_CreateHypothesesDlg::Init()
//================================================================================= //=================================================================================
void SMESHGUI_CreateHypothesesDlg::ClickOnCancel() void SMESHGUI_CreateHypothesesDlg::ClickOnCancel()
{ {
close() ; close();
} }
//================================================================================= //=================================================================================
@ -181,29 +181,26 @@ 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)
return; return;
QString aHypType = item->text( 1 ); QString aHypType = item->text(1);
MESSAGE("Apply " << aHypType); MESSAGE("Apply " << aHypType);
char* sHypType = (char*)aHypType.latin1(); char* sHypType = (char*)aHypType.latin1();
HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType); HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType);
if ( !aHypData ) if (!aHypData)
return; return;
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);
@ -222,29 +219,29 @@ void SMESHGUI_CreateHypothesesDlg::ClickOnApply()
//================================================================================= //=================================================================================
void SMESHGUI_CreateHypothesesDlg::ActivateThisDialog() void SMESHGUI_CreateHypothesesDlg::ActivateThisDialog()
{ {
mySMESHGUI->EmitSignalDeactivateDialog() ; mySMESHGUI->EmitSignalDeactivateDialog();
GroupButtons->setEnabled(true) ; GroupButtons->setEnabled(true);
return ; return;
} }
//================================================================================= //=================================================================================
// function : enterEvent() // function : enterEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_CreateHypothesesDlg::enterEvent(QEvent* e) void SMESHGUI_CreateHypothesesDlg::enterEvent (QEvent*)
{ {
ActivateThisDialog() ; ActivateThisDialog();
return ; return;
} }
//================================================================================= //=================================================================================
// function : closeEvent() // function : closeEvent()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_CreateHypothesesDlg::closeEvent( QCloseEvent* e ) void SMESHGUI_CreateHypothesesDlg::closeEvent (QCloseEvent* e)
{ {
mySMESHGUI->ResetState(); mySMESHGUI->ResetState();
QDialog::closeEvent( e ); QDialog::closeEvent(e);
} }
//================================================================================= //=================================================================================
@ -254,16 +251,16 @@ void SMESHGUI_CreateHypothesesDlg::closeEvent( QCloseEvent* e )
void SMESHGUI_CreateHypothesesDlg::onSelectionChanged() void SMESHGUI_CreateHypothesesDlg::onSelectionChanged()
{ {
QListViewItem* item = ListAlgoDefinition->selectedItem(); QListViewItem* item = ListAlgoDefinition->selectedItem();
buttonApply->setEnabled( item && item->depth() > 0 ) ; buttonApply->setEnabled(item && item->depth() > 0);
} }
//================================================================================= //=================================================================================
// function : onDoubleClicked() // function : onDoubleClicked()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_CreateHypothesesDlg::onDoubleClicked(QListViewItem* i) void SMESHGUI_CreateHypothesesDlg::onDoubleClicked (QListViewItem* i)
{ {
if ( i && i->depth() > 0 ) if (i && i->depth() > 0)
this->ClickOnApply(); this->ClickOnApply();
} }
@ -275,24 +272,23 @@ void SMESHGUI_CreateHypothesesDlg::InitAlgoDefinition()
{ {
ListAlgoDefinition->clear(); ListAlgoDefinition->clear();
QStringList HypList = SMESH::GetAvailableHypotheses(myIsAlgo); QStringList HypList = SMESH::GetAvailableHypotheses(myIsAlgo);
for ( int i = 0; i < HypList.count(); ++i ) { for (int i = 0; i < HypList.count(); ++i) {
HypothesisData* aHypData = SMESH::GetHypothesisData( HypList[i] ); HypothesisData* aHypData = SMESH::GetHypothesisData(HypList[i]);
QListViewItem* parentItem = 0; QListViewItem* parentItem = 0;
QListViewItem* childItem = ListAlgoDefinition->firstChild(); QListViewItem* childItem = ListAlgoDefinition->firstChild();
while ( childItem ) { while (childItem) {
if ( childItem->text(0) == aHypData->PluginName ) { if (childItem->text(0) == aHypData->PluginName) {
parentItem = childItem; parentItem = childItem;
break; break;
} }
childItem = childItem->nextSibling(); childItem = childItem->nextSibling();
} }
if ( !parentItem ) if (!parentItem)
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);

File diff suppressed because it is too large Load Diff

View File

@ -1,158 +1,147 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
// //
// //
// //
// File : SMESHGUI_CreatePatternDlg.h // File : SMESHGUI_CreatePatternDlg.h
// Author : Sergey LITONIN // Author : Sergey LITONIN
// Module : SMESH // Module : SMESH
#ifndef SMESHGUI_CreatePatternDlg_H #ifndef SMESHGUI_CreatePatternDlg_H
#define SMESHGUI_CreatePatternDlg_H #define SMESHGUI_CreatePatternDlg_H
#include <qdialog.h> #include <qdialog.h>
// IDL Headers // IDL Headers
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen) #include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Pattern) #include CORBA_SERVER_HEADER(SMESH_Pattern)
class SMESHGUI_PatternWidget; class SMESHGUI_PatternWidget;
class QCloseEvent; class SALOMEDSClient_SObject;
class QFrame;
class QLineEdit; class QCloseEvent;
class SMESHGUI_SpinBox; class QFrame;
class QPushButton; class QLineEdit;
class SALOME_Selection; class SMESHGUI_SpinBox;
class QRadioButton; class QPushButton;
class QCheckBox; class SalomeApp_SelectionMgr;
class QButtonGroup; class QRadioButton;
class QLabel; class QCheckBox;
class QButtonGroup;
/* class QLabel;
Class : SMESHGUI_CreatePatternDlg class SVTK_ViewWindow;
Description : Dialog to specify filters for VTK viewer class SVTK_Selector;
*/ class SMESHGUI;
class SMESHGUI_CreatePatternDlg : public QDialog /*!
{ * Class : SMESHGUI_CreatePatternDlg
Q_OBJECT * Description : Dialog to specify filters for VTK viewer
*/
public:
class SMESHGUI_CreatePatternDlg : public QDialog
enum { Type_2d, Type_3d }; {
Q_OBJECT
public:
SMESHGUI_CreatePatternDlg( QWidget*, public:
SALOME_Selection*, enum { Type_2d, Type_3d };
const int,
const char* = 0 ); public:
virtual ~SMESHGUI_CreatePatternDlg(); SMESHGUI_CreatePatternDlg( SMESHGUI*,
const int,
void Init( SALOME_Selection*, const int ); const char* = 0);
QString GetPatternName() const; virtual ~SMESHGUI_CreatePatternDlg();
SMESH::SMESH_Pattern_ptr GetPattern();
void SetMesh( SMESH::SMESH_Mesh_ptr ); void Init(const int);
QString GetPatternName() const;
signals: SMESH::SMESH_Pattern_ptr GetPattern();
void SetMesh (SMESH::SMESH_Mesh_ptr);
void NewPattern();
void Close(); signals:
private: void NewPattern();
void Close();
void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; private:
private slots: void closeEvent (QCloseEvent* e);
void enterEvent (QEvent*);
void onOk();
void onSave(); private slots:
void onClose();
void onOk();
void onDeactivate(); void onSave();
void onClose();
void onSelectionDone();
void onTypeChanged( int ); void onDeactivate();
void onProject( bool );
void onSelBtnClicked(); void onSelectionDone();
void onTypeChanged (int);
private: void onProject (bool);
void onSelBtnClicked();
QFrame* createButtonFrame( QWidget* );
QFrame* createMainFrame ( QWidget* ); private:
void displayPreview();
void erasePreview(); QFrame* createButtonFrame (QWidget*);
void activateSelection(); QFrame* createMainFrame (QWidget*);
QString autoExtension( const QString& theFileName ) const; void displayPreview();
bool isValid(); void erasePreview();
bool loadFromObject( const bool = true ); void activateSelection();
QString getDefaultName() const; QString autoExtension (const QString& theFileName) const;
GEOM::GEOM_Object_ptr getGeom( SALOMEDS::SObject_ptr ); bool isValid();
bool loadFromObject (const bool = true);
private: QString getDefaultName() const;
GEOM::GEOM_Object_ptr getGeom (SALOMEDSClient_SObject*) const;
QPushButton* myOkBtn;
QPushButton* mySaveBtn; private:
QPushButton* myCloseBtn;
QPushButton* myOkBtn;
QButtonGroup* myTypeGrp; QPushButton* mySaveBtn;
QRadioButton* mySwitch2d; QPushButton* myCloseBtn;
QRadioButton* mySwitch3d;
QRadioButton* mySwitchSMESH_Pattern3d; QButtonGroup* myTypeGrp;
QRadioButton* mySwitch2d;
QLineEdit* myMeshEdit; QRadioButton* mySwitch3d;
QLineEdit* myName; QRadioButton* mySwitchSMESH_Pattern3d;
SMESHGUI_PatternWidget* myPicture2d; QLineEdit* myMeshEdit;
QLineEdit* myName;
QCheckBox* myProjectChk;
SMESHGUI_PatternWidget* myPicture2d;
SALOME_Selection* mySelection;
int myNbPoints; QCheckBox* myProjectChk;
int myType;
SMESHGUI* mySMESHGUI;
SMESH::SMESH_Mesh_var myMesh; SVTK_ViewWindow* myViewWindow;
SMESH::SMESH_subMesh_var mySubMesh; SVTK_Selector* mySelector;
GEOM::GEOM_Object_var myGeomObj; SalomeApp_SelectionMgr* mySelectionMgr;
int myNbPoints;
SMESH::SMESH_Pattern_var myPattern; int myType;
bool myIsLoaded;
}; SMESH::SMESH_Mesh_var myMesh;
SMESH::SMESH_subMesh_var mySubMesh;
#endif GEOM::GEOM_Object_var myGeomObj;
SMESH::SMESH_Pattern_var myPattern;
bool myIsLoaded;
};
#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

@ -1,23 +1,23 @@
// SMESH SMESHGUI : GUI for SMESH component // SMESH SMESHGUI : GUI for SMESH component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
// //
// //
// //
@ -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,251 +52,256 @@
#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)
{ {
setCaption( tr( "CAPTION" ) ); setCaption(tr("CAPTION"));
QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); QVBoxLayout* aDlgLay = new QVBoxLayout(this, MARGIN, SPACING);
QFrame* aMainFrame = createMainFrame ( this ); QFrame* aMainFrame = createMainFrame (this);
QFrame* aBtnFrame = createButtonFrame( this ); QFrame* aBtnFrame = createButtonFrame(this);
aDlgLay->addWidget( aMainFrame ); aDlgLay->addWidget(aMainFrame);
aDlgLay->addWidget( aBtnFrame ); aDlgLay->addWidget(aBtnFrame);
aDlgLay->setStretchFactor( aMainFrame, 1 ); aDlgLay->setStretchFactor(aMainFrame, 1);
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->setMinimumHeight( 100 ); myListBox = new QListBox(aMainGrp);
myListBox->setSelectionMode( QListBox::NoSelection ); myListBox->setMinimumHeight(100);
myListBox->setRowMode( QListBox::FitToWidth ); myListBox->setSelectionMode(QListBox::NoSelection);
myListBox->setRowMode(QListBox::FitToWidth);
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);
aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
aLay->addWidget(myOkBtn);
aLay->addWidget(myApplyBtn);
aLay->addItem(aSpacer);
aLay->addWidget(myCloseBtn);
aLay->addWidget( myOkBtn );
aLay->addWidget( myApplyBtn );
aLay->addItem( aSpacer);
aLay->addWidget( myCloseBtn );
// connect signals and slots // connect signals and slots
connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
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()));
int x, y ; int x, y;
aSMESHGUI->DefineDlgPosition( this, x, y ); aSMESHGUI->DefineDlgPosition(this, x, y);
this->move( x, y ); this->move(x, y);
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())
return false; return false;
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);
} }
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)
return; return;
myListGrp.clear(); myListGrp.clear();
QStringList aNames; QStringList aNames;
const SALOME_ListIO& aListIO = mySelection->StoredIObjects(); SALOME_ListIO aListIO;
SALOME_ListIteratorOfListIO anIter( aListIO ); mySelectionMgr->selectedObjects(aListIO);
for( ; anIter.More(); anIter.Next() ) SALOME_ListIteratorOfListIO anIter (aListIO);
{ 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 );
} }
} }
myListBox->clear(); myListBox->clear();
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 :
//================================================================================= //=================================================================================
void SMESHGUI_DeleteGroupDlg::closeEvent( QCloseEvent* ) void SMESHGUI_DeleteGroupDlg::closeEvent (QCloseEvent*)
{ {
onClose() ; onClose();
} }

View File

@ -36,61 +36,56 @@
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
{ {
Q_OBJECT Q_OBJECT
public:
SMESHGUI_DeleteGroupDlg( QWidget*, SALOME_Selection* );
virtual ~SMESHGUI_DeleteGroupDlg();
void Init( SALOME_Selection* ) ; public:
SMESHGUI_DeleteGroupDlg (QWidget*,
SalomeApp_SelectionMgr*);
virtual ~SMESHGUI_DeleteGroupDlg();
void Init (SalomeApp_SelectionMgr*);
private: private:
void closeEvent( QCloseEvent* e ) ; void closeEvent (QCloseEvent*);
void enterEvent ( QEvent * ) ; void enterEvent (QEvent*);
private slots: private slots:
void onOk(); void onOk();
bool onApply(); bool onApply();
void onClose(); void onClose();
void onDeactivate(); void onDeactivate();
void onSelectionDone(); void onSelectionDone();
private: private:
QFrame* createButtonFrame( QWidget* ); QFrame* createButtonFrame (QWidget*);
QFrame* createMainFrame ( QWidget* ); QFrame* createMainFrame (QWidget*);
bool isValid(); bool isValid();
private: private:
QPushButton* myOkBtn; QPushButton* myOkBtn;
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

File diff suppressed because it is too large Load Diff

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,26 +52,29 @@ 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
// purpose : // purpose :
//================================================================================= //=================================================================================
class SMESHGUI_EditHypothesesDlg : public QDialog 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();
@ -88,23 +91,25 @@ private:
bool IsOld(QListBoxItem* hypItem); bool IsOld(QListBoxItem* hypItem);
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;
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;
bool myImportedMesh; bool myImportedMesh;
QGroupBox* GroupButtons; QGroupBox* GroupButtons;
QPushButton* buttonOk; QPushButton* buttonOk;
QPushButton* buttonApply; QPushButton* buttonApply;
@ -134,10 +139,10 @@ private slots:
void ClickOnOk(); void ClickOnOk();
bool ClickOnApply(); bool ClickOnApply();
void ClickOnCancel(); void ClickOnCancel();
void SetEditCurrentArgument() ; void SetEditCurrentArgument();
void SelectionIntoArgument() ; void SelectionIntoArgument();
void DeactivateActiveDialog() ; void DeactivateActiveDialog();
void ActivateThisDialog() ; void ActivateThisDialog();
void removeItem(QListBoxItem*); void removeItem(QListBoxItem*);
void addItem(QListBoxItem*); void addItem(QListBoxItem*);

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>
@ -57,12 +61,12 @@ class SMESH_Actor;
// purpose : // purpose :
//================================================================================= //=================================================================================
class SMESHGUI_ExtrusionAlongPathDlg : public QDialog class SMESHGUI_ExtrusionAlongPathDlg : public QDialog
{ {
Q_OBJECT Q_OBJECT
class SetBusy { class SetBusy {
public: public:
SetBusy( SMESHGUI_ExtrusionAlongPathDlg* _dlg ) { myDlg = _dlg; myDlg->myBusy = true; } SetBusy (SMESHGUI_ExtrusionAlongPathDlg* _dlg) { myDlg = _dlg; myDlg->myBusy = true; }
~SetBusy() { myDlg->myBusy = false; } ~SetBusy() { myDlg->myBusy = false; }
private: private:
SMESHGUI_ExtrusionAlongPathDlg* myDlg; SMESHGUI_ExtrusionAlongPathDlg* myDlg;
@ -70,39 +74,41 @@ 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 */
int GetConstructorId(); int GetConstructorId();
void SetEditCurrentArgument( QToolButton* button ); void SetEditCurrentArgument (QToolButton* button);
SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */
SVTK_ViewWindow* myViewWindow;
SVTK_Selector* mySelector;
QWidget* myEditCurrentArgument; /* Current argument */
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
SALOME_Selection* mySelection ; /* User shape selection */
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,20 +138,24 @@ 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();
void SelectionIntoArgument(); void SelectionIntoArgument();
void DeactivateActiveDialog(); void DeactivateActiveDialog();
void ActivateThisDialog(); void ActivateThisDialog();
void onTextChange(const QString&); void onTextChange (const QString&);
void onSelectMesh(); void onSelectMesh();
void onAnglesCheck(); void onAnglesCheck();
void onBasePointCheck(); void onBasePointCheck();

File diff suppressed because it is too large Load Diff

View File

@ -29,102 +29,101 @@
#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 :
//================================================================================= //=================================================================================
class SMESHGUI_ExtrusionDlg : public QDialog 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*,
~SMESHGUI_ExtrusionDlg(); bool modal = FALSE);
~SMESHGUI_ExtrusionDlg();
private: private:
void Init (bool ResetControls = true);
void enterEvent (QEvent*); /* mouse enter the QWidget */
int GetConstructorId();
//void closeEvent (QCloseEvent*);
//void hideEvent (QHideEvent*); /* ESC key */
void Init( bool ResetControls = true ) ; SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
void closeEvent( QCloseEvent* e ) ; SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */
void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ QLineEdit* myEditCurrentArgument; /* Current LineEdit */
void hideEvent ( QHideEvent * ); /* ESC key */ QString myElementsId;
int GetConstructorId(); int myNbOkElements; /* to check when elements are defined */
SVTK_ViewWindow* myViewWindow;
SVTK_Selector* mySelector;
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ bool myBusy;
SALOME_Selection* mySelection ; /* User shape selection */ SMESH::SMESH_Mesh_var myMesh;
QString myElementsId; SMESH_Actor* myActor;
int myNbOkElements ; /* to check when elements are defined */ SUIT_SelectionFilter* myMeshOrSubMeshOrGroupFilter;
QLineEdit* myEditCurrentArgument; /* Current LineEdit */
bool myBusy; // widgets
SMESH::SMESH_Mesh_var myMesh; QButtonGroup* GroupConstructors;
SMESH_Actor* myActor; QRadioButton* RadioButton1;
Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; QRadioButton* RadioButton2;
QButtonGroup* GroupConstructors; QGroupBox* GroupArguments;
QRadioButton* RadioButton1; QLabel* TextLabelElements;
QRadioButton* RadioButton2; QPushButton* SelectElementsButton;
QGroupBox* GroupButtons; QLineEdit* LineEditElements;
QPushButton* buttonOk; QCheckBox* CheckBoxMesh;
QPushButton* buttonCancel; QLabel* TextLabelVector;
QPushButton* buttonApply; QLabel* TextLabelDx;
QGroupBox* GroupArguments; SMESHGUI_SpinBox* SpinBox_Dx;
QLabel* TextLabelElements; QLabel* TextLabelDy;
QPushButton* SelectElementsButton; SMESHGUI_SpinBox* SpinBox_Dy;
QLineEdit* LineEditElements; QLabel* TextLabelDz;
QCheckBox* CheckBoxMesh; SMESHGUI_SpinBox* SpinBox_Dz;
QLabel* TextLabelVector; QLabel* TextLabelNbSteps;
QLabel* TextLabelDx; QSpinBox* SpinBox_NbSteps;
SMESHGUI_SpinBox* SpinBox_Dx;
QLabel* TextLabelDy;
SMESHGUI_SpinBox* SpinBox_Dy;
QLabel* TextLabelDz;
SMESHGUI_SpinBox* SpinBox_Dz;
QLabel* TextLabelNbSteps;
QSpinBox* SpinBox_NbSteps;
private slots:
void ConstructorsClicked(int constructorId); QGroupBox* GroupButtons;
void ClickOnOk(); QPushButton* buttonOk;
void ClickOnCancel(); QPushButton* buttonCancel;
void ClickOnApply(); QPushButton* buttonApply;
void SetEditCurrentArgument() ;
void SelectionIntoArgument() ; private slots:
void DeactivateActiveDialog() ; void ConstructorsClicked (int);
void ActivateThisDialog() ; void ClickOnOk();
void onTextChange(const QString&); bool ClickOnApply();
void onSelectMesh(bool toSelectMesh); void ClickOnCancel();
void SetEditCurrentArgument();
protected: void SelectionIntoArgument();
QGridLayout* SMESHGUI_ExtrusionDlgLayout; void DeactivateActiveDialog();
QGridLayout* GroupConstructorsLayout; void ActivateThisDialog();
QGridLayout* GroupButtonsLayout; void onTextChange (const QString&);
QGridLayout* GroupArgumentsLayout; void onSelectMesh (bool toSelectMesh);
}; };
#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)
@ -86,7 +90,7 @@ bool SMESHGUI_PredicateFilter::IsValid( const int theCellId ) const
SMESH_Actor* anActor = dynamic_cast<SMESH_Actor*>( myActor ); SMESH_Actor* anActor = dynamic_cast<SMESH_Actor*>( myActor );
if ( !anActor || anActor->GetObject() == 0 ) if ( !anActor || anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
SMESH::ElementType anElemType = myPred->GetElementType(); SMESH::ElementType anElemType = myPred->GetElementType();
int aMeshId = anElemType == SMESH::NODE ? anActor->GetNodeObjId( theCellId ) int aMeshId = anElemType == SMESH::NODE ? anActor->GetNodeObjId( theCellId )
@ -98,7 +102,7 @@ bool SMESHGUI_PredicateFilter::IsValid( const int theCellId ) const
: aMesh->FindElement( aMeshId ); : aMesh->FindElement( aMeshId );
if ( anElem != 0 && anElem->GetType() != (SMDSAbs_ElementType)myPred->GetElementType() ) if ( anElem != 0 && anElem->GetType() != (SMDSAbs_ElementType)myPred->GetElementType() )
return true; return true;
return myPred->IsSatisfy( aMeshId ); return myPred->IsSatisfy( aMeshId );
} }
@ -114,10 +118,10 @@ bool SMESHGUI_PredicateFilter::IsObjValid( const int theObjId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
SMESH::ElementType anElemType = myPred->GetElementType(); SMESH::ElementType anElemType = myPred->GetElementType();
// if type of element != type of predicate return true because // if type of element != type of predicate return true because
// this predicate is not intended for filtering sush elements // this predicate is not intended for filtering sush elements
const SMDS_MeshElement* anElem = anElemType == SMESH::NODE ? aMesh->FindNode( theObjId ) const SMDS_MeshElement* anElem = anElemType == SMESH::NODE ? aMesh->FindNode( theObjId )
@ -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);
@ -214,10 +221,10 @@ bool SMESHGUI_QuadrangleFilter::IsValid( const int theCellId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
return anElem && anElem->GetType() == SMDSAbs_Face && anElem->NbNodes() == 4; return anElem && anElem->GetType() == SMDSAbs_Face && anElem->NbNodes() == 4;
} }
@ -233,7 +240,7 @@ bool SMESHGUI_QuadrangleFilter::IsObjValid( const int theObjId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
@ -291,7 +298,7 @@ bool SMESHGUI_TriangleFilter::IsValid( const int theCellId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
@ -310,7 +317,7 @@ bool SMESHGUI_TriangleFilter::IsObjValid( const int theObjId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
@ -367,7 +374,7 @@ bool SMESHGUI_FacesFilter::IsValid( const int theCellId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
@ -386,7 +393,7 @@ bool SMESHGUI_FacesFilter::IsObjValid( const int theObjId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
@ -444,7 +451,7 @@ bool SMESHGUI_VolumesFilter::IsValid( const int theCellId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) );
@ -463,7 +470,7 @@ bool SMESHGUI_VolumesFilter::IsObjValid( const int theObjId ) const
SMESH_Actor* anActor = ( SMESH_Actor* )myActor; SMESH_Actor* anActor = ( SMESH_Actor* )myActor;
if ( anActor->GetObject() == 0 ) if ( anActor->GetObject() == 0 )
return false; return false;
SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId );
@ -488,14 +495,3 @@ bool SMESHGUI_VolumesFilter::IsNodeFilter() const
{ {
return false; return false;
} }

View File

@ -13,11 +13,11 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
// //
// //
// //
@ -50,7 +50,7 @@ enum SMESHGUI_FilterType
/* /*
Class : SMESHGUI_Filter Class : SMESHGUI_Filter
Description : Base class for SMESH selection filters for VTK viewer. Description : Base class for SMESH selection filters for VTK viewer.
*/ */
DEFINE_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) DEFINE_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter)

File diff suppressed because it is too large Load Diff

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,17 +56,19 @@ 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,66 +81,64 @@ 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, const QValueList<int>& type);
const QValueList<int>& type );
virtual ~SMESHGUI_FilterTable(); virtual ~SMESHGUI_FilterTable();
void Init( const int type ); void Init (const int type);
void Init( const QValueList<int>& types ); void Init (const QValueList<int>& types);
QGroupBox* GetTableGrp(); QGroupBox* GetTableGrp();
bool IsValid( const bool = true, const int theEntityType = -1 ) const; bool IsValid (const bool = true, const int theEntityType = -1) const;
int GetType() const; int GetType() const;
void SetType( const int ); void SetType (const int);
void RestorePreviousEntityType(); void RestorePreviousEntityType();
int NumRows( const int theEntityType = -1 ) const; int NumRows (const int theEntityType = -1) const;
void Clear( const int theEntityType = -1 ); void Clear (const int theEntityType = -1);
void SetEditable( const bool ); void SetEditable (const bool);
void SetEnabled( const bool ); void SetEnabled (const bool);
void SetLibsEnabled( const bool ); void SetLibsEnabled (const bool);
bool IsEditable() const; bool IsEditable() const;
int GetCriterionType( const int theRow, const int theType = -1 ) const; int GetCriterionType (const int theRow, const int theType = -1) const;
void GetCriterion( const int theRow, void GetCriterion (const int theRow,
SMESH::Filter::Criterion& theCriterion, SMESH::Filter::Criterion& theCriterion,
const int theEntityType = -1 ) const; const int theEntityType = -1) const;
void SetCriterion( const int theRow, void SetCriterion (const int theRow,
const SMESH::Filter::Criterion& theCriterion, const SMESH::Filter::Criterion& theCriterion,
const int theEntityType = -1 ); const int theEntityType = -1);
void AddCriterion( const SMESH::Filter::Criterion& theCriterion, void AddCriterion (const SMESH::Filter::Criterion& theCriterion,
const int theEntityType = -1 ); const int theEntityType = -1);
void Copy( const SMESHGUI_FilterTable* );
void SetValidity( const bool );
bool CurrentCell( int& theRow, int& theCol ) const; void Copy (const SMESHGUI_FilterTable*);
void SetThreshold( const int theRow, void SetValidity (const bool);
bool CurrentCell (int& theRow, int& theCol) const;
void SetThreshold (const int theRow,
const QString& theText, const QString& theText,
const int theEntityType = -1 ); const int theEntityType = -1);
bool GetThreshold( const int theRow, bool GetThreshold (const int theRow,
QString& theText, QString& theText,
const int theEntityType = -1 ); const int theEntityType = -1);
void Update(); void Update();
signals: signals:
void CopyFromClicked(); void CopyFromClicked();
void AddToClicked(); void AddToClicked();
void EntityTypeChanged( const int ); void EntityTypeChanged (const int);
void NeedValidation(); void NeedValidation();
void CretarionChanged( const int theRow, const int theEntityType ); void CretarionChanged (const int theRow, const int theEntityType);
void CurrentChanged( int, int ); void CurrentChanged (int, int);
private slots: private slots:
void onAddBtn(); void onAddBtn();
@ -146,30 +147,30 @@ private slots:
void onClearBtn(); void onClearBtn();
void onCopyFromBtn(); void onCopyFromBtn();
void onAddToBtn(); void onAddToBtn();
void onCriterionChanged( int, int ); void onCriterionChanged (int, int);
void onEntityType( int ); void onEntityType (int);
void onCurrentChanged( int, int ); void onCurrentChanged (int, int);
private: private:
void addRow( Table*, const int, const bool toTheEnd = true ); void addRow (Table*, const int, const bool toTheEnd = true);
QTableItem* getCriterionItem( QTable*, const int ); QTableItem* getCriterionItem (QTable*, const int);
QTableItem* getCompareItem( QTable* ); QTableItem* getCompareItem (QTable*);
QTableItem* getUnaryItem( QTable* ); QTableItem* getUnaryItem (QTable*);
QTableItem* getBinaryItem( QTable* ); QTableItem* getBinaryItem (QTable*);
const QMap<int, QString>& getCriteria( const int theType ) const; const QMap<int, QString>& getCriteria (const int theType) const;
const QMap<int, QString>& getCompare() const; const QMap<int, QString>& getCompare() const;
Table* createTable( QWidget*, const int ); Table* createTable (QWidget*, const int);
QWidget* createAdditionalFrame( QWidget* theParent ); QWidget* createAdditionalFrame (QWidget* theParent);
int getFirstSelectedRow() const; int getFirstSelectedRow() const;
void onCriterionChanged( const int, const int, const int ); void onCriterionChanged (const int, const int, const int);
void updateBtnState(); void updateBtnState();
void removeAdditionalWidget( QTable* theTable, const int theRow ); void removeAdditionalWidget (QTable* theTable, const int theRow);
void updateAdditionalWidget(); void updateAdditionalWidget();
const QMap<int, QString>& getSupportedTypes() const; const QMap<int, QString>& getSupportedTypes() const;
private: private:
QGroupBox* myTableGrp; QGroupBox* myTableGrp;
@ -186,45 +187,46 @@ private:
QButtonGroup* myEntityTypeGrp; QButtonGroup* myEntityTypeGrp;
int myEntityType; int myEntityType;
int myIsValid; int myIsValid;
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
{ {
Q_OBJECT Q_OBJECT
// Source elements to be selected // Source elements to be selected
enum { Mesh, Selection, Dialog, None }; enum { Mesh, Selection, Dialog, None };
// Buttons // Buttons
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();
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*);
static SMESH::Filter::Criterion createCriterion(); static SMESH::Filter::Criterion createCriterion();
@ -239,35 +241,35 @@ private slots:
void onClose(); void onClose();
void onDeactivate(); void onDeactivate();
void onSelectionDone(); void onSelectionDone();
void onCriterionChanged( const int, const int ); void onCriterionChanged (const int, const int);
void onCurrentChanged( int, int ); void onCurrentChanged (int, int);
private: 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
QFrame* createButtonFrame( QWidget* ); QFrame* createButtonFrame (QWidget*);
QFrame* createMainFrame( QWidget* ); QFrame* createMainFrame (QWidget*);
QButtonGroup* createSourceGroup( QWidget* ); QButtonGroup* createSourceGroup (QWidget*);
void updateMainButtons(); void updateMainButtons();
// execution // execution
bool isValid() const; bool isValid() const;
bool createFilter( const int theType ); bool createFilter (const int theType);
void insertFilterInViewer(); void insertFilterInViewer();
void selectInViewer( const int theType, void selectInViewer (const int theType,
const QValueList<int>& theIds ); const QValueList<int>& theIds);
void filterSource( const int theType, void filterSource (const int theType,
QValueList<int>& theResIds ); QValueList<int>& theResIds);
void filterSelectionSource( const int theType, void filterSelectionSource (const int theType,
QValueList<int>& theResIds ); QValueList<int>& theResIds);
void getIdsFromWg( const QWidget*, QValueList<int>& ) const; void getIdsFromWg (const QWidget*, QValueList<int>&) const;
void setIdsToWg( QWidget*, const QValueList<int>& ); void setIdsToWg (QWidget*, const QValueList<int>&);
Selection_Mode getSelMode( const int ) const; Selection_Mode getSelMode (const int) const;
void updateSelection(); void updateSelection();
private: private:
@ -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

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +1,31 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// 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_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

@ -1,48 +1,52 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// 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

@ -10,7 +10,7 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -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

File diff suppressed because it is too large Load Diff

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,21 +104,23 @@ 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);
void enterEvent ( QEvent * ) ; void enterEvent (QEvent*);
void hideEvent ( QHideEvent * ); /* ESC key */ void hideEvent (QHideEvent*); /* ESC key */
void setSelectionMode(int theMode); void setSelectionMode(int theMode);
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

@ -1,23 +1,23 @@
// SMESH SMESHGUI : GUI for SMESH component // SMESH SMESHGUI : GUI for SMESH component
// //
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
// //
// //
// //
@ -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,71 +52,73 @@
#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
*/ */
//======================================================================= //=======================================================================
// name : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg // name : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg
// 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)
{ {
myMode = theMode; myMode = theMode;
if ( myMode == UNION ) setCaption( tr( "UNION_OF_TWO_GROUPS" ) ); if (myMode == UNION) setCaption(tr("UNION_OF_TWO_GROUPS"));
else if ( myMode == INTERSECT ) setCaption( tr( "INTERSECTION_OF_TWO_GROUPS" ) ); else if (myMode == INTERSECT) setCaption(tr("INTERSECTION_OF_TWO_GROUPS"));
else setCaption( tr( "CUT_OF_TWO_GROUPS" ) ); else setCaption(tr("CUT_OF_TWO_GROUPS"));
QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING);
QFrame* aMainFrame = createMainFrame ( this ); QFrame* aMainFrame = createMainFrame (this);
QFrame* aBtnFrame = createButtonFrame( this ); QFrame* aBtnFrame = createButtonFrame(this);
aDlgLay->addWidget( aMainFrame ); aDlgLay->addWidget(aMainFrame);
aDlgLay->addWidget( aBtnFrame ); aDlgLay->addWidget(aBtnFrame);
aDlgLay->setStretchFactor( aMainFrame, 1 ); aDlgLay->setStretchFactor(aMainFrame, 1);
Init( theSelection ); Init(theSelection);
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_GroupOpDlg::createMainFrame // name : SMESHGUI_GroupOpDlg::createMainFrame
// Purpose : Create frame containing dialog's input fields // Purpose : Create frame containing dialog's input fields
//======================================================================= //=======================================================================
QFrame* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent ) QFrame* SMESHGUI_GroupOpDlg::createMainFrame (QWidget* theParent)
{ {
QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent);
aMainGrp->setFrameStyle( QFrame::NoFrame ); aMainGrp->setFrameStyle(QFrame::NoFrame);
aMainGrp->setInsideMargin( 0 ); aMainGrp->setInsideMargin(0);
QGroupBox* aNameGrp = new QGroupBox( 1, Qt::Vertical, tr( "NAME" ), aMainGrp ); QGroupBox* aNameGrp = new QGroupBox(1, Qt::Vertical, tr("NAME"), aMainGrp);
new QLabel( tr( "RESULT_NAME" ), aNameGrp ); new QLabel(tr("RESULT_NAME"), aNameGrp);
myNameEdit = new QLineEdit( aNameGrp ); myNameEdit = new QLineEdit(aNameGrp);
QGroupBox* anArgGrp = new QGroupBox( 3, Qt::Horizontal, tr( "ARGUMENTS" ), aMainGrp ); QGroupBox* anArgGrp = new QGroupBox(3, Qt::Horizontal, tr("ARGUMENTS"), aMainGrp);
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 );
myBtn2 = new QPushButton( anArgGrp ); new QLabel(myMode == CUT ? tr("TOOL_OBJECT") :tr("OBJECT_2"), anArgGrp);
myEdit2 = new QLineEdit( anArgGrp ); myBtn2 = new QPushButton(anArgGrp);
myEdit2 = new QLineEdit(anArgGrp);
myEdit1->setReadOnly( true ); myEdit2->setAlignment( Qt::AlignLeft );
myEdit2->setReadOnly( true );
myEdit1->setReadOnly(true);
myEdit2->setReadOnly(true);
QPixmap aPix (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
myBtn1->setPixmap(aPix);
myBtn2->setPixmap(aPix);
QPixmap aPix( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) );
myBtn1->setPixmap( aPix );
myBtn2->setPixmap( aPix );
return aMainGrp; return aMainGrp;
} }
@ -118,28 +126,28 @@ QFrame* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent )
// name : SMESHGUI_GroupOpDlg::createButtonFrame // name : SMESHGUI_GroupOpDlg::createButtonFrame
// Purpose : Create frame containing buttons // Purpose : Create frame containing buttons
//======================================================================= //=======================================================================
QFrame* SMESHGUI_GroupOpDlg::createButtonFrame( QWidget* theParent ) QFrame* SMESHGUI_GroupOpDlg::createButtonFrame (QWidget* theParent)
{ {
QFrame* aFrame = new QFrame( theParent ); QFrame* aFrame = new QFrame(theParent);
aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame);
myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame);
myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame);
QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING);
aLay->addWidget(myOkBtn);
aLay->addWidget(myApplyBtn);
aLay->addItem(aSpacer);
aLay->addWidget(myCloseBtn);
aLay->addWidget( myOkBtn );
aLay->addWidget( myApplyBtn );
aLay->addItem( aSpacer);
aLay->addWidget( myCloseBtn );
// connect signals and slots // connect signals and slots
connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
return aFrame; return aFrame;
} }
@ -156,32 +164,36 @@ 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;
myGroup1 = SMESH::SMESH_GroupBase::_nil(); myGroup1 = SMESH::SMESH_GroupBase::_nil();
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()));
connect( myBtn1, SIGNAL( clicked() ), this, SLOT( onFocusChanged() ) ); connect(myBtn1, SIGNAL(clicked()), this, SLOT(onFocusChanged()));
connect( myBtn2, SIGNAL( clicked() ), this, SLOT( onFocusChanged() ) ); connect(myBtn2, SIGNAL(clicked()), this, SLOT(onFocusChanged()));
int x, y ; int x, y;
aSMESHGUI->DefineDlgPosition( this, x, y ); aSMESHGUI->DefineDlgPosition(this, x, y);
this->move( x, y ); this->move(x, y);
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,85 +205,77 @@ 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;
} }
// Verify whether arguments belongs to same mesh // Verify whether arguments belongs to same mesh
SMESH::SMESH_Mesh_ptr aMesh1 = myGroup1->GetMesh(); SMESH::SMESH_Mesh_ptr aMesh1 = myGroup1->GetMesh();
SMESH::SMESH_Mesh_ptr aMesh2 = myGroup2->GetMesh(); SMESH::SMESH_Mesh_ptr aMesh2 = myGroup2->GetMesh();
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;
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_GroupOpDlg::onApply // name : SMESHGUI_GroupOpDlg::onApply
// Purpose : SLOT called when "Apply" button pressed. // Purpose : SLOT called when "Apply" button pressed.
//======================================================================= //=======================================================================
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();
QString aName = myNameEdit->text(); QString aName = myNameEdit->text();
SMESH::SMESH_Group_ptr aNewGrp = SMESH::SMESH_Group::_nil(); SMESH::SMESH_Group_ptr aNewGrp = SMESH::SMESH_Group::_nil();
if ( myMode == UNION ) aNewGrp = aMesh->UnionGroups( myGroup1, myGroup2, aName.latin1() );
else if ( myMode == INTERSECT ) aNewGrp = aMesh->IntersectGroups( myGroup1, myGroup2, aName.latin1() );
else aNewGrp = aMesh->CutGroups( myGroup1, myGroup2, aName.latin1() );
if ( !aNewGrp->_is_nil() ) if (myMode == UNION) aNewGrp = aMesh->UnionGroups(myGroup1, myGroup2, aName.latin1());
{ else if (myMode == INTERSECT) aNewGrp = aMesh->IntersectGroups(myGroup1, myGroup2, aName.latin1());
SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true ); else aNewGrp = aMesh->CutGroups(myGroup1, myGroup2, aName.latin1());
if (!aNewGrp->_is_nil()) {
SMESHGUI::GetSMESHGUI()->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;
} }
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_GroupOpDlg::onOk // name : SMESHGUI_GroupOpDlg::onOk
// Purpose : SLOT called when "Ok" button pressed. // Purpose : SLOT called when "Ok" button pressed.
//======================================================================= //=======================================================================
void SMESHGUI_GroupOpDlg::onOk() void SMESHGUI_GroupOpDlg::onOk()
{ {
if ( onApply() ) if (onApply())
onClose(); onClose();
} }
@ -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();
} }
@ -295,23 +299,26 @@ void SMESHGUI_GroupOpDlg::onClose()
//======================================================================= //=======================================================================
void SMESHGUI_GroupOpDlg::onSelectionDone() void SMESHGUI_GroupOpDlg::onSelectionDone()
{ {
if ( myFocusWg == myEdit1 ) if (myFocusWg == myEdit1)
myGroup1 = SMESH::SMESH_GroupBase::_nil(); myGroup1 = SMESH::SMESH_GroupBase::_nil();
else else
myGroup2 = SMESH::SMESH_GroupBase::_nil(); myGroup2 = SMESH::SMESH_GroupBase::_nil();
myFocusWg->setText( "" );
if ( mySelection->IObjectCount() == 1 )
{
SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>( mySelection->firstIObject() );
if ( !aGroup->_is_nil() )
{
myFocusWg->setText( aGroup->GetName() );
if ( myFocusWg == myEdit1 ) myFocusWg->setText("");
SALOME_ListIO aList;
mySelectionMgr->selectedObjects(aList);
if (aList.Extent() == 1) {
SMESH::SMESH_GroupBase_var aGroup =
SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(aList.First());
if (!aGroup->_is_nil())
{
myFocusWg->setText(aGroup->GetName());
myFocusWg->setCursorPosition( 0 );
if (myFocusWg == myEdit1)
myGroup1 = aGroup; myGroup1 = aGroup;
else else
myGroup2 = aGroup; myGroup2 = aGroup;
@ -325,30 +332,33 @@ void SMESHGUI_GroupOpDlg::onSelectionDone()
//======================================================================= //=======================================================================
void SMESHGUI_GroupOpDlg::onDeactivate() void SMESHGUI_GroupOpDlg::onDeactivate()
{ {
setEnabled( false ); setEnabled(false);
mySelection->ClearFilters(); mySelectionMgr->clearFilters();
} }
//======================================================================= //=======================================================================
// name : SMESHGUI_GroupOpDlg::enterEvent // name : SMESHGUI_GroupOpDlg::enterEvent
// Purpose : Event filter // Purpose : Event filter
//======================================================================= //=======================================================================
void SMESHGUI_GroupOpDlg::enterEvent( QEvent* ) 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();
} }
//======================================================================= //=======================================================================
@ -368,34 +378,9 @@ void SMESHGUI_GroupOpDlg::onFocusChanged()
//======================================================================= //=======================================================================
void SMESHGUI_GroupOpDlg::reset() void SMESHGUI_GroupOpDlg::reset()
{ {
myNameEdit->setText( "" ); myNameEdit->setText("");
myEdit1->setText( "" ); myEdit1->setText("");
myEdit2->setText( "" ); myEdit2->setText("");
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

@ -1,29 +1,34 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// 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

@ -1,49 +1,54 @@
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either // License as published by the Free Software Foundation; either
// version 2.1 of the License. // version 2.1 of the License.
// //
// This library is distributed in the hope that it will be useful, // This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details. // Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public // You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software // License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// 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
@ -51,7 +56,7 @@ static int MYDEBUG = 0;
#endif #endif
namespace SMESH{ namespace SMESH{
using namespace std; using namespace std;
typedef map<string,HypothesisData*> THypothesisDataMap; typedef map<string,HypothesisData*> THypothesisDataMap;
@ -61,12 +66,12 @@ namespace SMESH{
typedef map<string,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap; typedef map<string,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap;
THypCreatorMap myHypCreatorMap; THypCreatorMap myHypCreatorMap;
void addMap( const THypothesisDataMap& theMap, void addMap(const THypothesisDataMap& theMap,
THypothesisDataMap& toMap) THypothesisDataMap& toMap)
{ {
THypothesisDataMap::const_iterator it; THypothesisDataMap::const_iterator it;
for ( it = theMap.begin(); it != theMap.end(); it++ ) for (it = theMap.begin(); it != theMap.end(); it++)
toMap.insert( *it ); toMap.insert(*it);
} }
@ -74,79 +79,79 @@ namespace SMESH{
SMESH::SMESH_Hypothesis_ptr theHyp, SMESH::SMESH_Hypothesis_ptr theHyp,
const bool theIsAddition) const bool theIsAddition)
{ {
if ( theHypStatus > SMESH::HYP_OK ) { if (theHypStatus > SMESH::HYP_OK) {
// 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;
} }
// message // message
bool isFatal = ( theHypStatus >= SMESH::HYP_UNKNOWN_FATAL ); bool isFatal = (theHypStatus >= SMESH::HYP_UNKNOWN_FATAL);
QString aMsg; QString aMsg;
if ( theIsAddition ) if (theIsAddition)
aMsg = ( isFatal ? "SMESH_CANT_ADD_HYP" : "SMESH_ADD_HYP_WRN"); aMsg = (isFatal ? "SMESH_CANT_ADD_HYP" : "SMESH_ADD_HYP_WRN");
else else
aMsg = ( isFatal ? "SMESH_CANT_RM_HYP" : "SMESH_RM_HYP_WRN"); aMsg = (isFatal ? "SMESH_CANT_RM_HYP" : "SMESH_RM_HYP_WRN");
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"));
} }
} }
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");
QString HypsXml; QString HypsXml;
char* cenv = getenv("SMESH_MeshersList"); char* cenv = getenv("SMESH_MeshersList");
if (cenv) if (cenv)
HypsXml.sprintf("%s", cenv); HypsXml.sprintf("%s", cenv);
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"));
return; return;
} }
// loop on files in HypsXml // loop on files in HypsXml
QString aNoAccessFiles; QString aNoAccessFiles;
for ( int i = 0; i < HypsXmlList.count(); i++ ) { for (int i = 0; i < HypsXmlList.count(); i++) {
QString HypsXml = HypsXmlList[ i ]; QString HypsXml = HypsXmlList[ i ];
// 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();
SMESHGUI_XmlHandler* aXmlHandler = new SMESHGUI_XmlHandler(); SMESHGUI_XmlHandler* aXmlHandler = new SMESHGUI_XmlHandler();
ASSERT(aXmlHandler); ASSERT(aXmlHandler);
QXmlInputSource source (file); QXmlInputSource source (file);
QXmlSimpleReader reader; QXmlSimpleReader reader;
reader.setContentHandler(aXmlHandler); reader.setContentHandler(aXmlHandler);
@ -154,11 +159,11 @@ namespace SMESH{
bool ok = reader.parse(source); bool ok = reader.parse(source);
file.close(); file.close();
if (ok) { if (ok) {
addMap( aXmlHandler->myHypothesesMap, myHypothesesMap ); addMap(aXmlHandler->myHypothesesMap, myHypothesesMap);
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"));
@ -171,17 +176,17 @@ namespace SMESH{
aNoAccessFiles += ", " + xmlFile; aNoAccessFiles += ", " + xmlFile;
} }
} // end loop } // end loop
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();
} }
} }
} }
@ -190,10 +195,10 @@ namespace SMESH{
QStringList GetAvailableHypotheses(const bool isAlgo) QStringList GetAvailableHypotheses(const bool isAlgo)
{ {
QStringList aHypList; QStringList aHypList;
// Init list of available hypotheses, if needed // Init list of available hypotheses, if needed
InitAvailableHypotheses(); InitAvailableHypotheses();
// fill list of hypotheses/algorithms // fill list of hypotheses/algorithms
THypothesisDataMap::iterator anIter; THypothesisDataMap::iterator anIter;
if (isAlgo) { if (isAlgo) {
@ -208,10 +213,10 @@ namespace SMESH{
aHypList.append(((*anIter).first).c_str()); aHypList.append(((*anIter).first).c_str());
} }
} }
return aHypList; return aHypList;
} }
HypothesisData* GetHypothesisData (const char* aHypType) HypothesisData* GetHypothesisData (const char* aHypType)
{ {
@ -237,7 +242,7 @@ namespace SMESH{
if(MYDEBUG) MESSAGE("Get HypothesisCreator for " << aHypType); if(MYDEBUG) MESSAGE("Get HypothesisCreator for " << aHypType);
SMESHGUI_GenericHypothesisCreator* aCreator = 0; SMESHGUI_GenericHypothesisCreator* aCreator = 0;
// check, if creator for this hypothesis type already exists // check, if creator for this hypothesis type already exists
if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) { if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) {
aCreator = myHypCreatorMap[aHypType]; aCreator = myHypCreatorMap[aHypType];
@ -270,7 +275,7 @@ namespace SMESH{
typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \ typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \
(QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI); (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI);
GetHypothesisCreator procHandle = GetHypothesisCreator procHandle =
(GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" ); (GetHypothesisCreator)dlsym(libHandle, "GetHypothesisCreator");
if (!procHandle) { if (!procHandle) {
if(MYDEBUG) MESSAGE("bad hypothesis client plugin library"); if(MYDEBUG) MESSAGE("bad hypothesis client plugin library");
dlclose(libHandle); dlclose(libHandle);
@ -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);
} }
} }
@ -305,24 +310,29 @@ namespace SMESH{
if(MYDEBUG) MESSAGE("Create " << aHypType << " with name " << aHypName); if(MYDEBUG) MESSAGE("Create " << aHypType << " with name " << aHypName);
SMESH::SMESH_Hypothesis_var Hyp; SMESH::SMESH_Hypothesis_var Hyp;
HypothesisData* aHypData = GetHypothesisData(aHypType); HypothesisData* aHypData = GetHypothesisData(aHypType);
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)
SMESH::SetName( SHyp, aHypName ); if (strlen(aHypName) > 0)
GetActiveStudy()->updateObjBrowser(true); SMESH::SetName(SHyp, aHypName);
//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();
@ -332,29 +342,29 @@ namespace SMESH{
bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp) bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp)
{ {
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;
} }
} }
@ -364,164 +374,164 @@ namespace SMESH{
bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp) bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp)
{ {
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;
} }
} }
else { else {
SCRUTE( aSubMesh->_is_nil() ); SCRUTE(aSubMesh->_is_nil());
SCRUTE( aHyp->_is_nil() ); SCRUTE(aHyp->_is_nil());
} }
return res < SMESH::HYP_UNKNOWN_FATAL; return res < SMESH::HYP_UNKNOWN_FATAL;
} }
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 =
SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM); SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh_var aSubMesh =
SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM); SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
if (!aSubMesh->_is_nil()) if (!aSubMesh->_is_nil())
aMesh = aSubMesh->GetFather(); aMesh = aSubMesh->GetFather();
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();
} }
} }
} }
} }
} }
} }
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;
} }
} }
else if (IObject->hasEntry()) { else if (IObject->hasEntry()) {
if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry()); if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry());
} }
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()) {
SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM); SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM); SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
if ( !aSubMesh->_is_nil() ) if (!aSubMesh->_is_nil())
aMesh = aSubMesh->GetFather(); aMesh = aSubMesh->GetFather();
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;
} }
} }
@ -529,8 +539,7 @@ namespace SMESH{
} }
} }
} }
if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed"); if (MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed");
return listSOmesh._retn(); return listSOmesh;
} }
} }

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