]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
PR: SMDS refactoring in progress
authorprascle <prascle>
Fri, 2 Apr 2010 13:55:36 +0000 (13:55 +0000)
committerprascle <prascle>
Fri, 2 Apr 2010 13:55:36 +0000 (13:55 +0000)
17 files changed:
src/OBJECT/Makefile.am
src/OBJECT/SMESH_vtkPVUpdateSuppressor.cxx [new file with mode: 0644]
src/OBJECT/SMESH_vtkPVUpdateSuppressor.h [new file with mode: 0644]
src/SMDS/Makefile.am
src/SMDS/SMDS_Mesh.cxx
src/SMDS/SMDS_MeshIDFactory.cxx
src/SMDS/SMDS_UnstructuredGrid.cxx
src/SMDS/SMDS_UnstructuredGrid.hxx
src/SMDS/SMDS_VtkCellIterator.cxx
src/SMDS/SMDS_VtkCellIterator.hxx
src/SMDS/SMDS_VtkEdge.cxx
src/SMDS/SMDS_VtkEdge.hxx
src/SMDS/SMDS_VtkFace.cxx
src/SMDS/SMDS_VtkFace.hxx
src/SMDS/SMDS_VtkVolume.cxx
src/SMDS/SMDS_VtkVolume.hxx
src/SMESHDS/SMESHDS_SubMesh.cxx

index 9a04613b394b6663d8e378c79d02e9ac699d8ffd..34520f8289ed873912bb0a5b3c55a4b16fae1e4f 100644 (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) \
diff --git a/src/OBJECT/SMESH_vtkPVUpdateSuppressor.cxx b/src/OBJECT/SMESH_vtkPVUpdateSuppressor.cxx
new file mode 100644 (file)
index 0000000..a9fd819
--- /dev/null
@@ -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;
+}
diff --git a/src/OBJECT/SMESH_vtkPVUpdateSuppressor.h b/src/OBJECT/SMESH_vtkPVUpdateSuppressor.h
new file mode 100644 (file)
index 0000000..bf023a4
--- /dev/null
@@ -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
index 39837410d2da64d0af40dec16dd91476cdeb42f8..44326fe5b9cfc321329a0ec82b62a5e17996acb8 100644 (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 = \
index 7239155356e88cacbae78ea30064b799d00b1a92..c6f18287e5ee81d0915ecfd591394cbf464d1f29 100644 (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);
+  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());
+
+    SMDS_MeshFace * face = 0;
+    SMDS_VtkFace *facevtk = myFacePool->getNew();
+    facevtk->init(nodeIds, this);
+    face = facevtk;
     adjustmyCellsCapacity(ID);
-  myCells[ID] = face;
-  myInfo.myNbQuadTriangles++;
+    myCells[ID] = face;
+    myInfo.myNbQuadTriangles++;
 
-  if (!registerElement(ID, face)) {
-    RemoveElement(face, false);
-    face = NULL;
+    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);
+  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());
+
+    SMDS_MeshFace * face = 0;
+    SMDS_VtkFace *facevtk = myFacePool->getNew();
+    facevtk->init(nodeIds, this);
+    face = facevtk;
     adjustmyCellsCapacity(ID);
-  myCells[ID] = face;
-  myInfo.myNbQuadQuadrangles++;
+    myCells[ID] = face;
+    myInfo.myNbQuadQuadrangles++;
 
-  if (!registerElement(ID, face)) {
-    RemoveElement(face, false);
-    face = NULL;
+    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()
index c8045954d65be6aa5c9878d7efa2782482d2192c..7465a1a8d2addd358e85d5aec5fddd5e7d0d621f 100644 (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;
 }
index 7a2b682a1590f770578e014c9a32c078f18306ee..1c219a27d61e1a077bb6941aeae9b65320462411 100644 (file)
@@ -1,82 +1,97 @@
 
 
 #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()
-{
-}
+//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_CellLinks::~SMDS_CellLinks()
+SMDS_UnstructuredGrid* SMDS_UnstructuredGrid::New()
 {
+       MESSAGE("SMDS_UnstructuredGrid::New");
+  return new SMDS_UnstructuredGrid();
 }
 
-/*! initialize an SMDS_CellLinks instance instead of a vtkCellLinks instance
- *
- */
-void SMDS_UnstructuredGrid::BuildLinks()
+SMDS_UnstructuredGrid::SMDS_UnstructuredGrid() : vtkUnstructuredGrid()
 {
-  // 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()
+SMDS_UnstructuredGrid::~SMDS_UnstructuredGrid()
 {
-  return static_cast<SMDS_CellLinks*>(this->Links);
 }
 
-SMDS_UnstructuredGrid* SMDS_UnstructuredGrid::New()
-{
-  return new SMDS_UnstructuredGrid();
-}
 
-SMDS_UnstructuredGrid::SMDS_UnstructuredGrid() : vtkUnstructuredGrid()
+unsigned long SMDS_UnstructuredGrid::GetMTime()
 {
+       unsigned long mtime = vtkUnstructuredGrid::GetMTime();
+       MESSAGE("vtkUnstructuredGrid::GetMTime: " << mtime);
+       return mtime;
 }
 
-SMDS_UnstructuredGrid::~SMDS_UnstructuredGrid()
+void SMDS_UnstructuredGrid::UpdateInformation()
 {
+       MESSAGE("SMDS_UnstructuredGrid::UpdateInformation");
+       return vtkUnstructuredGrid::UpdateInformation();
 }
-
-
index aba1c52014bf5c9e8e445e1a45cb689a626037f0..ce4fed74c0af77162fb38a086cdd5cb95c182a39 100644 (file)
@@ -9,27 +9,30 @@
 #define        _SMDS_UNSTRUCTUREDGRID_HXX
 
 #include <vtkUnstructuredGrid.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();
-};
+//#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_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();
index 497f649aa78de01fb3104ca0f217c8eb4fbb8155..8d6fe266ff64c242dea9026478bb483b465e7f34 100644 (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;
index 9051ce0007364abb846b09067281a07ef3f6ed6e..3a98cfac9d8defe6ee0e3708650f8bcd78fc12be 100644 (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;
index d35f635421c596ca2158158d400d5afa01e3d6d6..75a96b966ecf4eb33cc1fad64a4b7f0d3f885fe6 100644 (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
index a87ed3ff36f7778d156c6d18e04e2fb3d205ee99..f3772114105805cc6c4e8f0450e8e3c0318c4541 100644 (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
index 57ff907f4b645dd24ad60433bf76ec08b0b53def..ad53647cc5512bf63cf61c851bb84ab0c0d34ab9 100644 (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
index 08897bc799af9552f43d2c01dcdabcbf8fe1ff9d..e371396b9c8991bfecde2e5e8612d9ac412cbb7d 100644 (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
index aa0b5d79bed29bc4a4ffee9952989d5bd2c37f50..ebcc20851af4fe585504a0b7a2ce9b557b5d66d5 100644 (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;
 }
index 683bfb1d74e2438b6fdfd1ce7f92349c3eef1e08..078533ba69cac31eb8b264c3e20f65d118253a24 100644 (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
index 6093089a460f04cc04b9ae05e610f0acfd573ecd..f06398de151fbfb4df7115723400c92ab44afd3b 100644 (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));
 }