From 8711c19cef98f6547804aa3b74e6773d0d1f68c7 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 16 May 2007 14:57:05 +0000 Subject: [PATCH] To fix regression in selection of GaussPoints --- src/CONVERTOR/VISU_AppendFilter.cxx | 2 +- src/CONVERTOR/VISU_AppendFilterUtilities.cxx | 2 +- src/CONVERTOR/VISU_AppendPolyData.cxx | 14 +++-- src/CONVERTOR/VISU_ConvertorUtils.cxx | 10 ++-- src/CONVERTOR/VISU_Convertor_impl.cxx | 59 ++++++++++++++++---- src/CONVERTOR/VISU_MedConvertor.cxx | 5 +- src/CONVERTOR/VISU_MedConvertor.hxx | 3 +- src/CONVERTOR/VISU_PointCoords.cxx | 28 +++++----- src/CONVERTOR/VISU_PointCoords.hxx | 20 +++---- src/CONVERTOR/VISU_Structures_impl.cxx | 29 ++++++++-- src/CONVERTOR/VISU_Structures_impl.hxx | 12 +++- 11 files changed, 123 insertions(+), 61 deletions(-) diff --git a/src/CONVERTOR/VISU_AppendFilter.cxx b/src/CONVERTOR/VISU_AppendFilter.cxx index 7207f68b..604e38c1 100644 --- a/src/CONVERTOR/VISU_AppendFilter.cxx +++ b/src/CONVERTOR/VISU_AppendFilter.cxx @@ -56,7 +56,7 @@ VISU_AppendFilter vtkInformationVector *theOutputVector) { bool anIsExecuted = false; - if(GetNumberOfInputConnections(0) > 1) + if(GetNumberOfInputConnections(0) > 1 || IsMergingInputs() || IsMappingInputs()) anIsExecuted = VISU::UnstructuredGridRequestData(theInputVector, this->GetNumberOfInputConnections(0), theOutputVector, diff --git a/src/CONVERTOR/VISU_AppendFilterUtilities.cxx b/src/CONVERTOR/VISU_AppendFilterUtilities.cxx index 18b58571..d09b24a5 100644 --- a/src/CONVERTOR/VISU_AppendFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_AppendFilterUtilities.cxx @@ -312,8 +312,8 @@ namespace if(vtkDataSet *aDataSet = VISU::GetInput(theInputVector, anInputId)){ vtkIdType aNbCells = aDataSet->GetNumberOfCells(); for(vtkIdType aCellId = 0; aCellId < aNbCells; aCellId++){ - aDataArray->SetValue(aTupleId++, anInputId); aDataArray->SetValue(aTupleId++, aCellId); + aDataArray->SetValue(aTupleId++, anInputId); } } } diff --git a/src/CONVERTOR/VISU_AppendPolyData.cxx b/src/CONVERTOR/VISU_AppendPolyData.cxx index 728bbb94..6a549521 100644 --- a/src/CONVERTOR/VISU_AppendPolyData.cxx +++ b/src/CONVERTOR/VISU_AppendPolyData.cxx @@ -55,12 +55,14 @@ VISU_AppendPolyData vtkInformationVector **theInputVector, vtkInformationVector *theOutputVector) { - bool anIsExecuted = VISU::PolyDataRequestData(theInputVector, - this->GetNumberOfInputConnections(0), - theOutputVector, - GetSharedPointSet(), - IsMergingInputs(), - IsMappingInputs()); + bool anIsExecuted = false; + if(GetNumberOfInputConnections(0) > 1 || IsMergingInputs() || IsMappingInputs()) + anIsExecuted = VISU::PolyDataRequestData(theInputVector, + this->GetNumberOfInputConnections(0), + theOutputVector, + GetSharedPointSet(), + IsMergingInputs(), + IsMappingInputs()); if(!anIsExecuted) anIsExecuted = Superclass::RequestData(theRequest, theInputVector, diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index 35db58b1..85f49eec 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -362,8 +362,8 @@ namespace VISU GetObjID(vtkDataSet *theDataSet, vtkIdType theID) { theDataSet->Update(); - vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData(); - if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_GAUSS_MAPPER")){ + vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); + if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){ if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ vtkIdType anID = 2 * theID; TCellID aCellID = anIntArray->GetValue(anID); @@ -380,13 +380,13 @@ namespace VISU GetInputCellID(vtkDataSet *theDataSet, vtkIdType theObjID) { theDataSet->Update(); - vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData(); + vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_INPUTS_MAPPER")){ if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ vtkIdType aVTKID = GetElemVTKID(theDataSet, theObjID); vtkIdType aTupleID = 2 * aVTKID; - TInputID anInputID = anIntArray->GetValue(aTupleID); - TCellID aCellID = anIntArray->GetValue(aTupleID + 1); + TCellID aCellID = anIntArray->GetValue(aTupleID); + TInputID anInputID = anIntArray->GetValue(aTupleID + 1); return TInputCellID(anInputID, aCellID); } } diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 9f67b8fe..c2cd8893 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -414,9 +414,9 @@ namespace //--------------------------------------------------------------- void - GetSource(const VISU::PPolyData& theSource, - const VISU::PGaussSubMeshImpl& theGaussSubMesh, - const VISU::PMeshOnEntityImpl& theMeshOnEntity) + GetGaussSubMeshSource(const VISU::PPolyData& theSource, + const VISU::PGaussSubMeshImpl& theGaussSubMesh, + const VISU::PMeshOnEntityImpl& theMeshOnEntity) { vtkCellArray* aConnectivity = vtkCellArray::New(); vtkIdType aCellsSize = theGaussSubMesh->myCellsSize; @@ -438,6 +438,38 @@ namespace aSource->SetVerts(aConnectivity); aConnectivity->Delete(); + + { + vtkIdType aNbTuples = aNbPoints; + vtkIntArray *aDataArray = vtkIntArray::New(); + aDataArray->SetName("VISU_POINTS_MAPPER"); + aDataArray->SetNumberOfComponents(2); + aDataArray->SetNumberOfTuples(aNbTuples); + int *aDataArrayPtr = aDataArray->GetPointer(0); + for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ + vtkIdType aGlobalID = theGaussSubMesh->GetGlobalID(aTupleId); + *aDataArrayPtr++ = aGlobalID; + *aDataArrayPtr++ = 0; + } + aSource->GetPointData()->AddArray(aDataArray); + aDataArray->Delete(); + } + + { + vtkIdType aNbTuples = aNbPoints; + vtkIntArray *aDataArray = vtkIntArray::New(); + aDataArray->SetName("VISU_CELLS_MAPPER"); + aDataArray->SetNumberOfComponents(2); + aDataArray->SetNumberOfTuples(aNbTuples); + int *aDataArrayPtr = aDataArray->GetPointer(0); + for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){ + VISU::TGaussPointID aGaussPointID = theGaussSubMesh->GetObjID(aTupleId); + *aDataArrayPtr++ = aGaussPointID.first; + *aDataArrayPtr++ = aGaussPointID.second; + } + aSource->GetCellData()->AddArray(aDataArray); + aDataArray->Delete(); + } } @@ -460,7 +492,7 @@ namespace INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<myGeom<GetSource(); - GetSource(aSource, theGaussSubMesh, theMeshOnEntity); + GetGaussSubMeshSource(aSource, theGaussSubMesh, theMeshOnEntity); INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<GetNumberOfPoints()<GetNumberOfCells()<GetFilter(); const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh; VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); - for(; anIter != aGeom2GaussSubMesh.end(); anIter++){ + for(vtkIdType aStartID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){ VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second; if(aGaussSubMesh->myStatus == VISU::eRemoveAll) continue; - + + aGaussSubMesh->myStartID = aStartID; + GetGaussSubMesh(theMesh, theMeshOnEntity, theGaussMesh, aGaussSubMesh); const VISU::PPolyData& aSource = aGaussSubMesh->GetSource(); - + aStartID += aSource->GetNumberOfCells(); + anAppendFilter->AddInput(aSource.GetPointer()); } anAppendFilter->Update(); // Fix on VTK @@ -662,7 +697,7 @@ VISU_Convertor_impl if(MYDEBUGWITHFILES){ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; - aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk"; + aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk"; VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName); } @@ -730,7 +765,7 @@ VISU_Convertor_impl std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1(); std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; - aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk"; + aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk"; VISU::WriteToFile(aSource.GetPointer(),aFileName); } @@ -813,7 +848,7 @@ VISU_Convertor_impl std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1(); std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; - aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk"; + aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk"; VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName); } } @@ -919,7 +954,7 @@ VISU_Convertor_impl std::string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + - aFieldName + dtos("-%d", theStampsNum) + "-Conv.vtk"; + aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk"; VISU::WriteToFile(anOutput,aFileName); } if(MYVTKDEBUG){ @@ -1008,7 +1043,7 @@ VISU_Convertor_impl std::string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + - aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; + aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk"; VISU::WriteToFile(anOutput, aFileName); } if(MYVTKDEBUG){ diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index a2f0f396..b4d1f741 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1218,8 +1218,7 @@ namespace VISU //--------------------------------------------------------------- TGaussPointID TMEDGaussSubMesh - ::GetObjID(vtkIdType theID, - vtkIdType theStartID) const + ::GetObjID(vtkIdType theID) const { TCellID aCellID = theID / myGauss->myNbPoints; TLocalPntID aLocalPntID = theID % myGauss->myNbPoints; @@ -1227,7 +1226,7 @@ namespace VISU if(myIsElemNum) aCellID = (*myElemNum)[aCellID]; else - aCellID += theStartID; + aCellID += myStartID; return TGaussPointID(aCellID, aLocalPntID); } diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 6935b63f..4b950244 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -236,8 +236,7 @@ namespace VISU virtual TGaussPointID - GetObjID(vtkIdType theID, - vtkIdType theStartID) const; + GetObjID(vtkIdType theID) const; //! Gets memory size used by the instance (bytes). virtual diff --git a/src/CONVERTOR/VISU_PointCoords.cxx b/src/CONVERTOR/VISU_PointCoords.cxx index bfdf7aef..ac1e3dbb 100644 --- a/src/CONVERTOR/VISU_PointCoords.cxx +++ b/src/CONVERTOR/VISU_PointCoords.cxx @@ -127,6 +127,20 @@ namespace VISU return myCoord->GetCoordSlice(theNodeId); } + vtkIdType + TPointCoords + ::GetObjID(vtkIdType theID) const + { + return theID; + } + + vtkIdType + TPointCoords + ::GetVTKID(vtkIdType theID) const + { + return theID; + } + void TPointCoords ::SetVoidArray() const @@ -203,20 +217,6 @@ namespace VISU return myPointsDim[theDim]; } - vtkIdType - TNamedPointCoords - ::GetObjID(vtkIdType theID) const - { - return theID; - } - - vtkIdType - TNamedPointCoords - ::GetVTKID(vtkIdType theID) const - { - return theID; - } - std::string TNamedPointCoords ::GetNodeName(vtkIdType theObjID) const diff --git a/src/CONVERTOR/VISU_PointCoords.hxx b/src/CONVERTOR/VISU_PointCoords.hxx index 6a420ec7..dfb30f2a 100644 --- a/src/CONVERTOR/VISU_PointCoords.hxx +++ b/src/CONVERTOR/VISU_PointCoords.hxx @@ -187,6 +187,16 @@ namespace VISU TCoordSlice GetCoordSlice(vtkIdType theNodeId); + //! Get object number for node by its VTK one + virtual + vtkIdType + GetObjID(vtkIdType theID) const; + + //! Get VTK number for node by its object one + virtual + vtkIdType + GetVTKID(vtkIdType theID) const; + protected: //! An container for coordinates of the nodes /*! @@ -222,16 +232,6 @@ namespace VISU const std::string& GetName(vtkIdType theDim) const; - //! Get object number for node by its VTK one - virtual - vtkIdType - GetObjID(vtkIdType theID) const; - - //! Get VTK number for node by its object one - virtual - vtkIdType - GetVTKID(vtkIdType theID) const; - //! Get name of node by its object number virtual std::string diff --git a/src/CONVERTOR/VISU_Structures_impl.cxx b/src/CONVERTOR/VISU_Structures_impl.cxx index 76b59d96..34e202e8 100644 --- a/src/CONVERTOR/VISU_Structures_impl.cxx +++ b/src/CONVERTOR/VISU_Structures_impl.cxx @@ -601,18 +601,25 @@ namespace VISU TGaussSubMeshImpl ::TGaussSubMeshImpl(): myPointCoords(new TPointCoords()), - myStatus(eNone) + myStatus(eNone), + myStartID(0) {} TGaussPointID TGaussSubMeshImpl - ::GetObjID(vtkIdType theID, - vtkIdType theStartID) const + ::GetObjID(vtkIdType theID) const { - TCellID aCellID = theStartID + theID / myGauss->myNbPoints; + TCellID aCellID = myStartID + theID / myGauss->myNbPoints; TLocalPntID aLocalPntID = theID % myGauss->myNbPoints; - return TGaussPointID(aCellID,aLocalPntID); + return TGaussPointID(aCellID, aLocalPntID); + } + + vtkIdType + TGaussSubMeshImpl + ::GetGlobalID(vtkIdType theID) const + { + return myStartID + theID; } unsigned long int @@ -720,6 +727,11 @@ namespace VISU //--------------------------------------------------------------- + TSubMeshImpl + ::TSubMeshImpl(): + myStartID(0) + {} + vtkIdType TSubMeshImpl ::GetElemObjID(vtkIdType theID) const @@ -747,6 +759,13 @@ namespace VISU } //--------------------------------------------------------------- + TMeshOnEntityImpl + ::TMeshOnEntityImpl() + { + const PAppendFilter& anAppendFilter = GetFilter(); + anAppendFilter->SetMappingInputs(true); + } + vtkIdType TMeshOnEntityImpl ::GetNodeVTKID(vtkIdType theID) const diff --git a/src/CONVERTOR/VISU_Structures_impl.hxx b/src/CONVERTOR/VISU_Structures_impl.hxx index 351b886c..57fc5335 100644 --- a/src/CONVERTOR/VISU_Structures_impl.hxx +++ b/src/CONVERTOR/VISU_Structures_impl.hxx @@ -443,8 +443,11 @@ namespace VISU //! To implement the TGaussPtsIDMapper::GetObjID virtual TGaussPointID - GetObjID(vtkIdType theID, - vtkIdType theStartID) const; + GetObjID(vtkIdType theID) const; + + virtual + vtkIdType + GetGlobalID(vtkIdType theID) const; //! Gets memory size used by the instance (bytes). virtual @@ -460,6 +463,7 @@ namespace VISU */ ESubMeshStatus myStatus; + vtkIdType myStartID; PPointCoords myPointCoords; //!< Keeps coordinates of Gauss Points }; @@ -536,6 +540,8 @@ namespace VISU //! The class is responsible for mapping of cells of defined geometrical type struct TSubMeshImpl: virtual TUnstructuredGridHolder { + TSubMeshImpl(); + //! To implement the TIDMapper::GetElemObjID virtual vtkIdType @@ -565,6 +571,8 @@ namespace VISU virtual TAppendFilterHolder, virtual TSizeCounter { + TMeshOnEntityImpl(); + //! Reimplement the TIDMapper::GetNodeVTKID virtual vtkIdType -- 2.39.2