PR: SMDS refactoring in progress

This commit is contained in:
prascle 2010-04-02 13:55:36 +00:00
parent 3c1d19eebf
commit 9d4adbe924
17 changed files with 841 additions and 232 deletions

View File

@ -37,6 +37,7 @@ salomeinclude_HEADERS = \
SMESH_PreviewActorsCollection.h \
SMESH_ExtractGeometry.h \
SMESH_FaceOrientationFilter.h
# SMESH_vtkPVUpdateSuppressor.h
# Libraries targets
@ -49,6 +50,7 @@ dist_libSMESHObject_la_SOURCES = \
SMESH_ExtractGeometry.cxx \
SMESH_ActorUtils.cxx \
SMESH_FaceOrientationFilter.cxx
# SMESH_vtkPVUpdateSuppressor.cxx
libSMESHObject_la_CPPFLAGS = \
$(QT_INCLUDES) \

View File

@ -0,0 +1,231 @@
/*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "SMESH_vtkPVUpdateSuppressor.h"
#include "vtkAlgorithmOutput.h"
#include "vtkCollection.h"
#include "vtkCommand.h"
#include "vtkCompositeDataPipeline.h"
#include "vtkDataObject.h"
#include "vtkDemandDrivenPipeline.h"
#include "vtkInformation.h"
#include "vtkInformationDoubleVectorKey.h"
#include "vtkInformationExecutivePortKey.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
//#include "vtkProcessModule.h"
#include "vtkSmartPointer.h"
#include "vtkUnstructuredGrid.h"
//#include "vtkUpdateSuppressorPipeline.h"
#include <vtkstd/map>
#ifdef MYDEBUG
# define vtkMyDebug(x)\
cout << x;
#else
# define vtkMyDebug(x)
#endif
vtkCxxRevisionMacro(vtkPVUpdateSuppressor, "$Revision$");
vtkStandardNewMacro(vtkPVUpdateSuppressor);
//----------------------------------------------------------------------------
vtkPVUpdateSuppressor::vtkPVUpdateSuppressor()
{
this->UpdatePiece = 0;
this->UpdateNumberOfPieces = 1;
this->UpdateTime = 0.0;
this->UpdateTimeInitialized = false;
this->Enabled = 1;
// vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
//
// if (pm)
// {
// this->UpdateNumberOfPieces = pm->GetNumberOfLocalPartitions();
// this->UpdatePiece = pm->GetPartitionId();
// }
}
//----------------------------------------------------------------------------
vtkPVUpdateSuppressor::~vtkPVUpdateSuppressor()
{
}
//----------------------------------------------------------------------------
void vtkPVUpdateSuppressor::SetUpdateTime(double utime)
{
this->UpdateTimeInitialized = true;
if (this->UpdateTime != utime)
{
this->Modified();
this->UpdateTime = utime;
}
}
//----------------------------------------------------------------------------
void vtkPVUpdateSuppressor::SetEnabled(int enable)
{
if (this->Enabled == enable)
{
return;
}
this->Enabled = enable;
this->Modified();
// vtkUpdateSuppressorPipeline* executive =
// vtkUpdateSuppressorPipeline::SafeDownCast(this->GetExecutive());
// if (executive)
// {
// executive->SetEnabled(enable);
// }
}
//----------------------------------------------------------------------------
void vtkPVUpdateSuppressor::ForceUpdate()
{
// Make sure that output type matches input type
this->UpdateInformation();
vtkDataObject *input = this->GetInput();
if (input == 0)
{
vtkErrorMacro("No valid input.");
return;
}
vtkDataObject *output = this->GetOutput();
// int fixme; // I do not like this hack. How can we get rid of it?
// Assume the input is the collection filter.
// Client needs to modify the collection filter because it is not
// connected to a pipeline.
vtkAlgorithm *source = input->GetProducerPort()->GetProducer();
if (source &&
(source->IsA("vtkMPIMoveData") ||
source->IsA("vtkCollectPolyData") ||
source->IsA("vtkM2NDuplicate") ||
source->IsA("vtkM2NCollect") ||
source->IsA("vtkOrderedCompositeDistributor") ||
source->IsA("vtkClientServerMoveData")))
{
source->Modified();
}
vtkInformation* info = input->GetPipelineInformation();
vtkStreamingDemandDrivenPipeline* sddp =
vtkStreamingDemandDrivenPipeline::SafeDownCast(
vtkExecutive::PRODUCER()->GetExecutive(info));
if (sddp)
{
sddp->SetUpdateExtent(info,
this->UpdatePiece,
this->UpdateNumberOfPieces,
0);
}
else
{
input->SetUpdatePiece(this->UpdatePiece);
input->SetUpdateNumberOfPieces(this->UpdateNumberOfPieces);
input->SetUpdateGhostLevel(0);
}
vtkMyDebug("ForceUpdate ");
if (this->UpdateTimeInitialized)
{
info->Set(vtkCompositeDataPipeline::UPDATE_TIME_STEPS(), &this->UpdateTime, 1);
vtkMyDebug(this->UpdateTime);
}
vtkMyDebug(endl);
input->Update();
// Input may have changed, we obtain the pointer again.
input = this->GetInput();
output->ShallowCopy(input);
this->PipelineUpdateTime.Modified();
}
//----------------------------------------------------------------------------
vtkExecutive* vtkPVUpdateSuppressor::CreateDefaultExecutive()
{
vtkUpdateSuppressorPipeline* executive = vtkUpdateSuppressorPipeline::New();
executive->SetEnabled(this->Enabled);
return executive;
}
//----------------------------------------------------------------------------
int vtkPVUpdateSuppressor::RequestDataObject(
vtkInformation* vtkNotUsed(reqInfo),
vtkInformationVector** inputVector ,
vtkInformationVector* outputVector)
{
vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
if (!inInfo)
{
return 0;
}
vtkDataObject *input = inInfo->Get(vtkDataObject::DATA_OBJECT());
if (input)
{
// for each output
for(int i=0; i < this->GetNumberOfOutputPorts(); ++i)
{
vtkInformation* outInfo = outputVector->GetInformationObject(i);
vtkDataObject *output = outInfo->Get(vtkDataObject::DATA_OBJECT());
if (!output || !output->IsA(input->GetClassName()))
{
vtkDataObject* newOutput = input->NewInstance();
newOutput->SetPipelineInformation(outInfo);
newOutput->Delete();
this->GetOutputPortInformation(i)->Set(
vtkDataObject::DATA_EXTENT_TYPE(), newOutput->GetExtentType());
}
}
return 1;
}
return 0;
}
//----------------------------------------------------------------------------
int vtkPVUpdateSuppressor::RequestData(vtkInformation* vtkNotUsed(reqInfo),
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
// RequestData is only called by its executive when
// (Enabled==off) and thus acting as a passthrough filter
vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
vtkDataObject *input = inInfo->Get(vtkDataObject::DATA_OBJECT());
vtkDataObject *output = outInfo->Get(vtkDataObject::DATA_OBJECT());
output->ShallowCopy(input);
return 1;
}
//----------------------------------------------------------------------------
void vtkPVUpdateSuppressor::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "UpdatePiece: " << this->UpdatePiece << endl;
os << indent << "UpdateNumberOfPieces: " << this->UpdateNumberOfPieces << endl;
os << indent << "Enabled: " << this->Enabled << endl;
os << indent << "UpdateTime: " << this->UpdateTime << endl;
}

View File

@ -0,0 +1,91 @@
/*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPVUpdateSuppressor - prevents propagation of update
// .SECTION Description
// vtkPVUpdateSuppressor now uses the vtkProcessModule singleton to set up the
// default values for UpdateNumberOfPieces and UpdatePiece, so we no longer have
// to set the default values (in most cases).
// .SECTION See Also
// vtkPVCacheKeeper vtkUpdateSuppressorPipeline
#ifndef __vtkPVUpdateSuppressor_h
#define __vtkPVUpdateSuppressor_h
#include "vtkDataObjectAlgorithm.h"
class VTK_EXPORT vtkPVUpdateSuppressor : public vtkDataObjectAlgorithm
{
public:
vtkTypeRevisionMacro(vtkPVUpdateSuppressor,vtkDataObjectAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Construct with user-specified implicit function.
static vtkPVUpdateSuppressor *New();
// Description:
// Force update on the input.
virtual void ForceUpdate();
// Description:
// Set number of pieces and piece on the data.
// This causes the filter to ingore the request from the output.
// It is here because the user may not have celled update on the output
// before calling force update (it is an easy fix).
vtkSetMacro(UpdatePiece, int);
vtkGetMacro(UpdatePiece, int);
vtkSetMacro(UpdateNumberOfPieces, int);
vtkGetMacro(UpdateNumberOfPieces, int);
// Description:
// Get/Set if the update suppressor is enabled. If the update suppressor
// is not enabled, it won't supress any updates. Enabled by default.
void SetEnabled(int);
vtkGetMacro(Enabled, int);
// Description:
// Get/Set the update time that is sent up the pipeline.
void SetUpdateTime(double utime);
vtkGetMacro(UpdateTime, double);
protected:
vtkPVUpdateSuppressor();
~vtkPVUpdateSuppressor();
int RequestDataObject(vtkInformation* request, vtkInformationVector **inputVector,
vtkInformationVector *outputVector);
int RequestData(vtkInformation* request, vtkInformationVector **inputVector,
vtkInformationVector *outputVector);
int UpdatePiece;
int UpdateNumberOfPieces;
double UpdateTime;
bool UpdateTimeInitialized;
int Enabled;
vtkTimeStamp PipelineUpdateTime;
// Create a default executive.
virtual vtkExecutive* CreateDefaultExecutive();
private:
vtkPVUpdateSuppressor(const vtkPVUpdateSuppressor&); // Not implemented.
void operator=(const vtkPVUpdateSuppressor&); // Not implemented.
};
#endif

View File

@ -71,7 +71,8 @@ salomeinclude_HEADERS = \
SMDS_QuadraticVolumeOfNodes.hxx \
SMDS_SetIterator.hxx \
SMESH_SMDS.hxx \
SMDS_MeshInfo.hxx
SMDS_MeshInfo.hxx \
SMDS_UnstructuredGrid.hxx
# Libraries targets
@ -111,7 +112,8 @@ dist_libSMDS_la_SOURCES = \
SMDS_VolumeTool.cxx \
SMDS_QuadraticEdge.cxx \
SMDS_QuadraticFaceOfNodes.cxx \
SMDS_QuadraticVolumeOfNodes.cxx
SMDS_QuadraticVolumeOfNodes.cxx \
SMDS_UnstructuredGrid.cxx
# additionnal information to compil and link file
libSMDS_la_CPPFLAGS = \

View File

@ -37,6 +37,7 @@
#include "SMDS_QuadraticFaceOfNodes.hxx"
#include "SMDS_QuadraticVolumeOfNodes.hxx"
#include "SMDS_SpacePosition.hxx"
#include "SMDS_UnstructuredGrid.hxx"
#include <vtkUnstructuredGrid.h>
#include <vtkUnstructuredGridWriter.h>
@ -145,7 +146,7 @@ SMDS_Mesh::SMDS_Mesh()
myCells.clear();
myIDElements.clear();
myVtkIndex.clear();
myGrid = vtkUnstructuredGrid::New();
myGrid = SMDS_UnstructuredGrid::New();
myGrid->Initialize();
myGrid->Allocate();
vtkPoints* points = vtkPoints::New();
@ -2744,25 +2745,38 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
case SMDSAbs_0DElement:
myCells[(*it)->GetID()] = 0; // -PR- ici ou dans myElementIDFactory->ReleaseID ?
myInfo.remove(*it);
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID((*it)->GetID());
delete (*it);
break;
case SMDSAbs_Edge:
myCells[(*it)->GetID()] = 0;
myInfo.RemoveEdge(*it);
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID((*it)->GetID());
if (const SMDS_VtkEdge* vtkElem = dynamic_cast<const SMDS_VtkEdge*>(*it))
myEdgePool->destroy((SMDS_VtkEdge*)vtkElem);
else delete (*it);
break;
case SMDSAbs_Face:
myCells[(*it)->GetID()] = 0;
myInfo.RemoveFace(*it);
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID((*it)->GetID());
if (const SMDS_VtkFace* vtkElem = dynamic_cast<const SMDS_VtkFace*>(*it))
myFacePool->destroy((SMDS_VtkFace*)vtkElem);
else delete (*it);
break;
case SMDSAbs_Volume:
myCells[(*it)->GetID()] = 0;
myInfo.RemoveVolume(*it);
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID((*it)->GetID());
if (const SMDS_VtkVolume* vtkElem = dynamic_cast<const SMDS_VtkVolume*>(*it))
myVolumePool->destroy((SMDS_VtkVolume*)vtkElem);
else delete (*it);
break;
}
//MESSAGE( "SMDS: RM elem " << (*it)->GetID() );
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID((*it)->GetID());
MYASSERT("problem delete elem")
delete (*it);
it++;
}
@ -2777,8 +2791,9 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
myInfo.myNbNodes--;
myNodeIDFactory->ReleaseID((*it)->GetID());
removedNodes.push_back( (*it) );
MYASSERT("problem delete node")
delete *it;
if (const SMDS_MeshNode* vtkElem = dynamic_cast<const SMDS_MeshNode*>(*it))
myNodePool->destroy((SMDS_MeshNode*)vtkElem);
else delete (*it);
it++;
}
}
@ -2794,7 +2809,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem)
{
int elemId = elem->GetID();
MESSAGE("SMDS_Mesh::RemoveFreeElement " << elemId);
//MESSAGE("SMDS_Mesh::RemoveFreeElement " << elemId);
SMDSAbs_ElementType aType = elem->GetType();
SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem);
if (aType == SMDSAbs_Node) {
@ -3031,24 +3046,28 @@ SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1,
int ID)
{
if ( !n1 || !n2 || !n12 ) return 0;
SMDS_QuadraticEdge* edge = new SMDS_QuadraticEdge(n1,n2,n12);
if(myElementIDFactory->BindID(ID, edge)) {
SMDS_MeshNode *node1,*node2, *node12;
//node1 = const_cast<SMDS_MeshNode*>(n1);
//node2 = const_cast<SMDS_MeshNode*>(n2);
//node12 = const_cast<SMDS_MeshNode*>(n12);
//node1->AddInverseElement(edge); // --- fait avec BindID
//node2->AddInverseElement(edge);
//node12->AddInverseElement(edge);
adjustmyCellsCapacity(ID);
myCells[ID] = edge;
myInfo.myNbQuadEdges++;
return edge;
}
else {
delete edge;
return NULL;
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getId());
nodeIds.push_back(n2->getId());
nodeIds.push_back(n12->getId());
SMDS_MeshEdge * edge = 0;
SMDS_VtkEdge *edgevtk = myEdgePool->getNew();
edgevtk->init(nodeIds, this);
edge = edgevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = edge;
myInfo.myNbQuadEdges++;
if (!registerElement(ID, edge)) {
RemoveElement(edge, false);
edge = NULL;
}
return edge;
}
@ -3101,17 +3120,32 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
// creation quadratic edges - not implemented
return 0;
}
SMDS_QuadraticFaceOfNodes* face =
new SMDS_QuadraticFaceOfNodes(n1,n2,n3,n12,n23,n31);
adjustmyCellsCapacity(ID);
myCells[ID] = face;
myInfo.myNbQuadTriangles++;
else
{
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getId());
nodeIds.push_back(n2->getId());
nodeIds.push_back(n3->getId());
nodeIds.push_back(n12->getId());
nodeIds.push_back(n23->getId());
nodeIds.push_back(n31->getId());
if (!registerElement(ID, face)) {
RemoveElement(face, false);
face = NULL;
SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this);
face = facevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = face;
myInfo.myNbQuadTriangles++;
if (!registerElement(ID, face)) {
RemoveElement(face, false);
face = NULL;
}
return face;
}
return face;
}
@ -3168,18 +3202,36 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
if ( !n1 || !n2 || !n3 || !n4 || !n12 || !n23 || !n34 || !n41) return 0;
if(hasConstructionEdges()) {
// creation quadratic edges - not implemented
return 0;
}
SMDS_QuadraticFaceOfNodes* face =
new SMDS_QuadraticFaceOfNodes(n1,n2,n3,n4,n12,n23,n34,n41);
adjustmyCellsCapacity(ID);
myCells[ID] = face;
myInfo.myNbQuadQuadrangles++;
else
{
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getId());
nodeIds.push_back(n2->getId());
nodeIds.push_back(n3->getId());
nodeIds.push_back(n4->getId());
nodeIds.push_back(n12->getId());
nodeIds.push_back(n23->getId());
nodeIds.push_back(n34->getId());
nodeIds.push_back(n41->getId());
if (!registerElement(ID, face)) {
RemoveElement(face, false);
face = NULL;
SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this);
face = facevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = face;
myInfo.myNbQuadQuadrangles++;
if (!registerElement(ID, face)) {
RemoveElement(face, false);
face = NULL;
}
return face;
}
return face;
}
@ -3249,17 +3301,33 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
// creation quadratic faces - not implemented
return 0;
}
SMDS_QuadraticVolumeOfNodes * volume =
new SMDS_QuadraticVolumeOfNodes(n1,n2,n3,n4,n12,n23,n31,n14,n24,n34);
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getId());
nodeIds.push_back(n3->getId());
nodeIds.push_back(n2->getId());
nodeIds.push_back(n4->getId());
nodeIds.push_back(n31->getId());
nodeIds.push_back(n23->getId());
nodeIds.push_back(n12->getId());
nodeIds.push_back(n14->getId());
nodeIds.push_back(n34->getId());
nodeIds.push_back(n24->getId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
adjustmyCellsCapacity(ID);
myCells[ID] = volvtk;
myInfo.myNbQuadTetras++;
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
volume = NULL;
if (!registerElement(ID, volvtk)) {
RemoveElement(volvtk, false);
volvtk = NULL;
}
return volume;
return volvtk;
}
@ -3340,18 +3408,36 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
// creation quadratic faces - not implemented
return 0;
}
SMDS_QuadraticVolumeOfNodes * volume =
new SMDS_QuadraticVolumeOfNodes(n1,n2,n3,n4,n5,n12,n23,
n34,n41,n15,n25,n35,n45);
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getId());
nodeIds.push_back(n4->getId());
nodeIds.push_back(n3->getId());
nodeIds.push_back(n2->getId());
nodeIds.push_back(n5->getId());
nodeIds.push_back(n41->getId());
nodeIds.push_back(n34->getId());
nodeIds.push_back(n23->getId());
nodeIds.push_back(n12->getId());
nodeIds.push_back(n15->getId());
nodeIds.push_back(n45->getId());
nodeIds.push_back(n35->getId());
nodeIds.push_back(n25->getId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
adjustmyCellsCapacity(ID);
myCells[ID] = volvtk;
myInfo.myNbQuadPyramids++;
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
volume = NULL;
if (!registerElement(ID, volvtk)) {
RemoveElement(volvtk, false);
volvtk = NULL;
}
return volume;
return volvtk;
}
@ -3440,18 +3526,40 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
// creation quadratic faces - not implemented
return 0;
}
SMDS_QuadraticVolumeOfNodes * volume =
new SMDS_QuadraticVolumeOfNodes(n1,n2,n3,n4,n5,n6,n12,n23,n31,
n45,n56,n64,n14,n25,n36);
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getId());
nodeIds.push_back(n3->getId());
nodeIds.push_back(n2->getId());
nodeIds.push_back(n4->getId());
nodeIds.push_back(n6->getId());
nodeIds.push_back(n5->getId());
nodeIds.push_back(n31->getId());
nodeIds.push_back(n23->getId());
nodeIds.push_back(n12->getId());
nodeIds.push_back(n64->getId());
nodeIds.push_back(n56->getId());
nodeIds.push_back(n45->getId());
nodeIds.push_back(n14->getId());
nodeIds.push_back(n36->getId());
nodeIds.push_back(n25->getId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
adjustmyCellsCapacity(ID);
myCells[ID] = volvtk;
myInfo.myNbQuadPrisms++;
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
volume = NULL;
if (!registerElement(ID, volvtk)) {
RemoveElement(volvtk, false);
volvtk = NULL;
}
return volume;
return volvtk;
}
@ -3555,18 +3663,45 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1,
return 0;
// creation quadratic faces - not implemented
}
SMDS_QuadraticVolumeOfNodes * volume =
new SMDS_QuadraticVolumeOfNodes(n1,n2,n3,n4,n5,n6,n7,n8,n12,n23,n34,n41,
n56,n67,n78,n85,n15,n26,n37,n48);
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
// --- retrieve nodes ID
vector<vtkIdType> nodeIds;
nodeIds.clear();
nodeIds.push_back(n1->getId());
nodeIds.push_back(n4->getId());
nodeIds.push_back(n3->getId());
nodeIds.push_back(n2->getId());
nodeIds.push_back(n5->getId());
nodeIds.push_back(n8->getId());
nodeIds.push_back(n7->getId());
nodeIds.push_back(n6->getId());
nodeIds.push_back(n41->getId());
nodeIds.push_back(n34->getId());
nodeIds.push_back(n23->getId());
nodeIds.push_back(n12->getId());
nodeIds.push_back(n85->getId());
nodeIds.push_back(n78->getId());
nodeIds.push_back(n67->getId());
nodeIds.push_back(n56->getId());
nodeIds.push_back(n15->getId());
nodeIds.push_back(n48->getId());
nodeIds.push_back(n37->getId());
nodeIds.push_back(n26->getId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
adjustmyCellsCapacity(ID);
myCells[ID] = volvtk;
myInfo.myNbQuadHexas++;
if (!registerElement(ID, volume)) {
RemoveElement(volume, false);
volume = NULL;
if (!registerElement(ID, volvtk)) {
RemoveElement(volvtk, false);
volvtk = NULL;
}
return volume;
return volvtk;
}
void SMDS_Mesh::updateNodeMinMax()

View File

@ -49,10 +49,10 @@ int SMDS_MeshIDFactory::GetFreeID()
}
else
{
set<int>::iterator i = myPoolOfID.begin();
set<int>::iterator i = myPoolOfID.begin();
newid = *i;//myPoolOfID.top();
myPoolOfID.erase( i );//myPoolOfID.pop();
MESSAGE("GetFreeID pool " << newid);
//MESSAGE("GetFreeID pool " << newid);
}
return newid;
}

View File

@ -1,73 +1,76 @@
#include "SMDS_UnstructuredGrid.hxx"
#include "utilities.h"
using namespace std;
vtkCellLinks::Link* SMDS_CellLinks::AdjustSize(vtkIdType sz)
{
vtkIdType i;
vtkCellLinks::Link *newArray;
vtkIdType newSize = sz;
vtkCellLinks::Link linkInit = {0,NULL};
newArray = new vtkCellLinks::Link[newSize];
for (i=0; i<sz && i<this->Size; i++)
{
newArray[i] = this->Array[i];
}
for (i=this->Size; i < newSize ; i++)
{
newArray[i] = linkInit;
}
this->Size = newSize;
delete [] this->Array;
this->Array = newArray;
return this->Array;
}
SMDS_CellLinks* SMDS_CellLinks::New()
{
return new SMDS_CellLinks();
}
SMDS_CellLinks::SMDS_CellLinks() : vtkCellLinks()
{
}
SMDS_CellLinks::~SMDS_CellLinks()
{
}
/*! initialize an SMDS_CellLinks instance instead of a vtkCellLinks instance
*
*/
void SMDS_UnstructuredGrid::BuildLinks()
{
// Remove the old links if they are already built
if (this->Links)
{
this->Links->UnRegister(this);
}
this->Links = SMDS_CellLinks::New();
this->Links->Allocate(this->GetNumberOfPoints());
this->Links->Register(this);
this->Links->BuildLinks(this, this->Connectivity);
this->Links->Delete();
}
SMDS_CellLinks* SMDS_UnstructuredGrid::GetCellLinks()
{
return static_cast<SMDS_CellLinks*>(this->Links);
}
//vtkCellLinks::Link* SMDS_CellLinks::AdjustSize(vtkIdType sz)
//{
// vtkIdType i;
// vtkCellLinks::Link *newArray;
// vtkIdType newSize = sz;
// vtkCellLinks::Link linkInit = {0,NULL};
//
// newArray = new vtkCellLinks::Link[newSize];
//
// for (i=0; i<sz && i<this->Size; i++)
// {
// newArray[i] = this->Array[i];
// }
//
// for (i=this->Size; i < newSize ; i++)
// {
// newArray[i] = linkInit;
// }
//
// this->Size = newSize;
// delete [] this->Array;
// this->Array = newArray;
//
// return this->Array;
//}
//
//SMDS_CellLinks* SMDS_CellLinks::New()
//{
// return new SMDS_CellLinks();
//}
//
//SMDS_CellLinks::SMDS_CellLinks() : vtkCellLinks()
//{
//}
//
//SMDS_CellLinks::~SMDS_CellLinks()
//{
//}
//
//
///*! initialize an SMDS_CellLinks instance instead of a vtkCellLinks instance
// *
// */
//void SMDS_UnstructuredGrid::BuildLinks()
//{
// // Remove the old links if they are already built
// if (this->Links)
// {
// this->Links->UnRegister(this);
// }
//
// this->Links = SMDS_CellLinks::New();
// this->Links->Allocate(this->GetNumberOfPoints());
// this->Links->Register(this);
// this->Links->BuildLinks(this, this->Connectivity);
// this->Links->Delete();
//}
//
//SMDS_CellLinks* SMDS_UnstructuredGrid::GetCellLinks()
//{
// return static_cast<SMDS_CellLinks*>(this->Links);
//}
SMDS_UnstructuredGrid* SMDS_UnstructuredGrid::New()
{
MESSAGE("SMDS_UnstructuredGrid::New");
return new SMDS_UnstructuredGrid();
}
@ -80,3 +83,15 @@ SMDS_UnstructuredGrid::~SMDS_UnstructuredGrid()
}
unsigned long SMDS_UnstructuredGrid::GetMTime()
{
unsigned long mtime = vtkUnstructuredGrid::GetMTime();
MESSAGE("vtkUnstructuredGrid::GetMTime: " << mtime);
return mtime;
}
void SMDS_UnstructuredGrid::UpdateInformation()
{
MESSAGE("SMDS_UnstructuredGrid::UpdateInformation");
return vtkUnstructuredGrid::UpdateInformation();
}

