-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 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.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "SMESHGUI_MeshEditPreview.h"
#include "SMESHGUI_VTKUtils.h"
-
-#include <SMESH_Actor.h>
-#include <SMESH_ActorUtils.h>
+#include "SMESH_Actor.h"
+#include "SMESH_ActorUtils.h"
// SALOME GUI includes
-#include <VTKViewer_CellLocationsArray.h>
+#include <SVTK_Renderer.h>
#include <SVTK_ViewWindow.h>
+#include <VTKViewer_CellLocationsArray.h>
// VTK includes
-#include <vtkPoints.h>
-#include <vtkIdList.h>
#include <vtkCellArray.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkUnstructuredGridWriter.h>
+#include <vtkCoordinate.h>
#include <vtkDataSetMapper.h>
+#include <vtkIdList.h>
+#include <vtkPoints.h>
#include <vtkProperty.h>
+#include <vtkRenderer.h>
+#include <vtkTextActor.h>
+#include <vtkTextMapper.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkUnstructuredGrid.h>
// Qt includes
#include <QColor>
aMapper->Delete();
myViewWindow->AddActor(myPreviewActor);
-
}
//================================================================================
{
myGrid->Delete();
+ for ( size_t iA = 0; iA < myLabelActors.size(); ++iA )
+ if ( myLabelActors[iA] )
+ {
+ myPreviewActor->GetRenderer()->RemoveActor( myLabelActors[iA] );
+ myLabelActors[iA]->Delete();
+ }
+
myViewWindow->RemoveActor(myPreviewActor);
myPreviewActor->Delete();
-
}
//================================================================================
{
switch( theType )
{
+ case SMDSAbs_Ball: return VTK_VERTEX;
case SMDSAbs_Node: return VTK_VERTEX;
- case SMDSAbs_Edge:
+ case SMDSAbs_Edge:
if( theNbNodes == 2 ) return VTK_LINE;
else if ( theNbNodes == 3 ) return VTK_QUADRATIC_EDGE;
else return VTK_EMPTY_CELL;
else if ( theNbNodes == 20 ) return VTK_QUADRATIC_HEXAHEDRON;
else if ( theNbNodes == 27 ) return VTK_TRIQUADRATIC_HEXAHEDRON;
else if ( theNbNodes == 15 ) return VTK_QUADRATIC_WEDGE;
+ else if ( theNbNodes == 18 ) return VTK_BIQUADRATIC_QUADRATIC_WEDGE;
else if ( theNbNodes == 13 ) return VTK_QUADRATIC_PYRAMID;//VTK_CONVEX_POINT_SET;
else return VTK_EMPTY_CELL;
*/
//================================================================================
-void SMESHGUI_MeshEditPreview::SetData (const SMESH::MeshPreviewStruct* previewData)
+void SMESHGUI_MeshEditPreview::SetData (const SMESH::MeshPreviewStruct& previewData)
{
// Create points
- const SMESH::nodes_array& aNodesXYZ = previewData->nodesXYZ;
+ const SMESH::nodes_array& aNodesXYZ = previewData.nodesXYZ;
vtkPoints* aPoints = vtkPoints::New();
aPoints->SetNumberOfPoints(aNodesXYZ.length());
- for ( int i = 0; i < aNodesXYZ.length(); i++ ) {
+ for ( size_t i = 0; i < aNodesXYZ.length(); i++ ) {
aPoints->SetPoint( i, aNodesXYZ[i].x, aNodesXYZ[i].y, aNodesXYZ[i].z );
}
myGrid->SetPoints(aPoints);
aPoints->Delete();
// Create cells
- const SMESH::long_array& anElemConnectivity = previewData->elementConnectivities;
- const SMESH::types_array& anElemTypes = previewData->elementTypes;
+ const SMESH::long_array& anElemConnectivity = previewData.elementConnectivities;
+ const SMESH::types_array& anElemTypes = previewData.elementTypes;
vtkIdType aCellsSize = anElemConnectivity.length() + anElemTypes.length();
vtkIdType aNbCells = anElemTypes.length();
vtkIdList *anIdList = vtkIdList::New();
int aNodePos = 0;
- for ( int i = 0; i < anElemTypes.length(); i++ ) {
+ for ( size_t i = 0; i < anElemTypes.length(); i++ ) {
const SMESH::ElementSubType& anElementSubType = anElemTypes[i];
SMDSAbs_ElementType aType = SMDSAbs_ElementType(anElementSubType.SMDS_ElementType);
vtkIdType aNbNodes = anElementSubType.nbNodesInElement;
aCellLocationsArray->SetNumberOfTuples( aNbCells );
aConnectivity->InitTraversal();
- for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
+ vtkIdType const *pts(nullptr);
+ for( vtkIdType idType = 0, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
myGrid->SetCells( aCellTypesArray, aCellLocationsArray, aConnectivity );
*/
//================================================================================
-void SMESHGUI_MeshEditPreview::SetArrowShapeAndNb( int nbArrows,
- double headLength,
- double headRadius,
- double start)
+void SMESHGUI_MeshEditPreview::SetArrowShapeAndNb( int nbArrows,
+ double headLength,
+ double headRadius,
+ double start,
+ const char* labels)
{
const int theNbPoints = 10; // in one arrow
myUnitArrowPnts.reserve( theNbPoints );
myGrid->InsertNextCell( VTK_LINE, 2, conn );
}
- myNbArrows = nbArrows;
+ myLabelActors.resize( nbArrows, ( vtkTextActor*) NULL );
+ char label[] = "X";
+ if ( labels )
+ for ( int iA = 0; iA < nbArrows; ++iA )
+ {
+ label[0] = labels[iA];
+ vtkTextMapper* text = vtkTextMapper::New();
+ text->SetInput( label );
+ vtkCoordinate* coord = vtkCoordinate::New();
+
+ myLabelActors[iA] = vtkTextActor::New();
+ //myLabelActors[iA]->SetMapper( text );
+ myLabelActors[iA]->SetInput( label );
+ myLabelActors[iA]->SetTextScaleModeToNone();
+ myLabelActors[iA]->PickableOff();
+ myLabelActors[iA]->GetPositionCoordinate()->SetReferenceCoordinate( coord );
+
+ text->Delete();
+ coord->Delete();
+
+ myPreviewActor->GetRenderer()->AddActor(myLabelActors[iA]);
+ }
}
//================================================================================
{
vtkPoints* aPoints = myGrid->GetPoints();
- for ( int iP = 0, iA = 0; iA < myNbArrows; ++iA )
+ for ( int iP = 0, iA = 0; iA < (int) myLabelActors.size(); ++iA )
{
gp_Trsf trsf;
trsf.SetTransformation( gp_Ax3( axes[iA].Location(), axes[iA].Direction() ), gp::XOY() );
p.Transform( trsf );
aPoints->SetPoint( iP, p.X(), p.Y(), p.Z() );
}
+ if ( myLabelActors[iA] )
+ if ( vtkCoordinate* aCoord =
+ myLabelActors[iA]->GetPositionCoordinate()->GetReferenceCoordinate() )
+ {
+ double p[3];
+ aPoints->GetPoint( iP-1, p );
+ aCoord->SetValue( p );
+ }
}
myGrid->Modified();
void SMESHGUI_MeshEditPreview::SetVisibility (bool theVisibility)
{
myPreviewActor->SetVisibility(theVisibility);
+ for ( size_t iA = 0; iA < myLabelActors.size(); ++iA )
+ if ( myLabelActors[iA] )
+ myLabelActors[iA]->SetVisibility(theVisibility);
SMESH::RepaintCurrentView();
}
{
return myGrid;
}
+
+//================================================================================
+/*!
+ * \brief Returns myViewWindow
+ */
+//================================================================================
+
+SVTK_ViewWindow* SMESHGUI_MeshEditPreview::GetViewWindow() const
+{
+ return myViewWindow;
+}