#include "VTKViewer_ViewFrame.h"
#include <vtkLegendBoxActor.h>
#include <vtkFeatureEdges.h>
+#include <vtkDoubleArray.h>
// Open CASCADE Includes
bool SMESHGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y)
{
/* Here the position is on the bottom right corner - 10 */
+ aDlg->resize(QSize().expandedTo(aDlg->minimumSizeHint()));
QAD_Desktop* PP = QAD_Application::getDesktop() ;
x = abs ( PP->x() + PP->size().width() - aDlg->size().width() - 10 ) ;
y = abs ( PP->y() + PP->size().height() - aDlg->size().height() - 10 ) ;
Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId );
else if ( TypeAlgo.compare("Hexa_3D") == 0 )
Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId );
+ else if ( TypeAlgo.compare("NETGEN_3D") == 0 )
+ Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId );
if ( !Hyp->_is_nil() ) {
SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewAlgorithms( Hyp );
*
*/
//=============================================================================
-void SMESHGUI::CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, double nbSegments )
+void SMESHGUI::CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, int nbSegments )
{
QApplication::setOverrideCursor( Qt::waitCursor );
try {
case 0 : {
QApplication::setOverrideCursor( Qt::waitCursor );
if (ac->getDisplayMode()==2) {
+ bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (ac->getMapper());
meshMapper->SetInput(ac->DataSource);
+ meshMapper->SetScalarVisibility(isColored); //SAL3899
}
ac->setDisplayMode(0);
ac->GetProperty()->SetRepresentationToWireframe();
case 1 : {
QApplication::setOverrideCursor( Qt::waitCursor );
if (ac->getDisplayMode()==2) {
+ bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (ac->getMapper());
meshMapper->SetInput(ac->DataSource);
+ meshMapper->SetScalarVisibility(isColored); //SAL3899
}
ac->setDisplayMode(1);
ac->GetProperty()->SetRepresentationToSurface();
// ChangeRepresentation(ac, 1);
QApplication::setOverrideCursor( Qt::waitCursor );
ac->setDisplayMode(2);
+ bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (ac->getMapper());
- meshMapper->SetInput(ac->DataSource);
vtkShrinkFilter *shrink = vtkShrinkFilter::New();
- shrink->SetInput(meshMapper->GetInput());
+ shrink->SetInput(ac->DataSource);
shrink->SetShrinkFactor(ac->GetShrinkFactor());
meshMapper->SetInput( shrink->GetOutput() );
+ meshMapper->SetScalarVisibility(isColored); //SAL3899
ac->SetMapper( meshMapper );
QApplication::restoreOverrideCursor();
// }
float backfacecolor[3];
float nodecolor[3];
ac->GetColor(color[0],color[1],color[2]);
- QColor c(color[0]*255,color[1]*255,color[2]*255);
+// QColor c(color[0]*255,color[1]*255,color[2]*255);
+ int c0 = int(color[0]*255);
+ int c1 = int(color[1]*255);
+ int c2 = int(color[2]*255);
+ QColor c( c0, c1, c2 );
ac->GetEdgeColor(edgecolor[0],edgecolor[1],edgecolor[2]);
- QColor e(edgecolor[0]*255,edgecolor[1]*255,edgecolor[2]*255);
+// QColor e(edgecolor[0]*255,edgecolor[1]*255,edgecolor[2]*255);
+ c0 = int(edgecolor[0]*255);
+ c1 = int(edgecolor[1]*255);
+ c2 = int(edgecolor[2]*255);
+ QColor e( c0, c1, c2 );
ac->GetBackfaceProperty()->GetColor(backfacecolor);
- QColor b(backfacecolor[0]*255,backfacecolor[1]*255,backfacecolor[2]*255);
+// QColor b(backfacecolor[0]*255,backfacecolor[1]*255,backfacecolor[2]*255);
+ c0 = int(backfacecolor[0]*255);
+ c1 = int(backfacecolor[1]*255);
+ c2 = int(backfacecolor[2]*255);
+ QColor b( c0, c1, c2 );
ac->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2] ) ;
- QColor n(nodecolor[0]*255, nodecolor[1]*255, nodecolor[2]*255 ) ;
+// QColor n(nodecolor[0]*255, nodecolor[1]*255, nodecolor[2]*255 ) ;
+ c0 = int(nodecolor[0]*255);
+ c1 = int(nodecolor[1]*255);
+ c2 = int(nodecolor[2]*255);
+ QColor n( c0, c1, c2 ) ;
int Edgewidth = (int)ac->EdgeDevice->GetProperty()->GetLineWidth();
if ( Edgewidth == 0 )
ac->SetNodeSize(aDlg->GetIntValue(2)) ;
if (ac->getDisplayMode()==2) {
+ bool isColored = ac->getMapper()->GetScalarVisibility(); //SAL3899
vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (ac->getMapper());
meshMapper->SetInput(ac->DataSource);
vtkShrinkFilter *shrink = vtkShrinkFilter::New();
shrink->SetShrinkFactor(ac->GetShrinkFactor());
meshMapper->SetInput( shrink->GetOutput() );
+ meshMapper->SetScalarVisibility(isColored); //SAL3899
ac->SetMapper( meshMapper );
}
}
double beforeMaxVolume = MEV->GetMaxElementVolume() ;
double MaxVolume = smeshGUI->Parameter( res,
beforeMaxVolume,
- tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"),
+ tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"),
tr("SMESH_VALUE"),
1.0E-5, 1E6, 6 ) ;
if ( res && MaxVolume != beforeMaxVolume ) {
}
case 5020:
{
- smeshGUI->CreateAlgorithm("Hexa_3D","Hexaedral (i,j,k)");
+ smeshGUI->CreateAlgorithm("Hexa_3D","Hexahedron (i,j,k)");
+ break;
+ }
+ case 5021:
+ {
+ smeshGUI->CreateAlgorithm("NETGEN_3D","Tetrahedron (Netgen)");
break;
}
// Mesh_Reader* myReader = SMESHDriver::GetMeshReader(myExtension, myClass);
int myMeshId = (smeshGUI->myDocument)->NewMesh();
- Handle(SMDS_Mesh) myMesh = (smeshGUI->myDocument)->GetMesh(myMeshId);
+ SMDS_Mesh* myMesh = (smeshGUI->myDocument)->GetMesh(myMeshId);
myReader->SetFile(string(filename.latin1()));
myReader->SetMesh(myMesh);
QApplication::setOverrideCursor( Qt::waitCursor );
string myClass = string("SMESHDS_Document");
// Document_Reader* myReader = SMESHDriver::GetDocumentReader(myExtension, myClass);
- Handle(SMESHDS_Document) newDocument = new SMESHDS_Document(1);
+ SMESHDS_Document* newDocument = new SMESHDS_Document(1);
myReader->SetFile(string(filename.latin1()));
myReader->SetDocument(smeshGUI->myDocument);
QApplication::setOverrideCursor( Qt::waitCursor );
DisplayScalarBar( false );
-// mpv porting vtk 4.2.2
-// vtkScalars *scalars = vtkScalars::New();
- vtkIntArray *scalars = vtkIntArray::New();
+ vtkDoubleArray *scalars = vtkDoubleArray::New();
scalars->SetNumberOfComponents(1);
vtkDataSetMapper* meshMapper = 0;
return;
}
- bool ValidateScalars = false;
- if ( result ) {
+ vtkDataSet* aDataSet = MeshActor->DataSource;
+ typedef double (*TScalarFun)(vtkCell* theCell);
+ TScalarFun aScalarFun;
+ if(result){
QString type;
- switch (theCommandID)
- {
- case 6001: //Length Edges
- {
- type = tr( "SMESH_CONTROL_LENGTH_EDGES");
- meshMapper = (vtkDataSetMapper*)MeshActor->EdgeDevice->GetMapper();
- vtkUnstructuredGrid* grid = (vtkUnstructuredGrid*)meshMapper->GetInput();
- MESSAGE ( " init minimum length " << grid->GetNumberOfCells() )
- for (int i=0; i<grid->GetNumberOfCells(); i++ ) {
- vtkCell* cell = grid->GetCell(i);
- float len = SMESHGUI_ComputeScalarValue::LengthEdges(cell);
- if (len == 0) continue;
- else {
- ValidateScalars = true;
-// mpv porting vtk 4.2.2
-// scalars->InsertScalar(i,len);
- scalars->InsertTuple1(i,len);
- }
- }
- if (ValidateScalars && (MeshActor->getDisplayMode()!=0))
- ChangeRepresentation( MeshActor, 1 );// limitation; in Wireframe, colored edges are not visible
- break;
- }
- case 6011: // Area Elements
- {
- type = tr( "SMESH_CONTROL_AREA_ELEMENTS");
- for (int i=0; i< MeshActor->GetMapper()->GetInput()->GetNumberOfCells(); i++ ) {
- vtkCell* cell = MeshActor->GetMapper()->GetInput()->GetCell(i);
- float area = SMESHGUI_ComputeScalarValue::AreaElements(cell);
- if (area == 0) continue;
- else {
- ValidateScalars = true;
-// mpv porting vtk 4.2.2
-// scalars->InsertScalar(i,area);
- scalars->InsertTuple1(i,area);
- }
- }
- if (ValidateScalars && (MeshActor->getDisplayMode()!=1))
- ChangeRepresentation( MeshActor, 1 );
- break;
- }
- case 6012: // Taper
- {
- type = tr( "SMESH_CONTROL_TAPER_ELEMENTS");
- for (int i=0; i< MeshActor->DataSource->GetNumberOfCells(); i++ ) {
- vtkCell* cell = MeshActor->DataSource->GetCell(i);
- float taper = SMESHGUI_ComputeScalarValue::Taper(cell);
- if (taper == 0) continue;
- else {
- ValidateScalars = true;
-// mpv porting vtk 4.2.2
-// scalars->InsertScalar(i,taper);
- scalars->InsertTuple1(i,taper);
- }
- }
- break;
- }
- case 6013: // Aspect ratio
- {
- type = tr( "SMESH_CONTROL_ASPECTRATIO_ELEMENTS");
- for (int i=0; i<MeshActor->DataSource->GetNumberOfCells(); i++ ) {
- vtkCell* cell = MeshActor->DataSource->GetCell(i);
- float aspect = SMESHGUI_ComputeScalarValue::AspectRatio(cell);
- if (aspect == 0) continue;
- else {
- ValidateScalars = true;
-// mpv porting vtk 4.2.2
-// scalars->InsertScalar(i,aspect);
- scalars->InsertTuple1(i,aspect);
- }
- }
- if (ValidateScalars && (MeshActor->getDisplayMode()!=1))
- ChangeRepresentation( MeshActor, 1 );
- break;
- }
- case 6014: // Minimum angle
- {
- type = tr( "SMESH_CONTROL_MINIMUMANGLE_ELEMENTS");
- for (int i=0; i<MeshActor->DataSource->GetNumberOfCells(); i++ ) {
- vtkCell* cell = MeshActor->DataSource->GetCell(i);
- float angle = SMESHGUI_ComputeScalarValue::MinimumAngle(cell);
- if (angle == 0) continue;
- else {
- ValidateScalars = true;
-// mpv porting vtk 4.2.2
-// scalars->InsertScalar(i,angle);
- scalars->InsertTuple1(i,angle);
- }
- }
- if (ValidateScalars && (MeshActor->getDisplayMode()!=1))
- ChangeRepresentation( MeshActor, 1 );
- break;
- }
- case 6015: // Warp
- {
- type = tr( "SMESH_CONTROL_WARP_ELEMENTS");
- for (int i=0; i<MeshActor->DataSource->GetNumberOfCells(); i++ ) {
- vtkCell* cell = MeshActor->DataSource->GetCell(i);
- float Warp = SMESHGUI_ComputeScalarValue::Warp(cell);
- if (Warp == 0) continue;
- else {
- ValidateScalars = true;
-// mpv porting vtk 4.2.2
-// scalars->InsertScalar(i,Warp);
- scalars->InsertTuple1(i,Warp);
- }
- }
- break;
- }
- case 6016: // Skew
- {
- type = tr( "SMESH_CONTROL_SKEW_ELEMENTS");
- for (int i=0; i<MeshActor->DataSource->GetNumberOfCells(); i++ ) {
- vtkCell* cell = MeshActor->DataSource->GetCell(i);
- float angle = SMESHGUI_ComputeScalarValue::Skew(cell);
- if (angle == 0) continue;
- else {
- ValidateScalars = true;
-// mpv porting vtk 4.2.2
-// scalars->InsertScalar(i,angle);
- scalars->InsertTuple1(i,angle);
- }
- }
- break;
- }
- }
-
- if ( !ValidateScalars ) {
- QApplication::restoreOverrideCursor();
- return;
+ switch (theCommandID){
+ case 6001: {
+ type = tr( "SMESH_CONTROL_LENGTH_EDGES");
+ aDataSet = MeshActor->EdgeDevice->GetMapper()->GetInput();
+ aScalarFun = &(SMESHGUI_ComputeScalarValue::LengthEdges);
+ MESSAGE ( " init minimum length " << aDataSet->GetNumberOfCells() );
+ if(MeshActor->getDisplayMode() != 0)
+ ChangeRepresentation( MeshActor, 1);// limitation; in Wireframe, colored edges are not visible
+ break;
+ }
+ case 6011: {
+ type = tr( "SMESH_CONTROL_AREA_ELEMENTS");
+ aScalarFun = &(SMESHGUI_ComputeScalarValue::AreaElements);
+ if(MeshActor->getDisplayMode() != 1)
+ ChangeRepresentation( MeshActor, 1 );
+ break;
+ }
+ case 6012: {
+ type = tr( "SMESH_CONTROL_TAPER_ELEMENTS");
+ aScalarFun = &(SMESHGUI_ComputeScalarValue::Taper);
+ break;
+ }
+ case 6013: {
+ type = tr( "SMESH_CONTROL_ASPECTRATIO_ELEMENTS");
+ aScalarFun = &(SMESHGUI_ComputeScalarValue::AspectRatio);
+ if(MeshActor->getDisplayMode() != 1)
+ ChangeRepresentation( MeshActor, 1 );
+ break;
}
+ case 6014: {
+ type = tr( "SMESH_CONTROL_MINIMUMANGLE_ELEMENTS");
+ aScalarFun = &(SMESHGUI_ComputeScalarValue::MinimumAngle);
+ if(MeshActor->getDisplayMode() != 1)
+ ChangeRepresentation( MeshActor, 1 );
+ break;
+ }
+ case 6015: {
+ type = tr( "SMESH_CONTROL_WARP_ELEMENTS");
+ aScalarFun = &(SMESHGUI_ComputeScalarValue::Warp);
+ break;
+ }
+ case 6016: {
+ type = tr( "SMESH_CONTROL_SKEW_ELEMENTS");
+ aScalarFun = &(SMESHGUI_ComputeScalarValue::Skew);
+ break;
+ }}
+
+ for(int i = 0, iEnd = aDataSet->GetNumberOfCells(); i < iEnd; i++)
+ scalars->InsertTuple1(i,aScalarFun(aDataSet->GetCell(i)));
float range[2];
scalars->GetRange(range);
if (!meshMapper) meshMapper = (vtkDataSetMapper*) (MeshActor->getMapper());
meshMapper->SetScalarModeToUseCellData();
- meshMapper->GetInput()->GetCellData()->SetScalars(scalars);
+ MeshActor->DataSource->GetCellData()->SetScalars(scalars);
meshMapper->SetScalarRange( range );
meshMapper->ScalarVisibilityOn();
QString SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue");
QColor nodecolor(SCr.toInt(), SCg.toInt(), SCb.toInt());
if ( !nodecolor.isValid() )
- nodecolor = QColor(0.,1.,0.);
+// nodecolor = QColor(0.,1.,0.);
+ nodecolor = QColor(0,1,0);
node->GetProperty()->SetColor( float(nodecolor.red())/255.,
float(nodecolor.green())/255.,