Salome HOME
8fbf7bd2e8932a7091b6eac2dd782c5085d3f762
[tools/medcoupling.git] / src / INTERP_KERNEL / Geometric2D / InterpKernelGeo2DComposedEdge.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 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__
22 #define __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__
23
24 #include "INTERPKERNELDefines.hxx"
25
26 #include <set>
27 #include <list>
28 #include <vector>
29 #include <ostream>
30
31 namespace INTERP_KERNEL
32 {
33   class Node;
34   class Edge;
35   class Bounds;
36   class ElementaryEdge;
37   class IteratorOnComposedEdge;
38
39   class INTERPKERNEL_EXPORT ComposedEdge
40   {
41     friend class IteratorOnComposedEdge;
42   public:
43     ComposedEdge() { }
44     ComposedEdge(const ComposedEdge& other);
45     ComposedEdge(int sz):_sub_edges(sz) { }
46     static void Delete(ComposedEdge *pt) { delete pt; }
47     static void SoftDelete(ComposedEdge *pt) { pt->_sub_edges.clear(); delete pt; }
48     void reverse();
49     int recursiveSize() const { return (int)_sub_edges.size(); }
50     bool presenceOfOn() const;
51     bool presenceOfQuadraticEdge() const;
52     void initLocations() const;
53     ComposedEdge *clone() const;
54     bool isNodeIn(Node *n) const;
55     double getArea() const;
56     double getPerimeter() const;
57     double getHydraulicDiameter() const;
58     void getBarycenter(double *bary) const;
59     void getBarycenterGeneral(double *bary) const;
60     double normalize(ComposedEdge *other, double& xBary, double& yBary);
61     double normalizeExt(ComposedEdge *other, double& xBary, double& yBary);
62     void unApplyGlobalSimilarityExt(ComposedEdge& other, double xBary, double yBary, double fact);
63     void fillBounds(Bounds& output) const;
64     void applySimilarity(double xBary, double yBary, double dimChar);
65     void applyGlobalSimilarity(double xBary, double yBary, double dimChar);
66     void applyGlobalSimilarity2(ComposedEdge *other, double xBary, double yBary, double dimChar);
67     void dispatchPerimeter(double& partConsidered) const;
68     void dispatchPerimeterExcl(double& partConsidered, double& commonPart) const;
69     double dispatchPerimeterAdv(const ComposedEdge& father, std::vector<double>& result) const;
70     void getAllNodes(std::set<Node *>& output) const;
71     void getBarycenter(double *bary, double& weigh) const;
72     bool completed() const { return getEndNode()==getStartNode(); }
73     void setValueAt(int i, Edge *e, bool direction=true);
74     double getCommonLengthWith(const ComposedEdge& other) const;
75     void clear();
76     bool empty() const { return _sub_edges.empty(); }
77     ElementaryEdge *front() const { return _sub_edges.front(); }
78     ElementaryEdge *back() const { return _sub_edges.back(); }
79     void resize(int i) { _sub_edges.resize(i); }
80     void pushBack(Edge *edge, bool direction=true);
81     void pushBack(ElementaryEdge *elem);
82     void pushBack(ComposedEdge *elem);
83     int size() const { return (int)_sub_edges.size(); }
84     ElementaryEdge *operator[](int i) const;
85     Node *getEndNode() const;
86     Node *getStartNode() const;
87     bool changeEndNodeWith(Node *node) const;
88     bool changeStartNodeWith(Node *node) const;
89     void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const;
90     bool isInOrOut(Node *nodeToTest) const;
91     bool getDirection() const;
92     bool intresincEqCoarse(const Edge *other) const;
93   private:
94     std::list<ElementaryEdge *>* getListBehind() { return &_sub_edges; }
95   protected:
96     ~ComposedEdge();
97   private:
98     void clearAll(std::list<ElementaryEdge *>::iterator startToDel);
99   protected:
100     std::list<ElementaryEdge *> _sub_edges;
101   };
102 }
103
104 #endif