//---------------------------------------------------------------
- typedef vtkIdType TCellID;
- typedef vtkIdType TLocalPntID;
- typedef std::pair<TCellID,TLocalPntID> TGaussPointID;
-
- struct TGaussMesh: virtual TIDMapper
- {
- virtual
- TGaussPointID
- GetObjID(int theVtkI) const = 0;
- };
+ struct TGaussMesh: virtual TGaussPtsIDMapper
+ {};
//---------------------------------------------------------------
typedef std::map<TName,PFamily> TFamilyMap;
typedef std::map<TName,PField> TFieldMap;
- struct TMeshOnEntity: virtual TIDMapper
+ struct TMeshOnEntity: virtual TNamedIDMapper
{
TGaussMeshMap myGaussMeshMap;
TProfileMap myProfileMap;
#ifdef _DEBUG_
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
+static int MYDEBUGWITHFILES = 1;
//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
TAppendFilter
::GetVTKOutput()
{
+ GetFilter()->Update();
return GetFilter()->GetOutput();
}
return -1;
}
+ std::string
+ TNamedPointCoords
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ return "";
+ }
+
//---------------------------------------------------------------
TMeshImpl::TMeshImpl():
- myNamedPointCoords(new TNamedPointCoords()),
myPoints(vtkPoints::New()),
myNbPoints(0)
{
return GetFilter()->GetOutput()->GetCell(aVtkID);
}
+ TVTKOutput*
+ TProfileImpl
+ ::GetVTKOutput()
+ {
+ return mySource.GetVTKOutput();
+ }
//---------------------------------------------------------------
TGaussSubMeshImpl::TGaussSubMeshImpl():
//---------------------------------------------------------------
TGaussMeshImpl
- ::TGaussMeshImpl()
- {
- myParentMesh=0;
- }
+ ::TGaussMeshImpl():
+ myParent(NULL)
+ {}
TGaussPointID
TGaussMeshImpl
return aSubMeshImpl.GetObjID(anInputID);
}
- void TGaussMeshImpl::SetParentMesh(VISU::TMeshOnEntityImpl* theMesh)
+ TVTKOutput*
+ TGaussMeshImpl
+ ::GetVTKOutput()
{
- myParentMesh=theMesh;
+ return mySource.GetVTKOutput();
}
- VISU::TMeshOnEntityImpl* TGaussMeshImpl::GetParentMesh()
+
+ TNamedIDMapper*
+ TGaussMeshImpl::
+ GetParent()
{
- return myParentMesh;
+ return myParent;
}
//---------------------------------------------------------------
return myStartID + theID;
}
+ std::string
+ TSubMeshImpl
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ return "";
+ }
//---------------------------------------------------------------
vtkIdType
return aSubMesh->GetElemObjID(aID);
}
+ std::string
+ TMeshOnEntityImpl
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ return myNamedPointCoords->GetNodeName(theObjID);
+ }
+
+ std::string
+ TMeshOnEntityImpl
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ vtkIdType anInputID;
+ const TVTKAppendFilter& anAppendFilter = GetFilter();
+ vtkIdType aID = anAppendFilter->GetCellInputID(theObjID,anInputID);
+ const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputID];
+ return aSubMesh->GetElemName(aID);
+ }
//---------------------------------------------------------------
vtkIdType
return myNamedPointCoords->GetVTKID(theID);
}
+ TVTKOutput*
+ TFamilyImpl
+ ::GetVTKOutput()
+ {
+ return TSource::GetVTKOutput();
+ }
+
//---------------------------------------------------------------
TNbASizeCells
anAppendFilter->AddInput(aSource.GetPointer());
}
anAppendFilter->Update(); // Fix on VTK
- theGaussMesh->SetParentMesh(theMeshOnEntity.get());
+
+ theGaussMesh->myParent = theMeshOnEntity.get();
+
vtkDataSet* aSource = anAppendFilter->GetOutput();
INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
virtual
vtkIdType
GetVTKID(vtkIdType theID) const;
+
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
};
typedef SharedPtr<TNamedPointCoords> PNamedPointCoords;
//---------------------------------------------------------------
- struct TMeshImpl: virtual TMesh, virtual TIsVTKDone
+ struct TMeshImpl: virtual TMesh,
+ virtual TIsVTKDone
{
PNamedPointCoords myNamedPointCoords;
typedef TVector<vtkIdType> TSubMeshID;
typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus;
- struct TSubProfileImpl: virtual TSubProfile, virtual TSource
+ struct TSubProfileImpl: virtual TSubProfile,
+ virtual TSource
{
TSubProfileImpl();
typedef TVector<PSubProfileImpl> TSubProfileArr;
typedef std::map<vtkIdType,PSubProfileImpl> TGeom2SubProfile;
- struct TProfileImpl: virtual TProfile, virtual TAppendFilter
+ struct TProfileImpl: virtual TProfile,
+ virtual TAppendFilter
{
TProfileImpl();
bool myIsAll;
virtual
TVTKOutput*
- GetVTKOutput()
- {
- return mySource.GetVTKOutput();
- }
+ GetVTKOutput();
TID2ID myElemObj2VTKID;
TSubProfileArr mySubProfileArr;
//---------------------------------------------------------------
- struct TGaussSubMeshImpl: virtual TGaussSubMesh, virtual TSource
+ struct TGaussSubMeshImpl: virtual TGaussSubMesh,
+ virtual TSource
{
TGaussSubMeshImpl();
typedef TVector<PGaussSubMeshImpl> TGaussSubMeshArr;
typedef std::map<vtkIdType,PGaussSubMeshImpl> TGeom2GaussSubMesh;
- struct TGaussMeshImpl: virtual TGaussMesh, virtual TAppendFilter
+ struct TGaussMeshImpl: virtual TGaussMesh,
+ virtual TAppendFilter
{
TGaussMeshImpl();
virtual
TGaussPointID
- GetObjID(int theVtkI) const;
+ GetObjID(vtkIdType theID) const;
virtual
TVTKOutput*
- GetVTKOutput()
- {
- return mySource.GetVTKOutput();
- }
-
- void SetParentMesh(VISU::TMeshOnEntityImpl* theMesh);
-
- VISU::TMeshOnEntityImpl* GetParentMesh();
+ GetVTKOutput();
- TGaussSubMeshArr myGaussSubMeshArr;
+ virtual
+ TNamedIDMapper*
+ GetParent();
TSource mySource;
+ TNamedIDMapper* myParent;
+ TGaussSubMeshArr myGaussSubMeshArr;
TGeom2GaussSubMesh myGeom2GaussSubMesh;
- TMeshOnEntityImpl* myParentMesh;
};
typedef SharedPtr<TGaussMeshImpl> PGaussMeshImpl;
vtkIdType
GetElemObjID(vtkIdType theID) const;
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
+
vtkIdType myStartID;
TCell2Connect myCell2Connect;
};
typedef std::map<vtkIdType,PSubMeshImpl> TGeom2SubMesh;
typedef TVector<PSubMeshImpl> TSubMeshArr;
- struct TMeshOnEntityImpl: virtual TMeshOnEntity, virtual TAppendFilter, virtual TSizeCounter
+ struct TMeshOnEntityImpl: virtual TMeshOnEntity,
+ virtual TAppendFilter,
+ virtual TSizeCounter
{
virtual
vtkIdType
vtkIdType
GetElemObjID(vtkIdType theID) const;
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
+
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
+
TID2ID myElemObj2VTKID;
TSubMeshArr mySubMeshArr;
PNamedPointCoords myNamedPointCoords;
//---------------------------------------------------------------
typedef std::map<vtkIdType,TSubMeshID> TGeom2SubMeshID;
- struct TFamilyImpl: virtual TFamily, virtual TSource
+ struct TFamilyImpl: virtual TFamily,
+ virtual TSource
{
vtkIdType
GetNodeObjID(vtkIdType theID) const ;
virtual
TVTKOutput*
- GetVTKOutput()
- {
- return TSource::GetVTKOutput();
- }
+ GetVTKOutput();
PNamedPointCoords myNamedPointCoords;
TID2ID myElemObj2VTKID;
typedef std::pair<vtkIdType,vtkIdType> TNbASizeCells;
typedef TVector<PFamilyImpl> TFamilyArr;
- struct TGroupImpl: virtual TGroup, virtual TAppendFilter
+ struct TGroupImpl: virtual TGroup,
+ virtual TAppendFilter
{
TNbASizeCells
GetNbASizeCells() const;
#include "MED_SharedPtr.hxx"
#include <vtkSystemIncludes.h>
+#include <string>
class vtkUnstructuredGrid;
class vtkCell;
};
typedef SharedPtr<TIDMapper> PIDMapper;
+
+ //---------------------------------------------------------------
+ struct TNamedIDMapper: virtual TIDMapper
+ {
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const = 0;
+
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const = 0;
+ };
+ typedef SharedPtr<TNamedIDMapper> PNamedIDMapper;
+
+
+ //---------------------------------------------------------------
+ typedef vtkIdType TCellID;
+ typedef vtkIdType TLocalPntID;
+ typedef std::pair<TCellID,TLocalPntID> TGaussPointID;
+
+ struct TGaussPtsIDMapper: virtual TIDMapper
+ {
+ virtual
+ TGaussPointID
+ GetObjID(vtkIdType theID) const = 0;
+
+ virtual
+ TNamedIDMapper*
+ GetParent() = 0;
+ };
+ typedef SharedPtr<TGaussPtsIDMapper> PGaussPtsIDMapper;
+
+ //---------------------------------------------------------------
}
#endif
}
+ //---------------------------------------------------------------
+ void
+ TMEDNamedPointCoords
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim,
+ const MED::PNodeInfo& theNodeInfo)
+ {
+ if(theNodeInfo->IsElemNum())
+ TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum);
+ else
+ TNamedPointCoords::Init(theNbPoints,theDim);
+
+ if(theNodeInfo->IsElemNames() && theNbPoints > 0){
+ myPointNames.resize(theNbPoints);
+ for(vtkIdType anID = 0; anID < theNbPoints; anID++)
+ myPointNames[anID] = theNodeInfo->GetElemName(anID);
+ }
+ }
+
+ std::string
+ TMEDNamedPointCoords
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ if(myPointNames.empty())
+ return TNamedPointCoords::GetNodeName(theObjID);
+ return myPointNames[theObjID];
+ }
+
+
//---------------------------------------------------------------
vtkIdType
TMEDSubProfile
//---------------------------------------------------------------
+ void
+ TMEDSubMesh
+ ::Init(const MED::PElemInfo& theElemInfo)
+ {
+ myIsElemNum = theElemInfo->IsElemNum();
+ myElemNum = theElemInfo->myElemNum;
+ if(theElemInfo->IsElemNames()){
+ TInt aNbElem = theElemInfo->GetNbElem();
+ myElemNames.resize(aNbElem);
+ for(TInt anID = 0; anID < aNbElem; anID++){
+ myElemNames[anID] = theElemInfo->GetElemName(anID);
+ }
+ }
+ }
+
vtkIdType
TMEDSubMesh
::GetElemObjID(vtkIdType theID) const
else
return TSubMeshImpl::GetElemObjID(theID);
}
+
+ std::string
+ TMEDSubMesh
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ if(myElemNames.empty())
+ return TSubMeshImpl::GetElemName(theObjID);
+ else
+ return myElemNames[theObjID];
+ }
}
aMesh->myNbPoints = aNodeInfo->GetNbElem();
aMesh->myMeshInfo = aMeshInfo;
aMesh->myEntityInfo = aEntityInfo;
-
+ aMesh->myNamedPointCoords(new TMEDNamedPointCoords());
+
INITMSG(MYDEBUG,"aMeshName = '"<<aMeshName<<
"'; myNbPoints = "<<aMesh->myNbPoints<<
"; aDim = "<<aDim<<"\n");
TInt aNbElem = aNodeInfo->GetNbElem();
TInt aDim = theMesh->myDim;
- TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- if(EBooleen anIsNodeNum = aNodeInfo->IsElemNum())
- aCoords.Init(aNbElem,aDim,aNodeInfo->myElemNum);
- else
- aCoords.Init(aNbElem,aDim);
+ PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
+ TMEDNamedPointCoords& aCoords = aNamedPointCoords;
+ aCoords.Init(aNbElem,aDim,aNodeInfo);
for(int iDim = 0; iDim < aDim; iDim++)
aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim);
TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
PMEDSubMesh aSubMesh = aGeom2SubMesh[VTK_VERTEX](new TMEDSubMesh());
-
- aSubMesh->myIsElemNum = aNodeInfo->IsElemNum();
- aSubMesh->myElemNum = aNodeInfo->myElemNum;
+
+ aSubMesh->Init(aNodeInfo);
aSubMesh->myNbCells = theMesh->myNbPoints;
aSubMesh->myCellsSize = 2*theMesh->myNbPoints;
if(aNbElem > 0){
PMEDSubMesh aSubMesh = aGeom2SubMesh[aVGeom](new TMEDSubMesh());
- aSubMesh->myIsElemNum = aPolygoneInfo->IsElemNum();
- aSubMesh->myElemNum = aPolygoneInfo->myElemNum;
+ aSubMesh->Init(aPolygoneInfo);
aSubMesh->myNbCells = aNbElem;
TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
if(aNbElem > 0){
PMEDSubMesh aSubMesh = aGeom2SubMesh[aVGeom](new TMEDSubMesh());
- aSubMesh->myIsElemNum = aPolyedreInfo->IsElemNum();
- aSubMesh->myElemNum = aPolyedreInfo->myElemNum;
+ aSubMesh->Init(aPolyedreInfo);
aSubMesh->myNbCells = aNbElem;
TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect;
if(aNbElem > 0){
PMEDSubMesh aSubMesh = aGeom2SubMesh[aVGeom](new TMEDSubMesh());
- aSubMesh->myIsElemNum = aCellInfo->IsElemNum();
- aSubMesh->myElemNum = aCellInfo->myElemNum;
+ aSubMesh->Init(aCellInfo);
aSubMesh->myNbCells = aNbElem;
aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1);
namespace VISU
{
+ typedef TVector<TName> TNames;
+
+ //---------------------------------------------------------------
+ class TMEDNamedPointCoords: public virtual TNamedPointCoords
+ {
+ TNames myPointNames;
+ public:
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim,
+ const MED::PNodeInfo& theNodeInfo);
+
+ virtual
+ std::string
+ GetNodeName(vtkIdType theObjID) const;
+ };
+ typedef SharedPtr<TMEDNamedPointCoords> PMEDNamedPointCoords;
+
+
//---------------------------------------------------------------
struct TMEDMesh: virtual TMeshImpl
{
MED::EBooleen myIsElemNum;
MED::TElemNum myElemNum;
+ TNames myElemNames;
+
+ void
+ Init(const MED::PElemInfo& theElemInfo);
virtual
vtkIdType
GetElemObjID(vtkIdType theID) const;
+
+ virtual
+ std::string
+ GetElemName(vtkIdType theObjID) const;
};
typedef SharedPtr<TMEDSubMesh> PMEDSubMesh;
#include <vtkCell.h>
#include <vtkMath.h>
-#include "VISU_Convertor_impl.hxx"
//
///////////////////////////////////////////////////////////////////////////
//
mySphereActorSelected->GetProperty()->SetColor(aColorSelected);
//
// Cell
- myCellSource=vtkUnstructuredGrid::New();
+ myCellSource = vtkUnstructuredGrid::New();
myCellSource->Allocate();
- myCellMapper=vtkDataSetMapper::New();
- myCellActor=vtkActor::New();
- //
myCellSource->Delete();
+ //
+ myCellMapper = vtkDataSetMapper::New();
myCellMapper->Delete();
+ //
+ myCellActor = vtkActor::New();
myCellActor->Delete();
//
myCellMapper->SetInput(myCellSource.GetPointer());
myCellActor->SetMapper(myCellMapper.GetPointer());
myCellActor->SetVisibility(0);
myCellActor->SetPickable(0);
-
- float aColorCell[3]={.9,.9,.9};
- vtkProperty* pPropertyCell=myCellActor->GetProperty();
- pPropertyCell->SetColor(aColorCell);
- pPropertyCell->SetRepresentationToWireframe();
+ //
+ myCellActor->GetProperty()->SetAmbient(1.0);
+ myCellActor->GetProperty()->SetDiffuse(0.0);
+ myCellActor->GetProperty()->SetRepresentationToWireframe();
}
VISU_GaussPtsAct
{
myTextActor->SetVisibility(false);
mySphereActor->SetVisibility(false);
- myCursorPyramid->SetVisibility(0);
+ myCursorPyramid->SetVisibility(false);
+ myCellActor->SetVisibility(false);
if(theSelectionEvent->mySelectionMode == ActorSelection || !theIsHighlight)
return Superclass::PreHighlight(theSelector,theInteractorStyle,theSelectionEvent,theIsHighlight);
std::ostringstream aStr;
aStr<<"Global ID: "<<anObjId;
+ const VISU::PGaussMesh& aGaussMesh = myGaussPointsPL->GetGaussMesh();
+ VISU::TNamedIDMapper* aParent = aGaussMesh->GetParent();
+
VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
VISU::TCellID aCellID = aGaussPointID.first;
VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
aStr<<"\nParentCellID: "<<aCellID;
+ //aStr<<"\nParentCellName: '"<<aParent->GetElemName(aCellID)<<"'";
aStr<<"\nLocalPntID: "<<aLocalPntID;
vtkDataSet* aDataSet = GetInput();
// function : Highlight
// purpose :
//==================================================================
-bool VISU_GaussPtsAct::Highlight(SVTK_Selector* theSelector,
- vtkInteractorStyle* theInteractorStyle,
- SVTK_SelectionEvent* theSelectionEvent,
- bool theIsHighlight)
+bool
+VISU_GaussPtsAct
+::Highlight(SVTK_Selector* theSelector,
+ vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
{
int aTextVisibility = myTextActor->GetVisibility();
int aSphereVisibility = mySphereActor->GetVisibility();
//
if(aSelectionMode == CellSelection){
// Hilighting an element from the parent Mesh
- int k, aNbPoints, aIDs[20];
- float *pX;
- vtkIdType aCellID;
- vtkCell* pCell;
- vtkPoints *pPoints;
- VISU::TMeshOnEntityImpl* pMeshOnEntityImpl;
- //
- const VISU::PGaussMesh& aGaussMesh=myGaussPointsPL->GetGaussMesh();
- VISU::TGaussMeshImpl* pGaussMeshImpl=
- dynamic_cast<VISU::TGaussMeshImpl*>(aGaussMesh.get());
- //
- VISU::TGaussPointID anGPID= aGaussMesh->GetObjID(anObjId);
- aCellID=anGPID.first;
-
- pMeshOnEntityImpl=pGaussMeshImpl->GetParentMesh();
- pCell=pMeshOnEntityImpl->GetElemCell(aCellID);
- //
- pPoints=pCell->GetPoints();
- //
- aNbPoints=pCell->GetNumberOfPoints();
- for (k=0; k<aNbPoints; ++k) {
- pX=pPoints->GetPoint(k);
- aIDs[k]=k;
- }
- myCellSource->Initialize();
- myCellSource->Allocate();
- myCellSource->SetPoints(pCell->GetPoints());
- myCellSource->InsertNextCell(pCell->GetCellType(), aNbPoints, aIDs);
- //
- vtkProperty* pPropertyCell=myCellActor->GetProperty();
- pPropertyCell->SetAmbient(1.0);
- pPropertyCell->SetDiffuse(0.0);
- pPropertyCell->SetRepresentationToWireframe();
- if (theSelector->HasIndex(myIO)) {
+ if(theSelector->HasIndex(myIO)){
+ const VISU::PGaussMesh& aGaussMesh = myGaussPointsPL->GetGaussMesh();
+ VISU::TNamedIDMapper* aParent = aGaussMesh->GetParent();
+
+ myCellSource->Reset();
+ myCellSource->Modified(); // a VTK bug
+ myCellSource->SetPoints(aParent->GetVTKOutput()->GetPoints());
+
+ VISU::TGaussPointID aGaussPointID = aGaussMesh->GetObjID(anObjId);
+ vtkIdType aCellID = aGaussPointID.first;
+ vtkCell* aCell = aParent->GetElemCell(aCellID);
+ myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+
myCellActor->SetVisibility(1);
}
- else {
- myCellActor->SetVisibility(0);
- }
}
return bRet;