Salome HOME
Merge from V6_main_20120808 08Aug12
[tools/medcoupling.git] / src / INTERP_KERNEL / Geometric2D / InterpKernelGeo2DEdgeLin.hxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __INTERPKERNELGEO2DEDGELIN_HXX__
21 #define __INTERPKERNELGEO2DEDGELIN_HXX__
22
23 #include "INTERPKERNELDefines.hxx"
24 #include "InterpKernelGeo2DEdge.hxx"
25
26 namespace INTERP_KERNEL
27 {
28   class INTERPKERNEL_EXPORT SegSegIntersector : SameTypeEdgeIntersector
29     {
30       friend class Edge;
31     public:
32       SegSegIntersector(const EdgeLin& e1, const EdgeLin& e2);
33       bool areColinears() const;
34       bool haveTheySameDirection() const;
35       void getPlacements(Node *start, Node *end, TypeOfLocInEdge& whereStart, TypeOfLocInEdge& whereEnd, MergePoints& commonNode) const;
36       void areOverlappedOrOnlyColinears(const Bounds *whereToFind, bool& obviousNoIntersection, bool& areOverlapped);
37       std::list< IntersectElement > getIntersectionsCharacteristicVal() const;
38     private:
39       void getCurveAbscisse(Node *node, TypeOfLocInEdge& where, MergePoints& commonNode) const;
40     private:
41       //! index on which all single index op will be performed. Filled in case colinearity is equal to true.
42       int _ind;
43       double _col[2];
44       double _matrix[4];//SPACEDIM*SPACEDIM
45     };
46
47   class INTERPKERNEL_EXPORT EdgeLin : public Edge
48   {
49     friend class SegSegIntersector;
50   public:
51     EdgeLin(std::istream& lineInXfig);
52     EdgeLin(Node *start, Node *end, bool direction=true);
53     EdgeLin(double sX, double sY, double eX, double eY);
54     ~EdgeLin();
55     TypeOfFunction getTypeOfFunc() const { return SEG; }
56     void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const;
57     void update(Node *m);
58     double getNormSq() const;
59     double getAreaOfZone() const;
60     double getCurveLength() const;
61     void getBarycenter(double *bary) const;
62     void getBarycenterOfZone(double *bary) const;
63     bool isIn(double characterVal) const;
64     Node *buildRepresentantOfMySelf() const;
65     double getCharactValue(const Node& node) const;
66     double getCharactValueBtw0And1(const Node& node) const;
67     double getDistanceToPoint(const double *pt) const;
68     bool isNodeLyingOn(const double *coordOfNode) const;
69     bool isLower(double val1, double val2) const { return val1<val2; }
70     double getCharactValueEng(const double *node) const;
71     bool doIHaveSameDirectionAs(const Edge& other) const;
72     void dynCastFunction(const EdgeLin * &seg,
73                          const EdgeArcCircle * &arcSeg) const { seg=this; }
74   protected:
75     EdgeLin() { }
76     void updateBounds();
77     Edge *buildEdgeLyingOnMe(Node *start, Node *end, bool direction) const;
78     void fillGlobalInfoAbs(bool direction, const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
79                            std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
80     void fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
81                             std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
82   };
83 }
84
85 #endif