Salome HOME
Copyright update 2022
[modules/yacs.git] / src / engine / LinkedBlocPoint.cxx
index e9c32e8f5b69c8606a37dda1cfed25e0b5331e5f..6e3ac0aa39dea35639c35d1237f825bded3fd7e4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2015-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2015-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 
 #include "LinkedBlocPoint.hxx"
+#include "ElementaryPoint.hxx"
+#include "NotSimpleCasePoint.hxx"
+#include "ForkBlocPoint.hxx"
 #include "PointVisitor.hxx"
 #include "Exception.hxx"
 
+#ifdef WIN32
+#include <algorithm>
+#endif
+
+
 using namespace YACS::ENGINE;
 
 LinkedBlocPoint::LinkedBlocPoint(const std::list<AbstractPoint *>& nodes, AbstractPoint *father):BlocPoint(nodes,father)
 {
 }
 
+AbstractPoint *LinkedBlocPoint::deepCopy(AbstractPoint *father) const
+{
+  LinkedBlocPoint *ret(new LinkedBlocPoint);
+  ret->deepCopyFrom(*this);
+  ret->setFather(father);
+  return ret;
+}
+
 Node *LinkedBlocPoint::getFirstNode()
 {
   if(_nodes.empty())
@@ -80,6 +96,35 @@ std::string LinkedBlocPoint::getRepr() const
   return ret;
 }
 
+AbstractPoint *LinkedBlocPoint::expandNonSimpleCaseOn(NotSimpleCasePoint *pathologicalPt, const std::set<Node *>& uncatchedNodes)
+{
+  if(anyOf(uncatchedNodes))
+    {
+      for(auto& it : _nodes)
+        {
+          AbstractPoint *ret(it->expandNonSimpleCaseOn(pathologicalPt,uncatchedNodes));
+          if(ret!=it)
+            {
+              ret->setFather(this);
+              auto oldIt(it);
+              it = ret;
+              delete oldIt;
+            }
+        }
+      return this;
+    }
+  else
+    {
+      std::list<AbstractPoint *> l;
+      AbstractPoint *p0(this->deepCopy(getFather())),*p1(pathologicalPt->getUnique()->deepCopy(getFather()));
+      l.push_back(p0);
+      l.push_back(p1);
+      AbstractPoint *ret(new ForkBlocPoint(l,getFather()));
+      p0->setFather(ret); p1->setFather(ret);
+      return ret;
+    }
+}
+
 void LinkedBlocPoint::accept(PointVisitor *pv)
 {
   pv->beginLinkedBlocPoint(this);