Back to index

salome-med  6.5.0
MEDCouplingMesh.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
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 __PARAMEDMEM_MEDCOUPLINGMESH_HXX__
00021 #define __PARAMEDMEM_MEDCOUPLINGMESH_HXX__
00022 
00023 #include "MEDCoupling.hxx"
00024 #include "MEDCouplingTimeLabel.hxx"
00025 #include "MEDCouplingRefCountObject.hxx"
00026 #include "NormalizedUnstructuredMesh.hxx"
00027 #include "InterpKernelException.hxx"
00028 
00029 #include <set>
00030 #include <vector>
00031 
00032 namespace ParaMEDMEM
00033 {
00034   typedef enum
00035     {
00036       UNSTRUCTURED = 5,
00037       UNSTRUCTURED_DESC = 6,
00038       CARTESIAN = 7,
00039       EXTRUDED = 8
00040     } MEDCouplingMeshType;
00041 
00042   class DataArrayInt;
00043   class DataArrayDouble;
00044   class MEDCouplingUMesh;
00045   class MEDCouplingFieldDouble;
00046 
00047   class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject, public TimeLabel
00048   {
00049   public:
00050     void setName(const char *name) { _name=name; }
00051     const char *getName() const { return _name.c_str(); }
00052     void setDescription(const char *descr) { _description=descr; }
00053     const char *getDescription() const { return _description.c_str(); }
00054     double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _time; }
00055     void setTime(double val, int iteration, int order) { _time=val; _iteration=iteration; _order=order; }
00056     void setTimeUnit(const char *unit) { _time_unit=unit; }
00057     const char *getTimeUnit() const { return _time_unit.c_str(); }
00058     virtual MEDCouplingMesh *deepCpy() const = 0;
00059     virtual MEDCouplingMeshType getType() const = 0;
00060     bool isStructured() const;
00061     virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
00062     virtual void copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
00063     // comparison methods
00064     virtual bool isEqual(const MEDCouplingMesh *other, double prec) const;
00065     virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0;
00066     virtual void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
00067                                       DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception) = 0;
00068     virtual void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
00069                                                  DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception) = 0;
00070     virtual void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
00071     void checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec,
00072                              DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
00073     //
00074     virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
00075     virtual void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0;
00076     virtual void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0;
00077     virtual int getNumberOfCells() const = 0;
00078     virtual int getNumberOfNodes() const = 0;
00079     virtual int getSpaceDimension() const = 0;
00080     virtual int getMeshDimension() const = 0;
00081     virtual DataArrayDouble *getCoordinatesAndOwner() const = 0;
00082     virtual DataArrayDouble *getBarycenterAndOwner() const = 0;
00083     virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const = 0;
00084     virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0;
00085     virtual std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const = 0;
00086     virtual void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const = 0;
00087     virtual DataArrayInt *getCellIdsFullyIncludedInNodeIds(const int *partBg, const int *partEnd) const;
00088     virtual void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const throw(INTERP_KERNEL::Exception) = 0;
00089     virtual std::string simpleRepr() const = 0;
00090     virtual std::string advancedRepr() const = 0;
00091     // tools
00092     virtual std::vector<int> getDistributionOfTypes() const throw(INTERP_KERNEL::Exception) = 0;
00093     virtual DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception) = 0;
00094     virtual void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception) = 0;
00095     virtual void getBoundingBox(double *bbox) const = 0;
00096     virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
00097     virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0;
00098     virtual int getCellContainingPoint(const double *pos, double eps) const = 0;
00099     virtual void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
00100     virtual void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
00101     virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const;
00102     virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const;
00103     virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const;
00104     virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const;
00105     virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0;
00106     virtual void rotate(const double *center, const double *vector, double angle) = 0;
00107     virtual void translate(const double *vector) = 0;
00108     virtual void scale(const double *point, double factor) = 0;
00109     virtual void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception) = 0;
00110     virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const = 0;
00111     virtual MEDCouplingMesh *buildPart(const int *start, const int *end) const = 0;
00112     virtual MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const = 0;
00113     virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception) = 0;
00114     virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception) = 0;
00115     virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const;
00116     static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) throw(INTERP_KERNEL::Exception);
00117     static MEDCouplingMesh *MergeMeshes(std::vector<const MEDCouplingMesh *>& meshes) throw(INTERP_KERNEL::Exception);
00118     //serialisation-unserialization
00119     virtual void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const = 0;
00120     virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const = 0;
00121     virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const = 0;
00122     virtual void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
00123                                  const std::vector<std::string>& littleStrings) = 0;
00124     void writeVTK(const char *fileName) const throw(INTERP_KERNEL::Exception);
00126     void writeVTKAdvanced(const char *fileName, const std::string& cda, const std::string& pda) const throw(INTERP_KERNEL::Exception);
00128     virtual void writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception) = 0;
00129   protected:
00130     MEDCouplingMesh();
00131     MEDCouplingMesh(const MEDCouplingMesh& other);
00132     virtual std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception) = 0;
00133     virtual ~MEDCouplingMesh() { }
00134   private:
00135     std::string _name;
00136     std::string _description;
00137     double _time;
00138     int _iteration;
00139     int _order;
00140     std::string _time_unit;
00141   };
00142 }
00143 
00144 #endif