Salome HOME
Merge from V6_main_20120808 08Aug12
[tools/medcoupling.git] / src / INTERP_KERNEL / Geometric2D / InterpKernelGeo2DElementaryEdge.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 __INTERPKERNELGEO2DELEMENTARYEDGE_HXX__
21 #define __INTERPKERNELGEO2DELEMENTARYEDGE_HXX__
22
23 #include "INTERPKERNELDefines.hxx"
24 #include "InterpKernelException.hxx"
25 #include "InterpKernelGeo2DAbstractEdge.hxx"
26 #include "InterpKernelGeo2DEdge.hxx"
27
28 namespace INTERP_KERNEL
29 {
30   class INTERPKERNEL_EXPORT ElementaryEdge
31   {
32   public:
33     ElementaryEdge(Edge *ptr, bool direction):_direction(direction),_ptr(ptr) { }
34     ElementaryEdge(const ElementaryEdge& other);
35     ~ElementaryEdge();
36     bool isThereStartPoint() const { return _iterator.isValid(); }
37     IteratorOnComposedEdge& getIterator() { return _iterator; }
38     bool completed() const { return false; }
39     void declareOn() const { _ptr->declareOn(); }
40     void declareIn() const { _ptr->declareIn(); }
41     void declareOut() const { _ptr->declareOut(); }
42     TypeOfEdgeLocInPolygon getLoc() const { return _ptr->getLoc(); }
43     Edge *getPtr() const { return _ptr; }
44     void reverse() { _direction=(!_direction); }
45     bool isNodeIn(Node *n) const;
46     double getAreaOfZone() const { double ret=_ptr->getAreaOfZone(); return _direction?ret:-ret; }
47     void getBarycenterOfZone(double *bary) const;
48     void fillBounds(Bounds& output) const;
49     void applySimilarity(double xBary, double yBary, double dimChar) { _ptr->applySimilarity(xBary,yBary,dimChar); }
50     void unApplySimilarity(double xBary, double yBary, double dimChar) { _ptr->unApplySimilarity(xBary,yBary,dimChar); }
51     void getAllNodes(std::set<Node *>& output) const;
52     void getBarycenter(double *bary, double& weigh) const;
53     ElementaryEdge *clone() const;
54     void initLocations() const;
55     int size() const;
56     TypeOfEdgeLocInPolygon locateFullyMySelfAbsolute(const ComposedEdge& pol) const;
57     TypeOfEdgeLocInPolygon locateFullyMySelf(const ComposedEdge& pol, TypeOfEdgeLocInPolygon precEdgeLoc) const;
58     Node *getEndNode() const;
59     Node *getStartNode() const;
60     double getCurveLength() const { return _ptr->getCurveLength(); }
61     bool changeEndNodeWith(Node *node) const;
62     bool changeStartNodeWith(Node *node) const;
63     bool intresicEqual(const ElementaryEdge *other) const;
64     bool intresicEqualDirSensitive(const ElementaryEdge *other) const;
65     void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const;
66     bool getDirection() const { return _direction; }
67     bool intresincEqCoarse(const Edge *other) const;
68     bool isEqual(const ElementaryEdge& other) const;
69   public:
70     void fillGlobalInfoAbs(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,
71                            std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const;
72     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,
73                             std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const;
74     static ElementaryEdge *BuildEdgeFromCrudeDataArray(bool direction, INTERP_KERNEL::Node *start, INTERP_KERNEL::Node *end);
75   private:
76     bool _direction;
77     Edge *_ptr;
78     IteratorOnComposedEdge _iterator;
79   };
80 }
81
82 #endif