View File

@ -9,27 +9,30 @@
#define _SMDS_UNSTRUCTUREDGRID_HXX
#include <vtkUnstructuredGrid.h>
#include <vtkCellLinks.h>
//#include <vtkCellLinks.h>
class SMDS_CellLinks: public vtkCellLinks
{
public:
Link *AdjustSize(vtkIdType sz);
//virtual void Delete();
static SMDS_CellLinks* New();
protected:
SMDS_CellLinks();
~SMDS_CellLinks();
};
//class SMDS_CellLinks: public vtkCellLinks
//{
//public:
// Link *AdjustSize(vtkIdType sz);
//
// //virtual void Delete();
// static SMDS_CellLinks* New();
//protected:
// SMDS_CellLinks();
// ~SMDS_CellLinks();
//};
class SMDS_UnstructuredGrid: public vtkUnstructuredGrid
{
public:
void BuildLinks(); // initialise un SMDS_CellLinks;
SMDS_CellLinks* GetCellLinks();
// void BuildLinks(); // initialise un SMDS_CellLinks;
// SMDS_CellLinks* GetCellLinks();
//
// vtkIdType GetCellArraySize() { return (this->Connectivity ? this->Connectivity->GetSize() : 0); };
vtkIdType GetCellArraySize() { return (this->Connectivity ? this->Connectivity->GetSize() : 0); };
virtual unsigned long GetMTime();
virtual void UpdateInformation();
//virtual void Delete();
static SMDS_UnstructuredGrid* New();

View File

@ -12,37 +12,60 @@ SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSA
{
case SMDSEntity_Tetra:
{
tempid = _vtkIdList->GetId(1);
_vtkIdList->SetId(1, _vtkIdList->GetId(2));
_vtkIdList->SetId(2, tempid);
this->exchange(1, 2);
break;
}
case SMDSEntity_Pyramid:
{
tempid = _vtkIdList->GetId(1);
_vtkIdList->SetId(1, _vtkIdList->GetId(3));
_vtkIdList->SetId(3, tempid);
this->exchange(1, 3);
break;
}
case SMDSEntity_Penta:
{
tempid = _vtkIdList->GetId(1);
_vtkIdList->SetId(1, _vtkIdList->GetId(2));
_vtkIdList->SetId(2, tempid);
tempid = _vtkIdList->GetId(4);
_vtkIdList->SetId(4, _vtkIdList->GetId(5));
_vtkIdList->SetId(5, tempid);
break;
this->exchange(1, 2);
this->exchange(4, 5);
break;
}
case SMDSEntity_Hexa:
{
tempid = _vtkIdList->GetId(1);
_vtkIdList->SetId(1, _vtkIdList->GetId(3));
_vtkIdList->SetId(3, tempid);
tempid = _vtkIdList->GetId(5);
_vtkIdList->SetId(5, _vtkIdList->GetId(7));
_vtkIdList->SetId(7, tempid);
break;
this->exchange(1, 3);
this->exchange(5, 7);
break;
}
case SMDSEntity_Quad_Tetra:
{
this->exchange(1, 2);
this->exchange(4, 6);
this->exchange(8, 9);
break;
}
case SMDSEntity_Quad_Pyramid:
{
this->exchange(1, 3);
this->exchange(5, 8);
this->exchange(6, 7);
this->exchange(10, 12);
break;
}
case SMDSEntity_Quad_Penta:
{
this->exchange(1, 2);
this->exchange(4, 5);
this->exchange(6, 8);
this->exchange(9, 11);
this->exchange(13, 14);
break;
}
case SMDSEntity_Quad_Hexa:
{
this->exchange(1, 3);
this->exchange(5, 7);
this->exchange(8, 11);
this->exchange(9, 10);
this->exchange(12, 15);
this->exchange(13, 14);
this->exchange(17, 19);
break;
}
default:
break;

View File

@ -15,6 +15,9 @@ public:
virtual ~SMDS_VtkCellIterator();
virtual bool more();
virtual const SMDS_MeshElement* next();
inline void exchange(vtkIdType a, vtkIdType b) { vtkIdType t = _vtkIdList->GetId(a);
_vtkIdList->SetId(a, _vtkIdList->GetId(b));
_vtkIdList->SetId(b, t); };
protected:
SMDS_Mesh* _mesh;
int _cellId;

View File

@ -27,7 +27,10 @@ void SMDS_VtkEdge::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
vtkUnstructuredGrid* grid = mesh->getGrid();
myIdInShape = -1;
myMeshId = mesh->getMeshId();
myVtkID = grid->InsertNextLinkedCell(VTK_LINE, nodeIds.size(), &nodeIds[0]);
vtkIdType aType = VTK_LINE;
if (nodeIds.size() == 3)
aType = VTK_QUADRATIC_EDGE;
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
}
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1,
@ -43,7 +46,9 @@ void SMDS_VtkEdge::Print(std::ostream & OS) const
int SMDS_VtkEdge::NbNodes() const
{
return 2;
vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
return nbPoints;
}
int SMDS_VtkEdge::NbEdges() const
@ -53,12 +58,19 @@ int SMDS_VtkEdge::NbEdges() const
SMDSAbs_EntityType SMDS_VtkEdge::GetEntityType() const
{
return SMDSEntity_Edge;
if (NbNodes() == 2)
return SMDSEntity_Edge;
else
return SMDSEntity_Quad_Edge;
}
vtkIdType SMDS_VtkEdge::GetVtkType() const
{
return VTK_LINE;
if (NbNodes() == 2)
return VTK_LINE;
else
return VTK_QUADRATIC_EDGE;
}
/*!
@ -69,7 +81,15 @@ vtkIdType SMDS_VtkEdge::GetVtkType() const
const SMDS_MeshNode*
SMDS_VtkEdge::GetNode(const int ind) const
{
return 0;
return SMDS_MeshElement::GetNode(ind); // --- a optimiser !
}
bool SMDS_VtkEdge::IsQuadratic() const
{
if (this->NbNodes() > 2)
return true;
else
return false;
}
SMDS_ElemIteratorPtr SMDS_VtkEdge::elementsIterator(SMDSAbs_ElementType type) const

View File

@ -24,6 +24,7 @@ public:
virtual vtkIdType GetVtkType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const;
protected:
SMDS_ElemIteratorPtr

View File

@ -28,8 +28,14 @@ void SMDS_VtkFace::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
myIdInShape = -1;
myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_TRIANGLE;
if (nodeIds.size() == 4)
aType = VTK_QUAD;
switch(nodeIds.size())
{
case 3: aType = VTK_TRIANGLE; break;
case 4: aType = VTK_QUAD; break;
case 6: aType = VTK_QUADRATIC_TRIANGLE; break;
case 8: aType = VTK_QUADRATIC_QUAD; break;
default: aType = VTK_TRIANGLE; break;
}
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
}
@ -45,7 +51,15 @@ void SMDS_VtkFace::Print(std::ostream & OS) const
int SMDS_VtkFace::NbEdges() const
{
return NbNodes();
switch(NbNodes())
{
case 3:
case 6: return 3;
case 4:
case 8: return 4;
default: MESSAGE("invalid number of nodes");
}
return 0;
}
int SMDS_VtkFace::NbFaces() const
@ -68,26 +82,39 @@ int SMDS_VtkFace::NbNodes() const
const SMDS_MeshNode*
SMDS_VtkFace::GetNode(const int ind) const
{
return 0;
return SMDS_MeshElement::GetNode(ind); // --- a optimiser !
}
bool SMDS_VtkFace::IsQuadratic() const
{
if (this->NbNodes() > 5)
return true;
else
return false;
}
SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const
{
int nbNodes = NbNodes();
if (nbNodes == 3)
return SMDSEntity_Triangle;
else
return SMDSEntity_Quadrangle;
SMDSAbs_EntityType aType = SMDSEntity_Triangle;
switch(NbNodes())
{
case 3:
case 6: aType = SMDSEntity_Triangle; break;
case 4:
case 8: aType = SMDSEntity_Quadrangle; break;
}
return aType;
}
vtkIdType SMDS_VtkFace::GetVtkType() const
{
int nbNodes = NbNodes();
if (nbNodes == 3)
return VTK_TRIANGLE;
else
return VTK_QUAD;
switch(NbNodes())
{
case 3: return VTK_TRIANGLE;
case 6: return VTK_QUADRATIC_TRIANGLE;
case 4: return VTK_QUAD;
case 8: return VTK_QUADRATIC_QUAD;
}
}
SMDS_ElemIteratorPtr SMDS_VtkFace::elementsIterator(SMDSAbs_ElementType type) const

View File

@ -24,6 +24,7 @@ public:
virtual vtkIdType GetVtkType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const;
protected:
SMDS_ElemIteratorPtr

View File

@ -17,7 +17,10 @@ SMDS_VtkVolume::SMDS_VtkVolume(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
init(nodeIds, mesh);
}
/*!
* typed used are vtk types (@see vtkCellType.h)
* see GetEntityType() for conversion in SMDS type (@see SMDSAbs_ElementType.hxx)
*/
void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
vtkUnstructuredGrid* grid = mesh->getGrid();
@ -26,11 +29,15 @@ void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
vtkIdType aType = VTK_TETRA;
switch(nodeIds.size())
{
case 4: aType = VTK_TETRA; break;
case 5: aType = VTK_PYRAMID; break;
case 6: aType = VTK_WEDGE; break;
case 8:
default: aType = VTK_HEXAHEDRON; break;
case 4: aType = VTK_TETRA; break;
case 5: aType = VTK_PYRAMID; break;
case 6: aType = VTK_WEDGE; break;
case 8: aType = VTK_HEXAHEDRON; break;
case 10: aType = VTK_QUADRATIC_TETRA; break;
case 13: aType = VTK_QUADRATIC_PYRAMID; break;
case 15: aType = VTK_QUADRATIC_WEDGE; break;
case 20: aType = VTK_QUADRATIC_HEXAHEDRON; break;
default: aType = VTK_HEXAHEDRON; break;
}
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
}
@ -55,10 +62,14 @@ int SMDS_VtkVolume::NbFaces() const
{
switch(NbNodes())
{
case 4: return 4;
case 5: return 5;
case 6: return 5;
case 8: return 6;
case 4:
case 10: return 4;
case 5:
case 13: return 5;
case 6:
case 15: return 5;
case 8:
case 20: return 6;
default: MESSAGE("invalid number of nodes");
}
return 0;
@ -75,10 +86,14 @@ int SMDS_VtkVolume::NbEdges() const
{
switch(NbNodes())
{
case 4: return 6;
case 5: return 8;
case 6: return 9;
case 8: return 12;
case 4:
case 10: return 6;
case 5:
case 13: return 8;
case 6:
case 15: return 9;
case 8:
case 20: return 12;
default: MESSAGE("invalid number of nodes");
}
return 0;
@ -108,7 +123,15 @@ SMDSAbs_ElementType SMDS_VtkVolume::GetType() const
*/
const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) const
{
return 0;
return SMDS_MeshElement::GetNode(ind); // --- a optimiser !
}
bool SMDS_VtkVolume::IsQuadratic() const
{
if (this->NbNodes() > 9)
return true;
else
return false;
}
SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
@ -116,11 +139,15 @@ SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
SMDSAbs_EntityType aType = SMDSEntity_Tetra;
switch(NbNodes())
{
case 4: aType = SMDSEntity_Tetra; break;
case 5: aType = SMDSEntity_Pyramid; break;
case 6: aType = SMDSEntity_Penta; break;
case 8:
default: aType = SMDSEntity_Hexa; break;
case 4: aType = SMDSEntity_Tetra; break;
case 5: aType = SMDSEntity_Pyramid; break;
case 6: aType = SMDSEntity_Penta; break;
case 8: aType = SMDSEntity_Hexa; break;
case 10: aType = SMDSEntity_Quad_Tetra; break;
case 13: aType = SMDSEntity_Quad_Pyramid; break;
case 15: aType = SMDSEntity_Quad_Penta; break;
case 20: aType = SMDSEntity_Quad_Hexa; break;
default: aType = SMDSEntity_Hexa; break;
}
return aType;
}
@ -130,11 +157,15 @@ vtkIdType SMDS_VtkVolume::GetVtkType() const
vtkIdType aType = VTK_TETRA;
switch(NbNodes())
{
case 4: aType = VTK_TETRA; break;
case 5: aType = VTK_PYRAMID; break;
case 6: aType = VTK_WEDGE; break;
case 8:
default: aType = VTK_HEXAHEDRON; break;
case 4: aType = VTK_TETRA; break;
case 5: aType = VTK_PYRAMID; break;
case 6: aType = VTK_WEDGE; break;
case 8: aType = VTK_HEXAHEDRON; break;
case 10: aType = VTK_QUADRATIC_TETRA; break;
case 13: aType = VTK_QUADRATIC_PYRAMID; break;
case 15: aType = VTK_QUADRATIC_WEDGE; break;
case 20: aType = VTK_QUADRATIC_HEXAHEDRON; break;
default: aType = VTK_HEXAHEDRON; break;
}
return aType;
}

