Back to index

salome-gui  6.5.0
VTKViewer_ArcBuilder.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef VTKVIEWER_ARCBUILDER_H
00021 #define VTKVIEWER_ARCBUILDER_H
00022 
00023 #include "VTKViewer.h"
00024 #include <list>
00025 #include <map>
00026 #include <vector>
00027 
00028 class vtkCell;
00029 class vtkDataArray;
00030 class vtkPoints;
00031 class vtkPolyData;
00032 class vtkUnstructuredGrid;
00033 
00034 class Pnt;
00035 
00036 typedef std::list<Pnt> PntList;
00037 
00038 vtkIdType MergevtkPoints(const std::vector<vtkPoints*>& theCollection,
00039                          const std::vector< std::vector<double> >& theScalarCollection,
00040                          vtkPoints* thePoints,
00041                          std::map<int, double>& thePntId2ScalarValue,
00042                          vtkIdType* &theIds);
00043 
00044 vtkIdType Build1DArc(vtkIdType cellId, 
00045                      vtkUnstructuredGrid* input, 
00046                      vtkPolyData *output,
00047                      vtkIdType *pts, 
00048                      vtkFloatingPointType myMaxArcAngle);
00049 
00050 Pnt CreatePnt(vtkCell* cell,
00051               vtkDataArray* scalars,
00052               vtkIdType index);
00053 
00057 class XYZ{
00058  public:
00059   
00060   XYZ();
00061   XYZ(double , double , double);
00062   ~XYZ();
00063   
00064   double X()const {return x;}
00065   double Y()const {return y;}
00066   double Z()const {return z;}
00067 
00068   void SetX(const double X) { x=X; }
00069   void SetY(const double Y) { y=Y; }
00070   void SetZ(const double Z) { z=Z; }
00071   
00072   void Coord (double& X, double& Y, double& Z) const { X = x; Y = y; Z = z; }
00073 
00074   double Modulus () const;
00075 
00076  private:
00077   double x;
00078   double y;
00079   double z;
00080 };
00081 
00085 class Pnt{
00086  public:
00087   Pnt();
00088   Pnt(double, double, double, double);
00089   ~Pnt();
00090 
00091   void Coord (double& X, double& Y, double& Z) const {coord.Coord(X,Y,Z);}
00092   XYZ GetXYZ() const {return coord;}
00093   double GetScalarValue() const { return scalarValue; }
00094 
00095  private:
00096   XYZ coord;
00097   double scalarValue;
00098 };
00099 
00103 class Vec{
00104  public:
00105 
00106   Vec(const double Xv, const double Yv, const double Zv);
00107   ~Vec();
00108   
00109   XYZ GetXYZ() const {return coord;}
00110 
00111   double AngleBetween(const Vec & Other);
00112   double AngleBetweenInGrad(const Vec & Other);
00113 
00114   Vec VectMultiplication(const Vec & Other) const;
00115   
00116  private:
00117   XYZ coord;
00118 };
00119 
00123 class Plane{
00124 
00125  public:
00126   Plane(const Pnt& thePnt1, const Pnt& thePnt2, const Pnt& thePnt3);
00127   ~Plane();
00128 
00129   double A() const {return myA;}
00130   double B() const {return myB;}
00131   double C() const {return myC;} 
00132 
00133   Vec GetNormale() const; 
00134   
00135  private:
00136   void CalculatePlane(const Pnt& thePnt1, const Pnt& thePnt2, const Pnt& thePnt3);
00137   
00138  private:
00139         double myA;
00140         double myB;
00141         double myC;
00142 };
00143 
00144 
00145 class VTKViewer_ArcBuilder{
00146  public:
00147   enum ArcStatus {Arc_Done=0, Arc_Error};
00148   VTKViewer_ArcBuilder(const Pnt& thePnt1,
00149                        const Pnt& thePnt2,
00150                        const Pnt& thePnt3,
00151                        double theAngle);
00152   
00153   ~VTKViewer_ArcBuilder();  
00154 
00155   Vec GetNormale();
00156   
00157   ArcStatus GetStatus(){return myStatus;}
00158 
00159   void GetAngle(const double theAngle);
00160 
00161   static double GetPointAngleOnCircle(const double theXCenter, const double theYCenter,
00162                                       const double theXPoint, const double theYPoint);
00163 
00164   vtkPoints* GetPoints();
00165   const std::vector<double>& GetScalarValues();
00166 
00167  private:
00168   
00169   enum IncOrder{MINUS=0,PLUS};
00170   
00171   vtkUnstructuredGrid* BuildGrid(const PntList& theList) const;
00172   vtkUnstructuredGrid* TransformGrid(vtkUnstructuredGrid* theGrid, const Vec& theAxis, const double angle) const;
00173   vtkUnstructuredGrid* BuildArc(std::vector<double>& theScalarValues);
00174   IncOrder GetArcAngle( const double& P1, const double& P2, const double& P3, double* Ang);
00175   
00176 
00177 
00178   private:
00179   Pnt myPnt1;
00180   Pnt myPnt2;
00181   Pnt myPnt3;
00182 
00183   double myAngle;
00184   ArcStatus myStatus;
00185   vtkPoints* myPoints;
00186   std::vector<double> myScalarValues;
00187 };
00188 
00189 #endif //VTKVIEWER_ARCBUILDER_H