From: admin Date: Tue, 14 Oct 2003 08:52:00 +0000 (+0000) Subject: This commit was generated by cvs2git to create tag 'V1_2c'. X-Git-Tag: V1_2c X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4a368b20da78d252780218f51140197646c5dc0d;p=modules%2Fvisu.git This commit was generated by cvs2git to create tag 'V1_2c'. Sprout from IMPORT 2003-10-14 08:51:59 UTC nri 'sources v1.2c' Delete: src/OBJECT/VISU_LookupTable.cxx src/OBJECT/VISU_LookupTable.hxx src/OBJECT/VISU_ScalarBarActor.cxx src/OBJECT/VISU_ScalarBarActor.hxx src/VISU_I/VISU_Convertor.cxx src/VISU_I/VISU_Convertor.hxx src/VISU_I/VISU_Convertor_impl.cxx src/VISU_I/VISU_Convertor_impl.hxx src/VISU_I/VISU_DatConvertor.cxx src/VISU_I/VISU_DatConvertor.hxx src/VISU_I/VISU_Extractor.cxx src/VISU_I/VISU_Extractor.hxx src/VISU_I/VISU_FieldTransform.cxx src/VISU_I/VISU_FieldTransform.hxx src/VISU_I/VISU_MedConvertor.cxx src/VISU_I/VISU_MedConvertor.hxx --- diff --git a/src/OBJECT/VISU_LookupTable.cxx b/src/OBJECT/VISU_LookupTable.cxx deleted file mode 100644 index be0f137b..00000000 --- a/src/OBJECT/VISU_LookupTable.cxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_LookupTable.cxx -// Author : Vitaliy Smetannikov -// Module : VISU - -using namespace std; -#include "VISU_LookupTable.hxx" - -VISU_LookupTable *VISU_LookupTable::New() { - vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_LookupTable"); - if(ret) - return (VISU_LookupTable*)ret; - return new VISU_LookupTable; -} - -VISU_LookupTable::VISU_LookupTable(int sze, int ext) - : vtkLookupTable(sze, ext), myScale(1.0) {} - -int VISU_LookupTable::ComputeLogRange(float inRange[2], float outRange[2]){ - if(inRange[0] >= inRange[1]) - return -1; - if(0.0 <= inRange[0] && 0.0 < inRange[1]){ - if(inRange[0] != 0.0) - outRange[0] = log10((double)inRange[0]); - else - outRange[0] = log10((double)inRange[1]*1.0E-6); - outRange[1] = log10((double)inRange[1]); - return 0; - }else if(inRange[0] < 0.0 && inRange[1] <= 0.0){ - outRange[0] = log10((double)-inRange[0]); - outRange[1] = log10((double)-inRange[1]); - return 1; - }else - return -1; -} - -unsigned char* VISU_LookupTable::MapValue(float v) { - if(GetScale() == VTK_SCALE_LOG10) { - float aLowBound = log10(this->TableRange[0]); - v = pow(10.0f,aLowBound + (v - aLowBound)*myScale); - return vtkLookupTable::MapValue(v); - }else{ - v = this->TableRange[0] + (v - this->TableRange[0])*myScale; - return vtkLookupTable::MapValue(v); - } -} diff --git a/src/OBJECT/VISU_LookupTable.hxx b/src/OBJECT/VISU_LookupTable.hxx deleted file mode 100644 index 960b9d55..00000000 --- a/src/OBJECT/VISU_LookupTable.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_LookupTable.h -// Author : Vitaliy Smetannikov -// Module : VISU - -#ifndef VISU_LookupTable_H -#define VISU_LookupTable_H - -//#include -#include "VTKViewer_Common.h" -#include - -class VISU_LookupTable: public vtkLookupTable { - public: - vtkTypeMacro(VISU_LookupTable,vtkLogLookupTable); - static VISU_LookupTable *New(); - - float GetMapScale() { return myScale; } - void SetMapScale(float theScale) { myScale = theScale; Modified(); } - - static int ComputeLogRange(float inRange[2], float outRange[2]); - unsigned char *MapValue(float v); - - protected: - VISU_LookupTable(int sze=256, int ext=256); - ~VISU_LookupTable() {}; - - float myScale; -}; -#endif // VISU_LookupTable_H diff --git a/src/OBJECT/VISU_ScalarBarActor.cxx b/src/OBJECT/VISU_ScalarBarActor.cxx deleted file mode 100644 index 78591002..00000000 --- a/src/OBJECT/VISU_ScalarBarActor.cxx +++ /dev/null @@ -1,575 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_ScalarBarActor.cxx -// Author : Alexey PETROV -// Module : VISU - -using namespace std; -#include "VISU_ScalarBarActor.hxx" - -vtkCxxRevisionMacro(VISU_ScalarBarActor, "$Revision$"); - -vtkCxxSetObjectMacro(VISU_ScalarBarActor,LookupTable,VISU_LookupTable); -vtkCxxSetObjectMacro(VISU_ScalarBarActor,LabelTextProperty,vtkTextProperty); -vtkCxxSetObjectMacro(VISU_ScalarBarActor,TitleTextProperty,vtkTextProperty); - -//------------------------------------------------------------------------------ -VISU_ScalarBarActor* VISU_ScalarBarActor::New(){ - vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_ScalarBarActor"); - if(ret) - return (VISU_ScalarBarActor*)ret; - return new VISU_ScalarBarActor; -} - -VISU_ScalarBarActor::VISU_ScalarBarActor() -{ - this->LookupTable = NULL; - this->Position2Coordinate->SetValue(0.17, 0.8); - - this->PositionCoordinate->SetCoordinateSystemToNormalizedViewport(); - this->PositionCoordinate->SetValue(0.82,0.1); - - this->MaximumNumberOfColors = 64; - this->NumberOfLabels = 5; - this->NumberOfLabelsBuilt = 0; - this->Orientation = VTK_ORIENT_VERTICAL; - this->Title = NULL; - - this->LabelTextProperty = vtkTextProperty::New(); - this->LabelTextProperty->SetFontSize(12); - this->LabelTextProperty->SetBold(1); - this->LabelTextProperty->SetItalic(1); - this->LabelTextProperty->SetShadow(1); - this->LabelTextProperty->SetFontFamilyToArial(); - - this->TitleTextProperty = vtkTextProperty::New(); - this->TitleTextProperty->ShallowCopy(this->LabelTextProperty); - - this->LabelFormat = new char[8]; - sprintf(this->LabelFormat,"%s","%-#6.3g"); - - this->TitleMapper = vtkTextMapper::New(); - this->TitleActor = vtkActor2D::New(); - this->TitleActor->SetMapper(this->TitleMapper); - this->TitleActor->GetPositionCoordinate()-> - SetReferenceCoordinate(this->PositionCoordinate); - - this->TextMappers = NULL; - this->TextActors = NULL; - - this->ScalarBar = vtkPolyData::New(); - this->ScalarBarMapper = vtkPolyDataMapper2D::New(); - this->ScalarBarMapper->SetInput(this->ScalarBar); - this->ScalarBarActor = vtkActor2D::New(); - this->ScalarBarActor->SetMapper(this->ScalarBarMapper); - this->ScalarBarActor->GetPositionCoordinate()-> - SetReferenceCoordinate(this->PositionCoordinate); - this->LastOrigin[0] = 0; - this->LastOrigin[1] = 0; - this->LastSize[0] = 0; - this->LastSize[1] = 0; -} - -void VISU_ScalarBarActor::ReleaseGraphicsResources(vtkWindow *win) -{ - this->TitleActor->ReleaseGraphicsResources(win); - if (this->TextMappers != NULL ) - { - for (int i=0; i < this->NumberOfLabelsBuilt; i++) - { - this->TextActors[i]->ReleaseGraphicsResources(win); - } - } - this->ScalarBarActor->ReleaseGraphicsResources(win); -} - -VISU_ScalarBarActor::~VISU_ScalarBarActor() -{ - if (this->LabelFormat) - { - delete [] this->LabelFormat; - this->LabelFormat = NULL; - } - - this->TitleMapper->Delete(); - this->TitleActor->Delete(); - - if (this->TextMappers != NULL ) - { - for (int i=0; i < this->NumberOfLabelsBuilt; i++) - { - this->TextMappers[i]->Delete(); - this->TextActors[i]->Delete(); - } - delete [] this->TextMappers; - delete [] this->TextActors; - } - - this->ScalarBar->Delete(); - this->ScalarBarMapper->Delete(); - this->ScalarBarActor->Delete(); - - if (this->Title) - { - delete [] this->Title; - this->Title = NULL; - } - - this->SetLookupTable(NULL); - this->SetLabelTextProperty(NULL); - this->SetTitleTextProperty(NULL); -} - -int VISU_ScalarBarActor::RenderOverlay(vtkViewport *viewport) -{ - int renderedSomething = 0; - int i; - - // Everything is built, just have to render - if (this->Title != NULL) - { - renderedSomething += this->TitleActor->RenderOverlay(viewport); - } - this->ScalarBarActor->RenderOverlay(viewport); - if( this->TextActors == NULL) - { - vtkWarningMacro(<<"Need a mapper to render a scalar bar"); - return renderedSomething; - } - - for (i=0; iNumberOfLabels; i++) - { - renderedSomething += this->TextActors[i]->RenderOverlay(viewport); - } - - renderedSomething = (renderedSomething > 0)?(1):(0); - - return renderedSomething; -} - -int VISU_ScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport) -{ - int renderedSomething = 0; - int i; - int size[2]; - - if (!this->LookupTable) - { - vtkWarningMacro(<<"Need a mapper to render a scalar bar"); - return 0; - } - - if (!this->TitleTextProperty) - { - vtkErrorMacro(<<"Need title text property to render a scalar bar"); - return 0; - } - - if (!this->LabelTextProperty) - { - vtkErrorMacro(<<"Need label text property to render a scalar bar"); - return 0; - } - - // Check to see whether we have to rebuild everything - int positionsHaveChanged = 0; - if (viewport->GetMTime() > this->BuildTime || - (viewport->GetVTKWindow() && - viewport->GetVTKWindow()->GetMTime() > this->BuildTime)) - { - // if the viewport has changed we may - or may not need - // to rebuild, it depends on if the projected coords chage - int *barOrigin; - barOrigin = this->PositionCoordinate->GetComputedViewportValue(viewport); - size[0] = - this->Position2Coordinate->GetComputedViewportValue(viewport)[0] - - barOrigin[0]; - size[1] = - this->Position2Coordinate->GetComputedViewportValue(viewport)[1] - - barOrigin[1]; - if (this->LastSize[0] != size[0] || - this->LastSize[1] != size[1] || - this->LastOrigin[0] != barOrigin[0] || - this->LastOrigin[1] != barOrigin[1]) - { - positionsHaveChanged = 1; - } - } - - // Check to see whether we have to rebuild everything - if (positionsHaveChanged || - this->GetMTime() > this->BuildTime || - this->LookupTable->GetMTime() > this->BuildTime || - this->LabelTextProperty->GetMTime() > this->BuildTime || - this->TitleTextProperty->GetMTime() > this->BuildTime) - { - - // Delete previously constructed objects - // - if (this->TextMappers != NULL ) - { - for (i=0; i < this->NumberOfLabelsBuilt; i++) - { - this->TextMappers[i]->Delete(); - this->TextActors[i]->Delete(); - } - delete [] this->TextMappers; - delete [] this->TextActors; - } - - // Build scalar bar object; determine its type - // - VISU_LookupTable *lut = this->LookupTable; //SALOME specific - int isLogTable = lut->GetScale() == VTK_SCALE_LOG10; - - // we hard code how many steps to display - int numColors = this->MaximumNumberOfColors; - float *range = lut->GetRange(); - - int numPts = 2*(numColors + 1); - vtkPoints *pts = vtkPoints::New(); - pts->SetNumberOfPoints(numPts); - vtkCellArray *polys = vtkCellArray::New(); - polys->Allocate(polys->EstimateSize(numColors,4)); - vtkUnsignedCharArray *colors = vtkUnsignedCharArray::New(); - colors->SetNumberOfComponents(3); - colors->SetNumberOfTuples(numColors); - - this->ScalarBarActor->SetProperty(this->GetProperty()); - this->ScalarBar->Initialize(); - this->ScalarBar->SetPoints(pts); - this->ScalarBar->SetPolys(polys); - this->ScalarBar->GetCellData()->SetScalars(colors); - pts->Delete(); polys->Delete(); colors->Delete(); - - // get the viewport size in display coordinates - int *barOrigin, barWidth, barHeight; - barOrigin = this->PositionCoordinate->GetComputedViewportValue(viewport); - size[0] = - this->Position2Coordinate->GetComputedViewportValue(viewport)[0] - - barOrigin[0]; - size[1] = - this->Position2Coordinate->GetComputedViewportValue(viewport)[1] - - barOrigin[1]; - this->LastOrigin[0] = barOrigin[0]; - this->LastOrigin[1] = barOrigin[1]; - this->LastSize[0] = size[0]; - this->LastSize[1] = size[1]; - - // Update all the composing objects - this->TitleActor->SetProperty(this->GetProperty()); - this->TitleMapper->SetInput(this->Title); - if (this->TitleTextProperty->GetMTime() > this->BuildTime) - { - // Shallow copy here so that the size of the title prop is not affected - // by the automatic adjustment of its text mapper's size (i.e. its - // mapper's text property is identical except for the font size - // which will be modified later). This allows text actors to - // share the same text property, and in that case specifically allows - // the title and label text prop to be the same. - this->TitleMapper->GetTextProperty()->ShallowCopy(this->TitleTextProperty); - this->TitleMapper->GetTextProperty()->SetJustificationToCentered(); - } - - // find the best size for the title font - int titleSize[2]; - this->SizeTitle(titleSize, size, viewport); - - // find the best size for the ticks - int labelSize[2]; - this->AllocateAndSizeLabels(labelSize, size, viewport,range); - this->NumberOfLabelsBuilt = this->NumberOfLabels; - - // generate points - float x[3]; x[2] = 0.0; - float delta, val; - if ( this->Orientation == VTK_ORIENT_VERTICAL ) - { - barWidth = size[0] - 4 - labelSize[0]; - barHeight = (int)(0.86*size[1]); - delta=(float)barHeight/numColors; - for (i=0; iSetPoint(2*i,x); - x[0] = barWidth; - pts->SetPoint(2*i+1,x); - } - } - else - { - barWidth = size[0]; - barHeight = (int)(0.4*size[1]); - delta=(float)barWidth/numColors; - for (i=0; iSetPoint(2*i,x); - x[1] = 0; - pts->SetPoint(2*i+1,x); - } - } - - //polygons & cell colors - unsigned char *rgba, *rgb; - vtkIdType ptIds[4]; - for (i=0; iInsertNextCell(4,ptIds); - - if ( isLogTable ){ //SALOME specific - float rgbval = log10(range[0]) + - i*(log10(range[1])-log10(range[0]))/(numColors -1); - rgba = lut->MapValue(rgbval); - }else{ - rgba = lut->MapValue(range[0] + (range[1] - range[0])* - ((float)i /(numColors-1.0))); - } - - rgb = colors->GetPointer(3*i); //write into array directly - rgb[0] = rgba[0]; - rgb[1] = rgba[1]; - rgb[2] = rgba[2]; - } - - // Now position everything properly - // - if (this->Orientation == VTK_ORIENT_VERTICAL) - { - int sizeTextData[2]; - - // center the title - this->TitleActor->SetPosition(size[0]/2, 0.9*size[1]); - - for (i=0; i < this->NumberOfLabels; i++) - { - val = (float)i/(this->NumberOfLabels-1) *barHeight; - this->TextMappers[i]->GetSize(viewport,sizeTextData); - this->TextMappers[i]->GetTextProperty()->SetJustificationToLeft(); - this->TextActors[i]->SetPosition(barWidth+3, - val - sizeTextData[1]/2); - } - } - else - { - this->TitleActor->SetPosition(size[0]/2, - barHeight + labelSize[1] + 0.1*size[1]); - for (i=0; i < this->NumberOfLabels; i++) - { - this->TextMappers[i]->GetTextProperty()->SetJustificationToCentered(); - val = (float)i/(this->NumberOfLabels-1) * barWidth; - this->TextActors[i]->SetPosition(val, barHeight + 0.05*size[1]); - } - } - - this->BuildTime.Modified(); - } - - // Everything is built, just have to render - if (this->Title != NULL) - { - renderedSomething += this->TitleActor->RenderOpaqueGeometry(viewport); - } - this->ScalarBarActor->RenderOpaqueGeometry(viewport); - for (i=0; iNumberOfLabels; i++) - { - renderedSomething += this->TextActors[i]->RenderOpaqueGeometry(viewport); - } - - renderedSomething = (renderedSomething > 0)?(1):(0); - - return renderedSomething; -} - -void VISU_ScalarBarActor::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os,indent); - - if ( this->LookupTable ) - { - os << indent << "Lookup Table:\n"; - this->LookupTable->PrintSelf(os,indent.GetNextIndent()); - } - else - { - os << indent << "Lookup Table: (none)\n"; - } - - if (this->TitleTextProperty) - { - os << indent << "Title Text Property:\n"; - this->TitleTextProperty->PrintSelf(os,indent.GetNextIndent()); - } - else - { - os << indent << "Title Text Property: (none)\n"; - } - - if (this->LabelTextProperty) - { - os << indent << "Label Text Property:\n"; - this->LabelTextProperty->PrintSelf(os,indent.GetNextIndent()); - } - else - { - os << indent << "Label Text Property: (none)\n"; - } - - os << indent << "Title: " << (this->Title ? this->Title : "(none)") << "\n"; - os << indent << "Maximum Number Of Colors: " - << this->MaximumNumberOfColors << "\n"; - os << indent << "Number Of Labels: " << this->NumberOfLabels << "\n"; - os << indent << "Number Of Labels Built: " << this->NumberOfLabelsBuilt << "\n"; - - os << indent << "Orientation: "; - if ( this->Orientation == VTK_ORIENT_HORIZONTAL ) - { - os << "Horizontal\n"; - } - else - { - os << "Vertical\n"; - } - - os << indent << "Label Format: " << this->LabelFormat << "\n"; -} - -void VISU_ScalarBarActor::ShallowCopy(vtkProp *prop) -{ - VISU_ScalarBarActor *a = VISU_ScalarBarActor::SafeDownCast(prop); - if ( a != NULL ) - { - this->SetPosition2(a->GetPosition2()); - this->SetLookupTable(a->GetLookupTable()); - this->SetMaximumNumberOfColors(a->GetMaximumNumberOfColors()); - this->SetOrientation(a->GetOrientation()); - this->SetLabelTextProperty(a->GetLabelTextProperty()); - this->SetTitleTextProperty(a->GetTitleTextProperty()); - this->SetLabelFormat(a->GetLabelFormat()); - this->SetTitle(a->GetTitle()); - this->GetPositionCoordinate()->SetCoordinateSystem( - a->GetPositionCoordinate()->GetCoordinateSystem()); - this->GetPositionCoordinate()->SetValue( - a->GetPositionCoordinate()->GetValue()); - this->GetPosition2Coordinate()->SetCoordinateSystem( - a->GetPosition2Coordinate()->GetCoordinateSystem()); - this->GetPosition2Coordinate()->SetValue( - a->GetPosition2Coordinate()->GetValue()); - } - - // Now do superclass - this->vtkActor2D::ShallowCopy(prop); -} - -void VISU_ScalarBarActor::AllocateAndSizeLabels(int *labelSize, int *size, - vtkViewport *viewport, - float *range) -{ - labelSize[0] = labelSize[1] = 0; - - this->TextMappers = new vtkTextMapper * [this->NumberOfLabels]; - this->TextActors = new vtkActor2D * [this->NumberOfLabels]; - - char string[512]; - - float val; - int i; - - // TODO: this should be optimized, maybe by keeping a list of - // allocated mappers, in order to avoid creation/destruction of - // their underlying text properties (i.e. each time a mapper is - // created, text properties are created and shallow-assigned a font size - // which value might be "far" from the target font size). - - VISU_LookupTable *lut = this->LookupTable; //SALOME specific - int isLogTable = lut->GetScale() == VTK_SCALE_LOG10; - - for (i=0; i < this->NumberOfLabels; i++) - { - this->TextMappers[i] = vtkTextMapper::New(); - - if(isLogTable && 0 < i && i < this->NumberOfLabels - 1){ // SALOME specific - float lval = log10(range[0]) + (float)i/(this->NumberOfLabels-1) * - (log10(range[1])-log10(range[0])); - val = pow(10,lval); - }else{ - val = range[0] + (float)i/(this->NumberOfLabels-1) * (range[1]-range[0]); - } - sprintf(string, this->LabelFormat, val); - this->TextMappers[i]->SetInput(string); - - // Shallow copy here so that the size of the label prop is not affected - // by the automatic adjustment of its text mapper's size (i.e. its - // mapper's text property is identical except for the font size - // which will be modified later). This allows text actors to - // share the same text property, and in that case specifically allows - // the title and label text prop to be the same. - this->TextMappers[i]->GetTextProperty()->ShallowCopy( - this->LabelTextProperty); - - this->TextActors[i] = vtkActor2D::New(); - this->TextActors[i]->SetMapper(this->TextMappers[i]); - this->TextActors[i]->SetProperty(this->GetProperty()); - this->TextActors[i]->GetPositionCoordinate()-> - SetReferenceCoordinate(this->PositionCoordinate); - } - - if (this->NumberOfLabels) - { - int targetWidth, targetHeight; - - if ( this->Orientation == VTK_ORIENT_VERTICAL ) - { - targetWidth = (int)(0.6*size[0]); - targetHeight = (int)(0.86*size[1]/this->NumberOfLabels); - } - else - { - targetWidth = (int)(size[0]*0.8/this->NumberOfLabels); - targetHeight = (int)(0.25*size[1]); - } - - vtkTextMapper::SetMultipleConstrainedFontSize(viewport, - targetWidth, - targetHeight, - this->TextMappers, - this->NumberOfLabels, - labelSize); - } -} - -void VISU_ScalarBarActor::SizeTitle(int *titleSize, int *size, - vtkViewport *viewport) -{ - titleSize[0] = titleSize[1] = 0; - - if (this->Title == NULL || !strlen(this->Title)) - { - return; - } - - int targetWidth, targetHeight; - - targetWidth = size[0]; - if ( this->Orientation == VTK_ORIENT_VERTICAL ) - { - targetHeight = (int)(0.1*size[1]); - } - else - { - targetHeight = (int)(0.25*size[1]); - } - - this->TitleMapper->SetConstrainedFontSize( - viewport, targetWidth, targetHeight); - - this->TitleMapper->GetSize(viewport, titleSize); -} diff --git a/src/OBJECT/VISU_ScalarBarActor.hxx b/src/OBJECT/VISU_ScalarBarActor.hxx deleted file mode 100644 index 6852b8c4..00000000 --- a/src/OBJECT/VISU_ScalarBarActor.hxx +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_ScalarBarActor.hxx -// Author : Alexey PETROV -// Module : VISU - -#ifndef VISU_ScalarBarActor_HeaderFile -#define VISU_ScalarBarActor_HeaderFile - -#include "VTKViewer_Common.h" -#include "VISU_LookupTable.hxx" -#include - -#define VTK_ORIENT_HORIZONTAL 0 -#define VTK_ORIENT_VERTICAL 1 - -class VISU_ScalarBarActor : public vtkActor2D -{ -public: - vtkTypeRevisionMacro(VISU_ScalarBarActor,vtkActor2D); - void PrintSelf(ostream& os, vtkIndent indent); - - // Description: - // Instantiate object with 64 maximum colors; 5 labels; %%-#6.3g label - // format, no title, and vertical orientation. The initial scalar bar - // size is (0.05 x 0.8) of the viewport size. - static VISU_ScalarBarActor *New(); - - // Description: - // Draw the scalar bar and annotation text to the screen. - int RenderOpaqueGeometry(vtkViewport* viewport); - int RenderTranslucentGeometry(vtkViewport*) { return 0; }; - int RenderOverlay(vtkViewport* viewport); - - // Description: - // Release any graphics resources that are being consumed by this actor. - // The parameter window could be used to determine which graphic - // resources to release. - virtual void ReleaseGraphicsResources(vtkWindow *); - - // Description: - // Set/Get the vtkLookupTable to use. The lookup table specifies the number - // of colors to use in the table (if not overridden), as well as the scalar - // range. - virtual void SetLookupTable(VISU_LookupTable*); - vtkGetObjectMacro(LookupTable,VISU_LookupTable); - - // Description: - // Set/Get the maximum number of scalar bar segments to show. This may - // differ from the number of colors in the lookup table, in which case - // the colors are samples from the lookup table. - vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_LARGE_INTEGER); - vtkGetMacro(MaximumNumberOfColors, int); - - // Description: - // Set/Get the number of annotation labels to show. - vtkSetClampMacro(NumberOfLabels, int, 0, 64); - vtkGetMacro(NumberOfLabels, int); - - // Description: - // Control the orientation of the scalar bar. - vtkSetClampMacro(Orientation,int,VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL); - vtkGetMacro(Orientation, int); - void SetOrientationToHorizontal() - {this->SetOrientation(VTK_ORIENT_HORIZONTAL);}; - void SetOrientationToVertical() {this->SetOrientation(VTK_ORIENT_VERTICAL);}; - - // Description: - // Set/Get the title text property. - virtual void SetTitleTextProperty(vtkTextProperty *p); - vtkGetObjectMacro(TitleTextProperty,vtkTextProperty); - - // Description: - // Set/Get the labels text property. - virtual void SetLabelTextProperty(vtkTextProperty *p); - vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); - - // Description: - // Set/Get the format with which to print the labels on the scalar - // bar. - vtkSetStringMacro(LabelFormat); - vtkGetStringMacro(LabelFormat); - - // Description: - // Set/Get the title of the scalar bar actor, - vtkSetStringMacro(Title); - vtkGetStringMacro(Title); - - // Description: - // Shallow copy of a scalar bar actor. Overloads the virtual vtkProp method. - void ShallowCopy(vtkProp *prop); - -protected: - VISU_ScalarBarActor(); - ~VISU_ScalarBarActor(); - - VISU_LookupTable *LookupTable; - vtkTextProperty *TitleTextProperty; - vtkTextProperty *LabelTextProperty; - - int MaximumNumberOfColors; - int NumberOfLabels; - int NumberOfLabelsBuilt; - int Orientation; - char *Title; - char *LabelFormat; - - vtkTextMapper **TextMappers; - virtual void AllocateAndSizeLabels(int *labelSize, int *size, - vtkViewport *viewport, float *range); - -private: - vtkTextMapper *TitleMapper; - vtkActor2D *TitleActor; - - vtkActor2D **TextActors; - - vtkPolyData *ScalarBar; - vtkPolyDataMapper2D *ScalarBarMapper; - vtkActor2D *ScalarBarActor; - - vtkTimeStamp BuildTime; - int LastSize[2]; - int LastOrigin[2]; - - void SizeTitle(int *titleSize, int *size, vtkViewport *viewport); - -private: - VISU_ScalarBarActor(const VISU_ScalarBarActor&); // Not implemented. - void operator=(const VISU_ScalarBarActor&); // Not implemented. -}; - -#endif diff --git a/src/VISU_I/VISU_Convertor.cxx b/src/VISU_I/VISU_Convertor.cxx deleted file mode 100644 index c0d655c6..00000000 --- a/src/VISU_I/VISU_Convertor.cxx +++ /dev/null @@ -1,703 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_Convertor.cxx -// Author : Alexey PETROV -// Module : VISU - -using namespace std; -#include "VISU_Convertor.hxx" -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -#ifdef DEBUG -static int MYDEBUG = 1; -#else -static int MYDEBUG = 1; -#endif - -namespace VISU{ - TVtkCellInfoMap aVtkCellInfoMap; - static int INIT = ( - aVtkCellInfoMap[VTK_VERTEX] = TVtkCellInfo("VTK_VERTEX",1), - aVtkCellInfoMap[VTK_LINE] = TVtkCellInfo("VTK_LINE",2), - aVtkCellInfoMap[VTK_TRIANGLE] = TVtkCellInfo("VTK_TRIANGLE",3), - aVtkCellInfoMap[VTK_QUAD] = TVtkCellInfo("VTK_QUAD",4), - aVtkCellInfoMap[VTK_TETRA] = TVtkCellInfo("VTK_TETRA",4), - aVtkCellInfoMap[VTK_HEXAHEDRON] = TVtkCellInfo("VTK_HEXAHEDRON",8), - aVtkCellInfoMap[VTK_WEDGE] = TVtkCellInfo("VTK_WEDGE",6), - aVtkCellInfoMap[VTK_PYRAMID] = TVtkCellInfo("VTK_PYRAMID",5), - 1); - - pair TMeshOnEntity::GetCellsDims(const string& theFamilyName) const - throw(std::runtime_error&) - { - bool isFamilyPresent = (theFamilyName != ""); - int aNbCells = 0, aCellsSize = 0; - if(!isFamilyPresent){ - TCellsConn::const_iterator aCellsConnIter = myCellsConn.begin(); - for(; aCellsConnIter != myCellsConn.end(); aCellsConnIter++){ - const TConnForCellType& aConnForCellType = aCellsConnIter->second; - if(!aConnForCellType.empty()){ - aNbCells += aConnForCellType.size(); - aCellsSize += aConnForCellType.size()*(aConnForCellType[0].size()+1); - } - } - }else{ - TFamilyMap::const_iterator aFamilyMapIter = myFamilyMap.find(theFamilyName); - if(aFamilyMapIter == myFamilyMap.end()) - throw std::runtime_error("GetCellsDims >> There is no family on the mesh with entity !!!"); - const TFamily& aFamily = aFamilyMapIter->second; - const TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh; - TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.begin(); - for(; aSubMeshIter != aSubMesh.end(); aSubMeshIter++){ - const TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - if(!aSubMeshOnCellType.empty()){ - int tmp = aSubMeshOnCellType.size(); - aNbCells += tmp; - int aVtkType = aSubMeshIter->first; - int aVtkSize = aVtkCellInfoMap[aVtkType].mySize; - aCellsSize += tmp*(aVtkSize+1); - } - } - } - return make_pair(aNbCells,aCellsSize); - } - - void TMesh::CreateMeshOnNodes(){ - TMeshOnEntity& aMeshOnEntity = myMeshOnEntityMap[NODE_ENTITY]; - TMeshOnEntity::TConnForCellType& aConnForCellType = aMeshOnEntity.myCellsConn[VTK_VERTEX]; - int jEnd = myPointsCoord.size()/myDim; - aConnForCellType.resize(jEnd); - for (int j = 0; j < jEnd; j++) aConnForCellType[j] = TMeshOnEntity::TConnect(1,j); - } - - const TField* TMesh::GetField(const string& theFieldName) const { - TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = myMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != myMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const TFieldMap& aFieldMap = (aMeshOnEntityMapIter->second).myFieldMap; - TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); - for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++) - if(theFieldName == aFieldMapIter->first) return &(aFieldMapIter->second); - } - return NULL; - } - - const TFamily* GetFamily(const VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) - throw(std::runtime_error&) - { - if(theFamilyName == "") return NULL; - const VISU::TFamilyMap& aFamilyMap = theMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); - if(aFamilyMapIter == aFamilyMap.end()) - throw std::runtime_error("GetFamily >> There is no family on the mesh with entity !!!"); - const VISU::TFamily& aFamily = aFamilyMapIter->second; - return &aFamily; - } - - TFamily* GetFamily(VISU::TMeshOnEntity& theMeshOnEntity, const string& theFamilyName) - throw(std::runtime_error&) - { - if(theFamilyName == "") return NULL; - VISU::TFamilyMap& aFamilyMap = theMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); - if(aFamilyMapIter == aFamilyMap.end()) - throw std::runtime_error("GetFamily >> There is no family on the mesh with entity !!!"); - VISU::TFamily& aFamily = aFamilyMapIter->second; - return &aFamily; - } - - void TField::ShallowCopy(const TField& aField){ - myEntity = aField.myEntity; - myMeshName = aField.myMeshName; - myNbComp = aField.myNbComp; - VISU::TField::TValField::const_iterator iter = aField.myValField.begin(); - for(; iter != aField.myValField.end(); iter++) - myValField[iter->first]; - } -} - -const VISU::TMeshMap& VISU_Convertor::GetMeshMap() throw(std::runtime_error&){ - if(!myIsDone) { myIsDone = true; Build();} - return myMeshMap; -} - -const VISU::TField& VISU_Convertor::GetField(const string& theMeshName, - VISU::TEntity theEntity, - const string& theFieldName) - throw (std::runtime_error&) -{ - if(!myIsDone) { myIsDone = true; Build();} - VISU::TMeshMap::const_iterator aMeshMapIter = myMeshMap.find(theMeshName); - if(aMeshMapIter == myMeshMap.end()) - throw std::runtime_error("GetField >> There is no mesh with the name !!!"); - const VISU::TMesh& aMesh = aMeshMapIter->second; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMesh.myMeshOnEntityMap.find(theEntity); - if(aMeshOnEntityMapIter == aMesh.myMeshOnEntityMap.end()) - throw std::runtime_error("GetField >> There is no mesh with the entity !!!"); - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; - VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.find(theFieldName); - if(aFieldMapIter == aFieldMap.end()) - throw std::runtime_error("GetField >> There is no field with the name !!!"); - return aFieldMapIter->second; -} - -string VISU_Convertor::GenerateName(const VISU::TField::TTime& aTime){ - static QString aName; - const string aUnits = aTime.second, tmp(aUnits.size(),' '); - if(aUnits == "" || aUnits == tmp) - aName.sprintf("%g, -",aTime.first); - else - aName.sprintf("%g, %s",aTime.first,aTime.second.c_str()); - aName = aName.simplifyWhiteSpace(); - return aName.latin1(); -} - -string VISU_Convertor::GenerateName(const string& theName, unsigned int theTimeId) { - static QString aName; - aName = QString(theName.c_str()).simplifyWhiteSpace(); - int iEnd = strlen(aName); - static int VtkHighLevelLength = 12; //25 - if(iEnd > VtkHighLevelLength) iEnd = VtkHighLevelLength; - char aNewName[iEnd+1]; - aNewName[iEnd] = '\0'; - strncpy(aNewName,aName,iEnd); - replace(aNewName,aNewName+iEnd,' ','_'); - if(true || theTimeId == 0) - aName = aNewName; - else - aName.sprintf("%s_%d",aNewName,theTimeId); - return aName.latin1(); -} - -/* -void parseFile(const char* theFileName) throw(std::runtime_error&){ - try{ - auto_ptr aCon(CreateConvertor(theFileName)); - const VISU::TMeshMap& aMeshMap = aCon->GetMeshMap(); - VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - //Import fields - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; - VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); - for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ - const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); - for(; aValFieldIter != aValField.end(); aValFieldIter++){ - int aTimeStamp = aValFieldIter->first; - aCon->GetFieldOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); - } - } - } - //Importing groups - const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; - VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); - for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ - const string& aGroupName = aGroupMapIter->first; - aCon->GetMeshOnGroup(aMeshName,aGroupName); - } - //Import families - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - //aCon->GetMeshOnEntity(aMeshName,anEntity); - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const string& aFamilyName = aFamilyMapIter->first; - aCon->GetMeshOnEntity(aMeshName,anEntity,aFamilyName); - } - } - //Import mesh on entity - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - aCon->GetMeshOnEntity(aMeshName,anEntity); - } - } - }catch(std::runtime_error& exc){ - MESSAGE("Follow exception was accured in file:"< 1){ - for(int i = 0; i < 1; i++){ - QFileInfo fi(argv[1]); - if ( fi.exists() ) { - if ( fi.isDir() ) { - QDir aDir(fi.absFilePath()); - cout< myValues; -}; - -struct TTable2D{ - string myTitle; - vector myColumnUnits; - vector myColumnTitles; - vector myRows; -}; - -vector aTables; - -int GetLine(ifstream& theStmIn, QString& theString){ - char tmp; - ostrstream aStrOut; - while(theStmIn.get(tmp)){ - aStrOut< aRet(aStrOut.str()); - theString = aRet.get(); - return !theStmIn.eof(); -} - -int main(int argc, char** argv){ - try{ - if(argc > 1){ - ifstream aStmIn; - aStmIn.open(argv[1]); - QString aTmp; - while(!aStmIn.eof()){ - //Find beginning of Table - while(GetLine(aStmIn,aTmp) && aTmp.find("#TITLE:") != 0); - if(aStmIn.eof()) return 0; - cout<<"\n There is new Table2D with Title = "; - TTable2D aTable2D; - while(!aStmIn.eof() && aTmp != "\n"){ - if(aTmp.find("#TITLE:") == 0){ - int aLen = aTmp.find(":") + 1; - aTmp.remove(0,aLen); - QString aTitle = aTmp.stripWhiteSpace(); - aTable2D.myTitle = aTitle; - cout< 0){ - QStringList aStrList = QStringList::split("#TITLE:",aTmp); - QString aTitle = aStrList[1].stripWhiteSpace(); - TRow aRow; - aRow.myTitle = aTitle; - cout< -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -static float EPS = 1.0E-3; -const float PI = 3.1415; -extern float* GetIdent(float theR[3][3]); -extern float* GetRx(float theRx[3][3], float thaAng); -extern float* GetRy(float theRy[3][3], float thaAng); -extern float* GetRz(float theRz[3][3], float thaAng); -extern void MulMatrix(float C[3][3], const float A[3][3], const float B[3][3]); // C = A*B; -extern void Sub(float C[3], const float A[3], float B[3]); // AxB -extern float DotMul(const float A[3], const float B[3]); // A*B; -extern void Mul(float C[3], const float A[3], float B[3]); // AxB -extern void Mul(float C[3], const float A[3], float B); // A*B; -extern void CorrectPnt(float thePnt[3], const float BoundPrj[3]); -extern void GetBoundProject(float BoundPrj[3], const float BoundBox[6], const float Dir[3]); - -typedef map TXYMap; -typedef vector TCurveVect; - -void FillCurveXYMap(float theBasePnt[3], float theDir[3], float theBndDist, - vtkPolyData* thePolyData, TXYMap& theXYMap) -{ - int aNbPoints = thePolyData->GetNumberOfPoints(); - //cout<<"aNbPoints = "<GetPointData(); - vtkScalars *aScalars = aPointData->GetScalars(); - float aPnt[3], aVect[3], aDist; - for(int i = 0; i < aNbPoints; i++){ - thePolyData->GetPoint(i,aPnt); - Sub(aVect,theBasePnt,aPnt); - aDist = DotMul(aVect,theDir) / theBndDist; - // the workaround - if(aDist < 0.0) aDist = 0.0; - if(aDist > 1.0) aDist = 1.0; - theXYMap[aDist] = aScalars->GetScalar(i); - //cout<first, aY = aXYMapIter->second; - aStm< 1){ - vtkRenderWindow *renWin = vtkRenderWindow::New(); - vtkRenderer *ren = vtkRenderer::New(); - renWin->AddRenderer(ren); - ren->GetActiveCamera()->ParallelProjectionOn(); - vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New(); - iren->SetRenderWindow(renWin); - VISU_Convertor* aConvertor = CreateConvertor(argv[1]); - const VISU::TMeshMap& aMeshMap = aConvertor->GetMeshMap(); - VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); - if(aMeshMapIter == aMeshMap.end()) return 0; - const string& aMeshName = aMeshMapIter->first; - const VISU::TMesh& aMesh = aMeshMapIter->second; - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; - //Import fields - aMeshOnEntityMapIter = aMeshOnEntityMap.begin(); - for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){ - const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first; - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; - VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); - if(aFieldMapIter == aFieldMap.end()) return 0; - const string& aFieldName = aFieldMapIter->first; - const VISU::TField& aField = aFieldMapIter->second; - const VISU::TField::TValField& aValField = aField.myValField; - VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin(); - if(aValFieldIter == aValField.end()) return 0; - int aTimeStamp = aValFieldIter->first; - vtkUnstructuredGridReader* aReader = - aConvertor->GetFieldOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); - VISU_Extractor *anExtractor = VISU_Extractor::New(); - anExtractor->Extract(aReader,aFieldName,0,aField.myNbComp,anEntity); - vtkUnstructuredGrid *aDataSet = anExtractor->GetUnstructuredGridOutput(); - VISU_FieldTransform* aFieldTransform = VISU_FieldTransform::New(); - aFieldTransform->SetInput(aDataSet); - //if(argc > 2) aFieldTransform->SetTransformFunction(&log10); - vtkDataSetMapper *aMapper = vtkDataSetMapper::New(); - float aScalarRange[2], myBounds[6]; - anExtractor->GetUnstructuredGridOutput()->GetScalarRange(aScalarRange); - int aNumberOfColors = 64, aNumberOfLabels = 5; - aDataSet->GetBounds(myBounds); - cout<<"myBounds : \n"; - cout< 2) myBasePlane = atoi(argv[2]); - vtkAppendPolyData *myAppendPolyData = vtkAppendPolyData::New(); - - float aRx[3][3], aRy[3][3], aRz[3][3]; - int iPlane = 0; - if(myBasePlane == 0){ // X-Y - if(fabs(myAng[0]) > EPS) ::GetRx(aRx,myAng[0]); else ::GetIdent(aRx); - if(fabs(myAng[1]) > EPS) ::GetRy(aRy,myAng[1]); else ::GetIdent(aRy); - ::MulMatrix(myRotation,aRx,aRy); - iPlane = 2; - }else if(myBasePlane == 1){ // Y-Z - if(fabs(myAng[1]) > EPS) ::GetRy(aRy,myAng[1]); else ::GetIdent(aRy); - if(fabs(myAng[2]) > EPS) ::GetRz(aRz,myAng[2]); else ::GetIdent(aRz); - ::MulMatrix(myRotation,aRy,aRz); - iPlane = 0; - }else if(myBasePlane == 2){ // Z-X - if(fabs(myAng[2]) > EPS) ::GetRz(aRz,myAng[2]); else ::GetIdent(aRz); - if(fabs(myAng[0]) > EPS) ::GetRx(aRx,myAng[0]); else ::GetIdent(aRx); - ::MulMatrix(myRotation,aRz,aRx); - iPlane = 1; - } - for(int i = 0; i < 3; i++) myDir[i] = myRotation[i][iPlane]; - ::Mul(myInvDir,myDir,-1.0); - ::GetBoundProject(myBoundPrj, myBounds, myDir); - if(MYDEBUG) MESSAGE("myDir "<SetInput(aFieldTransform->GetUnstructuredGridOutput()); - vtkPlane *aPlane = vtkPlane::New(); - int i = 1; - float aOrig[3]; - Mul(aOrig,myDir,myBoundPrj[0] + i*myDBPrj); - if(0 && MYDEBUG) MESSAGE("aOrig["<SetOrigin(aOrig); - if(i == 0) aPlane->SetNormal(myInvDir); - else aPlane->SetNormal(myDir); - aCutPlane->SetCutFunction(aPlane); - aPlane->Delete(); - myAppendPolyData->AddInput(aCutPlane->GetOutput()); - aCutPlane->Delete(); - - //CutLines specific - //--------------------------------------------------------------------- - float myDirPln[3], myDirLn[3], myBoundPrjLn[3], myBasePnt[3]; - if(argc > 3) myBasePlane = atoi(argv[3]); - else myBasePlane = myBasePlane + 1; - if(argc > 4) myNbPlanes = atoi(argv[4]); - TCurveVect aCurveVect(myNbPlanes); //Declaration of Curve container - vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New(); - if(myBasePlane == 0){ // X-Y - if(fabs(myAng[0]) > EPS) ::GetRx(aRx,myAng[0]); else ::GetIdent(aRx); - if(fabs(myAng[1]) > EPS) ::GetRy(aRy,myAng[1]); else ::GetIdent(aRy); - ::MulMatrix(myRotation,aRx,aRy); - iPlane = 2; - }else if(myBasePlane == 1){ // Y-Z - if(fabs(myAng[1]) > EPS) ::GetRy(aRy,myAng[1]); else ::GetIdent(aRy); - if(fabs(myAng[2]) > EPS) ::GetRz(aRz,myAng[2]); else ::GetIdent(aRz); - ::MulMatrix(myRotation,aRy,aRz); - iPlane = 0; - }else if(myBasePlane == 2){ // Z-X - if(fabs(myAng[2]) > EPS) ::GetRz(aRz,myAng[2]); else ::GetIdent(aRz); - if(fabs(myAng[0]) > EPS) ::GetRx(aRx,myAng[0]); else ::GetIdent(aRx); - ::MulMatrix(myRotation,aRz,aRx); - iPlane = 1; - } - for(int i = 0; i < 3; i++) myDirPln[i] = myRotation[i][iPlane]; - // Get Direction of CutLines and its Bounds - ::Mul(myDirLn,myDirPln,myDir); - ::GetBoundProject(myBoundPrjLn, myBounds, myDirLn); - Mul(myBasePnt,myDirLn,myBoundPrjLn[0]); - CorrectPnt(myBasePnt,myBounds); - cout<<"myBasePnt : "< 1 ) { - myDBPrj = myBoundPrj[2]/(aNbPlanes - 1); - for (int i = 0; i < aNbPlanes; i++){ - vtkCutter *aCutPlane = vtkCutter::New(); - aCutPlane->SetInput(myAppendPolyData->GetOutput()); - vtkPlane *aPlane = vtkPlane::New(); - float aOrig[3]; - Mul(aOrig,myDirPln,myBoundPrj[0] + i*myDBPrj); - if(0 && MYDEBUG) MESSAGE("aOrig["<SetOrigin(aOrig); - if(i == 0) aPlane->SetNormal(myInvDir); - else aPlane->SetNormal(myDirPln); - aCutPlane->SetCutFunction(aPlane); - aPlane->Delete(); - vtkPolyData *aPolyData = aCutPlane->GetOutput(); - aPolyData->Update(); - anAppendPolyData->AddInput(aPolyData); - FillCurveXYMap(myBasePnt,myDirLn,myBoundPrjLn[2],aPolyData,aCurveVect[i]); - aCutPlane->Delete(); - string aFileName("/users/"); - aFileName = aFileName + getenv("USER") + "/" + "CutLine" + dtos("-%d.vtk",i); - vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); - aWriter->SetFileName(aFileName.c_str()); - aWriter->SetInput(anAppendPolyData->GetInput(i)); - //aWriter->SetInput(aCutPlane->GetOutput()); - aWriter->Write(); - aWriter->Delete(); - } - }else{ - myDBPrj = myBoundPrj[2]/2.0; - int i = 1; - vtkCutter *aCutPlane = vtkCutter::New(); - aCutPlane->SetInput(myAppendPolyData->GetOutput()); - vtkPlane *aPlane = vtkPlane::New(); - float aOrig[3]; - Mul(aOrig,myDirPln,myBoundPrj[0] + i*myDBPrj); - if(0 && MYDEBUG) MESSAGE("aOrig["<SetOrigin(aOrig); - if(i == 0) aPlane->SetNormal(myInvDir); - else aPlane->SetNormal(myDirPln); - aCutPlane->SetCutFunction(aPlane); - aPlane->Delete(); - vtkPolyData *aPolyData = aCutPlane->GetOutput(); - aPolyData->Update(); - anAppendPolyData->AddInput(aPolyData); - FillCurveXYMap(myBasePnt,myDirLn,myBoundPrjLn[2],aPolyData,aCurveVect[i]); - aCutPlane->Delete(); - } - - PrintTable(aCurveVect); - aMapper->SetInput(anAppendPolyData->GetOutput()); - - vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); - string aFileName("/users/"); - aFileName = aFileName + getenv("USER") + "/" + "CutLines.vtk"; - aWriter->SetFileName(aFileName.c_str()); - aWriter->SetInput(anAppendPolyData->GetOutput()); - aWriter->Write(); - aWriter->Delete(); - - //aMapper->SetInput(myAppendPolyData->GetOutput()); - - //aMapper->SetInput(aFieldTransform->GetUnstructuredGridOutput()); - aMapper->ScalarVisibilityOn(); - VISU_LookupTable* aActorLookupTbl = VISU_LookupTable::New(); - //if(argc > 2) aActorLookupTbl->SetLog(true); - aActorLookupTbl->SetHueRange(0.667,0.0); - aActorLookupTbl->SetNumberOfColors(aNumberOfColors); - aActorLookupTbl->SetTableRange(aScalarRange[0],aScalarRange[1]); // - aActorLookupTbl->SetMapScale(1.); - aActorLookupTbl->Build(); - aMapper->SetLookupTable(aActorLookupTbl); - aMapper->SetScalarRange(aScalarRange); - aActorLookupTbl->Delete(); - - vtkActor* aActor = vtkActor::New(); - aActor->SetMapper(aMapper); - - VISU_ScalarBarActor* aBar = VISU_ScalarBarActor::New(); - VISU_LookupTable* aBarLookupTbl = VISU_LookupTable::New(); - //if(argc > 2) aBarLookupTbl->SetLog(true); - aBarLookupTbl->SetHueRange(0.667,0.0); - aBarLookupTbl->SetNumberOfColors(aNumberOfColors); - aBarLookupTbl->SetTableRange(aScalarRange[0],aScalarRange[1]); // - aBarLookupTbl->Build(); - aBar->SetLookupTable(aBarLookupTbl); - aBarLookupTbl->Delete(); - - aBar->SetTitle(aFieldName.c_str()); - aBar->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); - aBar->SetNumberOfLabels(aNumberOfLabels); - - vtkProperty* aProperty = aActor->GetProperty(); - aProperty->SetSpecularColor( 1, 1, 1); - aProperty->SetSpecular( 0.3 ); - aProperty->SetSpecularPower( 20 ); - aProperty->SetAmbient( 0.2); - aProperty->SetDiffuse( 0.8 ); - aProperty->EdgeVisibilityOn(); - - ren->AddActor(aActor); - ren->AddActor2D(aBar); - - renWin->Render(); - iren->Start(); - return 1; - } - } - }catch(std::runtime_error& exc){ - cout<<"Follow exception was accured :\n"< - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "utilities.h" -#ifndef MESSAGE -#define MESSAGE(msg) cout< TVtkCellInfoMap; - extern TVtkCellInfoMap aVtkCellInfoMap; - - enum TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY}; - //enum TEntity {CELL_ENTITY, FACE_ENTITY, EDGE_ENTITY, NODE_ENTITY}; - template class vtk_ptr { - private: - _Tp* _M_ptr; - public: - typedef _Tp element_type; - explicit vtk_ptr(_Tp* __p = 0) : _M_ptr(__p) {} - vtk_ptr(const vtk_ptr& __a) : _M_ptr(0) {} - vtk_ptr(vtk_ptr& __a) : _M_ptr(__a.release()) {} - vtk_ptr& operator=(const vtk_ptr& __a) { return *this;} - vtk_ptr& operator=(vtk_ptr& __a) { - if (&__a != this) { - if(_M_ptr) _M_ptr->Delete(); - _M_ptr = __a.release(); - } - return *this; - } - ~vtk_ptr() { - if(_M_ptr) _M_ptr->Delete(); - _M_ptr = 0; - } - _Tp& operator*() const { return *_M_ptr;} - _Tp* operator->() const { return _M_ptr;} - _Tp* get() const { return _M_ptr;} - _Tp* release() { - _Tp* __tmp = _M_ptr; - _M_ptr = 0; - return __tmp; - } - void reset(_Tp* __p = 0) { - if(_M_ptr) _M_ptr->Delete(); - _M_ptr = __p; - } - }; - typedef vtk_ptr TVTKReader; - - typedef std::set TBindGroups; - - struct TFamily{ - TVTKReader myStorage; - int myId; - string myName; - TEntity myEntity; - TBindGroups myGroups; - typedef std::set TSubMeshOnCellType; - typedef std::map TSubMesh; - TSubMesh mySubMesh; - }; - typedef std::map TFamilyMap; - - struct TField{ - int myId; - string myName; - TEntity myEntity; - string myMeshName; - int myNbComp; - typedef std::vector TValForCellsWithType; - typedef std::map TValForCells; - typedef std::pair TTime; - typedef std::vector TCompNames; - typedef std::vector TUnitNames; - struct TValForTime{ - TVTKReader myStorage; - int myId; - TTime myTime; - TValForCells myValForCells; - }; - typedef std::map TValField; - TValField myValField; - TCompNames myCompNames; - TUnitNames myUnitNames; - void ShallowCopy(const TField& aField); - }; - typedef map TFieldMap; - - struct TMeshOnEntity{ - TVTKReader myStorage; - string myMeshName; - TEntity myEntity; - typedef vector TConnect; - typedef vector TConnForCellType; - typedef map TCellsConn; - TCellsConn myCellsConn; - TFamilyMap myFamilyMap; - TFieldMap myFieldMap; - pair GetCellsDims(const string& theFamilyName = "") const - throw(std::runtime_error&); - }; - typedef std::map TMeshOnEntityMap; - const TFamily* GetFamily(const VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName) - throw(std::runtime_error&); - TFamily* GetFamily(VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName) - throw(std::runtime_error&); - - typedef std::pair TFamilyAndEntity; - typedef std::set TFamilyAndEntitySet; - struct TGroup{ - TVTKReader myStorage; - string myName; - string myMeshName; - TFamilyAndEntitySet myFamilyAndEntitySet; - }; - typedef std::map TGroupMap; - - struct TMesh{ - int myDim; - string myName; - typedef vector TPointsCoord; - TPointsCoord myPointsCoord; - TMeshOnEntityMap myMeshOnEntityMap; - TGroupMap myGroupMap; - void CreateMeshOnNodes(); - const TField* GetField(const string& theFieldName) const; - }; - typedef std::map TMeshMap; -}; - -class VISU_Convertor{ -protected: - std::string myName; - VISU::TMeshMap myMeshMap; - int myIsDone; -public: - virtual ~VISU_Convertor(){}; - virtual const string& GetName() { return myName;} - virtual int IsDone() const { return myIsDone;} - typedef vtkUnstructuredGridReader OutputType; - virtual VISU_Convertor* Build() throw (std::runtime_error&) = 0; - virtual OutputType* GetMeshOnEntity(const string& theMeshName, - const VISU::TEntity& theEntity, - const string& theFamilyName = "") - throw(std::runtime_error&) = 0; - virtual OutputType* GetMeshOnGroup(const string& theMeshName, - const string& theGroupName) - throw(std::runtime_error&) = 0; - virtual OutputType* GetFieldOnMesh(const string& theMeshName, - const VISU::TEntity& theEntity, - const string& theFieldName, - int theStampsNum) - throw(std::runtime_error&) = 0; - virtual const VISU::TMeshMap& GetMeshMap() throw(std::runtime_error&); - virtual const VISU::TField& GetField(const string& theMeshName, VISU::TEntity theEntity, - const string& theFieldName) - throw(std::runtime_error&); - static string GenerateName(const VISU::TField::TTime& aTime); - static string GenerateName(const string& theName, unsigned int theTimeId); -}; - -template std::string dtos(const string& fmt, T val){ - static QString aString; - aString.sprintf(fmt.c_str(),val); - return aString.latin1(); -} -extern "C"{ - VISU_Convertor* CreateMedConvertor(const std::string& theFileName) throw(std::runtime_error&); - VISU_Convertor* CreateDatConvertor(const std::string& theFileName) throw(std::runtime_error&); - VISU_Convertor* CreateConvertor(const std::string& theFileName) throw(std::runtime_error&); -}; - -#endif diff --git a/src/VISU_I/VISU_Convertor_impl.cxx b/src/VISU_I/VISU_Convertor_impl.cxx deleted file mode 100644 index 353b12c0..00000000 --- a/src/VISU_I/VISU_Convertor_impl.cxx +++ /dev/null @@ -1,436 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_Convertor_impl.cxx -// Author : Alexey PETROV -// Module : VISU - -using namespace std; -#include "VISU_Convertor_impl.hxx" - -#include -#include -#include -#include -#include -#include -using namespace std; - -#ifdef DEBUG -static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; -#else -static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; -#endif -static int PRECISION = 7; - -#define MED2VTK(MEDTYPE,VTKTYPE,VTKNBNODES) \ - {MEDTYPE,#MEDTYPE,getNbMedNodes(MEDTYPE),VTKTYPE,#VTKTYPE,VTKNBNODES} -Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE] = { - MED2VTK(MED_POINT1,VTK_VERTEX,1), - MED2VTK(MED_SEG2,VTK_LINE,2), - MED2VTK(MED_SEG3,VTK_LINE,2), - MED2VTK(MED_TRIA3,VTK_TRIANGLE,3), - MED2VTK(MED_TRIA6,VTK_TRIANGLE,3), - MED2VTK(MED_QUAD4,VTK_QUAD,4), - MED2VTK(MED_QUAD8,VTK_QUAD,4), - MED2VTK(MED_TETRA4,VTK_TETRA,4), - MED2VTK(MED_TETRA10,VTK_TETRA,4), - MED2VTK(MED_HEXA8,VTK_HEXAHEDRON,8), - MED2VTK(MED_HEXA20,VTK_HEXAHEDRON,8), - MED2VTK(MED_PENTA6,VTK_WEDGE,6), - MED2VTK(MED_PENTA15,VTK_WEDGE,6), - MED2VTK(MED_PYRA5,VTK_PYRAMID,5), - MED2VTK(MED_PYRA13,VTK_PYRAMID,5) -}; -#undef MED2VTK - -extern "C" { - VISU_Convertor* CreateConvertor(const string& theFileName) throw(std::runtime_error&){ - if(QFileInfo(theFileName.c_str()).extension(false) == "med") - return CreateMedConvertor(theFileName); - else - return CreateDatConvertor(theFileName); - } - - int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim){ - int anElemDim = theMedType / 100, nsup = 0; - if(theMedEntity == VISU::CELL_ENTITY && anElemDim < theMeshDim) nsup = 1; - return nsup + theMedType % 100; - } - - int getNbMedNodes(int geom){ - return geom % 100; - } - - int getIdMedType(int medType){ - for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - if(med2vtk[i].medType == medType) return i; - return -1; - } -} - -VISU_Convertor_impl::VISU_Convertor_impl() { - myIsDone = false; -} - -VISU_Convertor_impl::~VISU_Convertor_impl() {} - -VISU_Convertor::OutputType* VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName, - const VISU::TEntity& theEntity, - const string& theFamilyName) - throw (std::runtime_error&) -{ - if(!myIsDone) { myIsDone = true; Build();} - if(MYDEBUG) - MESSAGE("GetMeshOnEntity - theMeshName = '"<> There is no mesh with the name!!!"); - VISU::TMesh& aMesh = myMeshMap[theMeshName]; - VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - if(aMeshOnEntityMap.find(theEntity) == aMeshOnEntityMap.end()) - throw std::runtime_error("MeshOnEntityToString >> There is no mesh on the entity!!!"); - VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMap[theEntity]; - VISU::TFamily* pFamily = VISU::GetFamily(aMeshOnEntity,theFamilyName); - VISU::TVTKReader* pReader; - if(pFamily != NULL) - pReader = &(pFamily->myStorage); - else - pReader = &(aMeshOnEntity.myStorage); - VISU::TVTKReader& aReader = *pReader; - //Main part of code - if(aReader.get() == NULL){ - LoadMeshOnEntity(aMeshOnEntity,theFamilyName); - ostrstream strOut; - strOut< aCellsDim = aMeshOnEntity.GetCellsDims(theFamilyName); - int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second; - ostrstream strCellsOut, strTypesOut; - GetCells(strCellsOut,strTypesOut,aMeshOnEntity,theFamilyName); - strCellsOut< aRet(strCellsOut.str()); - strOut<DebugOn(); - aReader->ReadFromInputStringOn(); - aRet.reset(strOut.str()); - aReader->SetInputString(aRet.get()); - //aReader->Update(); - //aReader->Print(cout); - if(MYDEBUGWITHFILES){ - string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1(); - string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; - aFileName += aMeshName + dtos("-%d-",theEntity) + aFamilyName + "-Conv.vtk"; - ofstream stmOut(aFileName.c_str(),ios::out); - stmOut<> There is no mesh with the name!!!"); - VISU::TMesh& aMesh = myMeshMap[theMeshName]; - VISU::TGroupMap& aGroupMap = aMesh.myGroupMap; - VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName); - if(aGroupMapIter == aGroupMap.end()) - throw std::runtime_error("GetMeshOnGroup >> There is no the group in the mesh!!!"); - VISU::TGroup& aGroup = aGroupMapIter->second; - const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; - VISU::TVTKReader& aReader = aGroup.myStorage; - if(aReader.get() == NULL){ - LoadMeshOnGroup(aMesh,aFamilyAndEntitySet); - ostrstream strOut; - strOut< aCellsDim = aMeshOnEntity.GetCellsDims(aFamilyName); - aNbCells += aCellsDim.first; - aCellsSize += aCellsDim.second; - GetCells(strCellsOut,strTypesOut,aMeshOnEntity,aFamilyName); - } - strCellsOut< aRet(strCellsOut.str()); - strOut<ReadFromInputStringOn(); - aRet.reset(strOut.str()); - aReader->SetInputString(aRet.get()); - if(MYDEBUGWITHFILES){ - string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1(); - string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; - aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk"; - ofstream stmOut(aFileName.c_str(),ios::out); - stmOut<> There is no mesh with the name!!!"); - VISU::TMesh& aMesh = myMeshMap[theMeshName]; - VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - if(aMeshOnEntityMap.find(theEntity) == aMeshOnEntityMap.end()) - throw std::runtime_error("GetFieldOnMesh >> There is no mesh on the entity!!!"); - VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMap[theEntity]; - VISU::TMeshOnEntity* pVtkMeshOnEntity = &aMeshOnEntity; - if(theEntity == VISU::NODE_ENTITY){ - if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) == aMeshOnEntityMap.end()) - throw std::runtime_error("GetFieldOnMesh >> There is no mesh on CELL_ENTITY!!!"); - pVtkMeshOnEntity = &aMeshOnEntityMap[VISU::CELL_ENTITY]; - } - VISU::TMeshOnEntity& aVtkMeshOnEntity = *pVtkMeshOnEntity; - VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap; - if(aFieldMap.find(theFieldName) == aFieldMap.end()) - throw std::runtime_error("GetFieldOnMesh >> There is no field on the mesh!!!"); - VISU::TField& aField = aFieldMap[theFieldName]; - VISU::TField::TValField& aValField = aField.myValField; - if(aValField.find(theStampsNum) == aValField.end()) - throw std::runtime_error("GetFieldOnMesh >> There is no field with the timestamp!!!"); - VISU::TField::TValForTime& aValForTime = aValField[theStampsNum]; - VISU::TVTKReader& aReader = aValForTime.myStorage; - //Main part of code - if(aReader.get() == NULL){ - LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime); - try{ - LoadMeshOnEntity(aVtkMeshOnEntity); - }catch(std::runtime_error& exc){ - aVtkMeshOnEntity = aMeshOnEntity; - MESSAGE("Follow exception was accured :\n"< aCellsDim = aVtkMeshOnEntity.GetCellsDims(); - int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second; - ostrstream strCellsOut, strTypesOut; - GetCells(strCellsOut,strTypesOut,aVtkMeshOnEntity); - strCellsOut< aRet(strCellsOut.str()); - strOut<ReadFromInputStringOn(); - aRet.reset(strOut.str()); - aReader->SetInputString(aRet.get()); - if(MYDEBUGWITHFILES){ - string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); - string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-"; - aFileName += aMeshName + dtos("-%d-",theEntity) + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; - ofstream stmOut(aFileName.c_str(),ios::out); - stmOut<> There is no elements on the family !!!"); - VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType); - if(aSubMeshIter == aSubMesh.end()) continue; - const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second; - if(MYDEBUG) MESSAGE("GetCells - aSubMeshOnCellType.size() = "< aRet(strOut.str()); - return aRet.get(); -} - -string VISU_Convertor_impl::GetPoints(const VISU::TMesh& theMesh) const - throw (std::runtime_error&) -{ - ostrstream strOut; - strOut.setf(ios::scientific,ios::floatfield); strOut.precision(PRECISION); - const VISU::TMesh::TPointsCoord& anArray = theMesh.myPointsCoord; - int iEnd = theMesh.myPointsCoord.size(); - int aNbPoints = iEnd/theMesh.myDim; - strOut<<"POINTS "< aRet(strOut.str()); - return aRet.get(); -} - -string VISU_Convertor_impl::GetField(const VISU::TField& theField, - const VISU::TField::TValForTime& theValForTime, - int theDim, int theNbPoints, int theNbCells) const - throw (std::runtime_error&) -{ - ostrstream strOut; - strOut.setf(ios::scientific,ios::floatfield); strOut.precision(PRECISION); - string aName = GenerateName(theField.myName,theValForTime.myId); - if(MYDEBUG) MESSAGE("GetField - aTime = "<second; - int iEnd = anArray.size()/theField.myNbComp; - int aVtkType = aValForCellsIter->first; - if(MYDEBUG) MESSAGE("GetField - iEnd = "< aRet(strOut.str()); - return aRet.get(); -} diff --git a/src/VISU_I/VISU_Convertor_impl.hxx b/src/VISU_I/VISU_Convertor_impl.hxx deleted file mode 100644 index e4442719..00000000 --- a/src/VISU_I/VISU_Convertor_impl.hxx +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_Convertor_impl.hxx -// Author : Alexey PETROV -// Module : VISU - -#ifndef VISU_Convertor_impl_HeaderFile -#define VISU_Convertor_impl_HeaderFile - -#include "VISU_Convertor.hxx" - -extern "C"{ -#include -} - -#include -#include - -#include -#include -using namespace std; - -class VISU_Convertor_impl: public VISU_Convertor{ - private: - string GetHead(const string& theMeshName) const throw (std::runtime_error&); - string GetPoints(const VISU::TMesh& theMesh) const throw (std::runtime_error&); - int GetCells(ostrstream& strCellsOut, ostrstream& strTypesOut, - const VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName = "") const throw (std::runtime_error&); - string GetField(const VISU::TField& theField, - const VISU::TField::TValForTime& theValForTime, - int theDim, int theNbPoints, int theNbCells) const - throw (std::runtime_error&); - public: - VISU_Convertor_impl(); - virtual ~VISU_Convertor_impl(); - virtual VISU_Convertor* Build() throw (std::runtime_error&) { return this;}; - virtual OutputType* GetMeshOnEntity(const string& theMeshName, - const VISU::TEntity& theEntity, - const string& theFamilyName = "") - throw(std::runtime_error&); - virtual OutputType* GetMeshOnGroup(const string& theMeshName, - const string& theGroupName) - throw(std::runtime_error&); - virtual OutputType* GetFieldOnMesh(const string& theMeshName, - const VISU::TEntity& theEntity, - const string& theFieldName, - int theStampsNum) - throw(std::runtime_error&); - - protected: - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName = "") - throw (std::runtime_error&) = 0; - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) - throw (std::runtime_error&) = 0; - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) - throw (std::runtime_error&) = 0; -}; - -extern "C"{ - int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim); - int getNbMedNodes(int theMedType); - int med2vtkCellType(int theMedType); - int vtk2medCellType(int theVtkType); - int getIdMedType(int medType); -} - -struct Med2vtk { - med_geometrie_element medType; - const char *medName; - int medNbNodes; - int vtkType; - const char *vtkName; - int vtkNbNodes; -}; -extern Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE]; -#endif diff --git a/src/VISU_I/VISU_DatConvertor.cxx b/src/VISU_I/VISU_DatConvertor.cxx deleted file mode 100644 index 91151aff..00000000 --- a/src/VISU_I/VISU_DatConvertor.cxx +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_DatConvertor.cxx -// Author : Alexey PETROV -// Module : VISU - -using namespace std; -#include "VISU_DatConvertor.hxx" -using namespace std; - -#ifdef DEBUG -static int MYDEBUG = 1; -#else -static int MYDEBUG = 0; -#endif -static int PRECISION = 7; - -extern "C" -VISU_Convertor* CreateDatConvertor(const string& theFileName) throw(std::runtime_error&){ - VISU_DatConvertor* aConvertor = new VISU_DatConvertor(theFileName); - aConvertor->Build(); - return aConvertor; -} -VISU_DatConvertor::VISU_DatConvertor(const string& theFileName) throw(std::runtime_error&){ - myFileInfo.setFile(QString(theFileName.c_str())); - myName = (const char*)(myFileInfo.baseName()); -} - -VISU_Convertor* VISU_DatConvertor::Build() throw (std::runtime_error&){ - /* - ifstream stmIn(myFileInfo.absFilePath()); - if(!stmIn.good()) - throw std::runtime_error(string("VISU_DatConvertor::CreateResult() >> can't open file - ") + - (const char*)myFileInfo.absFilePath()); - int aNbPoints, aNbCells, aNbFields; - ImportHead(&stmIn,&aNbPoints,&aNbCells,&aNbFields); - ImportPoints(&stmIn,aNbPoints); - vector aCellsType(aNbCells); - ImportCells(&stmIn,&aCellsType); - for(int i = 0; i < aNbFields; i++) - ImportField(&stmIn,aNbPoints,&aCellsType); - myIsDone = true; - */ - return this; -} - -int VISU_DatConvertor::ImportField(ifstream* pStmIn, int theNbPoints, vector* pCellsType) - throw (std::runtime_error&) -{ - /* - ifstream &stmIn = *pStmIn; - vector& aCellsType = *pCellsType; - int aNbCells = aCellsType.size(); - string aName; stmIn>>aName; stmIn>>aName; - VISU::TMesh& aMesh = myMeshMap[myName]; - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY]; - VISU::TField& aField = aMeshOnEntity.myFieldMap[aName]; - aField.myMeshName = myName; - stmIn>>(aField.myNbComp); - aField.myNbComp %= 100; - int iEnd; stmIn>>iEnd; - if(iEnd == theNbPoints) - aField.myEntity = VISU::NODE_ENTITY; - else if(iEnd == aNbCells) - aField.myEntity = VISU::CELL_ENTITY; - else - throw std::runtime_error("ImportChamp >> elements doesn't connected to points or cells"); - if(MYDEBUG) - MESSAGE("FieldInfo - myMeshName = "<>tmp; - anArray.push_back(tmp); - } - } - */ - return 0; -} - -int VISU_DatConvertor::ImportHead(ifstream* pStmIn, int* theNbPoints, - int* theNbCells, int* theNbFields) - throw (std::runtime_error&) -{ - /* - ifstream &stmIn = *pStmIn; - const int BUFSIZE = 256; - char buf[BUFSIZE]; - stmIn.getline(buf,BUFSIZE); - istrstream strIn(buf); - VISU::TMesh& aMesh = myMeshMap[myName]; - *theNbFields = 0; - strIn>>(*theNbPoints); strIn>>(*theNbCells); strIn>>(*theNbFields); - if(MYDEBUG) - MESSAGE("ImportHead - theNbPoints = "<<(*theNbPoints)<< - "; theNbCells = "<<(*theNbCells)<< - "; theNbFields = "<<(*theNbFields)); - */ - return 0; -} - -int VISU_DatConvertor::ImportPoints(ifstream* pStmIn, int theNbPoints) - throw (std::runtime_error&) -{ - /* - ifstream &stmIn = *pStmIn; - VISU::TMesh& aMesh = myMeshMap[myName]; - aMesh.myName = myName; - aMesh.myDim = 3; - int iEnd = aMesh.myDim*theNbPoints; - if(MYDEBUG) MESSAGE("ImportPoints - iEnd = "< &aPointsCoord = aMesh.myPointsCoord; - aPointsCoord.resize(iEnd); - for(int i = 0, tmp; i < iEnd;){ - stmIn>>tmp; - stmIn>>aPointsCoord[i++]; stmIn>>aPointsCoord[i++]; stmIn>>aPointsCoord[i++]; - } - */ - return 0; -} - -int VISU_DatConvertor::ImportCells(ifstream* pStmIn, vector* pCellsType) - throw (std::runtime_error&) -{ - /* - ifstream &stmIn = *pStmIn; - vector& aCellsType = *pCellsType; - int aNbCells = aCellsType.size(); - if(MYDEBUG) MESSAGE("ImportCells - theNbCells - Beginning"); - VISU::TMesh& aMesh = myMeshMap[myName]; - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[VISU::CELL_ENTITY]; - aMeshOnEntity.myEntity = VISU::CELL_ENTITY; - aMeshOnEntity.myMeshName = myName; - for(int i = 0, aMedType, aVtkType; i < aNbCells; i++){ - stmIn>>aMedType; stmIn>>aMedType; - aCellsType[i] = aVtkType = med2vtkCellType(aMedType); - VISU::TMeshOnEntity::TConnForCellType& anArray = aMeshOnEntity.myCellsConn[aVtkType]; - anArray.push_back(VISU::TMeshOnEntity::TConnect()); - VISU::TMeshOnEntity::TConnect& aVector = anArray.back(); - int jEnd = getNbMedNodes(aMedType); - aVector.resize(jEnd); - for(int j = 0, tmp; j < jEnd; j++){ - stmIn>>tmp; - aVector[j] = tmp - 1; - } - } - if(MYDEBUG) MESSAGE("ImportCells - theNbCells - End"); - */ - return 0; -} - -/* -int VISU_Convertor_impl::ToDatFile(const string& theFileName) throw(std::runtime_error&){ - if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - "<second; - if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - aMeshName = "<first); - VISU::TFieldMap aFieldMap = GetFieldMapForMesh(aMeshIter->first); - const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap; - VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(VISU::CELL_ENTITY); - if(aMeshOnEntityMapIter != aMeshOnEntityMap.end()){ - const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second; - int aNbPoints = aMesh.myPointsCoord.size()/aMesh.myDim; - int aNbCells = aMeshOnEntity.GetCellsDims().first; - stmOut<first)<<"\t"; - const vector& aVector = anArray[j]; - int kEnd = aVector.size(); - for(int k = 0; k < kEnd; k++) - stmOut<second; - const VISU::TField::TValField &aValField = aField.myValField; - VISU::TField::TValField::const_reverse_iterator iter = aField.myValField.rbegin(); - for(int i = 0; iter != aValField.rend(); iter++, i++) { - if(MYDEBUG) MESSAGE("VISU_Convertor_impl::ToDatFile - aTime = "<second; - VISU::TField::TValForTime::const_iterator jter = aValForTime.begin(); - stmOut<<(++i)<first).c_str(),i); - stmOut< - -class VISU_DatConvertor: public VISU_Convertor_impl{ - VISU_DatConvertor(); - VISU_DatConvertor(const VISU_DatConvertor&); -public: - VISU_DatConvertor(const string& theFileName) throw (std::runtime_error&); - virtual VISU_Convertor* Build() throw (std::runtime_error&); -protected: - QFileInfo myFileInfo; - int ImportHead(ifstream* pStmIn, int* theNbPoints, int* theNbCells, int* theNbFields) - throw (std::runtime_error&); - int ImportPoints(ifstream*, int theNbPoints) - throw (std::runtime_error&); - int ImportCells(ifstream*, vector* aCellsType) - throw (std::runtime_error&); - int ImportField(ifstream*, int theNbPoints, vector* aCellsType) - throw (std::runtime_error&); - protected: - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName = "") - throw (std::runtime_error&) {return 1;} - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) - throw (std::runtime_error&) {return 1;} - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) - throw (std::runtime_error&) {return 1;} -}; - -#endif diff --git a/src/VISU_I/VISU_Extractor.cxx b/src/VISU_I/VISU_Extractor.cxx deleted file mode 100644 index 58fc4844..00000000 --- a/src/VISU_I/VISU_Extractor.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_Extractor.cxx -// Module : VISU - -using namespace std; -#include "VISU_Extractor.hxx" - -#include - -#ifdef DEBUG -static int MYDEBUG = 1; -#else -static int MYDEBUG = 0; -#endif - -VISU_Extractor::VISU_Extractor(){ - myNbComp = 0; - myScalarMode = 0; -} -VISU_Extractor::~VISU_Extractor() {} -VISU_Extractor* VISU_Extractor::New(){ - vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_Extractor"); - if(ret) return (VISU_Extractor*)ret; - return new VISU_Extractor; -} -void VISU_Extractor::Extract(vtkUnstructuredGridReader* theReader, - const string& theFieldName, int theScalarMode, - int theNbComp, const VISU::TEntity& theEntity) -{ - myScalarMode = theScalarMode; - myNbComp = theNbComp; - myEntity = theEntity; - if(myNbComp == 1) - theReader->SetScalarsName(theFieldName.c_str()); - else - theReader->SetVectorsName(theFieldName.c_str()); - SetInput((vtkDataSet*)(theReader->GetOutput())); - Modified(); - Update(); -} -template void -execute(int theNbComp, int theScalarMode, TypeData* theInputData, TypeData* theOutputData){ -// mpv porting vtk 4.2.2 -// vtkVectors *inVectors = theInputData->GetVectors(); - vtkDataArray *inVectors = theInputData->GetVectors(); - if ( !inVectors || theNbComp < 1 ) - return; -// mpv porting vtk 4.2.2 -// vtkScalars *newScalars = vtkScalars::New(); - vtkFloatArray *newScalars = vtkFloatArray::New(); - newScalars->SetNumberOfComponents(1); - newScalars->SetNumberOfTuples(theNbComp); - for (int ptId = 0; ptId < theNbComp; ptId++) { - float v[3], s; - inVectors->GetTuple(ptId,v); - if ( theScalarMode < 1 || theScalarMode > 3) - s = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); - else - s = v[theScalarMode - 1]; - newScalars->SetTuple1(ptId, s); - } - theOutputData->SetScalars(newScalars); - newScalars->Delete(); -} -void VISU_Extractor::Execute(){ - vtkDataSet *input = this->GetInput(), *output = this->GetOutput(); - output->CopyStructure(input); - output->GetPointData()->CopyAllOff(); - output->GetCellData()->CopyAllOff(); - if(myEntity == VISU::NODE_ENTITY){ - output->GetPointData()->CopyVectorsOn(); - int nbComp = input->GetNumberOfPoints(); - vtkPointData *inData = input->GetPointData(), *outData = output->GetPointData(); - if(myNbComp > 1) - execute(nbComp,myScalarMode,inData,outData); - else - output->GetPointData()->CopyScalarsOn(); - outData->PassData(inData); - }else{ - output->GetCellData()->CopyVectorsOn(); - int nbComp = input->GetNumberOfCells(); - vtkCellData *inData = input->GetCellData(), *outData = output->GetCellData(); - if(myNbComp > 1) - execute(nbComp,myScalarMode,inData,outData); - else - output->GetCellData()->CopyScalarsOn(); - outData->PassData(inData); - } -} - - diff --git a/src/VISU_I/VISU_Extractor.hxx b/src/VISU_I/VISU_Extractor.hxx deleted file mode 100644 index 699edaf9..00000000 --- a/src/VISU_I/VISU_Extractor.hxx +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_Extractor.hxx -// Author : Alexey PETROV -// Module : VISU - -#ifndef VISU_Extractor_HeaderFile -#define VISU_Extractor_HeaderFile - -#include "VTKViewer_Common.h" -#include -#include "VISU_Convertor.hxx" -class vtkUnstructuredGridReader; - -class VTK_EXPORT VISU_Extractor : public vtkDataSetToDataSetFilter{ -public: - vtkTypeMacro(VISU_Extractor,vtkDataSetToDataSetFilter); - static VISU_Extractor *New(); - void Extract(vtkUnstructuredGridReader* theReader, - const string& theFieldName, int theScalarMode, - int theNbComp, const VISU::TEntity& theEntity); -protected: - VISU_Extractor(); - virtual ~VISU_Extractor(); - VISU_Extractor(const VISU_Extractor&) {}; - void operator=(const VISU_Extractor&) {}; - void Execute(); - - int myNbComp; - int myScalarMode; - VISU::TEntity myEntity; -}; - -#endif diff --git a/src/VISU_I/VISU_FieldTransform.cxx b/src/VISU_I/VISU_FieldTransform.cxx deleted file mode 100644 index f51a9172..00000000 --- a/src/VISU_I/VISU_FieldTransform.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_FieldTransform.cxx -// Module : VISU - -using namespace std; -#include "VISU_FieldTransform.hxx" -#include "utilities.h" - -#include - -#ifdef DEBUG -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif - -extern "C" { -double Identical(double theArg) { - return theArg; -} - -double Logarithmic10(double theArg) { - if(theArg <= 0.0) return -1.0E+38; - //if(theArg == 0.0) return 0.0; - //if(theArg < 0.0) return log10(-theArg); - return log10(theArg); -} - -} - -VISU_FieldTransform::VISU_FieldTransform(){ - myFunction = &Identical; -} - -VISU_FieldTransform::~VISU_FieldTransform() {} - -VISU_FieldTransform* VISU_FieldTransform::New(){ - vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_FieldTransform"); - if(ret) return (VISU_FieldTransform*)ret; - return new VISU_FieldTransform; -} - -void VISU_FieldTransform::SetTransformFunction(TTransformFun theFunction) { - myFunction = theFunction; - if(myFunction == NULL) myFunction = &Identical; - Modified(); -} - -void VISU_FieldTransform::SetScalarRange(float theScalarRange[2]) { - myScalarRange[0] = theScalarRange[0]; - myScalarRange[1] = theScalarRange[1]; - Modified(); -} - -template void -ExecVectors(VISU_FieldTransform::TTransformFun theFunction, float theScalarRange[2], - int theNbComponent, TypeData* theInputData, TypeData* theOutputData) -{ - vtkDataArray *inVectors = theInputData->GetVectors(); - if ( !inVectors || theNbComponent < 1 ) return; - vtkFloatArray *newVectors = vtkFloatArray::New(); - newVectors->SetNumberOfComponents(3); - newVectors->SetNumberOfTuples(theNbComponent); - float aScalarRange[2] = {(*theFunction)(theScalarRange[0]),(*theFunction)(theScalarRange[1])}; - float *V, v[3], vMag, aDelta = aScalarRange[1] - aScalarRange[0]; - for (int ptId = 0; ptId < theNbComponent; ptId++) { - V = inVectors->GetTuple3(ptId); - vMag = vtkMath::Norm(V); - vMag = ((*theFunction)(vMag) - aScalarRange[0]) / aDelta * theScalarRange[1] / vMag; - if(vMag <= 0.0) vMag = 0.0; - v[0] = V[0]*vMag; - v[1] = V[1]*vMag; - v[2] = V[2]*vMag; - newVectors->SetTuple3(ptId, v[0], v[1], v[2]); - } - theOutputData->SetVectors(newVectors); - newVectors->Delete(); -} - -template void -ExecScalars(VISU_FieldTransform::TTransformFun theFunction, float theScalarRange[2], - int theNbComponent, TypeData* theInputData, TypeData* theOutputData) -{ - vtkDataArray *inScalars = theInputData->GetScalars(); - if ( !inScalars || theNbComponent < 1 ) - return; - vtkFloatArray *newScalars = vtkFloatArray::New(); - newScalars->SetNumberOfComponents(1); - newScalars->SetNumberOfTuples(theNbComponent); - float aScalarRange[2] = {(*theFunction)(theScalarRange[0]),(*theFunction)(theScalarRange[1])}; - for (int ptId = 0; ptId < theNbComponent; ptId++) { - float s = (*theFunction)(inScalars->GetTuple1(ptId )); - if(s < aScalarRange[0]) s = aScalarRange[0]; - newScalars->SetTuple1(ptId, s); - } - theOutputData->SetScalars(newScalars); - newScalars->Delete(); -} - -void VISU_FieldTransform::Execute(){ - vtkDataSet *input = this->GetInput(), *output = this->GetOutput(); - output->CopyStructure(input); - if(myFunction != &Identical){ - output->GetPointData()->CopyAllOff(); - output->GetCellData()->CopyAllOff(); - - ExecScalars(myFunction,myScalarRange,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData()); - ExecVectors(myFunction,myScalarRange,input->GetNumberOfPoints(),input->GetPointData(),output->GetPointData()); - - ExecScalars(myFunction,myScalarRange,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData()); - ExecVectors(myFunction,myScalarRange,input->GetNumberOfCells(),input->GetCellData(),output->GetCellData()); - }else{ - output->GetPointData()->CopyAllOn(); - output->GetCellData()->CopyAllOn(); - - output->GetPointData()->PassData(input->GetPointData()); - output->GetCellData()->PassData(input->GetCellData()); - } -} - - diff --git a/src/VISU_I/VISU_FieldTransform.hxx b/src/VISU_I/VISU_FieldTransform.hxx deleted file mode 100644 index 511299b4..00000000 --- a/src/VISU_I/VISU_FieldTransform.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_Extractor.hxx -// Author : Alexey PETROV -// Module : VISU - -#ifndef VISU_FieldTransform_HeaderFile -#define VISU_FieldTransform_HeaderFile - -#include "VTKViewer_Common.h" -#include - -class VTK_EXPORT VISU_FieldTransform : public vtkDataSetToDataSetFilter{ -public: - vtkTypeMacro(VISU_FieldTransform,vtkDataSetToDataSetFilter); - static VISU_FieldTransform *New(); - typedef double (*TTransformFun)(double); - void SetTransformFunction(TTransformFun theFunction); - void SetScalarRange(float theScalarRange[2]); -protected: - VISU_FieldTransform(); - virtual ~VISU_FieldTransform(); - VISU_FieldTransform(const VISU_FieldTransform&) {}; - void operator=(const VISU_FieldTransform&) {}; - void Execute(); - - TTransformFun myFunction; - float myScalarRange[2]; -}; -extern "C" { - double Identical(double theArg); - double Logarithmic10(double theArg); -} - -#endif diff --git a/src/VISU_I/VISU_MedConvertor.cxx b/src/VISU_I/VISU_MedConvertor.cxx deleted file mode 100644 index eb442ab9..00000000 --- a/src/VISU_I/VISU_MedConvertor.cxx +++ /dev/null @@ -1,663 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_MedConvertor.cxx -// Author : Alexey PETROV -// Module : VISU - -using namespace std; -#include "VISU_MedConvertor.hxx" -#include -#include -#define USER_INTERLACE MED_FULL_INTERLACE -using namespace std; - -#ifdef DEBUG -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif -static med_err ret = 0; - -typedef map TVisu2MedEntity; -static TVisu2MedEntity aVisu2MedEntity; -static int INIT = ( - aVisu2MedEntity[VISU::NODE_ENTITY] = MED_NOEUD, - aVisu2MedEntity[VISU::EDGE_ENTITY] = MED_ARETE, - aVisu2MedEntity[VISU::FACE_ENTITY] = MED_FACE, - aVisu2MedEntity[VISU::CELL_ENTITY] = MED_MAILLE, - 1); - -static med_geometrie_element NODEGEOM[1] = {MED_POINT1}; -static med_geometrie_element EDGEGEOM[MED_NBR_GEOMETRIE_ARETE] = { - MED_SEG2, MED_SEG3 - }; -static med_geometrie_element FACEGEOM[MED_NBR_GEOMETRIE_FACE] = { - MED_TRIA3, MED_QUAD4, MED_TRIA6, MED_QUAD8 - }; -static med_geometrie_element CELLGEOM[MED_NBR_GEOMETRIE_MAILLE] = { - MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3, - MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4, - MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10, - MED_PYRA13, MED_PENTA15, MED_HEXA20 - }; -void GetEntity2Geom(const VISU::TEntity& theEntity, med_geometrie_element*& theVector, int* theEnd) - throw (std::runtime_error&) -{ - switch(theEntity){ - case VISU::CELL_ENTITY: theVector = CELLGEOM; *theEnd = MED_NBR_GEOMETRIE_MAILLE; break; - case VISU::FACE_ENTITY: theVector = FACEGEOM; *theEnd = MED_NBR_GEOMETRIE_FACE; break; - case VISU::EDGE_ENTITY: theVector = EDGEGEOM; *theEnd = MED_NBR_GEOMETRIE_ARETE; break; - case VISU::NODE_ENTITY: theVector = NODEGEOM; *theEnd = 1; break; - default: - throw std::runtime_error("GetEntity2Geom >> theEntity is uncorrect"); - } -} - -extern "C" -VISU_Convertor* CreateMedConvertor(const string& theFileName) throw(std::runtime_error&){ - return new VISU_MedConvertor(theFileName); -} - -int med2vtkCellType(int medType){ - for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - if(med2vtk[i].medType == medType) return med2vtk[i].vtkType; - return -1; -} - -int vtk2medCellType(int vtkType){ - for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - if(med2vtk[i].vtkType == vtkType) return med2vtk[i].medType; - return -1; -} - -class MedFile{ - char* myFileName; - med_idt myFid; - MedFile(); - MedFile(const MedFile&); -public: - MedFile(const char* theFileName) throw(std::runtime_error&) : - myFileName(strdup(theFileName)) - { - myFid = MEDouvrir(myFileName,MED_LECT); - if(myFid < 0){ - free(myFileName); - throw std::runtime_error(string("MedFile::MedFile >> MEDouvrir(...) - ") + theFileName); - } - } - ~MedFile(){ - free(myFileName); - if(myFid >= 0) - MEDfermer(myFid); - } - const med_idt& GetFid() const { return myFid;}; -}; - -VISU_MedConvertor::VISU_MedConvertor(const string& theFileName) throw (std::runtime_error&) { - myFileInfo.setFile(QString(theFileName.c_str())); - myName = (const char*)(myFileInfo.baseName()); -} - -VISU_Convertor* VISU_MedConvertor::Build() throw (std::runtime_error&) { - MedFile aMedFile(myFileInfo.absFilePath()); - med_idt fid = aMedFile.GetFid(); - med_int iMeshEnd = MEDnMaa(fid); //Get number of meshes - if(MYDEBUG) MESSAGE("ImportInfo - MEDnMaa = "<> MEDnoeudsLire(...)"); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] != 0) - aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity; - } - } - //Get number of connectivities - med_int iNumElemEnd = MEDnEntMaa(fid,aMeshName,MED_CONN,aMedEntity,aMedType,MED_NOD); - if (iNumElemEnd > 0) { - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - aMeshOnEntity.myEntity = anEntity; - aMeshOnEntity.myMeshName = aMeshName; - med_booleen iname_elem, inum_elem; - valarray num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); - valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); - med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim); - if(MYDEBUG) - MESSAGE("ImportInfo -\t anEntity = "<> MEDelementsLire(...)"); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] != 0) - aFamily2EntityMap[num_fam_elem[iNumElem]] = anEntity; - } - } - } - med_int aNbFamily = MEDnFam(fid,aMeshName,0,MED_FAMILLE); - if(MYDEBUG) MESSAGE("ImportInfo - aNbFamily = "< anAttId(aNbAttrib), anAttVal(aNbAttrib); - valarray anAttDesc('\0',aNbAttrib*MED_TAILLE_DESC+1); - med_int aNbGroup = MEDnFam(fid,aMeshName,aFamInd,MED_GROUPE); - if(0 && MYDEBUG) - MESSAGE("ImportInfo - aFamInd = "<> MEDfamInfo"); - if(0 && MYDEBUG) - MESSAGE("ImportInfo - aFamilyNum = "<second; - const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap; - if(aFamilyMap.empty()) continue; - VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); - for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const VISU::TFamily& aFamily = aFamilyMapIter->second; - const VISU::TBindGroups& aBindGroups = aFamily.myGroups; - if(aBindGroups.empty()) continue; - VISU::TBindGroups::const_iterator aBindGroupsIter = aBindGroups.begin(); - for(; aBindGroupsIter != aBindGroups.end(); aBindGroupsIter++){ - const string& aGroupName = *aBindGroupsIter; - VISU::TGroup& aGroup = aGroupMap[aGroupName]; - aGroup.myName = aGroupName; - aGroup.myMeshName = aMesh.myName; - VISU::TFamilyAndEntity aFamilyAndEntity(aFamily.myName,aFamily.myEntity); - aGroup.myFamilyAndEntitySet.insert(aFamilyAndEntity); - } - } - } - //Displaing information for the TMesh.TGroupMap - VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); - if(MYDEBUG) MESSAGE("ImportInfo - aGroupMap.size() = "<first; - if(MYDEBUG) MESSAGE("ImportInfo - aGroupName = '"<second; - const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet; - VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = aFamilyAndEntitySet.begin(); - for(; aFamilyAndEntitySetIter != aFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){ - const string& aFamilyName = aFamilyAndEntitySetIter->first; - if(MYDEBUG) MESSAGE("ImportInfo - \t aFamilyName = '"<> MEDnChamp(fid,0)"); - if(MYDEBUG) MESSAGE("ImportInfo - iFieldEnd = "<> MEDnChamp(fid,i)"); - valarray aCompNames('\0',ncomp*MED_TAILLE_PNOM + 1); - valarray aUnitNames('\0',ncomp*MED_TAILLE_PNOM + 1); - char name_field[MED_TAILLE_NOM + 1] = ""; - med_type_champ type_field; - if(MEDchampInfo(fid,iField,name_field,&type_field,&aCompNames[0],&aUnitNames[0],ncomp) < 0) - throw std::runtime_error(string("ImportInfo >> MEDchampInfo(...)")); - //if(type_field != MED_REEL64) continue; //There is some problem in reading INTXX values - TVisu2MedEntity::const_iterator aVisu2MedEntityIter = aVisu2MedEntity.begin(); - for(; aVisu2MedEntityIter != aVisu2MedEntity.end(); aVisu2MedEntityIter++) { - VISU::TEntity anEntity = aVisu2MedEntityIter->first; - int iGeomElemEnd; - med_geometrie_element* aGeomElemVector; - GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd); - med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity]; - for (int iGeomElem = 0; iGeomElem < iGeomElemEnd; iGeomElem++) { - med_geometrie_element& aGeom = aGeomElemVector[iGeomElem]; - med_int iTimeStampEnd = MEDnPasdetemps(fid,name_field,aMedEntity,aGeom); - if(iTimeStampEnd < 0) throw std::runtime_error("ImportInfo >> MEDnPasdetemps(...)"); - if(iTimeStampEnd > 0) { - for(med_int iTimeStamp = 1; iTimeStamp <= iTimeStampEnd; iTimeStamp++) { - char aMeshName[MED_TAILLE_NOM+1] = ""; - med_int ngauss = 0, numdt = 0, numo = 0; - char dt_unit[MED_TAILLE_PNOM+1] = ""; - med_float dt = 0; - ret = MEDpasdetempsInfo(fid,name_field,aMedEntity,aGeom,iTimeStamp, - aMeshName,&ngauss,&numdt,dt_unit,&dt,&numo); - if(ret < 0) throw std::runtime_error("ImportInfo >> MEDpasdetempsInfo(...) < 0"); - if(myMeshMap.find(aMeshName) == myMeshMap.end()) - throw std::runtime_error("ImportInfo >> MEDpasdetempsInfo(...)"); - VISU::TMesh &aMesh = myMeshMap[aMeshName]; - VISU::TMeshOnEntity& aMeshOnEntity = aMesh.myMeshOnEntityMap[anEntity]; - VISU::TFieldMap::iterator aFieldMapIter = aMeshOnEntity.myFieldMap.find(name_field); - //if(MYDEBUG && aFieldMapIter == aMeshOnEntity.myFieldMap.end()){ - VISU::TField& aField = aMeshOnEntity.myFieldMap[name_field]; - if(iTimeStamp == 1){ - if(MYDEBUG){ - MESSAGE("ImportInfo - aField.myName = '"<first; - const VISU::TEntity& anEntity = aFamilyAndEntitySetIter->second; - VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[anEntity]; - if(anEntity == VISU::NODE_ENTITY){ - isPointsUpdated += LoadPoints(fid,theMesh,aFamilyName); - isCellsOnEntityUpdated += LoadCellsOnEntity(fid,aMeshOnEntity); - }else{ - isPointsUpdated += LoadPoints(fid,theMesh); - isCellsOnEntityUpdated += LoadCellsOnEntity(fid,aMeshOnEntity,aFamilyName); - } - } - - return (isPointsUpdated || isCellsOnEntityUpdated); -} - -int VISU_MedConvertor::LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) - throw (std::runtime_error&) -{ - //Open the med file (it will be closed by call of destructor) - MedFile aMedFile(myFileInfo.absFilePath()); - med_idt fid = aMedFile.GetFid(); - //Main part of code - int isPointsUpdated = LoadPoints(fid,theMesh); - int isCellsOnEntityUpdated = LoadCellsOnEntity(fid,theMeshOnEntity); - int isFieldUpdated = LoadField(fid,theMeshOnEntity,theField,theValForTime); - - return (isPointsUpdated || isCellsOnEntityUpdated || isFieldUpdated); -} - -int VISU_MedConvertor::LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, const string& theFamilyName) - throw (std::runtime_error&) -{ - try{ - //Check on existing family - VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap[VISU::NODE_ENTITY]; - aMeshOnEntity.myEntity = VISU::NODE_ENTITY; - aMeshOnEntity.myMeshName = theMesh.myName; - VISU::TFamily* pFamily = VISU::GetFamily(aMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; - //Check on loading already done - bool isPointsLoaded = !theMesh.myPointsCoord.empty(); - if(isPointsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; - if(MYDEBUG) - MESSAGE("LoadPoints - isPointsLoaded = "<> MEDnEntMaa(...)"); - if(MYDEBUG) MESSAGE("LoadPoints - iNumElemEnd = "< num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); - valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); - valarray name_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1); - valarray unit_coord('\0',theMesh.myDim*MED_TAILLE_PNOM+1); - valarray coord(theMesh.myDim*iNumElemEnd); - ret = MEDnoeudsLire(fid,aMeshName,theMesh.myDim,&coord[0],MED_FULL_INTERLACE,&rep, - &name_coord[0],&unit_coord[0],&name_elem[0],&iname_elem, - &num_elem[0],&inum_elem,&num_fam_elem[0],iNumElemEnd); - if(ret < 0) throw std::runtime_error("LoadPoints >> MEDnoeudsLire(...)"); - if(!isPointsLoaded){ - VISU::TMesh::TPointsCoord& aPointsCoord = theMesh.myPointsCoord; - aPointsCoord.resize(iNumElemEnd*theMesh.myDim); - if(MYDEBUG) MESSAGE("LoadPoints - Filling coordinates of the mesh - inum_elem = "< 0){ - if(MYDEBUG) MESSAGE("LoadPoints - Filling aFamily SubMesh"); - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[VTK_VERTEX]; - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] == aFamily.myId) - aSubMeshOnCellType.insert(iNumElem); - } - return 1; - }catch(std::runtime_error& exc){ - theMesh.myPointsCoord.clear(); - throw std::runtime_error(exc.what()); - }catch(...){ - theMesh.myPointsCoord.clear(); - throw std::runtime_error("Unknown exception !!!"); - } - return 0; -} - -int VISU_MedConvertor::LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName) - throw (std::runtime_error&) -{ - try{ - //Check on existing family - VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName); - bool isFamilyPresent = (pFamily != NULL); - VISU::TFamily& aFamily = *pFamily; - //Check on loading already done - bool isCellsLoaded = !theMeshOnEntity.myCellsConn.empty(); - if(isCellsLoaded) - if(!isFamilyPresent) return 0; - else if(!aFamily.mySubMesh.empty()) return 0; - if(MYDEBUG) { - MESSAGE("LoadCellsOnEntity - theFamilyName = '"< 0) { - med_booleen iname_elem, inum_elem; - valarray num_elem(iNumElemEnd), num_fam_elem(iNumElemEnd); - valarray name_elem('\0',iNumElemEnd*MED_TAILLE_PNOM+1); - med_int aNbConnForElem = getNbMedConnect(aMedType,anEntity,aMesh.myDim); - if(MYDEBUG) MESSAGE("LoadCellsOnEntity - medName = "<> MEDelementsLire(...)"); - if(!isCellsLoaded){ - VISU::TMeshOnEntity::TConnForCellType& aConnForCellType = theMeshOnEntity.myCellsConn[aVtkType]; - aConnForCellType.resize(iNumElemEnd); - valarray aConnect(nbMedNodes); - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) { - VISU::TMeshOnEntity::TConnect& anArray = aConnForCellType[iNumElem]; - anArray.resize(nbVtkNodes); - for (int k = 0, kj = iNumElem*aNbConnForElem; k < nbMedNodes; k++) { - aConnect[k] = conn[kj+k] - 1; - } - switch(aMedType){ - case MED_TETRA4 : - case MED_TETRA10 : - anArray[0] = aConnect[0]; - anArray[1] = aConnect[1]; - anArray[2] = aConnect[3]; - anArray[3] = aConnect[2]; - break; - case MED_PYRA5 : - case MED_PYRA13 : - anArray[0] = aConnect[0]; - anArray[1] = aConnect[3]; - anArray[2] = aConnect[2]; - anArray[3] = aConnect[1]; - anArray[4] = aConnect[4]; - break; - default: - for (int k = 0; k < nbVtkNodes; k++) - anArray[k] = aConnect[k]; - } - for (int k = 0; k < nbVtkNodes; k++) - if(anArray[k] < 0 || aNbPoints <= anArray[k]){ - static QString aString; - aString.sprintf("ImportCells >> aNbPoints(%d) <= anArray[%d][%d](%d) < 0",aNbPoints,iNumElem,k,anArray[k]); - throw std::runtime_error(aString.latin1()); - } - } - } - //Filling aFamily SubMesh - if(isFamilyPresent){ - VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aFamily.mySubMesh[aVtkType]; - for (int iNumElem = 0; iNumElem < iNumElemEnd; iNumElem++) - if(num_fam_elem[iNumElem] == aFamily.myId) - aSubMeshOnCellType.insert(iNumElem); - } - } - } - return 1; - }catch(std::runtime_error& exc){ - theMeshOnEntity.myCellsConn.clear(); - throw std::runtime_error(exc.what()); - }catch(...){ - theMeshOnEntity.myCellsConn.clear(); - throw std::runtime_error("Unknown exception !!!"); - } - return 0; -} - -int VISU_MedConvertor::LoadField(const med_idt& fid, const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, VISU::TField::TValForTime& theValForTime) - throw (std::runtime_error&) -{ - //Check on loading already done - if(!theValForTime.myValForCells.empty()) return 0; - //Main part of code - med_int ncomp = MEDnChamp(fid,theField.myId); - if(ncomp < 0) throw std::runtime_error("LoadField >> MEDnChamp(fid,i)"); - valarray comp('\0',ncomp*MED_TAILLE_PNOM + 1); - valarray unit('\0',ncomp*MED_TAILLE_PNOM + 1); - char aFieldName[MED_TAILLE_NOM + 1] = ""; - med_type_champ type_field; - if(MEDchampInfo(fid,theField.myId,aFieldName,&type_field,&comp[0],&unit[0],ncomp) < 0) - throw std::runtime_error(string("LoadField >> MEDchampInfo(...)")); - int iGeomElemEnd; - med_geometrie_element* aGeomElemVector; - const VISU::TEntity& anEntity = theField.myEntity; - GetEntity2Geom(anEntity,aGeomElemVector,&iGeomElemEnd); - med_entite_maillage& aMedEntity = aVisu2MedEntity[anEntity]; - if(MYDEBUG) { - MESSAGE("LoadField - aFieldName = '"<> MEDpasdetempsInfo(...)"); - med_int nval = MEDnVal(fid,aFieldName,aMedEntity,aGeom,numdt,numo); - if (nval <= 0) throw std::runtime_error("LoadField >> MEDnVal(...) - nval <= 0"); - else{ - //Checking for accordance between the mesh and the field on number of geomterical elements - int aVtkType = med2vtkCellType(aGeom); - const VISU::TMeshOnEntity::TCellsConn& aCellsConn = theMeshOnEntity.myCellsConn; - VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.find(aVtkType); - if(aCellsConnIter == aCellsConn.end()) throw std::runtime_error("LoadField - There is no the geom. elem. on the mesh !!!"); - const VISU::TMeshOnEntity::TConnForCellType aConnForCellType = aCellsConnIter->second; - if(aConnForCellType.size() != nval) throw std::runtime_error("LoadField - Size of values and size of mesh not equal !!!"); - if(MYDEBUG) MESSAGE("LoadField - aGeom = "< valr(jEnd); - ret = MEDchampLire(fid,aMeshName,aFieldName,(unsigned char*)&valr[0],MED_FULL_INTERLACE,MED_ALL, - pflname,aMedEntity,aGeom,numdt,numo); - for (med_int j = 0; j < jEnd; j++) anArray[j] = valr[j]; - break; - } - //case MED_INT64 : //valarray valr(jEnd); - case MED_INT32 : //valarray valr(jEnd); - case MED_INT : { - valarray valr(jEnd); - ret = MEDchampLire(fid,aMeshName,aFieldName,(unsigned char*)&valr[0],MED_FULL_INTERLACE,MED_ALL, - pflname,aMedEntity,aGeom,numdt,numo); - for (med_int j = 0; j < jEnd; j++) anArray[j] = valr[j]; - break; - } - default : - throw std::runtime_error("LoadField >> Value of med_type_champ for the field is wrong !!!"); - } - if(ret < 0) throw std::runtime_error("ChampLire >> MEDchampLire(...)"); - } - } - } - return 1; -} diff --git a/src/VISU_I/VISU_MedConvertor.hxx b/src/VISU_I/VISU_MedConvertor.hxx deleted file mode 100644 index 9b14cf1a..00000000 --- a/src/VISU_I/VISU_MedConvertor.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : VISU_MedConvertor.hxx -// Author : Alexey PETROV -// Module : VISU - -#ifndef VISU_MedConvertor_HeaderFile -#define VISU_MedConvertor_HeaderFile - -#include "VISU_Convertor_impl.hxx" - -extern "C"{ -#include -} - -class VISU_MedConvertor: public VISU_Convertor_impl{ - VISU_MedConvertor(); - VISU_MedConvertor(const VISU_MedConvertor&); -public: - VISU_MedConvertor(const string& theFileName) throw (std::runtime_error&); - virtual VISU_Convertor* Build() throw (std::runtime_error&); -protected: - QFileInfo myFileInfo; - - virtual int LoadMeshOnEntity(VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName = "") - throw (std::runtime_error&); - virtual int LoadMeshOnGroup(VISU::TMesh& theMesh, - const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet) - throw (std::runtime_error&); - virtual int LoadFieldOnMesh(VISU::TMesh& theMesh, - VISU::TMeshOnEntity& theMeshOnEntity, - VISU::TField& theField, - VISU::TField::TValForTime& theValForTime) - throw (std::runtime_error&); - - int LoadPoints(const med_idt& fid, VISU::TMesh& theMesh, - const string& theFamilyName = "") - throw (std::runtime_error&); - int LoadCellsOnEntity(const med_idt& fid, VISU::TMeshOnEntity& theMeshOnEntity, - const string& theFamilyName = "") - throw (std::runtime_error&); - int LoadField(const med_idt& fid, const VISU::TMeshOnEntity& theMeshOnEntity, - const VISU::TField& theField, VISU::TField::TValForTime& theValForTime) - throw (std::runtime_error&); -}; - -#endif