View File

@ -25,6 +25,7 @@ public:
virtual vtkIdType GetVtkType() const;
virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const;
protected:
SMDS_ElemIteratorPtr

View File

@ -64,6 +64,7 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
//=======================================================================
bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted)
{
// MESSAGE("--------------------------------------> RemoveElement " << isElemDeleted);
// if ( !IsComplexSubmesh() && NbElements() ) {
if (!isElemDeleted) // alive element has valid ID and can be found
@ -173,30 +174,53 @@ int SMESHDS_SubMesh::NbNodes() const
return nbElems;
}
// =====================
// class MySetIterator
// =====================
template <class ELEM, typename TSET> class MySetIterator : public SMDS_Iterator<ELEM>
/*!
* template class used for iteration on submesh elements. Interface of iterator remains
* unchanged after redesign of SMDS to avoid modification everywhere in SMESH.
* instances are stored in shared_ptr for automatic destruction.
* Container is copied for iteration, because original can be modified
* by addition of elements, for instance, and then reallocated (vector)
*/
template <class ELEM, typename TSET> class MySetIterator : public SMDS_Iterator<ELEM>
{
protected:
typename TSET::const_iterator _it, _end;
TSET _table;
// int _ind;
public:
MySetIterator(const TSET& table)
: _it(table.begin()), _end(table.end())
// : _it(table.begin()), _end(table.end())
{
// MESSAGE("table.size()="<< table.size());
_table = table;
_it = _table.begin();
_end = _table.end();
// for (int i=0; i< _table.size(); i++)
// if (_table[i]) { MESSAGE("_table["<< i << "]="<< _table[i]);}
// else
// { MESSAGE("_table["<< i << "]=NULL"); }
// _ind = 0;
}
virtual bool more()
{
while((_it != _end) && (*_it == 0))
{
_it++;
// _ind++;
}
// MESSAGE("more _ind=" << _ind);
return (_it != _end);
}
virtual ELEM next()
{
return *_it++;
ELEM e=*_it;
// if (e) { MESSAGE("next _ind=" << _ind << " *_it=" << *_it);}
// else { MESSAGE("next _ind=" << _ind << " *_it=NULL");}
// _ind++;
_it++;
return e;
}
};
@ -272,7 +296,6 @@ SMDS_ElemIteratorPtr SMESHDS_SubMesh::GetElements() const
{
if ( IsComplexSubmesh() )
return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes ));
return SMDS_ElemIteratorPtr(new MySetIterator<const SMDS_MeshElement*, std::vector<const SMDS_MeshElement*> >(myElements));
}