Back to index

salome-med  6.5.0
MEDCouplingPointSet.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_MEDCOUPLINGPOINTSET_HXX__
00021 #define __PARAMEDMEM_MEDCOUPLINGPOINTSET_HXX__
00022 
00023 #include "MEDCoupling.hxx"
00024 #include "MEDCouplingMesh.hxx"
00025 
00026 #include <vector>
00027 
00028 namespace INTERP_KERNEL
00029 {
00030   class DirectedBoundingBox;
00031 }
00032 
00033 namespace ParaMEDMEM
00034 {
00035   class DataArrayInt;
00036   class DataArrayDouble;
00037   
00046   class MEDCOUPLING_EXPORT MEDCouplingPointSet : public MEDCouplingMesh
00047   {
00048   protected:
00049     MEDCouplingPointSet();
00050     MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCopy);
00051     ~MEDCouplingPointSet();
00052   public:
00053     void updateTime() const;
00054     int getNumberOfNodes() const;
00055     int getSpaceDimension() const;
00056     void setCoords(const DataArrayDouble *coords);
00058     const DataArrayDouble *getCoords() const { return _coords; }
00060     DataArrayDouble *getCoords() { return _coords; }
00061     DataArrayDouble *getCoordinatesAndOwner() const;
00062     void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
00063     bool isEqual(const MEDCouplingMesh *other, double prec) const;
00064     bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
00065     bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
00066     bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const;
00067     virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
00068     virtual DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
00069     void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const throw(INTERP_KERNEL::Exception);
00070     DataArrayInt *buildPermArrayForMergeNode(double precision, int limitNodeId, bool& areNodesMerged, int& newNbOfNodes) const;
00071     std::vector<int> getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception);
00072     void getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& cI) const throw(INTERP_KERNEL::Exception);
00073     void findCommonNodes(double prec, int limitNodeId, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
00074     DataArrayInt *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex,
00075                                                          int& newNbOfNodes) const;
00076     void getBoundingBox(double *bbox) const throw(INTERP_KERNEL::Exception);
00077     void zipCoords();
00078     double getCaracteristicDimension() const;
00079     void rotate(const double *center, const double *vector, double angle);
00080     void translate(const double *vector);
00081     void scale(const double *point, double factor);
00082     void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception);
00083     void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
00084     virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
00085     void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector<int>& nodes) const throw(INTERP_KERNEL::Exception);
00086     void findNodesOnLine(const double *pt, const double *vec, double eps, std::vector<int>& nodes) const throw(INTERP_KERNEL::Exception);
00087     static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
00088     static DataArrayDouble *MergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception);
00089     static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type);
00090     static void Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords);
00091     static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords);
00092     MEDCouplingMesh *buildPart(const int *start, const int *end) const;
00093     MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
00094     virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0;
00095     virtual MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0;
00096     virtual MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0;
00097     virtual void findBoundaryNodes(std::vector<int>& nodes) const = 0;
00098     virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0;
00099     virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
00100     virtual void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes);
00101     virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const = 0;
00103     void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
00104     void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
00105     void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
00106     void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
00107                          const std::vector<std::string>& littleStrings);
00108     virtual void getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) const = 0;
00109     virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) = 0;
00110     virtual DataArrayInt *zipCoordsTraducer() = 0;
00111   protected:
00112     virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception) = 0;
00113     static bool intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps);
00114     static bool intersectsBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bb1, const double* bb2, int dim, double eps);
00115     void rotate2D(const double *center, double angle);
00116     void rotate3D(const double *center, const double *vect, double angle);
00117     void project2DCellOnXY(const int *startConn, const int *endConn, std::vector<double>& res) const;
00118     static bool isButterfly2DCell(const std::vector<double>& res, bool isQuad, double eps);
00119     template<int SPACEDIM>
00120     void findNodeIdsNearPointAlg(std::vector<double>& bbox, const double *pos, int nbNodes, double eps,
00121                                  std::vector<int>& c, std::vector<int>& cI) const;
00122   protected:
00123     DataArrayDouble *_coords;
00124   };
00125 }
00126 
00127 #endif