1 // Copyright (C) 2015-2019 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __ABSTRACTPOINT_HXX__
21 #define __ABSTRACTPOINT_HXX__
23 #include "YACSlibEngineExport.hxx"
24 #include "PlayGround.hxx"
25 #include "AutoRefCnt.hxx"
46 class LinkedBlocPoint;
47 class NotSimpleCasePoint;
48 class ElementaryPoint;
50 class YACSLIBENGINE_EXPORT AbstractPoint
53 AbstractPoint() = default;
54 AbstractPoint(AbstractPoint *father):_father(father) { }
55 AbstractPoint *getFather() const { return _father; }
56 AbstractPoint *getGodFather();
57 bool amIGod() { return getGodFather()==nullptr; }
58 void setFather(AbstractPoint *father) { _father=father; }
62 bool isSimplyLinkedBeforeAfter(BlocPoint *sop);
63 bool isSimplyLinkedAfterNullBefore(BlocPoint *sop);
64 bool isSimplyLinkedBeforeNullAfter(BlocPoint *sop);
66 LinkedBlocPoint *tryAsLink(BlocPoint *sop);
67 ForkBlocPoint *tryAsFork(BlocPoint *sop);
68 ForkBlocPoint *tryAsForkBis(BlocPoint *sop);
69 ForkBlocPoint *tryAsForkTer(BlocPoint *sop);
70 //void tryAsNotSimpleCase(BlocPoint *sop, std::list<AbstractPoint *>& nodes, bool& somethingDone);
71 static void TryAsNotSimpleCase(AbstractPoint *father, const std::vector<AbstractPoint *>& ptsToKill, std::list<AbstractPoint *>& nodes, bool& somethingDone);
73 virtual AbstractPoint *deepCopy(AbstractPoint *father) const = 0;
75 virtual Node *getFirstNode() = 0;
76 virtual Node *getLastNode() = 0;
77 virtual AbstractPoint *findPointWithNode(Node *node) = 0;
78 virtual bool contains(Node *node) const = 0;
79 virtual bool anyOf(const std::set<Node *>& nodes) const = 0;
80 virtual int getNumberOfNodes() const = 0;
81 virtual int getMaxLevelOfParallelism() const = 0;
82 virtual void getWeightRegardingDPL(ComplexWeight *weight) = 0;
83 virtual void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const = 0;
84 virtual std::string getRepr() const = 0;
85 virtual void accept(PointVisitor *pv) = 0;
86 virtual AbstractPoint *expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set<Node *>& uncatchedNodes) = 0;
87 virtual ~AbstractPoint();
89 static bool IsGatherB4Ext(Node *node);
90 bool isSimplyLinkedAfter(BlocPoint *sop, Node *node);
91 static bool IsSimplyLinkedAfterExt(Node *node);
92 static bool IsScatterAfterExt(Node *node);
93 bool isSimplyLinkedBefore(BlocPoint *sop, Node *node);
94 static bool IsSimplyLinkedBeforeExt(Node *node);
95 static bool IsNoLinksBefore(Node *node);
96 static bool IsNoLinksAfter(Node *node);
97 static Node *GetNodeB4(Node *node);
98 static Node *GetNodeAfter(Node *node);
99 static AbstractPoint *GetDirectSonOf(AbstractPoint *refFather, AbstractPoint *sonOrLittleSon);
100 static bool IsCommonDirectSonOf(AbstractPoint *refFather, const std::list<OutGate *>& outgs, AbstractPoint *&ret);
101 static bool IsCommonDirectSonOf(AbstractPoint *refFather, const std::list<InGate *>& ings, AbstractPoint *&ret);
102 static void FeedData(AbstractPoint *ptToBeRewired, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > > *m);
103 static void FeedData(const std::list<AbstractPoint *>& ptsToBeRewired, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > > *m);
104 static void Rewire(const std::vector<AbstractPoint *>& ptsToKill, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > > *m);
105 static void UnRewire(std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > >& m);
106 static void Display(std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > > *m);
108 AbstractPoint *_father = nullptr;