1 // Copyright (C) 2015-2023 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);
65 bool isNullBeforeNullAfter(BlocPoint *sop);
67 LinkedBlocPoint *tryAsLink(BlocPoint *sop);
68 ForkBlocPoint *tryAsFork(BlocPoint *sop);
69 ForkBlocPoint *tryAsForkBis(BlocPoint *sop);
70 ForkBlocPoint *tryAsForkTer(BlocPoint *sop);
71 ForkBlocPoint *tryAsForkQuatro(BlocPoint *sop);
72 //void tryAsNotSimpleCase(BlocPoint *sop, std::list<AbstractPoint *>& nodes, bool& somethingDone);
73 static void TryAsNotSimpleCase(AbstractPoint *father, const std::vector<AbstractPoint *>& ptsToKill, std::list<AbstractPoint *>& nodes, bool& somethingDone);
75 virtual AbstractPoint *deepCopy(AbstractPoint *father) const = 0;
77 virtual Node *getFirstNode() = 0;
78 virtual Node *getLastNode() = 0;
79 virtual AbstractPoint *findPointWithNode(Node *node) = 0;
80 virtual bool contains(Node *node) const = 0;
81 virtual bool anyOf(const std::set<Node *>& nodes) const = 0;
82 virtual int getNumberOfNodes() const = 0;
83 virtual int getMaxLevelOfParallelism() const = 0;
84 virtual void getWeightRegardingDPL(ComplexWeight *weight) = 0;
85 virtual void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap) const = 0;
86 virtual std::string getRepr() const = 0;
87 virtual void accept(PointVisitor *pv) = 0;
88 virtual AbstractPoint *expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set<Node *>& uncatchedNodes) = 0;
89 virtual ~AbstractPoint();
91 static bool IsGatherB4Ext(Node *node);
92 bool isSimplyLinkedAfter(BlocPoint *sop, Node *node);
93 static bool IsSimplyLinkedAfterExt(Node *node);
94 static bool IsScatterAfterExt(Node *node);
95 bool isSimplyLinkedBefore(BlocPoint *sop, Node *node);
96 static bool IsSimplyLinkedBeforeExt(Node *node);
97 static bool IsNoLinksBefore(Node *node);
98 static bool IsNoLinksAfter(Node *node);
99 static Node *GetNodeB4(Node *node);
100 static Node *GetNodeAfter(Node *node);
101 static AbstractPoint *GetDirectSonOf(AbstractPoint *refFather, AbstractPoint *sonOrLittleSon);
102 static bool IsCommonDirectSonOf(AbstractPoint *refFather, const std::list<OutGate *>& outgs, AbstractPoint *&ret);
103 static bool IsCommonDirectSonOf(AbstractPoint *refFather, const std::list<InGate *>& ings, AbstractPoint *&ret);
104 static void FeedData(AbstractPoint *ptToBeRewired, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > > *m);
105 static void FeedData(const std::list<AbstractPoint *>& ptsToBeRewired, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > > *m);
106 static void Rewire(const std::vector<AbstractPoint *>& ptsToKill, std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > > *m);
107 static void UnRewire(std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > >& m);
108 static void Display(std::map< std::string, std::tuple< ElementaryPoint *, Node *, std::shared_ptr<Bloc> > > *m);
110 AbstractPoint *_father = nullptr;