// Module : SMESH
#include "SMESH_ActorDef.h"
+
+#include "SMDS_UnstructuredGrid.hxx"
#include "SMESH_ActorUtils.h"
+#include "SMESH_CellLabelActor.h"
+#include "SMESH_ControlsDef.hxx"
#include "SMESH_DeviceActor.h"
#include "SMESH_NodeLabelActor.h"
-#include "SMESH_CellLabelActor.h"
#include "SMESH_ObjectDef.h"
-#include "SMESH_ControlsDef.hxx"
-#include "SMDS_UnstructuredGrid.hxx"
-#include "SMESH_ScalarBarActor.h"
-#include "VTKViewer_ExtractUnstructuredGrid.h"
-#include "VTKViewer_FramedTextActor.h"
-#include "SALOME_InteractiveObject.hxx"
#include "SMESH_SVTKActor.h"
-
-#include "SUIT_Session.h"
-#include "SUIT_ResourceMgr.h"
+#include "SMESH_ScalarBarActor.h"
#include <Qtx.h>
+#include <SALOME_InteractiveObject.hxx>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <VTKViewer_ExtractUnstructuredGrid.h>
+#include <VTKViewer_FramedTextActor.h>
#ifndef DISABLE_PLOT2DVIEWER
#include <SPlot2d_Histogram.h>
SMESH_ActorDef::SMESH_ActorDef()
{
if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
+
+ SALOME_Actor::SetVisibility(false); // avoid update of pipelines
+
myBaseActor = SMESH_DeviceActor::New();
myTimeStamp = vtkTimeStamp::New();
void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
{
+ if ( !mySelector || !mySelector->IsSelectionEnabled() )
+ {
+ myBaseActor->SetUnstructuredGrid( NULL );
+ myHighlitableActor->SetUnstructuredGrid( NULL );
+ // theRenderer->AddActor(this);
+ // cout << "SMESH_ActorDef " << this << endl;
+ }
theRenderer->AddActor(myBaseActor);
theRenderer->AddActor(myNodeExtActor);
theRenderer->AddActor(my1DExtActor);
double* SMESH_ActorDef::GetBounds()
{
- return myNodeActor->GetBounds();
+ if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
+ return myNodeActor->GetBounds();
+ return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
}
myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
myEntityMode = theMode;
- VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
- aFilter = myBaseActor->GetExtractUnstructuredGrid();
- aFilter->ClearRegisteredCellsWithType();
- aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
+ VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
+ aFilter->ClearRegisteredCellsWithType();
VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
aHightFilter->ClearRegisteredCellsWithType();
- aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
- if (myEntityMode & e0DElements) {
- if (MYDEBUG) MESSAGE("0D ELEMENTS");
- aFilter->RegisterCellsWithType(VTK_VERTEX);
- aHightFilter->RegisterCellsWithType(VTK_VERTEX);
+ bool isPassAll =
+ (( myEntityMode & e0DElements || myVisualObj->GetNbEntities(SMDSAbs_0DElement) == 0 ) &&
+ ( myEntityMode & eBallElem || myVisualObj->GetNbEntities(SMDSAbs_Ball) == 0 ) &&
+ ( myEntityMode & eEdges || myVisualObj->GetNbEntities(SMDSAbs_Edge) == 0 ) &&
+ ( myEntityMode & eFaces || myVisualObj->GetNbEntities(SMDSAbs_Face) == 0 ) &&
+ ( myEntityMode & eVolumes || myVisualObj->GetNbEntities(SMDSAbs_Volume) == 0 ));
+ if ( isPassAll && myEntityMode )
+ {
+ aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
+ aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
}
+ else
+ {
+ aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
+ aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
- if (myEntityMode & eBallElem) {
- aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
- }
+ if (myEntityMode & e0DElements) {
+ aFilter->RegisterCellsWithType(VTK_VERTEX);
+ aHightFilter->RegisterCellsWithType(VTK_VERTEX);
+ }
- if (myEntityMode & eEdges) {
- if (MYDEBUG) MESSAGE("EDGES");
- aFilter->RegisterCellsWithType(VTK_LINE);
- aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
+ if (myEntityMode & eBallElem) {
+ aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
+ }
- aHightFilter->RegisterCellsWithType(VTK_LINE);
- aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
- }
+ if (myEntityMode & eEdges) {
+ aFilter->RegisterCellsWithType(VTK_LINE);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
- if (myEntityMode & eFaces) {
- if (MYDEBUG) MESSAGE("FACES");
- aFilter->RegisterCellsWithType(VTK_TRIANGLE);
- aFilter->RegisterCellsWithType(VTK_QUAD);
- aFilter->RegisterCellsWithType(VTK_POLYGON);
- aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
- aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
- aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
- aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
- aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
-
- aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
- aHightFilter->RegisterCellsWithType(VTK_QUAD);
- aHightFilter->RegisterCellsWithType(VTK_POLYGON);
- aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
- aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
- aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
- aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
- aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
- }
+ aHightFilter->RegisterCellsWithType(VTK_LINE);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
+ }
- if (myEntityMode & eVolumes) {
- if (MYDEBUG) MESSAGE("VOLUMES");
- aFilter->RegisterCellsWithType(VTK_TETRA);
- aFilter->RegisterCellsWithType(VTK_VOXEL);
- aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
- aFilter->RegisterCellsWithType(VTK_WEDGE);
- aFilter->RegisterCellsWithType(VTK_PYRAMID);
- aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
- aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
- aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
- aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
- aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
- aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
- aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
- aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
-
- aHightFilter->RegisterCellsWithType(VTK_TETRA);
- aHightFilter->RegisterCellsWithType(VTK_VOXEL);
- aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
- aHightFilter->RegisterCellsWithType(VTK_WEDGE);
- aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
- aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
- aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
- aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
- aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
- aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
- aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
- aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
- aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
+ if (myEntityMode & eFaces) {
+ aFilter->RegisterCellsWithType(VTK_TRIANGLE);
+ aFilter->RegisterCellsWithType(VTK_QUAD);
+ aFilter->RegisterCellsWithType(VTK_POLYGON);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
+ aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
+ aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
+
+ aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
+ aHightFilter->RegisterCellsWithType(VTK_QUAD);
+ aHightFilter->RegisterCellsWithType(VTK_POLYGON);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
+ aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
+ aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
+ }
+
+ if (myEntityMode & eVolumes) {
+ aFilter->RegisterCellsWithType(VTK_TETRA);
+ aFilter->RegisterCellsWithType(VTK_VOXEL);
+ aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
+ aFilter->RegisterCellsWithType(VTK_WEDGE);
+ aFilter->RegisterCellsWithType(VTK_PYRAMID);
+ aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
+ aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
+ aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
+ aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
+ aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
+
+ aHightFilter->RegisterCellsWithType(VTK_TETRA);
+ aHightFilter->RegisterCellsWithType(VTK_VOXEL);
+ aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
+ aHightFilter->RegisterCellsWithType(VTK_WEDGE);
+ aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
+ aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
+ aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
+ aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
+ aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
+ aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
+ }
}
- aFilter->Update();
+ if ( GetVisibility() )
+ aFilter->Update();
if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
SetVisibility(GetVisibility(),false);
}
void SMESH_ActorDef::SetRepresentation (int theMode)
{
- int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
- int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
+ int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
+ int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
- int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
- int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
+ int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
+ int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
if (theMode < 0) {
myRepresentation = eSurface;
case SMESH_DeviceActor::eSurface:
case SMESH_DeviceActor::eWireframe:
{
+ // if ( !mySelector || !mySelector->IsSelectionEnabled() )
+ // myHighlitableActor->SetUnstructuredGrid( NULL );
+ // else if ( !myHighlitableActor->myExtractUnstructuredGrid->GetInput() )
+ // myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+
if(myIsHighlighted) {
myHighlitableActor->SetProperty(myHighlightProp);
}else if(myIsPreselected){
}
}
+void SMESH_ActorDef::EnableSelection( bool enable )
+{
+ // selection in the Viewer enabled/disabled
+ if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
+ {
+ myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+ myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+ myBaseActor->myExtractUnstructuredGrid->Update();
+ myHighlitableActor->myExtractUnstructuredGrid->Update();
+ }
+ if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
+ {
+ myBaseActor->SetUnstructuredGrid( NULL );
+ myHighlitableActor->SetUnstructuredGrid( NULL );
+ myBaseActor->myExtractUnstructuredGrid->Update();
+ myHighlitableActor->myExtractUnstructuredGrid->Update();
+ }
+}
void SMESH_ActorDef::highlight(bool theHighlight)
{
myHighlitableActor->SetPlaneCollection( myPlaneCollection );
myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+ if ( !mySelector || !mySelector->IsSelectionEnabled() )
+ {
+ myBaseActor->SetUnstructuredGrid( NULL );
+ myHighlitableActor->SetUnstructuredGrid( NULL );
+ }
my1DActor->SetPlaneCollection( myPlaneCollection );
my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
virtual void AddToRender(vtkRenderer* theRenderer);
virtual void RemoveFromRender(vtkRenderer* theRenderer);
+ virtual void EnableSelection( bool enable );
virtual bool hasHighlight() { return true; }
virtual void highlight(bool theHighlight);
virtual void SetPreSelected(bool thePreselect = false);
SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
}
-
void
SMESH_DeviceActor
::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
SMESH_DeviceActor
::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
{
- if(theGrid){
- //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
- myIsShrinkable = true;
+ myExtractUnstructuredGrid->SetInputData(theGrid);
- myExtractUnstructuredGrid->SetInputData(theGrid);
+ if ( theGrid )
+ {
+ myIsShrinkable = true;
myMergeFilter->SetGeometryConnection(myExtractUnstructuredGrid->GetOutputPort());
-
+
//Pass diameters of the balls
if(myMapper->GetBallEnabled()) {
myMergeFilter->SetScalarsConnection(myExtractUnstructuredGrid->GetOutputPort());
int anId = 0;
SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
myPassFilter[ anId + 1]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
-
+
anId++; // 1
myTransformFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
anId++; // 4
- myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() );
+ myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() );
myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
anId++; // 5
myMapper->SetClippingPlanes( myPlaneCollection );
vtkLODActor::SetMapper( myMapper );
- Modified();
}
+ Modified();
}
void
return myExtractUnstructuredGrid;
}
+#include "SMDS_Mesh.hxx"
vtkUnstructuredGrid*
SMESH_DeviceActor
-unsigned long int
+unsigned long int
SMESH_DeviceActor
::GetMTime()
{
+ // cout << this->myExtractUnstructuredGrid
+ // << " " << this->Superclass::GetMTime()
+ // << " " << myExtractGeometry->GetMTime()
+ // << " " << myExtractUnstructuredGrid->GetMTime()
+ // << " " << myMergeFilter->GetMTime()
+ // << " " << myGeomFilter->GetMTime()
+ // << " " << myTransformFilter->GetMTime()
+ // << " " << myFaceOrientationFilter->GetMTime() << endl;
+
unsigned long mTime = this->Superclass::GetMTime();
mTime = max(mTime,myExtractGeometry->GetMTime());
mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
::UpdateFaceOrientation()
{
bool aShowFaceOrientation = myIsFacesOriented;
- aShowFaceOrientation &= GetVisibility();
+ aShowFaceOrientation &= vtkLODActor::GetVisibility(); //GetVisibility(); -- avoid calling GetUnstructuredGrid()
aShowFaceOrientation &= myRepresentation == eSurface;
myFaceOrientation->SetVisibility(aShowFaceOrientation);
}
SMESH_DeviceActor
::SetVisibility(int theMode)
{
- if(!myExtractUnstructuredGrid->GetInput() ||
- GetUnstructuredGrid()->GetNumberOfCells())
+ if(( theMode ) &&
+ ( !myExtractUnstructuredGrid->GetInput() ||
+ GetUnstructuredGrid()->GetNumberOfCells()))
{
vtkLODActor::SetVisibility(theMode);
}else{
SMESH_DeviceActor
::GetVisibility()
{
- if(!GetUnstructuredGrid()->GetNumberOfCells()){
+ int visibi = vtkLODActor::GetVisibility();
+ if(visibi && !GetUnstructuredGrid()->GetNumberOfCells()){
vtkLODActor::SetVisibility(false);
+ visibi = 0;
}
- return vtkLODActor::GetVisibility();
+ return visibi;
}
{
vtkDataSet* aDataSet = myMergeFilter->GetOutput();
vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
- double* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
+ double* aCoord = (anID >=0 && anID < aDataSet->GetNumberOfPoints()) ? aDataSet->GetPoint(anID) : NULL;
if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
return aCoord;
}
points->SetNumberOfPoints(0);
myEmptyGrid->SetPoints( points );
points->Delete();
- myEmptyGrid->BuildLinks();
+ //myEmptyGrid->BuildLinks();
}
myGrid->ShallowCopy(myEmptyGrid);
return true;
myBallGrid->Initialize();
myBallGrid->Allocate();
- vtkDataSet *aSourceDataSet = theMapActor->GetInput();
- SVTK::CopyPoints( GetSource(), aSourceDataSet );
- SVTK::CopyPoints( myBallGrid, aSourceDataSet );
- SVTK::CopyPoints( my0DGrid, aSourceDataSet );
-
+ vtkUnstructuredGrid * aSourceGrid = (vtkUnstructuredGrid *)theMapActor->GetInput();
+ GetSource()->SetPoints( aSourceGrid->GetPoints() );
+ myBallGrid->SetPoints( aSourceGrid->GetPoints() );
+ my0DGrid->SetPoints( aSourceGrid->GetPoints() );
int aNbOfParts = theMapIndex.Extent();
//Copy deamaters of the balls
if(myVisualObj) {
outputCD = myBallGrid->GetCellData();
- cd = aSourceDataSet->GetCellData();
+ cd = aSourceGrid->GetCellData();
}
outputCD->CopyAllocate(cd,aNbOfParts,aNbOfParts/2);
for(int ind = 1; ind <= aNbOfParts; ind++){
points->SetNumberOfPoints(0 /*SMDS_Mesh::chunkSize*/);
myGrid->SetPoints( points );
points->Delete();
- myGrid->BuildLinks();
+ //myGrid->BuildLinks();
this->Modified();
// initialize static maps in SMDS_MeshCell, to be thread-safe
points->SetNumberOfPoints(0 /*SMDS_Mesh::chunkSize*/);
myGrid->SetPoints( points );
points->Delete();
- myGrid->BuildLinks();
+ myGrid->DeleteLinks();
}
///////////////////////////////////////////////////////////////////////////////
ficcon << endl;
}
ficcon << "-------------------------------- connectivity " << nbPoints << endl;
- vtkCellLinks *links = myGrid->GetCellLinks();
+ vtkCellLinks *links = myGrid->GetLinks();
for (int i=0; i<nbPoints; i++)
{
int ncells = links->GetNcells(i);
for (int j=0; j<ncells; j++)
{
ficcon << " " << cells[j];
- }
- ficcon << endl;
+ }
+ ficcon << endl;
}
ficcon.close();
void SMDS_Mesh::compactMesh()
{
- MESSAGE("SMDS_Mesh::compactMesh do nothing!");
+ this->myCompactTime = this->myModifTime;
}
int SMDS_Mesh::fromVtkToSmds(int vtkid)
bool SMDS_Mesh::isCompacted()
{
- if (this->myModifTime > this->myCompactTime)
- {
- this->myCompactTime = this->myModifTime;
- return false;
- }
- return true;
+ return this->myCompactTime == this->myModifTime;
}
void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z)
{
SMDS_MeshElement::init(id, meshId, shapeId);
- myVtkID = id -1;
+ myVtkID = id - 1;
assert(myVtkID >= 0);
- //MESSAGE("Node " << myID << " " << myVtkID << " (" << x << ", " << y << ", " << z << ")");
- SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId];
- SMDS_UnstructuredGrid * grid = mesh->getGrid();
+ SMDS_UnstructuredGrid * grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkPoints *points = grid->GetPoints();
points->InsertPoint(myVtkID, x, y, z);
- SMDS_CellLinks *cellLinks = dynamic_cast<SMDS_CellLinks*>(grid->GetCellLinks());
- assert(cellLinks);
- cellLinks->ResizeForPoint( myVtkID );
+ grid->GetLinks()->ResizeForPoint( myVtkID );
}
SMDS_MeshNode::~SMDS_MeshNode()
//MESSAGE("RemoveInverseElement " << myID << " " << parent->GetID());
const SMDS_MeshCell* cell = dynamic_cast<const SMDS_MeshCell*>(parent);
MYASSERT(cell);
- SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myVtkID, cell->getVtkId());
+ if ( SMDS_Mesh::_meshList[myMeshId]->getGrid()->HasLinks() )
+ SMDS_Mesh::_meshList[myMeshId]->getGrid()->RemoveReferenceToCell(myVtkID, cell->getVtkId());
}
//=======================================================================
SMDS_ElemIteratorPtr SMDS_MeshNode::GetInverseElementIterator(SMDSAbs_ElementType type) const
{
- vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
+ vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
return SMDS_MeshElement::elementsIterator(SMDSAbs_Node);
else
{
- vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
+ vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
}
const SMDS_MeshCell *cell = dynamic_cast<const SMDS_MeshCell*> (ME);
assert(cell);
SMDS_UnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
- vtkCellLinks *Links = grid->GetCellLinks();
+ vtkCellLinks *Links = grid->GetLinks();
Links->ResizeCellList(myVtkID, 1);
Links->AddCellReference(cell->getVtkId(), myVtkID);
}
bool SMDS_MeshNode::emptyInverseElements()
{
- vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
+ vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
return (l.ncells == 0);
}
int SMDS_MeshNode::NbInverseElements(SMDSAbs_ElementType type) const
{
- vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetCellLinks()->GetLink(myVtkID);
+ vtkCellLinks::Link l = SMDS_Mesh::_meshList[myMeshId]->getGrid()->GetLinks()->GetLink(myVtkID);
if ( type == SMDSAbs_All )
return l.ncells;
}
}
+void SMDS_CellLinks::BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity, vtkUnsignedCharArray* types)
+{
+ // build links taking into account removed cells
+
+ vtkIdType numPts = data->GetNumberOfPoints();
+ vtkIdType j, cellId = 0;
+ unsigned short *linkLoc;
+ vtkIdType npts=0;
+ vtkIdType *pts=0;
+ vtkIdType loc = Connectivity->GetTraversalLocation();
+
+ // traverse data to determine number of uses of each point
+ cellId = 0;
+ for (Connectivity->InitTraversal();
+ Connectivity->GetNextCell(npts,pts); cellId++)
+ {
+ if ( types->GetValue( cellId ) != VTK_EMPTY_CELL )
+ for (j=0; j < npts; j++)
+ {
+ this->IncrementLinkCount(pts[j]);
+ }
+ }
+
+ // now allocate storage for the links
+ this->AllocateLinks(numPts);
+ this->MaxId = numPts - 1;
+
+ // fill out lists with references to cells
+ linkLoc = new unsigned short[numPts];
+ memset(linkLoc, 0, numPts*sizeof(unsigned short));
+
+ cellId = 0;
+ for (Connectivity->InitTraversal();
+ Connectivity->GetNextCell(npts,pts); cellId++)
+ {
+ if ( types->GetValue( cellId ) != VTK_EMPTY_CELL )
+ for (j=0; j < npts; j++)
+ {
+ this->InsertCellReference(pts[j], (linkLoc[pts[j]])++, cellId);
+ }
+ }
+ delete [] linkLoc;
+ Connectivity->SetTraversalLocation(loc);
+}
+
SMDS_CellLinks::SMDS_CellLinks() :
vtkCellLinks()
{
//MESSAGE("------------------------- compactGrid " << newNodeSize << " " << newCellSize);//CHRONO(1);
int alreadyCopied = 0;
+ this->DeleteLinks();
+
// --- if newNodeSize, create a new compacted vtkPoints
vtkPoints *newPoints = vtkPoints::New();
int oldCellSize = this->Types->GetNumberOfTuples();
+ if ( oldCellSize == newCellSize )
+ {
+ for ( int i = 0; i < oldCellSize; ++i )
+ idCellsOldToNew[i] = i;
+ return;
+ }
vtkCellArray *newConnectivity = vtkCellArray::New();
newConnectivity->Initialize();
int oldCellDataSize = this->Connectivity->GetData()->GetSize();
newTypes->Delete();
newLocations->Delete();
newConnectivity->Delete();
- this->BuildLinks();
}
void SMDS_UnstructuredGrid::copyNodes(vtkPoints * newPoints,
{
// Remove the old links if they are already built
if (this->Links)
- {
+ {
this->Links->UnRegister(this);
- }
+ }
- this->Links = SMDS_CellLinks::New();
+ SMDS_CellLinks* links;
+ this->Links = links = SMDS_CellLinks::New();
this->Links->Allocate(this->GetNumberOfPoints());
this->Links->Register(this);
- this->Links->BuildLinks(this, this->Connectivity);
+ links->BuildLinks(this, this->Connectivity,this->GetCellTypesArray() );
this->Links->Delete();
}
+void SMDS_UnstructuredGrid::DeleteLinks()
+{
+ // Remove the old links if they are already built
+ if (this->Links)
+ {
+ this->Links->UnRegister(this);
+ this->Links = NULL;
+ }
+}
+SMDS_CellLinks* SMDS_UnstructuredGrid::GetLinks()
+{
+ if ( !this->Links )
+ BuildLinks();
+ return static_cast< SMDS_CellLinks* >( this->Links );
+}
+
/*! Create a volume (prism or hexahedron) by duplication of a face.
* Designed for use in creation of flat elements separating volume domains.
* A face separating two domains is shared by two volume cells.
{
public:
void ResizeForPoint(vtkIdType vtkID);
+ void BuildLinks(vtkDataSet *data, vtkCellArray *Connectivity, vtkUnsignedCharArray* types);
static SMDS_CellLinks* New();
protected:
SMDS_CellLinks();
void GetNodeIds(std::set<int>& nodeSet, int downId, unsigned char downType);
void ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds);
int getOrderedNodesOfFace(int vtkVolId, int& dim, std::vector<vtkIdType>& orderedNodes);
- void BuildLinks();
SMDS_MeshCell* extrudeVolumeFromFace(int vtkVolId, int domain1, int domain2,
std::set<int>& originalNodes,
std::map<int, std::map<int, int> >& nodeDomains,
std::map<int, std::map<long,int> >& nodeQuadDomains);
- vtkCellLinks* GetLinks()
- {
- return Links;
- }
+ void BuildLinks();
+ void DeleteLinks();
+ SMDS_CellLinks* GetLinks();
+ bool HasLinks() const { return this->Links; }
+
SMDS_Downward* getDownArray(unsigned char vtkType)
{
return _downArray[vtkType];
bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
- const bool aShapeOnly /*=false*/,
- const bool anUpward /*=false*/,
+ const int aFlags /*= COMPACT_MESH*/,
const ::MeshDimension aDim /*=::MeshDim_3D*/,
TSetOfInt* aShapesId /*=0*/)
{
MEMOSTAT;
+ const bool aShapeOnly = aFlags & SHAPE_ONLY;
+ const bool anUpward = aFlags & UPWARD;
+ const bool aCompactMesh = aFlags & COMPACT_MESH;
+
bool ret = true;
SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
SMESH_subMeshIteratorPtr smIt;
// Fix of Issue 22150. Due to !BLSURF->OnlyUnaryInput(), BLSURF computes edges
- // that must be computed by Projection 1D-2D when Projection asks to compute
+ // that must be computed by Projection 1D-2D while the Projection asks to compute
// one face only.
SMESH_subMesh::compute_event computeEvent =
aShapeOnly ? SMESH_subMesh::COMPUTE_SUBMESH : SMESH_subMesh::COMPUTE;
SMESH_Hypothesis::Hypothesis_Status status;
if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
// mesh a lower smToCompute starting from vertices
- Compute( aMesh, aSubShape, true, /*anUpward=*/true, aDim, aShapesId );
+ Compute( aMesh, aSubShape, aFlags | SHAPE_ONLY_UPWARD, aDim, aShapesId );
// Compute( aMesh, aSubShape, aShapeOnly, /*anUpward=*/true, aDim, aShapesId );
}
}
// -----------------------------------------------
// mesh the rest sub-shapes starting from vertices
// -----------------------------------------------
- ret = Compute( aMesh, aShape, aShapeOnly, /*anUpward=*/true, aDim, aShapesId );
+ ret = Compute( aMesh, aShape, aFlags | UPWARD, aDim, aShapesId );
}
MEMOSTAT;
- SMESHDS_Mesh *myMesh = aMesh.GetMeshDS();
- //MESSAGE("*** compactMesh after compute");
- myMesh->compactMesh();
+ if ( aCompactMesh )
+ aMesh.GetMeshDS()->compactMesh();
// fix quadratic mesh by bending iternal links near concave boundary
- if ( aShape.IsSame( aMesh.GetShapeToMesh() ) &&
+ if ( aCompactMesh && // a final compute
+ aShape.IsSame( aMesh.GetShapeToMesh() ) &&
!aShapesId && // not preview
ret ) // everything is OK
{
SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
throw(SALOME_Exception);
+ enum ComputeFlags
+ {
+ SHAPE_ONLY = 1, // to ignore algo->OnlyUnaryInput() feature and to compute a given shape only.
+ UPWARD = 2, // to compute from vertices up to more complex shape (internal usage)
+ COMPACT_MESH = 4, // to compact the mesh at the end
+ SHAPE_ONLY_UPWARD = 3 // SHAPE_ONLY | UPWARD
+ };
/*!
* \brief Computes aMesh on aShape
- * \param aShapeOnly - if true, algo->OnlyUnaryInput() feature is ignored and
- * only \a aShape is computed.
- * \param anUpward - compute from vertices up to more complex shape (internal usage)
- * \param aDim - upper level dimension of the mesh computation
+ * \param aMesh - the mesh.
+ * \param aShape - the shape.
+ * \param aFlags - ComputeFlags. By default compute the whole mesh and compact at the end.
+ * \param aDim - upper level dimension of the mesh computation (for preview)
* \param aShapesId - list of shapes with computed mesh entities (elements or nodes)
- * \retval bool - true if none submesh failed to compute
+ * \retval bool - true if none sub-mesh failed to compute
*/
bool Compute(::SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
- const bool aShapeOnly=false,
- const bool anUpward=false,
+ const int aFlags = COMPACT_MESH,
const ::MeshDimension aDim=::MeshDim_3D,
TSetOfInt* aShapesId=0);
}
meshDS->CleanDownWardConnectivity(); // Mesh has been modified, downward connectivity is no more usable, free memory
- grid->BuildLinks();
+ grid->DeleteLinks();
CHRONOSTOP(50);
counters::stats();
void SMESHDS_Mesh::compactMesh()
{
+ if ( isCompacted() )
+ return;
+ SMDS_Mesh::compactMesh();
+
int newNodeSize = 0;
int nbNodes = myNodes.size();
int nbVtkNodes = myGrid->GetNumberOfPoints();
- //MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
int nbNodeTemp = nbVtkNodes;
if (nbNodes > nbVtkNodes)
nbNodeTemp = nbNodes;
}
}
bool areNodesModified = (newNodeSize < nbVtkNodes);
- //MESSAGE("------------------------- compactMesh Nodes Modified: " << areNodesModified);
areNodesModified = true;
int newCellSize = 0;
int nbCells = myCells.size();
int nbVtkCells = myGrid->GetNumberOfCells();
- //MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
int nbCellTemp = nbVtkCells;
if (nbCells > nbVtkCells)
nbCellTemp = nbCells;
{
if (myCells[i])
{
- // //idCellsOldToNew[i] = myCellIdVtkToSmds[i]; // valid vtk indexes are > = 0
- // int vtkid = myCells[i]->getVtkId();
- // idCellsOldToNew[vtkid] = i; // old vtkId --> old smdsId (not used in input)
newCellSize++;
}
}
if (areNodesModified)
{
- //MESSAGE("-------------- modify myNodes");
SetOfNodes newNodes;
newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n
int newSmdsId = 0;
newSmdsId++; // SMDS id start to 1
int oldVtkId = myNodes[i]->getVtkId();
int newVtkId = idNodesOldToNew[oldVtkId];
- //MESSAGE("myNodes["<< i << "] vtkId " << oldVtkId << " --> " << newVtkId);
myNodes[i]->setVtkId(newVtkId);
myNodes[i]->setId(newSmdsId);
newNodes[newSmdsId] = myNodes[i];
- //MESSAGE("myNodes["<< i << "] --> newNodes[" << newSmdsId << "]");
}
}
myNodes.swap(newNodes);
this->myNodeIDFactory->emptyPool(newSmdsId); // newSmdsId = number of nodes
- //MESSAGE("myNodes.size " << myNodes.size());
}
// --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells
int newVtkId = idCellsOldToNew[oldVtkId];
if (newVtkId > maxVtkId)
maxVtkId = newVtkId;
- //MESSAGE("myCells["<< oldSmdsId << "] vtkId " << oldVtkId << " --> " << newVtkId);
myCells[oldSmdsId]->setVtkId(newVtkId);
}
}
- // MESSAGE("myCells.size()=" << myCells.size()
- // << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size()
- // << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() );
SetOfCells newCells;
- //vector<int> newSmdsToVtk;
vector<int> newVtkToSmds;
assert(maxVtkId < newCellSize);
newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n
- //newSmdsToVtk.resize(newCellSize+1, -1);
newVtkToSmds.resize(newCellSize+1, -1);
int myCellsSize = myCells.size();
assert(newSmdsId <= newCellSize);
newCells[newSmdsId] = myCells[i];
newCells[newSmdsId]->setId(newSmdsId);
- //MESSAGE("myCells["<< i << "] --> newCells[" << newSmdsId << "]");
int idvtk = myCells[i]->getVtkId();
- //newSmdsToVtk[newSmdsId] = idvtk;
assert(idvtk < newCellSize);
newVtkToSmds[idvtk] = newSmdsId;
}
}
myCells.swap(newCells);
- //myCellIdSmdsToVtk.swap(newSmdsToVtk);
myCellIdVtkToSmds.swap(newVtkToSmds);
- //MESSAGE("myCells.size()="<< myCells.size()<<" myCellIdVtkToSmds.size()="<<myCellIdVtkToSmds.size() );
this->myElementIDFactory->emptyPool(newSmdsId);
this->myScript->SetModified(true); // notify GUI client for buildPrs when update
aMesh = aSubMesh->GetFather();
_PTR(SObject) meshSO = SMESH::FindSObject( aMesh );
SMESH::ModifiedMesh( meshSO, false, aMesh->NbNodes()==0);
- SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() );
- if( actor ) {
- actor->Update();
- }
+ SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() );
+ if( actor ) {
+ actor->Update();
+ }
}
}
SMESHGUI::GetSMESHGUI()->updateObjBrowser( true, 0 );
*/
void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO )
{
+ if ( !IO.IsNull() )
+ myIO = IO;
+
SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
- if ( !CORBA::is_nil( obj ) ) {
+ if ( !CORBA::is_nil( obj ) )
+ {
myAddInfo->showInfo( obj ); // nb of nodes in a group can be computed by myAddInfo,
myBaseInfo->showInfo( obj ); // and it will be used by myBaseInfo (IPAL52871)
- myCtrlInfo->showInfo( obj );
+ if ( myTabWidget->currentIndex() == CtrlInfo )
+ myCtrlInfo->showInfo( obj );
- myActor = SMESH::FindActorByEntry( IO->getEntry() );
- SVTK_Selector* selector = SMESH::GetSelector();
- QString ID;
- int nb = 0;
- if ( myActor && selector ) {
- nb = myMode->checkedId() == NodeMode ?
- SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
- SMESH::GetNameOfSelectedNodes( selector, IO, ID );
- }
- myElemInfo->setSource( myActor ) ;
- if ( nb > 0 ) {
- myID->setText( ID.trimmed() );
- QSet<long> ids;
- QStringList idTxt = ID.split( " ", QString::SkipEmptyParts );
- foreach ( ID, idTxt )
- ids << ID.trimmed().toLong();
- myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
- }
- else {
- myID->clear();
- myElemInfo->clear();
+ {
+ myActor = SMESH::FindActorByEntry( IO->getEntry() );
+ SVTK_Selector* selector = SMESH::GetSelector();
+ QString ID;
+ int nb = 0;
+ if ( myActor && selector ) {
+ nb = myMode->checkedId() == NodeMode ?
+ SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
+ SMESH::GetNameOfSelectedNodes( selector, IO, ID );
+ }
+ myElemInfo->setSource( myActor ) ;
+ if ( nb > 0 ) {
+ myID->setText( ID.trimmed() );
+ QSet<long> ids;
+ QStringList idTxt = ID.split( " ", QString::SkipEmptyParts );
+ foreach ( ID, idTxt )
+ ids << ID.trimmed().toLong();
+ myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
+ }
+ else {
+ myID->clear();
+ myElemInfo->clear();
+ }
}
}
}
Handle(SALOME_InteractiveObject) IO = selected.First();
showInfo( IO );
}
-// else {
-// myBaseInfo->clear();
-// myElemInfo->clear();
-// myAddInfo->clear();
-// }
+ else {
+ showInfo( myIO );
+ }
}
/*!
SMESHGUI_AddInfo* myAddInfo;
SMESHGUI_CtrlInfo* myCtrlInfo;
SMESH_Actor* myActor;
+ Handle(SALOME_InteractiveObject) myIO;
};
class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
TSetOfInt shapeIds;
::MeshDimension aDim = (MeshDimension)theDimension;
- if ( myGen.Compute( myLocMesh, myLocShape, false, false, aDim, &shapeIds ) )
+ if ( myGen.Compute( myLocMesh, myLocShape, ::SMESH_Gen::COMPACT_MESH, aDim, &shapeIds ) )
{
int nbShapeId = shapeIds.size();
theShapesId.length( nbShapeId );
}
if ( !myIsPreviewMode ) {
- aPythonDump << "(" << aGroups << ", error) = "
- << this << ".ExtrusionAlongPathObjects( "
+ if ( aGroups->length() > 0 ) aPythonDump << "(" << aGroups << ", error) = ";
+ else aPythonDump << "(_noGroups, error) = ";
+ aPythonDump << this << ".ExtrusionAlongPathObjects( "
<< theNodes << ", "
<< theEdges << ", "
<< theFaces << ", "
tmpMesh.ShapeToMesh( theEdges[i] );
try {
if ( !mesh->GetGen() ) continue; // tmp mesh
- mesh->GetGen()->Compute( tmpMesh, theEdges[i], true, true ); // make nodes on VERTEXes
+ mesh->GetGen()->Compute( tmpMesh, theEdges[i], SMESH_Gen::SHAPE_ONLY_UPWARD ); // make nodes on VERTEXes
if ( !algo->Compute( tmpMesh, theEdges[i] ))
continue;
}
TmpMesh tmpMesh;
tmpMesh.ShapeToMesh( branchEdge );
try {
- mesh->GetGen()->Compute( tmpMesh, branchEdge, true, true ); // make nodes on VERTEXes
+ mesh->GetGen()->Compute( tmpMesh, branchEdge, SMESH_Gen::SHAPE_ONLY_UPWARD ); // make nodes on VERTEXes
if ( !algo->Compute( tmpMesh, branchEdge ))
return false;
}
{
if ( !theHasRadialHyp )
// use global hyps
- theHelper.GetGen()->Compute( *theHelper.GetMesh(), theShortEdges[i], true, true );
+ theHelper.GetGen()->Compute( *theHelper.GetMesh(), theShortEdges[i],
+ SMESH_Gen::SHAPE_ONLY_UPWARD );
SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh(theShortEdges[i] );
if ( sm->IsEmpty() )
if ( !_mainEdge.IsNull() && _isPropagOfDistribution )
{
TopoDS_Edge mainEdge = TopoDS::Edge( _mainEdge ); // should not be a reference!
- _gen->Compute( theMesh, mainEdge, /*aShapeOnly=*/true, /*anUpward=*/true);
+ _gen->Compute( theMesh, mainEdge, SMESH_Gen::SHAPE_ONLY_UPWARD );
SMESHDS_SubMesh* smDS = theMesh.GetMeshDS()->MeshElements( mainEdge );
if ( !smDS )