From 494641f1c87fcfe43597eb5ebce2fcea2e192315 Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 7 Jun 2005 07:17:04 +0000 Subject: [PATCH] portability gcc 3.4 and vtk 4.4.n --- src/VTKViewer/Makefile.in | 3 +- src/VTKViewer/VTKViewer_Actor.cxx | 4 +- src/VTKViewer/VTKViewer_Actor.h | 3 +- src/VTKViewer/VTKViewer_Algorithm.h | 2 +- src/VTKViewer/VTKViewer_CellRectPicker.cxx | 28 ++++---- src/VTKViewer/VTKViewer_CellRectPicker.h | 13 ++-- src/VTKViewer/VTKViewer_Definitions.h | 11 +++ .../VTKViewer_InteractorStyleSALOME.cxx | 34 ++++----- .../VTKViewer_InteractorStyleSALOME.h | 7 +- src/VTKViewer/VTKViewer_RectPicker.cxx | 72 +++++++++---------- src/VTKViewer/VTKViewer_RectPicker.h | 13 ++-- src/VTKViewer/VTKViewer_RenderWindow.cxx | 5 +- src/VTKViewer/VTKViewer_Trihedron.cxx | 22 +++--- src/VTKViewer/VTKViewer_Trihedron.h | 11 +-- src/VTKViewer/VTKViewer_Utilities.cxx | 24 +++---- src/VTKViewer/VTKViewer_Utilities.h | 6 +- src/VTKViewer/VTKViewer_ViewFrame.cxx | 13 ++-- 17 files changed, 146 insertions(+), 125 deletions(-) create mode 100644 src/VTKViewer/VTKViewer_Definitions.h diff --git a/src/VTKViewer/Makefile.in b/src/VTKViewer/Makefile.in index f5e06c1ed..3443ff9d9 100644 --- a/src/VTKViewer/Makefile.in +++ b/src/VTKViewer/Makefile.in @@ -35,7 +35,8 @@ VPATH=.:@srcdir@:$(top_builddir)/inc:$(top_builddir)/idl @COMMENCE@ # header files -EXPORT_HEADERS= VTKViewer_RenderWindow.h \ +EXPORT_HEADERS= VTKViewer_Definitions.h \ + VTKViewer_RenderWindow.h \ VTKViewer_ViewFrame.h \ VTKViewer_RenderWindowInteractor.h \ VTKViewer_InteractorStyleSALOME.h \ diff --git a/src/VTKViewer/VTKViewer_Actor.cxx b/src/VTKViewer/VTKViewer_Actor.cxx index eb8cd140f..a72ca5ccf 100644 --- a/src/VTKViewer/VTKViewer_Actor.cxx +++ b/src/VTKViewer/VTKViewer_Actor.cxx @@ -81,7 +81,7 @@ VTKViewer_Actor::VTKViewer_Actor() } -void VTKViewer_Actor::SetShrinkFactor(float theValue){ +void VTKViewer_Actor::SetShrinkFactor(_VTK_FLOAT_ theValue){ myShrinkFilter->SetShrinkFactor(theValue); Modified(); } @@ -164,7 +164,7 @@ void VTKViewer_Actor::MapPoints(SALOME_Actor* theMapActor, aPoints->SetNumberOfPoints(aNbOfParts); for(int i = 0; i < aNbOfParts; i++){ int aPartId = theMapIndex( i+1 ); - float* aCoord = theMapActor->GetNodeCoord(aPartId); + _VTK_FLOAT_* aCoord = theMapActor->GetNodeCoord(aPartId); aPoints->SetPoint(i,aCoord); myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i); } diff --git a/src/VTKViewer/VTKViewer_Actor.h b/src/VTKViewer/VTKViewer_Actor.h index a708aa63e..24a31a779 100644 --- a/src/VTKViewer/VTKViewer_Actor.h +++ b/src/VTKViewer/VTKViewer_Actor.h @@ -27,6 +27,7 @@ class vtkShrinkFilter; class vtkDataSetMapper; class vtkUnstructuredGrid; +#include "VTKViewer_Definitions.h" #include "SALOME_Actor.h" class VTKViewer_Actor : public SALOME_Actor { @@ -35,7 +36,7 @@ class VTKViewer_Actor : public SALOME_Actor { static VTKViewer_Actor* New(); virtual ~VTKViewer_Actor(); - void SetShrinkFactor(float value); + void SetShrinkFactor(_VTK_FLOAT_ value); virtual void SetShrink(); virtual void UnShrink(); diff --git a/src/VTKViewer/VTKViewer_Algorithm.h b/src/VTKViewer/VTKViewer_Algorithm.h index cd38a862d..aa9f83c90 100644 --- a/src/VTKViewer/VTKViewer_Algorithm.h +++ b/src/VTKViewer/VTKViewer_Algorithm.h @@ -30,7 +30,7 @@ #define VTKViewer_Algorithm_H class vtkActor; -class vtkActorCollection; +#include namespace SALOME{ namespace VTK{ diff --git a/src/VTKViewer/VTKViewer_CellRectPicker.cxx b/src/VTKViewer/VTKViewer_CellRectPicker.cxx index b2506538b..7d19e7d5d 100644 --- a/src/VTKViewer/VTKViewer_CellRectPicker.cxx +++ b/src/VTKViewer/VTKViewer_CellRectPicker.cxx @@ -68,7 +68,7 @@ void VTKViewer_CellRectPicker::Initialize() } //---------------------------------------------------------------------------- -float VTKViewer_CellRectPicker::IntersectWithHex(float p1[4][4], float p2[4][4], float tol, +_VTK_FLOAT_ VTKViewer_CellRectPicker::IntersectWithHex(_VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol, vtkAssemblyPath *path, vtkProp3D *prop3D, vtkAbstractMapper3D *m) { @@ -93,9 +93,9 @@ float VTKViewer_CellRectPicker::IntersectWithHex(float p1[4][4], float p2[4][4], } int i, k, subId; - float bounds[6], center[3], cp1[3], cp2[3]; - float pcoord[3], weight[4], dist; - float t1[2], t2[2], x[3], t; + _VTK_FLOAT_ bounds[6], center[3], cp1[3], cp2[3]; + _VTK_FLOAT_ pcoord[3], weight[4], dist; + _VTK_FLOAT_ t1[2], t2[2], x[3], t; for (k = 0; k < 4; k++) { this->Quad1->PointIds->SetId(k, k); @@ -118,8 +118,8 @@ float VTKViewer_CellRectPicker::IntersectWithHex(float p1[4][4], float p2[4][4], VTKViewer_CellData cellData; VTKViewer_CellDataSet dataList; - char inside; int n; float *point; - float tMin = VTK_LARGE_FLOAT, xMin[3]; + char inside; int n; _VTK_FLOAT_ *point; + _VTK_FLOAT_ tMin = VTK_LARGE_FLOAT, xMin[3]; for (cellId = 0; cellId < numCells; cellId++) { input->GetCell(cellId, this->Cell); @@ -206,7 +206,7 @@ void VTKViewer_CellRectPicker::IncludeCell(vtkDataSet* input, sub1 = cell1->GetFace(cellData.subId); int i, result; - float p1[3], p2[3], dir[3]; + _VTK_FLOAT_ p1[3], p2[3], dir[3]; char add = 1; VTKViewer_CellData curData; @@ -274,7 +274,7 @@ void VTKViewer_CellRectPicker::IncludeActor(vtkProp3D* prop, vtkGenericCell* cell2 = vtkGenericCell::New(); int i, result; - float p1[3], p2[3], dir[3]; + _VTK_FLOAT_ p1[3], p2[3], dir[3]; char removed; VTKViewer_CellDataSet actorData; @@ -331,10 +331,10 @@ void VTKViewer_CellRectPicker::IncludeActor(vtkProp3D* prop, cell2->Delete(); } -int VTKViewer_CellRectPicker::IntersectCells(vtkCell* c1, float d1, vtkCell* c2, float d2, float dir[3]) +int VTKViewer_CellRectPicker::IntersectCells(vtkCell* c1, _VTK_FLOAT_ d1, vtkCell* c2, _VTK_FLOAT_ d2, _VTK_FLOAT_ dir[3]) { int i, k; - float *orig, cp[3], bounds[6]; + _VTK_FLOAT_ *orig, cp[3], bounds[6]; vtkCell* cell = 0; vtkCell* tcell = 0; @@ -358,10 +358,10 @@ int VTKViewer_CellRectPicker::IntersectCells(vtkCell* c1, float d1, vtkCell* c2, cp[i] = (bounds[2*i] + bounds[2*i+1])/2; } - float proj[3]; + _VTK_FLOAT_ proj[3]; vtkPlane::GeneralizedProjectPoint(cp, orig, dir, proj); - float *p, pp[3]; + _VTK_FLOAT_ *p, pp[3]; vtkPoints* aPoints = vtkPoints::New(); for (k = 0; k < cell->Points->GetNumberOfPoints(); k++) { p = cell->Points->GetPoint(k); @@ -390,10 +390,10 @@ int VTKViewer_CellRectPicker::IntersectCells(vtkCell* c1, float d1, vtkCell* c2, return result; } -char VTKViewer_CellRectPicker::PointInside(float point[3], vtkPoints* list) +char VTKViewer_CellRectPicker::PointInside(_VTK_FLOAT_ point[3], vtkPoints* list) { int i, k, l, n; - float x[3], *a1, *a2, v[3], p[3], q[3]; + _VTK_FLOAT_ x[3], *a1, *a2, v[3], p[3], q[3]; n = list->GetNumberOfPoints(); if (n < 3) return 0; diff --git a/src/VTKViewer/VTKViewer_CellRectPicker.h b/src/VTKViewer/VTKViewer_CellRectPicker.h index 76b0b8c40..e451b27bb 100644 --- a/src/VTKViewer/VTKViewer_CellRectPicker.h +++ b/src/VTKViewer/VTKViewer_CellRectPicker.h @@ -28,6 +28,7 @@ #ifndef __VTKViewer_CellRectPicker_h #define __VTKViewer_CellRectPicker_h +#include "VTKViewer_Definitions.h" #include "VTKViewer_RectPicker.h" #include #include @@ -35,9 +36,9 @@ typedef struct { vtkIdType cellId; int subId; - float depth; - float p1[3]; - float p2[3]; + _VTK_FLOAT_ depth; + _VTK_FLOAT_ p1[3]; + _VTK_FLOAT_ p2[3]; } VTKViewer_CellData; typedef std::vector VTKViewer_CellDataSet; @@ -63,11 +64,11 @@ public: // The method returns a non-zero value if the cells intersect each other // in the direction dir[3]. Returned value is 1 if the first cell is top of // the second one according to direction and 2 if the second cell is top. - static int IntersectCells(vtkCell* c1, float d1, vtkCell* c2, float d2, float dir[3]); + static int IntersectCells(vtkCell* c1, _VTK_FLOAT_ d1, vtkCell* c2, _VTK_FLOAT_ d2, _VTK_FLOAT_ dir[3]); // Description: // The method returns a non-zero value if the point is inlide point data set - static char PointInside(float point[3], vtkPoints* list); + static char PointInside(_VTK_FLOAT_ point[3], vtkPoints* list); protected: VTKViewer_CellRectPicker(); @@ -75,7 +76,7 @@ protected: VTKViewer_ActorDataMap ActorData; - virtual float IntersectWithHex(float p1[4][4], float p2[4][4], float tol, + virtual _VTK_FLOAT_ IntersectWithHex(_VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol, vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m); void Initialize(); diff --git a/src/VTKViewer/VTKViewer_Definitions.h b/src/VTKViewer/VTKViewer_Definitions.h new file mode 100644 index 000000000..fd66496f2 --- /dev/null +++ b/src/VTKViewer/VTKViewer_Definitions.h @@ -0,0 +1,11 @@ + +#ifndef __VTKViewer_Definitions_h +#define __VTKViewer_Definitions_h + +#if ((VTK_MAJOR_VERSION == 4)&&(VTK_MINOR_VERSION <= 2)) +#define _VTK_FLOAT_ float +#else +#define _VTK_FLOAT_ double +#endif + +#endif diff --git a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx index 0fd4d7c52..140334fbf 100644 --- a/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx +++ b/src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx @@ -106,12 +106,12 @@ static bool IsSelected(Handle(SALOME_InteractiveObject)& theIO, static int GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId){ int anEdgeId = -1; if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) { - float aPickPosition[3]; + _VTK_FLOAT_ aPickPosition[3]; thePicker->GetPickPosition(aPickPosition); - float aMinDist = 1000000.0, aDist = 0; + _VTK_FLOAT_ aMinDist = 1000000.0, aDist = 0; for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){ if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){ - int subId; float pcoords[3], closestPoint[3], weights[3]; + int subId; _VTK_FLOAT_ pcoords[3], closestPoint[3], weights[3]; aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights); if (aDist < aMinDist) { aMinDist = aDist; @@ -993,15 +993,15 @@ void VTKViewer_InteractorStyleSALOME::onFinishOperation() if (vtkDataSet* aDataSet = SActor->GetInput()) { SALOME_Selection::TContainerOfId anIndices; for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) { - float aPoint[3]; + _VTK_FLOAT_ aPoint[3]; aDataSet->GetPoint(i,aPoint); if (IsInRect(aPoint,x1,y1,x2,y2)){ - float aDisp[3]; + _VTK_FLOAT_ aDisp[3]; ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp); if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){ if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){ if(anActorCollection->IsItemPresent(SActor)){ - float aPickedPoint[3]; + _VTK_FLOAT_ aPickedPoint[3]; aPointPicker->GetMapperPosition(aPickedPoint); vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint); if ( aVtkId >= 0 && IsValid( SActor, aVtkId, true ) ){ @@ -1351,7 +1351,7 @@ void VTKViewer_InteractorStyleSALOME::TranslateView(int toX, int toY, int fromX, { vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); double viewFocus[4], focalDepth, viewPoint[3]; - float newPickPoint[4], oldPickPoint[4], motionVector[3]; + _VTK_FLOAT_ newPickPoint[4], oldPickPoint[4], motionVector[3]; cam->GetFocalPoint(viewFocus); this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], @@ -1384,17 +1384,17 @@ bool VTKViewer_InteractorStyleSALOME::IsInRect(vtkActor* theActor, const int left, const int top, const int right, const int bottom) { - float* aBounds = theActor->GetBounds(); - float aMin[3], aMax[3]; + _VTK_FLOAT_* aBounds = theActor->GetBounds(); + _VTK_FLOAT_ aMin[3], aMax[3]; ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin); ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax); if (aMin[0] > aMax[0]) { - float aBuf = aMin[0]; + _VTK_FLOAT_ aBuf = aMin[0]; aMin[0] = aMax[0]; aMax[0] = aBuf; } if (aMin[1] > aMax[1]) { - float aBuf = aMin[1]; + _VTK_FLOAT_ aBuf = aMin[1]; aMin[1] = aMax[1]; aMax[1] = aBuf; } @@ -1408,17 +1408,17 @@ bool VTKViewer_InteractorStyleSALOME::IsInRect(vtkCell* theCell, const int left, const int top, const int right, const int bottom) { - float* aBounds = theCell->GetBounds(); - float aMin[3], aMax[3]; + _VTK_FLOAT_* aBounds = theCell->GetBounds(); + _VTK_FLOAT_ aMin[3], aMax[3]; ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin); ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax); if (aMin[0] > aMax[0]) { - float aBuf = aMin[0]; + _VTK_FLOAT_ aBuf = aMin[0]; aMin[0] = aMax[0]; aMax[0] = aBuf; } if (aMin[1] > aMax[1]) { - float aBuf = aMin[1]; + _VTK_FLOAT_ aBuf = aMin[1]; aMin[1] = aMax[1]; aMax[1] = aBuf; } @@ -1427,11 +1427,11 @@ bool VTKViewer_InteractorStyleSALOME::IsInRect(vtkCell* theCell, } -bool VTKViewer_InteractorStyleSALOME::IsInRect(float* thePoint, +bool VTKViewer_InteractorStyleSALOME::IsInRect(_VTK_FLOAT_* thePoint, const int left, const int top, const int right, const int bottom) { - float aPnt[3]; + _VTK_FLOAT_ aPnt[3]; ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt); return ((aPnt[0]>left) && (aPnt[0]bottom) && (aPnt[1] class vtkCell; @@ -116,13 +117,13 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl bool IsInRect(vtkCell* theCell, const int left, const int top, const int right, const int bottom); - bool IsInRect(float* thePoint, + bool IsInRect(_VTK_FLOAT_* thePoint, const int left, const int top, const int right, const int bottom); int State; - float MotionFactor; - float RadianToDegree; // constant: for conv from deg to rad + _VTK_FLOAT_ MotionFactor; + _VTK_FLOAT_ RadianToDegree; // constant: for conv from deg to rad double myScale; SALOME_Actor* myPreViewActor; diff --git a/src/VTKViewer/VTKViewer_RectPicker.cxx b/src/VTKViewer/VTKViewer_RectPicker.cxx index 6453097c0..9b5f99cbd 100644 --- a/src/VTKViewer/VTKViewer_RectPicker.cxx +++ b/src/VTKViewer/VTKViewer_RectPicker.cxx @@ -58,32 +58,32 @@ VTKViewer_RectPicker::VTKViewer_RectPicker() } //---------------------------------------------------------------------------- -int VTKViewer_RectPicker::Pick(float selectionX1, float selectionY1, float selectionZ1, - float selectionX2, float selectionY2, float selectionZ2, +int VTKViewer_RectPicker::Pick(_VTK_FLOAT_ selectionX1, _VTK_FLOAT_ selectionY1, _VTK_FLOAT_ selectionZ1, + _VTK_FLOAT_ selectionX2, _VTK_FLOAT_ selectionY2, _VTK_FLOAT_ selectionZ2, vtkRenderer *renderer) { int k, i; vtkProp *prop; vtkCamera *camera; vtkAbstractMapper3D *mapper = NULL; - float p1World[4][4], p2World[4][4], p1Mapper[4][4], p2Mapper[4][4]; - float c1[3], c2[3]; + _VTK_FLOAT_ p1World[4][4], p2World[4][4], p1Mapper[4][4], p2Mapper[4][4]; + _VTK_FLOAT_ c1[3], c2[3]; int picked=0; int *winSize; - float x, y, t, p; - float *viewport; - float cameraPos[4], cameraFP[4]; - float *displayCoords, *worldCoords; - float pickPosition[4][3]; + _VTK_FLOAT_ x, y, t, p; + _VTK_FLOAT_ *viewport; + _VTK_FLOAT_ cameraPos[4], cameraFP[4]; + _VTK_FLOAT_ *displayCoords, *worldCoords; + _VTK_FLOAT_ pickPosition[4][3]; double *clipRange; - float ray[4][3], rayLength[4]; + _VTK_FLOAT_ ray[4][3], rayLength[4]; int pickable; int LODId; - float windowLowerLeft[4], windowUpperRight[4]; - float bounds[6], tol; - float tF, tB; - float hitPosition[3]; - float cameraDOP[3]; + _VTK_FLOAT_ windowLowerLeft[4], windowUpperRight[4]; + _VTK_FLOAT_ bounds[6], tol; + _VTK_FLOAT_ tF, tB; + _VTK_FLOAT_ hitPosition[3]; + _VTK_FLOAT_ cameraDOP[3]; // Initialize picking process this->Initialize(); @@ -108,8 +108,8 @@ int VTKViewer_RectPicker::Pick(float selectionX1, float selectionY1, float selec // coordinates. We need a depth value for z-buffer. // camera = renderer->GetActiveCamera(); - camera->GetPosition((float *)cameraPos); cameraPos[3] = 1.0; - camera->GetFocalPoint((float *)cameraFP); cameraFP[3] = 1.0; + camera->GetPosition((_VTK_FLOAT_ *)cameraPos); cameraPos[3] = 1.0; + camera->GetFocalPoint((_VTK_FLOAT_ *)cameraFP); cameraFP[3] = 1.0; renderer->SetWorldPoint(cameraFP); renderer->WorldToDisplay(); @@ -396,13 +396,13 @@ int VTKViewer_RectPicker::Pick(float selectionX1, float selectionY1, float selec #define SIDE_RIGHT 1 #define SIDE_MIDDLE 2 -float GetParameterValue(float start, float end, float point) +_VTK_FLOAT_ GetParameterValue(_VTK_FLOAT_ start, _VTK_FLOAT_ end, _VTK_FLOAT_ point) { if (start == end) return -VTK_LARGE_FLOAT; return (point-start)/(end-start); } -void GetPointCoord(const float start[3], const float end[3], float t, float point[3]) +void GetPointCoord(const _VTK_FLOAT_ start[3], const _VTK_FLOAT_ end[3], _VTK_FLOAT_ t, _VTK_FLOAT_ point[3]) { int i; for (i = 0; i < 3; i++) { @@ -410,10 +410,10 @@ void GetPointCoord(const float start[3], const float end[3], float t, float poin } } -char GetIntersectionPoint(const float start[3], const float end[3], - const int& index, const float p, float point[3]) +char GetIntersectionPoint(const _VTK_FLOAT_ start[3], const _VTK_FLOAT_ end[3], + const int& index, const _VTK_FLOAT_ p, _VTK_FLOAT_ point[3]) { - float t = GetParameterValue(start[index], end[index], p); + _VTK_FLOAT_ t = GetParameterValue(start[index], end[index], p); char result = 0; if (t >= 0.0 && t <= 1.0) { result = 1; @@ -423,10 +423,10 @@ char GetIntersectionPoint(const float start[3], const float end[3], } //---------------------------------------------------------------------------- -char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float dir[4][3]) +char VTKViewer_RectPicker::HitBBox (_VTK_FLOAT_ bounds[6], _VTK_FLOAT_ origin[4][4], _VTK_FLOAT_ dir[4][3]) { int i, j, k, n; - float endray[4][3]; + _VTK_FLOAT_ endray[4][3]; for (k = 0; k < 4; k++) { for (i = 0; i < 3; i++) { @@ -435,7 +435,7 @@ char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float d } // Compute hex bounding box, center point and center direction - float hbounds[6], center[3], ray[3]; + _VTK_FLOAT_ hbounds[6], center[3], ray[3]; for (i = 0; i < 3; i++) { hbounds[2*i] = hbounds[2*i+1] = origin[0][i]; center[i] = ray[i] = 0; @@ -478,7 +478,7 @@ char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float d // Find the closest coord plane for the center point char side[3]; - float coordPlane[3]; + _VTK_FLOAT_ coordPlane[3]; inside = 1; for (i = 0; i < 3; i++) { if (center[i] < bounds[2*i]) { @@ -499,7 +499,7 @@ char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float d if (inside) return 1; // Calculate parametric distances to the planes and find the max - float maxT[3]; + _VTK_FLOAT_ maxT[3]; int whichPlane = 0; char defined = 0; for (i = 0; i < 3; i++) { @@ -516,7 +516,7 @@ char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float d } // Check for intersection along the center ray - float coord; + _VTK_FLOAT_ coord; if (maxT[whichPlane] <= 1.0 && maxT[whichPlane] >= 0.0) { inside = 1; for (i = 0; i < 3; i++) { @@ -545,7 +545,7 @@ char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float d } // Compute the intersection between hex and coord plane - float t[4]; + _VTK_FLOAT_ t[4]; for (k = 0; k < 4; k++) { if (dir[k][whichPlane] != 0.0) { t[k] = (coordPlane[whichPlane]-origin[k][whichPlane])/dir[k][whichPlane]; @@ -556,7 +556,7 @@ char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float d } vtkPoints* aPoints = vtkPoints::New(); - float p[3], q[3], t1; + _VTK_FLOAT_ p[3], q[3], t1; for (k = 0; k < 4; k++) { n = (k+1)%4; // next point if (t[k] > 1.0) { @@ -632,7 +632,7 @@ char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float d // Analize intersection int nearPlane, boundPlane = -1; - float boundCoord, boundMin, boundMax; + _VTK_FLOAT_ boundCoord, boundMin, boundMax; char intersect = 0; for (k = 0; k < n; k++) { aPoints->GetPoint(k, p); @@ -715,10 +715,10 @@ char VTKViewer_RectPicker::HitBBox (float bounds[6], float origin[4][4], float d } //---------------------------------------------------------------------------- -char VTKViewer_RectPicker::PointInside (float p[3], float p1[4][4], float p2[4][4], float tol) +char VTKViewer_RectPicker::PointInside (_VTK_FLOAT_ p[3], _VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol) { int i, j, k; - float t, coord[3]; + _VTK_FLOAT_ t, coord[3]; // Fix one coordinate (x, for example) and // compute intersection with coordinate plane @@ -806,7 +806,7 @@ char VTKViewer_RectPicker::PointInside (float p[3], float p1[4][4], float p2[4][ } // Fix the second coord and define bounds - float zMin = VTK_LARGE_FLOAT, zMax = -VTK_LARGE_FLOAT, z, ncoord[3]; + _VTK_FLOAT_ zMin = VTK_LARGE_FLOAT, zMax = -VTK_LARGE_FLOAT, z, ncoord[3]; char inside = 0; for (k = 0; k < n; k++) { aPoints->GetPoint(k, coord); @@ -837,12 +837,12 @@ char VTKViewer_RectPicker::PointInside (float p[3], float p1[4][4], float p2[4][ } //---------------------------------------------------------------------------- -float VTKViewer_RectPicker::IntersectWithHex(float p1[4][4], float p2[4][4], float tol, +_VTK_FLOAT_ VTKViewer_RectPicker::IntersectWithHex(_VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol, vtkAssemblyPath *path, vtkProp3D *prop3D, vtkAbstractMapper3D *mapper) { int i, k; - float *center, p0[3], ray[3], rayFactor, t; + _VTK_FLOAT_ *center, p0[3], ray[3], rayFactor, t; // Get the data from the modeler // diff --git a/src/VTKViewer/VTKViewer_RectPicker.h b/src/VTKViewer/VTKViewer_RectPicker.h index 44b7e0705..c3d86db01 100644 --- a/src/VTKViewer/VTKViewer_RectPicker.h +++ b/src/VTKViewer/VTKViewer_RectPicker.h @@ -28,6 +28,7 @@ #ifndef __VTKViewer_RectPicker_h #define __VTKViewer_RectPicker_h +#include "VTKViewer_Definitions.h" #include class VTK_EXPORT VTKViewer_RectPicker : public vtkPicker @@ -41,8 +42,8 @@ public: // first two values for the selection top-left and right-bottom points are // x-y pixel coordinate, and the third value is =0. // Return non-zero if something was successfully picked. - virtual int Pick(float selectionX1, float selectionY1, float selectionZ1, - float selectionX2, float selectionY2, float selectionZ2, + virtual int Pick(_VTK_FLOAT_ selectionX1, _VTK_FLOAT_ selectionY1, _VTK_FLOAT_ selectionZ1, + _VTK_FLOAT_ selectionX2, _VTK_FLOAT_ selectionY2, _VTK_FLOAT_ selectionZ2, vtkRenderer *renderer); // Description: @@ -50,7 +51,7 @@ public: // two values for the selection top-left and right-bottom points are x-y pixel // coordinate, and the third value is =0. // Return non-zero if something was successfully picked. - int Pick(float selectionPt1[3], float selectionPt2[3], vtkRenderer *ren) + int Pick(_VTK_FLOAT_ selectionPt1[3], _VTK_FLOAT_ selectionPt2[3], vtkRenderer *ren) {return this->Pick(selectionPt1[0], selectionPt1[1], selectionPt1[2], selectionPt2[0], selectionPt2[1], selectionPt2[2], ren);}; @@ -60,19 +61,19 @@ public: // if the bounding box is hit. Origin[4][4] starts the ray from corner points, // dir[4][3] is the vector components of the ray in the x-y-z directions. // (Notes: the intersection ray dir[4][3] is NOT normalized.) - static char HitBBox(float bounds[6], float origin[4][4], float dir[4][3]); + static char HitBBox(_VTK_FLOAT_ bounds[6], _VTK_FLOAT_ origin[4][4], _VTK_FLOAT_ dir[4][3]); // Description: // Position of point relative to hexahedron. The method returns a non-zero value // if the point is inside. p1[4][4] is the corner points of top face, // p2[4][4] is the corner points of bottom face. - static char PointInside(float point[3], float p1[4][4], float p2[4][4], float tol=0); + static char PointInside(_VTK_FLOAT_ point[3], _VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol=0); protected: VTKViewer_RectPicker(); ~VTKViewer_RectPicker() {}; - virtual float IntersectWithHex(float p1[4][4], float p2[4][4], float tol, + virtual _VTK_FLOAT_ IntersectWithHex(_VTK_FLOAT_ p1[4][4], _VTK_FLOAT_ p2[4][4], _VTK_FLOAT_ tol, vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m); diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx index bd97dd202..5027fba43 100644 --- a/src/VTKViewer/VTKViewer_RenderWindow.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -27,6 +27,7 @@ // $Header$ #include "VTKViewer_RenderWindow.h" +#include "VTKViewer_Definitions.h" #include "utilities.h" #include "QAD_Settings.h" #include "QAD_Config.h" @@ -185,8 +186,8 @@ void VTKViewer_RenderWindow::onCreatePopup() void VTKViewer_RenderWindow::onChangeBackgroundColor() { - float red, green, blue; - float backint[3]; + _VTK_FLOAT_ red, green, blue; + _VTK_FLOAT_ backint[3]; vtkRendererCollection * theRenderers = myRW->GetRenderers(); theRenderers->InitTraversal(); diff --git a/src/VTKViewer/VTKViewer_Trihedron.cxx b/src/VTKViewer/VTKViewer_Trihedron.cxx index 17b56a422..02712518b 100644 --- a/src/VTKViewer/VTKViewer_Trihedron.cxx +++ b/src/VTKViewer/VTKViewer_Trihedron.cxx @@ -57,19 +57,19 @@ VTKViewer_UnScaledActor::VTKViewer_UnScaledActor(){} void VTKViewer_UnScaledActor::Render(vtkRenderer *theRenderer){ if(theRenderer){ - float P[2][3] = {{-1.0, -1.0, 0.0},{+1.0, +1.0, 0.0}}; + _VTK_FLOAT_ P[2][3] = {{-1.0, -1.0, 0.0},{+1.0, +1.0, 0.0}}; theRenderer->ViewToWorld(P[0][0],P[0][1],P[0][2]); theRenderer->ViewToWorld(P[1][0],P[1][1],P[1][2]); - float aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+ + _VTK_FLOAT_ aWorldDiag = sqrt((P[1][0]-P[0][0])*(P[1][0]-P[0][0])+ (P[1][1]-P[0][1])*(P[1][1]-P[0][1])+ (P[1][2]-P[0][2])*(P[1][2]-P[0][2])); int* aSize = theRenderer->GetRenderWindow()->GetSize(); - float aWinDiag = sqrt(float(aSize[0]*aSize[0]+aSize[1]*aSize[1])); + _VTK_FLOAT_ aWinDiag = sqrt(_VTK_FLOAT_(aSize[0]*aSize[0]+aSize[1]*aSize[1])); vtkDataSet* aDataSet = GetMapper()->GetInput(); - float aLength = aDataSet->GetLength(); - float aPrecision = 1.0E-3; - float anOldScale = GetScale()[0]; - float aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(float(aSize[0])/float(aSize[1])); + _VTK_FLOAT_ aLength = aDataSet->GetLength(); + _VTK_FLOAT_ aPrecision = 1.0E-3; + _VTK_FLOAT_ anOldScale = GetScale()[0]; + _VTK_FLOAT_ aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(_VTK_FLOAT_(aSize[0])/_VTK_FLOAT_(aSize[1])); if(fabs(aScale - anOldScale)/aScale > aPrecision){ SetScale(aScale); } @@ -198,8 +198,8 @@ void VTKViewer_Axis::SetVisibility(VTKViewer_Trihedron::TVisibility theVis){ myVisibility = theVis; } -void VTKViewer_Axis::SetSize(float theSize){ - float aPosition[3] = {myDir[0]*theSize, myDir[1]*theSize, myDir[2]*theSize}; +void VTKViewer_Axis::SetSize(_VTK_FLOAT_ theSize){ + _VTK_FLOAT_ aPosition[3] = {myDir[0]*theSize, myDir[1]*theSize, myDir[2]*theSize}; myLineSource->SetPoint2(aPosition); myArrowActor->SetPosition(0.0,0.0,0.0); @@ -305,7 +305,7 @@ VTKViewer_Trihedron::VTKViewer_Trihedron(){ myAxis[0] = VTKViewer_XAxis::New(); myAxis[1] = VTKViewer_YAxis::New(); myAxis[2] = VTKViewer_ZAxis::New(); - static float aSize = 100; + static _VTK_FLOAT_ aSize = 100; SetSize(aSize); } @@ -316,7 +316,7 @@ VTKViewer_Trihedron::~VTKViewer_Trihedron(){ myAxis[i]->Delete(); } -void VTKViewer_Trihedron::SetSize(float theSize){ +void VTKViewer_Trihedron::SetSize(_VTK_FLOAT_ theSize){ mySize = theSize; for(int i = 0; i < 3; i++) myAxis[i]->SetSize(theSize); diff --git a/src/VTKViewer/VTKViewer_Trihedron.h b/src/VTKViewer/VTKViewer_Trihedron.h index 169e47345..d4037f18c 100644 --- a/src/VTKViewer/VTKViewer_Trihedron.h +++ b/src/VTKViewer/VTKViewer_Trihedron.h @@ -29,6 +29,7 @@ #ifndef VTKViewer_Trihedron_H #define VTKViewer_Trihedron_H +#include "VTKViewer_Definitions.h" #include #include @@ -98,8 +99,8 @@ class VTKViewer_Trihedron : public vtkObject{ vtkTypeMacro(VTKViewer_Trihedron,vtkObject); static VTKViewer_Trihedron *New(); - virtual void SetSize(float theSize); - virtual float GetSize() { return mySize;} + virtual void SetSize(_VTK_FLOAT_ theSize); + virtual _VTK_FLOAT_ GetSize() { return mySize;} enum TVisibility{eOff, eOn, eOnlyLineOn}; virtual void SetVisibility(TVisibility theVis); @@ -115,7 +116,7 @@ class VTKViewer_Trihedron : public vtkObject{ protected: vtkActorCollection* myPresent; VTKViewer_Axis* myAxis[3]; - float mySize; + _VTK_FLOAT_ mySize; }; //============================================================================== @@ -137,14 +138,14 @@ protected: virtual void SetCamera(vtkCamera* theCamera); virtual void SetProperty(vtkProperty* theProperty); - virtual void SetSize(float theSize); + virtual void SetSize(_VTK_FLOAT_ theSize); virtual VTKViewer_UnScaledActor* GetLabel(){ return myLabelActor; } virtual VTKViewer_UnScaledActor* GetArrow(){ return myArrowActor; } protected: VTKViewer_Trihedron::TVisibility myVisibility; - float myDir[3], myRot[3]; + _VTK_FLOAT_ myDir[3], myRot[3]; VTKViewer_LineActor *myLineActor; //vtkActor *myLineActor; diff --git a/src/VTKViewer/VTKViewer_Utilities.cxx b/src/VTKViewer/VTKViewer_Utilities.cxx index b8b61997f..cfecc21ad 100644 --- a/src/VTKViewer/VTKViewer_Utilities.cxx +++ b/src/VTKViewer/VTKViewer_Utilities.cxx @@ -38,13 +38,13 @@ using namespace std; -//see vtkRenderer::ResetCamera(float bounds[6]) method +//see vtkRenderer::ResetCamera(_VTK_FLOAT_ bounds[6]) method void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint){ if(!theRenderer) return; - float bounds[6]; + _VTK_FLOAT_ bounds[6]; int aCount = ComputeVisiblePropBounds(theRenderer,bounds); if(theUsingZeroFocalPoint || aCount){ - float aLength = bounds[1]-bounds[0]; + _VTK_FLOAT_ aLength = bounds[1]-bounds[0]; aLength = max((bounds[3]-bounds[2]),aLength); aLength = max((bounds[5]-bounds[4]),aLength); @@ -56,7 +56,7 @@ void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint){ return; } - float center[3] = {0.0, 0.0, 0.0}; + _VTK_FLOAT_ center[3] = {0.0, 0.0, 0.0}; if(!theUsingZeroFocalPoint){ center[0] = (bounds[0] + bounds[1])/2.0; center[1] = (bounds[2] + bounds[3])/2.0; @@ -64,12 +64,12 @@ void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint){ } theRenderer->GetActiveCamera()->SetFocalPoint(center[0],center[1],center[2]); - float width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + + _VTK_FLOAT_ width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) + (bounds[5]-bounds[4])*(bounds[5]-bounds[4])); double ang = theRenderer->GetActiveCamera()->GetViewAngle(); - float distance = 2.0*width/tan(ang*vtkMath::Pi()/360.0); + _VTK_FLOAT_ distance = 2.0*width/tan(ang*vtkMath::Pi()/360.0); // check view-up vector against view plane normal double *vup = theRenderer->GetActiveCamera()->GetViewUp(); @@ -84,7 +84,7 @@ void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint){ center[2]+distance*vn[2]); // find size of the window int* winsize = theRenderer->GetSize(); - if(winsize[0] < winsize[1]) width *= float(winsize[1])/float(winsize[0]); + if(winsize[0] < winsize[1]) width *= _VTK_FLOAT_(winsize[1])/_VTK_FLOAT_(winsize[0]); if(theUsingZeroFocalPoint) width *= sqrt(2.0); @@ -97,9 +97,9 @@ void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint){ // Compute the bounds of the visible props -int ComputeVisiblePropBounds(vtkRenderer* theRenderer, float theBounds[6]){ +int ComputeVisiblePropBounds(vtkRenderer* theRenderer, _VTK_FLOAT_ theBounds[6]){ vtkProp *prop; - float *bounds; + _VTK_FLOAT_ *bounds; int aCount=0; theBounds[0] = theBounds[2] = theBounds[4] = VTK_LARGE_FLOAT; @@ -154,7 +154,7 @@ int ComputeVisiblePropBounds(vtkRenderer* theRenderer, float theBounds[6]){ } -//see vtkRenderer::ResetCameraClippingRange(float bounds[6]) method +//see vtkRenderer::ResetCameraClippingRange(_VTK_FLOAT_ bounds[6]) method void ResetCameraClippingRange(vtkRenderer* theRenderer){ if(!theRenderer || !theRenderer->VisibleActorCount()) return; @@ -170,7 +170,7 @@ void ResetCameraClippingRange(vtkRenderer* theRenderer){ double position[3]; anActiveCamera->GetPosition(position); - float bounds[6]; + _VTK_FLOAT_ bounds[6]; theRenderer->ComputeVisiblePropBounds(bounds); double center[3]; @@ -186,7 +186,7 @@ void ResetCameraClippingRange(vtkRenderer* theRenderer){ (position[1]-center[1])*(position[1]-center[1]) + (position[2]-center[2])*(position[2]-center[2])); - float range[2] = {distance - width/2.0, distance + width/2.0}; + _VTK_FLOAT_ range[2] = {distance - width/2.0, distance + width/2.0}; // Do not let the range behind the camera throw off the calculation. if (range[0] < 0.0) range[0] = 0.0; diff --git a/src/VTKViewer/VTKViewer_Utilities.h b/src/VTKViewer/VTKViewer_Utilities.h index e297ce737..7103af014 100644 --- a/src/VTKViewer/VTKViewer_Utilities.h +++ b/src/VTKViewer/VTKViewer_Utilities.h @@ -29,11 +29,13 @@ #ifndef VTKViewer_Utilities_H #define VTKViewer_Utilities_H +#include "VTKViewer_Definitions.h" + class vtkRenderer; extern void ResetCamera(vtkRenderer* theRenderer, int theUsingZeroFocalPoint = false); -extern int ComputeVisiblePropBounds(vtkRenderer* theRenderer, float theBounds[6]); +extern int ComputeVisiblePropBounds(vtkRenderer* theRenderer, _VTK_FLOAT_ theBounds[6]); extern void ResetCameraClippingRange(vtkRenderer* theRenderer); -extern float EPS_BNDBOX; +extern _VTK_FLOAT_ EPS_BNDBOX; #endif diff --git a/src/VTKViewer/VTKViewer_ViewFrame.cxx b/src/VTKViewer/VTKViewer_ViewFrame.cxx index 783b60bae..87c577ce9 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.cxx +++ b/src/VTKViewer/VTKViewer_ViewFrame.cxx @@ -27,6 +27,7 @@ // $Header$ #include "VTKViewer_ViewFrame.h" +#include "VTKViewer_Definitions.h" #include "VTKViewer_Utilities.h" #include "VTKViewer_Trihedron.h" #include "VTKViewer_RenderWindow.h" @@ -157,7 +158,7 @@ bool VTKViewer_ViewFrame::isTrihedronDisplayed(){ bool VTKViewer_ViewFrame::ComputeTrihedronSize( double& theNewSize, double& theSize ) { // calculating diagonal of visible props of the renderer - float bnd[ 6 ]; + _VTK_FLOAT_ bnd[ 6 ]; m_Triedron->VisibilityOff(); if ( ::ComputeVisiblePropBounds( m_Renderer, bnd ) == 0 ) { @@ -165,7 +166,7 @@ bool VTKViewer_ViewFrame::ComputeTrihedronSize( double& theNewSize, double& theS bnd[ 0 ] = bnd[ 2 ] = bnd[ 100 ] = 0; } m_Triedron->VisibilityOn(); - float aLength = 0; + _VTK_FLOAT_ aLength = 0; static bool CalcByDiag = false; if ( CalcByDiag ) { @@ -180,12 +181,12 @@ bool VTKViewer_ViewFrame::ComputeTrihedronSize( double& theNewSize, double& theS aLength = max( ( bnd[ 5 ] - bnd[ 4 ] ),aLength ); } - static float aSizeInPercents = 105; + static _VTK_FLOAT_ aSizeInPercents = 105; QString aSetting = QAD_CONFIG->getSetting( "Viewer:TrihedronSize" ); if ( !aSetting.isEmpty() ) aSizeInPercents = aSetting.toFloat(); - static float EPS_SIZE = 5.0E-3; + static _VTK_FLOAT_ EPS_SIZE = 5.0E-3; theSize = m_Triedron->GetSize(); theNewSize = aLength * aSizeInPercents / 100.0; @@ -335,7 +336,7 @@ void VTKViewer_ViewFrame::onViewReset(){ ::ResetCamera(m_Renderer,true); if(aTriedronIsVisible) m_Triedron->VisibilityOn(); else m_Triedron->VisibilityOff(); - static float aCoeff = 3.0; + static _VTK_FLOAT_ aCoeff = 3.0; aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale()); Repaint(); } @@ -390,7 +391,7 @@ void VTKViewer_ViewFrame::setBackgroundColor( const QColor& color) */ QColor VTKViewer_ViewFrame::backgroundColor() const { - float backint[3]; + _VTK_FLOAT_ backint[3]; if ( m_Renderer ) { m_Renderer->GetBackground(backint); return QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL ); -- 2.39.2