00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 deepCpy);
00051 ~MEDCouplingPointSet();
00052 public:
00053 void updateTime() const;
00054 int getNumberOfNodes() const;
00055 int getSpaceDimension() const;
00056 void setCoords(const DataArrayDouble *coords);
00057 const DataArrayDouble *getCoords() const { return _coords; }
00058 DataArrayDouble *getCoords() { return _coords; }
00059 DataArrayDouble *getCoordinatesAndOwner() const;
00060 void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
00061 bool isEqual(const MEDCouplingMesh *other, double prec) const;
00062 bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
00063 bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
00064 bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const;
00065 virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
00066 virtual DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
00067 DataArrayInt *buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const;
00068 std::vector<int> getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception);
00069 void getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& cI) const throw(INTERP_KERNEL::Exception);
00070 void findCommonNodes(int limitNodeId, double prec, DataArrayInt *&comm, DataArrayInt *&commIndex) const;
00071 DataArrayInt *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex,
00072 int& newNbOfNodes) const;
00073 void getBoundingBox(double *bbox) const;
00074 void zipCoords();
00075 double getCaracteristicDimension() const;
00076 void rotate(const double *center, const double *vector, double angle);
00077 void translate(const double *vector);
00078 void scale(const double *point, double factor);
00079 void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception);
00080 void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
00081 virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
00082 void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector<int>& nodes) const throw(INTERP_KERNEL::Exception);
00083 static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
00084 static DataArrayDouble *MergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception);
00085 static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type);
00086 static void Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords);
00087 static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords);
00088 MEDCouplingMesh *buildPart(const int *start, const int *end) const;
00089 MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
00090 virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0;
00091 virtual MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0;
00092 virtual MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0;
00093 virtual void findBoundaryNodes(std::vector<int>& nodes) const = 0;
00094 virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0;
00095 virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
00096 virtual void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes);
00097 virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const = 0;
00099 void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
00100 void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
00101 void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
00102 void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
00103 const std::vector<std::string>& littleStrings);
00104 virtual void getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) = 0;
00105 virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) = 0;
00106 virtual DataArrayInt *zipCoordsTraducer() = 0;
00107 protected:
00108 virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception) = 0;
00109 static bool intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps);
00110 static bool intersectsBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bb1, const double* bb2, int dim, double eps);
00111 void rotate2D(const double *center, double angle);
00112 void rotate3D(const double *center, const double *vect, double angle);
00113 void project2DCellOnXY(const int *startConn, const int *endConn, std::vector<double>& res) const;
00114 static bool isButterfly2DCell(const std::vector<double>& res, bool isQuad);
00115 template<int SPACEDIM>
00116 void findCommonNodesAlg(std::vector<double>& bbox,
00117 int nbNodes, int limitNodeId, double prec, std::vector<int>& c, std::vector<int>& cI) const;
00118 template<int SPACEDIM>
00119 void findNodeIdsNearPointAlg(std::vector<double>& bbox, const double *pos, int nbNodes, double eps,
00120 std::vector<int>& c, std::vector<int>& cI) const;
00121 protected:
00122 DataArrayDouble *_coords;
00123 };
00124 }
00125
00126 #endif