//
#include "SMESHGUI_ConvToQuadDlg.h"
+#include "SMESHGUI_ConvToQuadOp.h"
+
// Qt includes
#include <QGroupBox>
#include <QCheckBox>
aBGLayout->setMargin(MARGIN);
aBGLayout->setSpacing(SPACING);
- myRB1 = new QRadioButton( tr( "RADIOBTN_1" ), myBGBox );
- myRB2 = new QRadioButton( tr( "RADIOBTN_2" ), myBGBox );
-
- aBGLayout->addWidget(myRB1);
- aBGLayout->addWidget(myRB2);
- myBG->addButton(myRB1, 0);
- myBG->addButton(myRB2, 1);
- myRB1->setChecked( true );
+ myRB2Lin = new QRadioButton( tr( "RADIOBTN_1" ), myBGBox );
+ myRB2Quad = new QRadioButton( tr( "RADIOBTN_2" ), myBGBox );
+ myRB2BiQua = new QRadioButton( tr( "RADIOBTN_3" ), myBGBox );
+
+ aBGLayout->addWidget(myRB2Lin);
+ aBGLayout->addWidget(myRB2Quad);
+ aBGLayout->addWidget(myRB2BiQua);
+ myBG->addButton(myRB2Lin, 0);
+ myBG->addButton(myRB2Quad, 1);
+ myBG->addButton(myRB2BiQua, 2);
+ myRB2Lin->setChecked( true );
myWarning = new QLabel(QString("<b>%1</b>").arg(tr("NON_CONFORM_WARNING")), mainFrame());
{
}
+bool SMESHGUI_ConvToQuadDlg::IsBiQuadratic() const
+{
+ return myRB2BiQua->isChecked();
+}
+
bool SMESHGUI_ConvToQuadDlg::IsMediumNdsOnGeom() const
{
return !myMedNdsOnGeom->isChecked();
void SMESHGUI_ConvToQuadDlg::SetEnabledControls( const bool theCheck )
{
//myBGBox->setEnabled( theCheck );
- myRB1->setEnabled( theCheck );
- myRB2->setEnabled( theCheck );
+ myRB2Lin->setEnabled( theCheck );
+ myRB2Quad->setEnabled( theCheck );
+ myRB2BiQua->setEnabled( theCheck );
myMedNdsOnGeom->setEnabled( theCheck );
//setButtonEnabled( theCheck, QtxDialog::OK | QtxDialog::Apply );
}
void SMESHGUI_ConvToQuadDlg::SetEnabledRB( const int idx, const bool theCheck )
{
- if(idx)
+ myRB2Lin ->setEnabled( idx & SMESHGUI_ConvToQuadOp::Linear );
+ myRB2Quad ->setEnabled( idx & SMESHGUI_ConvToQuadOp::Quadratic );
+ myRB2BiQua->setEnabled( idx & SMESHGUI_ConvToQuadOp::BiQuadratic );
+
+ if ( idx & SMESHGUI_ConvToQuadOp::Linear )
{
- myRB2->setEnabled( theCheck );
- myRB1->setEnabled( !theCheck );
- myRB1->setChecked( true );
+ myRB2Lin->setChecked( true );
+ myRB2Quad->setChecked( false );
}
else
{
- myRB1->setEnabled( theCheck );
- myRB2->setEnabled( !theCheck );
- myRB2->setChecked( true );
+ myRB2Lin->setChecked( false );
+ myRB2Quad->setChecked( true );
}
- emit onClicked( myBG->checkedId() );
-}
+ myRB2BiQua->setChecked( false );
+ myMedNdsOnGeom->setEnabled( theCheck );
+ emit onClicked( myBG->checkedId() );
+}
myDlg->setButtonEnabled( false, QtxDialog::OK | QtxDialog::Apply );
return;
}
- MeshType meshType = ConsistMesh( idSource );
- if( meshType == SMESHGUI_ConvToQuadOp::Quadratic )
- {
- myDlg->SetEnabledRB( 0, false );
- }
- else if( meshType == SMESHGUI_ConvToQuadOp::Linear )
- {
- myDlg->SetEnabledRB( 1, false );
- }
- else
- {
- myDlg->SetEnabledControls( true );
- }
+ SMESH::SMESH_Mesh_var mesh = idSource->GetMesh();
+ bool hasGeom = mesh->HasShapeToMesh();
+ MeshDestinationType meshTgtType = DestinationMesh( idSource );
+ myDlg->SetEnabledRB( meshTgtType, hasGeom && ( meshTgtType & ( BiQuadratic | Quadratic )));
// show warning on non-conformal result mesh
if ( ! idSource->_is_nil() )
{
SMESH::SMESH_Mesh_var mesh = idSource->GetMesh();
idSource = SMESH::SMESH_IDSource::_narrow( mesh );
- MeshType fullMeshType = ConsistMesh( idSource );
- toShow = ( fullMeshType != Comp );
+ bool isMixOrder;
+ DestinationMesh( idSource, &isMixOrder );
+ toShow = !isMixOrder;
}
myDlg->ShowWarning( toShow );
}
SMESH::SMESH_MeshEditor_var aEditor = mesh->GetMeshEditor();
aResult = true;
SMESH::SMESH_Mesh_var sourceMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pObj );
- if( !myDlg->CurrentRB() )
+ if( myDlg->CurrentRB()==1 || myDlg->CurrentRB()==2)
{
bool force3d = true;
if( myDlg->IsEnabledCheck() )
force3d = myDlg->IsMediumNdsOnGeom();
-
- if ( sourceMesh->_is_nil() )
- aEditor->ConvertToQuadraticObject( force3d, idSource );
- else
- aEditor->ConvertToQuadratic( force3d );
-
+ bool theToBiQuad = myDlg->IsBiQuadratic();
+ if ( sourceMesh->_is_nil() ) {
+ if ( theToBiQuad ) aEditor->ConvertToBiQuadratic ( force3d, idSource );
+ else aEditor->ConvertToQuadraticObject( force3d, idSource );
+ }
+ else {
+ if ( theToBiQuad ) aEditor->ConvertToBiQuadratic( force3d, sourceMesh );
+ else aEditor->ConvertToQuadratic ( force3d );
+ }
if ( !force3d )
{
SMESH::ComputeError_var error = aEditor->GetLastError();
{
if ( myBadElemsPreview ) delete myBadElemsPreview; // viewWindow may change
myBadElemsPreview = new SMESHGUI_MeshEditPreview( viewWindow() );
-
+
vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
vtkProperty* prop = vtkProperty::New();
//================================================================================
/*! ConsistMesh
- * Determines, what elements this mesh contains.
+ * Determines, what elements this mesh does not contain.
*/
//================================================================================
-SMESHGUI_ConvToQuadOp::MeshType SMESHGUI_ConvToQuadOp::ConsistMesh( const SMESH::SMESH_IDSource_var& idSource) const
+
+SMESHGUI_ConvToQuadOp::MeshDestinationType
+SMESHGUI_ConvToQuadOp::DestinationMesh( const SMESH::SMESH_IDSource_var& idSource,
+ bool* isMixOrder) const
{
SMESH::long_array_var nbElemOfType = idSource->GetMeshInfo();
+
+ bool hasBiQuad = ( nbElemOfType[SMDSEntity_BiQuad_Quadrangle ] ||
+ nbElemOfType[SMDSEntity_TriQuad_Hexa ] );
+ bool hasLinStruct = ( nbElemOfType[SMDSEntity_Quadrangle ] ||
+ nbElemOfType[SMDSEntity_Hexa ] );
+ bool hasQuadStruct = ( nbElemOfType[SMDSEntity_Quad_Quadrangle ] ||
+ nbElemOfType[SMDSEntity_Quad_Hexa ] );
+
bool hasQuad = ( nbElemOfType[SMDSEntity_Quad_Edge ] ||
nbElemOfType[SMDSEntity_Quad_Triangle ] ||
nbElemOfType[SMDSEntity_Quad_Quadrangle] ||
nbElemOfType[SMDSEntity_Pyramid ] ||
nbElemOfType[SMDSEntity_Penta ] );
- if ( hasQuad && hasLin )
- return Comp;
- return hasQuad ? Quadratic : Linear;
+ int tgtType = 0;
+ if ( hasBiQuad )
+ tgtType |= ( Quadratic | Linear );
+ if ( hasLinStruct )
+ tgtType |= ( BiQuadratic | Quadratic );
+ if ( hasQuadStruct )
+ tgtType |= ( BiQuadratic | Linear );
+ if ( hasQuad )
+ tgtType |= Linear;
+ if ( hasLin )
+ tgtType |= Quadratic;
+
+ if ( tgtType == 0 )
+ tgtType = Quadratic;
+
+ if ( isMixOrder )
+ *isMixOrder = ( hasLin && ( hasQuad || hasBiQuad ));
+
+ return MeshDestinationType( tgtType );
}
void SMESHGUI_ConvToQuadOp::ConnectRadioButtons( int id )
bool hasGeom = mesh->HasShapeToMesh();
- if( id || !hasGeom )
+ if( id==0 || !hasGeom )
myDlg->SetEnabledCheck( false );
else
myDlg->SetEnabledCheck( true );