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_PreviewActorsCollection.h \
SMESH_ExtractGeometry.h \ SMESH_ExtractGeometry.h \
SMESH_FaceOrientationFilter.h SMESH_FaceOrientationFilter.h
# SMESH_vtkPVUpdateSuppressor.h
# Libraries targets # Libraries targets
@ -49,6 +50,7 @@ dist_libSMESHObject_la_SOURCES = \
SMESH_ExtractGeometry.cxx \ SMESH_ExtractGeometry.cxx \
SMESH_ActorUtils.cxx \ SMESH_ActorUtils.cxx \
SMESH_FaceOrientationFilter.cxx SMESH_FaceOrientationFilter.cxx
# SMESH_vtkPVUpdateSuppressor.cxx
libSMESHObject_la_CPPFLAGS = \ libSMESHObject_la_CPPFLAGS = \
$(QT_INCLUDES) \ $(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_QuadraticVolumeOfNodes.hxx \
SMDS_SetIterator.hxx \ SMDS_SetIterator.hxx \
SMESH_SMDS.hxx \ SMESH_SMDS.hxx \
SMDS_MeshInfo.hxx SMDS_MeshInfo.hxx \
SMDS_UnstructuredGrid.hxx
# Libraries targets # Libraries targets
@ -111,7 +112,8 @@ dist_libSMDS_la_SOURCES = \
SMDS_VolumeTool.cxx \ SMDS_VolumeTool.cxx \
SMDS_QuadraticEdge.cxx \ SMDS_QuadraticEdge.cxx \
SMDS_QuadraticFaceOfNodes.cxx \ SMDS_QuadraticFaceOfNodes.cxx \
SMDS_QuadraticVolumeOfNodes.cxx SMDS_QuadraticVolumeOfNodes.cxx \
SMDS_UnstructuredGrid.cxx
# additionnal information to compil and link file # additionnal information to compil and link file
libSMDS_la_CPPFLAGS = \ libSMDS_la_CPPFLAGS = \

View File

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

View File

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

View File

@ -1,73 +1,76 @@
#include "SMDS_UnstructuredGrid.hxx" #include "SMDS_UnstructuredGrid.hxx"
#include "utilities.h"
using namespace std; using namespace std;
vtkCellLinks::Link* SMDS_CellLinks::AdjustSize(vtkIdType sz) //vtkCellLinks::Link* SMDS_CellLinks::AdjustSize(vtkIdType sz)
{ //{
vtkIdType i; // vtkIdType i;
vtkCellLinks::Link *newArray; // vtkCellLinks::Link *newArray;
vtkIdType newSize = sz; // vtkIdType newSize = sz;
vtkCellLinks::Link linkInit = {0,NULL}; // vtkCellLinks::Link linkInit = {0,NULL};
//
newArray = new vtkCellLinks::Link[newSize]; // newArray = new vtkCellLinks::Link[newSize];
//
for (i=0; i<sz && i<this->Size; i++) // for (i=0; i<sz && i<this->Size; i++)
{ // {
newArray[i] = this->Array[i]; // newArray[i] = this->Array[i];
} // }
//
for (i=this->Size; i < newSize ; i++) // for (i=this->Size; i < newSize ; i++)
{ // {
newArray[i] = linkInit; // newArray[i] = linkInit;
} // }
//
this->Size = newSize; // this->Size = newSize;
delete [] this->Array; // delete [] this->Array;
this->Array = newArray; // this->Array = newArray;
//
return this->Array; // return this->Array;
} //}
//
SMDS_CellLinks* SMDS_CellLinks::New() //SMDS_CellLinks* SMDS_CellLinks::New()
{ //{
return new SMDS_CellLinks(); // return new SMDS_CellLinks();
} //}
//
SMDS_CellLinks::SMDS_CellLinks() : vtkCellLinks() //SMDS_CellLinks::SMDS_CellLinks() : vtkCellLinks()
{ //{
} //}
//
SMDS_CellLinks::~SMDS_CellLinks() //SMDS_CellLinks::~SMDS_CellLinks()
{ //{
} //}
//
/*! initialize an SMDS_CellLinks instance instead of a vtkCellLinks instance //
* ///*! initialize an SMDS_CellLinks instance instead of a vtkCellLinks instance
*/ // *
void SMDS_UnstructuredGrid::BuildLinks() // */
{ //void SMDS_UnstructuredGrid::BuildLinks()
// Remove the old links if they are already built //{
if (this->Links) // // Remove the old links if they are already built
{ // if (this->Links)
this->Links->UnRegister(this); // {
} // this->Links->UnRegister(this);
// }
this->Links = SMDS_CellLinks::New(); //
this->Links->Allocate(this->GetNumberOfPoints()); // this->Links = SMDS_CellLinks::New();
this->Links->Register(this); // this->Links->Allocate(this->GetNumberOfPoints());
this->Links->BuildLinks(this, this->Connectivity); // this->Links->Register(this);
this->Links->Delete(); // this->Links->BuildLinks(this, this->Connectivity);
} // this->Links->Delete();
//}
SMDS_CellLinks* SMDS_UnstructuredGrid::GetCellLinks() //
{ //SMDS_CellLinks* SMDS_UnstructuredGrid::GetCellLinks()
return static_cast<SMDS_CellLinks*>(this->Links); //{
} // return static_cast<SMDS_CellLinks*>(this->Links);
//}
SMDS_UnstructuredGrid* SMDS_UnstructuredGrid::New() SMDS_UnstructuredGrid* SMDS_UnstructuredGrid::New()
{ {
MESSAGE("SMDS_UnstructuredGrid::New");
return new SMDS_UnstructuredGrid(); 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 #define _SMDS_UNSTRUCTUREDGRID_HXX
#include <vtkUnstructuredGrid.h> #include <vtkUnstructuredGrid.h>
#include <vtkCellLinks.h> //#include <vtkCellLinks.h>
class SMDS_CellLinks: public vtkCellLinks //class SMDS_CellLinks: public vtkCellLinks
{ //{
public: //public:
Link *AdjustSize(vtkIdType sz); // Link *AdjustSize(vtkIdType sz);
//
//virtual void Delete(); // //virtual void Delete();
static SMDS_CellLinks* New(); // static SMDS_CellLinks* New();
protected: //protected:
SMDS_CellLinks(); // SMDS_CellLinks();
~SMDS_CellLinks(); // ~SMDS_CellLinks();
}; //};
class SMDS_UnstructuredGrid: public vtkUnstructuredGrid class SMDS_UnstructuredGrid: public vtkUnstructuredGrid
{ {
public: public:
void BuildLinks(); // initialise un SMDS_CellLinks; // void BuildLinks(); // initialise un SMDS_CellLinks;
SMDS_CellLinks* GetCellLinks(); // 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(); //virtual void Delete();
static SMDS_UnstructuredGrid* New(); static SMDS_UnstructuredGrid* New();

View File

@ -12,37 +12,60 @@ SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSA
{ {
case SMDSEntity_Tetra: case SMDSEntity_Tetra:
{ {
tempid = _vtkIdList->GetId(1); this->exchange(1, 2);
_vtkIdList->SetId(1, _vtkIdList->GetId(2));
_vtkIdList->SetId(2, tempid);
break; break;
} }
case SMDSEntity_Pyramid: case SMDSEntity_Pyramid:
{ {
tempid = _vtkIdList->GetId(1); this->exchange(1, 3);
_vtkIdList->SetId(1, _vtkIdList->GetId(3));
_vtkIdList->SetId(3, tempid);
break; break;
} }
case SMDSEntity_Penta: case SMDSEntity_Penta:
{ {
tempid = _vtkIdList->GetId(1); this->exchange(1, 2);
_vtkIdList->SetId(1, _vtkIdList->GetId(2)); this->exchange(4, 5);
_vtkIdList->SetId(2, tempid); break;
tempid = _vtkIdList->GetId(4);
_vtkIdList->SetId(4, _vtkIdList->GetId(5));
_vtkIdList->SetId(5, tempid);
break;
} }
case SMDSEntity_Hexa: case SMDSEntity_Hexa:
{ {
tempid = _vtkIdList->GetId(1); this->exchange(1, 3);
_vtkIdList->SetId(1, _vtkIdList->GetId(3)); this->exchange(5, 7);
_vtkIdList->SetId(3, tempid); break;
tempid = _vtkIdList->GetId(5); }
_vtkIdList->SetId(5, _vtkIdList->GetId(7)); case SMDSEntity_Quad_Tetra:
_vtkIdList->SetId(7, tempid); {
break; 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: default:
break; break;

View File

@ -15,6 +15,9 @@ public:
virtual ~SMDS_VtkCellIterator(); virtual ~SMDS_VtkCellIterator();
virtual bool more(); virtual bool more();
virtual const SMDS_MeshElement* next(); 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: protected:
SMDS_Mesh* _mesh; SMDS_Mesh* _mesh;
int _cellId; int _cellId;

View File

@ -27,7 +27,10 @@ void SMDS_VtkEdge::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
vtkUnstructuredGrid* grid = mesh->getGrid(); vtkUnstructuredGrid* grid = mesh->getGrid();
myIdInShape = -1; myIdInShape = -1;
myMeshId = mesh->getMeshId(); 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, 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 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 int SMDS_VtkEdge::NbEdges() const
@ -53,12 +58,19 @@ int SMDS_VtkEdge::NbEdges() const
SMDSAbs_EntityType SMDS_VtkEdge::GetEntityType() 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 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* const SMDS_MeshNode*
SMDS_VtkEdge::GetNode(const int ind) const 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 SMDS_ElemIteratorPtr SMDS_VtkEdge::elementsIterator(SMDSAbs_ElementType type) const

View File

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

View File

@ -28,8 +28,14 @@ void SMDS_VtkFace::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
myIdInShape = -1; myIdInShape = -1;
myMeshId = mesh->getMeshId(); myMeshId = mesh->getMeshId();
vtkIdType aType = VTK_TRIANGLE; vtkIdType aType = VTK_TRIANGLE;
if (nodeIds.size() == 4) switch(nodeIds.size())
aType = VTK_QUAD; {
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]); 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 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 int SMDS_VtkFace::NbFaces() const
@ -68,26 +82,39 @@ int SMDS_VtkFace::NbNodes() const
const SMDS_MeshNode* const SMDS_MeshNode*
SMDS_VtkFace::GetNode(const int ind) const 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 SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const
{ {
int nbNodes = NbNodes(); SMDSAbs_EntityType aType = SMDSEntity_Triangle;
if (nbNodes == 3) switch(NbNodes())
return SMDSEntity_Triangle; {
else case 3:
return SMDSEntity_Quadrangle; case 6: aType = SMDSEntity_Triangle; break;
case 4:
case 8: aType = SMDSEntity_Quadrangle; break;
}
return aType;
} }
vtkIdType SMDS_VtkFace::GetVtkType() const vtkIdType SMDS_VtkFace::GetVtkType() const
{ {
int nbNodes = NbNodes(); switch(NbNodes())
if (nbNodes == 3) {
return VTK_TRIANGLE; case 3: return VTK_TRIANGLE;
else case 6: return VTK_QUADRATIC_TRIANGLE;
return VTK_QUAD; case 4: return VTK_QUAD;
case 8: return VTK_QUADRATIC_QUAD;
}
} }
SMDS_ElemIteratorPtr SMDS_VtkFace::elementsIterator(SMDSAbs_ElementType type) const SMDS_ElemIteratorPtr SMDS_VtkFace::elementsIterator(SMDSAbs_ElementType type) const

View File

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

View File

@ -17,7 +17,10 @@ SMDS_VtkVolume::SMDS_VtkVolume(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{ {
init(nodeIds, 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) void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{ {
vtkUnstructuredGrid* grid = mesh->getGrid(); vtkUnstructuredGrid* grid = mesh->getGrid();
@ -26,11 +29,15 @@ void SMDS_VtkVolume::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
vtkIdType aType = VTK_TETRA; vtkIdType aType = VTK_TETRA;
switch(nodeIds.size()) switch(nodeIds.size())
{ {
case 4: aType = VTK_TETRA; break; case 4: aType = VTK_TETRA; break;
case 5: aType = VTK_PYRAMID; break; case 5: aType = VTK_PYRAMID; break;
case 6: aType = VTK_WEDGE; break; case 6: aType = VTK_WEDGE; break;
case 8: case 8: aType = VTK_HEXAHEDRON; break;
default: 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]); myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
} }
@ -55,10 +62,14 @@ int SMDS_VtkVolume::NbFaces() const
{ {
switch(NbNodes()) switch(NbNodes())
{ {
case 4: return 4; case 4:
case 5: return 5; case 10: return 4;
case 6: return 5; case 5:
case 8: return 6; case 13: return 5;
case 6:
case 15: return 5;
case 8:
case 20: return 6;
default: MESSAGE("invalid number of nodes"); default: MESSAGE("invalid number of nodes");
} }
return 0; return 0;
@ -75,10 +86,14 @@ int SMDS_VtkVolume::NbEdges() const
{ {
switch(NbNodes()) switch(NbNodes())
{ {
case 4: return 6; case 4:
case 5: return 8; case 10: return 6;
case 6: return 9; case 5:
case 8: return 12; case 13: return 8;
case 6:
case 15: return 9;
case 8:
case 20: return 12;
default: MESSAGE("invalid number of nodes"); default: MESSAGE("invalid number of nodes");
} }
return 0; return 0;
@ -108,7 +123,15 @@ SMDSAbs_ElementType SMDS_VtkVolume::GetType() const
*/ */
const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) 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 SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
@ -116,11 +139,15 @@ SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
SMDSAbs_EntityType aType = SMDSEntity_Tetra; SMDSAbs_EntityType aType = SMDSEntity_Tetra;
switch(NbNodes()) switch(NbNodes())
{ {
case 4: aType = SMDSEntity_Tetra; break; case 4: aType = SMDSEntity_Tetra; break;
case 5: aType = SMDSEntity_Pyramid; break; case 5: aType = SMDSEntity_Pyramid; break;
case 6: aType = SMDSEntity_Penta; break; case 6: aType = SMDSEntity_Penta; break;
case 8: case 8: aType = SMDSEntity_Hexa; break;
default: 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; return aType;
} }
@ -130,11 +157,15 @@ vtkIdType SMDS_VtkVolume::GetVtkType() const
vtkIdType aType = VTK_TETRA; vtkIdType aType = VTK_TETRA;
switch(NbNodes()) switch(NbNodes())
{ {
case 4: aType = VTK_TETRA; break; case 4: aType = VTK_TETRA; break;
case 5: aType = VTK_PYRAMID; break; case 5: aType = VTK_PYRAMID; break;
case 6: aType = VTK_WEDGE; break; case 6: aType = VTK_WEDGE; break;
case 8: case 8: aType = VTK_HEXAHEDRON; break;
default: 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; return aType;
} }

View File

@ -25,6 +25,7 @@ public:
virtual vtkIdType GetVtkType() const; virtual vtkIdType GetVtkType() const;
virtual SMDSAbs_EntityType GetEntityType() const; virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const;
protected: protected:
SMDS_ElemIteratorPtr 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) bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted)
{ {
// MESSAGE("--------------------------------------> RemoveElement " << isElemDeleted);
// if ( !IsComplexSubmesh() && NbElements() ) { // if ( !IsComplexSubmesh() && NbElements() ) {
if (!isElemDeleted) // alive element has valid ID and can be found if (!isElemDeleted) // alive element has valid ID and can be found
@ -173,30 +174,53 @@ int SMESHDS_SubMesh::NbNodes() const
return nbElems; return nbElems;
} }
// ===================== /*!
// class MySetIterator * 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.
template <class ELEM, typename TSET> class MySetIterator : public SMDS_Iterator<ELEM> * 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: protected:
typename TSET::const_iterator _it, _end; typename TSET::const_iterator _it, _end;
TSET _table;
// int _ind;
public: public:
MySetIterator(const TSET& table) 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() virtual bool more()
{ {
while((_it != _end) && (*_it == 0)) while((_it != _end) && (*_it == 0))
{
_it++; _it++;
// _ind++;
}
// MESSAGE("more _ind=" << _ind);
return (_it != _end); return (_it != _end);
} }
virtual ELEM next() 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() ) if ( IsComplexSubmesh() )
return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes )); return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes ));
return SMDS_ElemIteratorPtr(new MySetIterator<const SMDS_MeshElement*, std::vector<const SMDS_MeshElement*> >(myElements)); return SMDS_ElemIteratorPtr(new MySetIterator<const SMDS_MeshElement*, std::vector<const SMDS_MeshElement*> >(myElements));
} }