Salome HOME
Merge branch 'CEA_2021_1'
authorArtem Zhidkov <Artem.Zhidkov@gmail.com>
Tue, 9 Mar 2021 12:55:13 +0000 (15:55 +0300)
committerArtem Zhidkov <Artem.Zhidkov@gmail.com>
Tue, 9 Mar 2021 12:55:13 +0000 (15:55 +0300)
src/FeaturesPlugin/Test/TestPipe_Compound.py
src/GeomAPI/GeomAPI_Lin2d.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp
src/SHAPERGUI/CMakeLists.txt
src/SHAPERGUI/shapergui_app.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/Test/Test24015.py [new file with mode: 0644]
src/SketchPlugin/Test/TestCenteredRectangle.py [new file with mode: 0644]

index ed5c4eb0f900cc60d0fcca2eb7959c75fab4e048..13eaf58e4370e2597dee39fd609316b3f32c8b42 100644 (file)
@@ -24,8 +24,8 @@ partSet = model.moduleDocument()
 Part_1 = model.addPart(partSet)
 Part_1_doc = Part_1.document()
 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
-SketchLine_1 = Sketch_1.addLine(50, 15, 100, 20)
-SketchLine_2 = Sketch_1.addLine(30, 10, 50, 0)
+SketchLine_1 = Sketch_1.addLine(60, 15, 100, 20)
+SketchLine_2 = Sketch_1.addLine(35, 10, 50, 0)
 SketchArc_1 = Sketch_1.addArc(30, 40, 60, 40, 30, 70, False)
 model.do()
 Compound_1 = model.addCompound(Part_1_doc, [model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")])
index f0a876a8aa44abe1b981d6204ad44e5450051bda..8d0278b31622fda4e31a0751c830c844a95e96f8 100644 (file)
@@ -80,8 +80,8 @@ const std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::intersect(
     const std::shared_ptr<GeomAPI_Lin2d>& theLine) const
 {
   IntAna2d_AnaIntersection anInter(*MY_LIN2D, theLine->impl<gp_Lin2d>());
-  if (!anInter.IsDone() || anInter.IsEmpty())
-  return std::shared_ptr<GeomAPI_Pnt2d>();
+  if (!anInter.IsDone() || anInter.NbPoints() == 0)
+    return std::shared_ptr<GeomAPI_Pnt2d>();
   const gp_Pnt2d& aResult = anInter.Point(1).Value();
   return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aResult.X(), aResult.Y()));
 }
index 819c8d70963bba7aa0da9d4016e3510a580e2c01..c6c3d28ef748a563d7cb8a62f0d76c562642cac5 100644 (file)
@@ -31,6 +31,7 @@
 #include <BRepOffsetAPI_MakePipe.hxx>
 #include <BRepOffsetAPI_MakePipeShell.hxx>
 #include <BRepBuilderAPI_MakeWire.hxx>
+#include <BOPAlgo_ArgumentAnalyzer.hxx>
 #include <Geom_Curve.hxx>
 #include <Geom_Line.hxx>
 #include <gp_Lin.hxx>
@@ -113,10 +114,23 @@ void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape,
   aPipeBuilder->Build();
 
   // Checking result.
-  if(!aPipeBuilder->IsDone() || aPipeBuilder->Shape().IsNull()) {
+  if (!aPipeBuilder->IsDone() || aPipeBuilder->Shape().IsNull()) {
     delete aPipeBuilder;
     return;
   }
+
+  // Check for self-interfering result
+  BOPAlgo_ArgumentAnalyzer aChecker;
+  aChecker.SetShape1(aPipeBuilder->Shape());
+  aChecker.SelfInterMode() = Standard_True;
+  aChecker.StopOnFirstFaulty() = Standard_True;
+  aChecker.Perform();
+  if (aChecker.HasFaulty()) {
+    myError = "Self-interfering result.";
+    delete aPipeBuilder;
+    return;
+  }
+
   this->initialize(aPipeBuilder);
 
   // Setting naming.
index 90a692aebffd11083a54b820fec4992bc796f0cd..905240030f66ab895adf807a9ec989a4e9da0c6b 100644 (file)
@@ -76,14 +76,14 @@ bool AlgoError::isAlgorithmFailed(const GeomMakeShapePtr& theAlgorithm,
   if (!theAlgorithm->shape() || theAlgorithm->shape()->isNull()) {
     theError = "Error: Resulting shape";
     if (!theFeature.empty())
-      theError += "of " + theFeature;
+      theError += " of " + theFeature;
     theError += " is Null.";
     return true;
   }
   if (!theAlgorithm->isValid()) {
     theError = "Error: Resulting shape";
     if (!theFeature.empty())
-      theError += "of " + theFeature;
+      theError += " of " + theFeature;
     theError += " is not valid.";
     return true;
   }
index 551dd96d06b4104e63a8e99caf331a96339ba1a2..18e2a19d45af6eae084fd1f326eebbf595ec0673 100644 (file)
@@ -139,4 +139,5 @@ CONFIGURE_FILE(
 install(TARGETS shapergui_app DESTINATION ${SHAPER_INSTALL_EXE})
 INSTALL(TARGETS SHAPER DESTINATION ${SHAPER_INSTALL_BIN})
 INSTALL(FILES ${PROJECT_RESOURCES} DESTINATION ${SHAPER_INSTALL_RESOURCES})
+install(FILES resources/SalomeApp.xml RENAME SalomeAppSL.xml DESTINATION ${SHAPER_INSTALL_RESOURCES})
 INSTALL(FILES ${QM_RESOURCES} DESTINATION ${SHAPER_INSTALL_QM_RESOURCES})
index a212c1c30d0f4aae73530dde4ef6465a5f4be125..a9a2bc6f0d5f3d937f66087139861e773dd3566f 100644 (file)
@@ -43,8 +43,8 @@ int main(int argc, char *argv[])
   QString gui_root_dir( QDir::fromNativeSeparators(pe.value(GUI_ROOT_DIR)) );
   QString shaper_root_dir( QDir::fromNativeSeparators(pe.value(SHAPER_ROOT_DIR)) );
   QString lightappconfig_val( QString("%1:%2")
-  .arg(QDir::toNativeSeparators(QString("%1/share/salome/resources/gui").arg(gui_root_dir)))
-  .arg(QDir::toNativeSeparators(QString("%1/share/salome/resources/shaper").arg(shaper_root_dir))));
+  .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/gui").arg(gui_root_dir) ) )
+  .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/shaper").arg(shaper_root_dir) ) ) );
   pe.insert(LIGHTAPPCONFIG,lightappconfig_val);
   //tells shutup to salome.salome_init invoked at shaper engine ignition
   pe.insert("SALOME_EMB_SERVANT","1");
@@ -55,6 +55,6 @@ int main(int argc, char *argv[])
   proc.setArguments({"--modules=SHAPER"});
   proc.setProcessChannelMode( QProcess::ForwardedErrorChannel );
   proc.start();
-  proc.waitForFinished();
+  proc.waitForFinished(-1);
   return proc.exitCode();
 }
index b5cbdd3d3d490ec995b2b1a67fbb935129265fef..938382105f4a0876664e8caa6d76b88bacfce7fa 100644 (file)
@@ -236,9 +236,11 @@ ADD_UNIT_TESTS(
   Test20274_1.py
   Test20274_2.py
   Test20274_3.py
+  Test24015.py
 
   TestArcBehavior.py
   TestBSplineAddPole.py
+  TestCenteredRectangle.py
   TestChangeSketchPlane1.py
   TestChangeSketchPlane2.py
   TestChangeSketchPlane3.py
diff --git a/src/SketchPlugin/Test/Test24015.py b/src/SketchPlugin/Test/Test24015.py
new file mode 100644 (file)
index 0000000..c972d2b
--- /dev/null
@@ -0,0 +1,49 @@
+# Copyright (C) 2021  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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(-62.43672548686145, -3.439140342201228, 39.05146750980462, 70.99404207935532)
+SketchLine_1.setAuxiliary(True)
+
+### Create SketchEllipse
+SketchEllipse_1 = Sketch_1.addEllipse(-11.02958888389993, 34.2637358599971, -5.505025597864623, 77.21113625278682, 25)
+[SketchPoint_1, SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5, SketchPoint_6, SketchPoint_7, SketchLine_2, SketchLine_3] = SketchEllipse_1.construction(center = "aux", firstFocus = "aux", secondFocus = "aux", majorAxisStart = "aux", majorAxisEnd = "aux", minorAxisStart = "aux", minorAxisEnd = "aux", majorAxis = "aux", minorAxis = "aux")
+Sketch_1.setCoincident(SketchLine_1.result(), SketchEllipse_1.center())
+Sketch_1.setLength(SketchLine_3.result(), 50)
+Sketch_1.setLength(SketchLine_2.result(), 100)
+
+### Create SketchConstraintAngle
+Sketch_1.setAngle(SketchLine_1.result(), SketchLine_2.result(), 0, type = "Direct")
+model.do()
+
+model.end()
+
+assert(Sketch_1.feature().error() == "")
diff --git a/src/SketchPlugin/Test/TestCenteredRectangle.py b/src/SketchPlugin/Test/TestCenteredRectangle.py
new file mode 100644 (file)
index 0000000..1221349
--- /dev/null
@@ -0,0 +1,153 @@
+# Copyright (C) 2021  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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+
+### Create Part
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+l = model.addParameter(Part_1_doc, "l", "50")
+h = model.addParameter(Part_1_doc, "h", "20")
+
+### Create Sketch
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+
+### Create SketchProjection
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+
+### Create SketchLine
+SketchLine_1 = Sketch_1.addLine(-25, -10, 25, -10)
+
+### Create SketchLine
+SketchLine_2 = Sketch_1.addLine(-25, -10, 25, 10)
+SketchLine_2.setAuxiliary(True)
+
+### Create SketchLine
+SketchLine_3 = Sketch_1.addLine(25, -10, -25, 10)
+SketchLine_3.setAuxiliary(True)
+
+### Create SketchLine
+SketchLine_4 = Sketch_1.addLine(25, -10, 25, 10)
+
+### Create SketchLine
+SketchLine_5 = Sketch_1.addLine(25, 10, -25, 10)
+
+### Create SketchLine
+SketchLine_6 = Sketch_1.addLine(-25, 10, -25, -10)
+
+### Create SketchPoint
+SketchPoint_2 = Sketch_1.addPoint(0, 0)
+SketchPoint_2.setAuxiliary(True)
+Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_2.result())
+Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_3.result())
+Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_1.startPoint())
+Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_1.startPoint())
+Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_4.startPoint())
+Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_4.startPoint())
+Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
+Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_5.startPoint())
+Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
+Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_6.startPoint())
+Sketch_1.setCoincident(SketchPoint_1.result(), SketchPoint_2.result())
+Sketch_1.setHorizontal(SketchLine_1.result())
+Sketch_1.setVertical(SketchLine_4.result())
+Sketch_1.setHorizontal(SketchLine_5.result())
+Sketch_1.setVertical(SketchLine_6.result())
+Sketch_1.setLength(SketchLine_5.result(), "l")
+Sketch_1.setLength(SketchLine_6.result(), "h")
+model.do()
+
+### Create Extrusion
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1f-SketchLine_4f-SketchLine_5f-SketchLine_6f")], model.selection(), 40, 0, "Faces|Wires")
+
+model.end()
+
+#=============================================================================================
+# Tests :
+#=============================================================================================
+from GeomDataAPI import *
+from ModelAPI import *
+from GeomAPI import *
+from SketchAPI import SketchAPI_Sketch, SketchAPI_SketchEntity
+
+def isSymetricX(line):
+    aStart = geomDataAPI_Point2D(line.attribute("StartPoint"))
+    aEnd   = geomDataAPI_Point2D(line.attribute("EndPoint"))
+    return aStart.x() == -aEnd.x()
+
+def isSymetricY(line):
+    aStart = geomDataAPI_Point2D(line.attribute("StartPoint"))
+    aEnd   = geomDataAPI_Point2D(line.attribute("EndPoint"))
+    return aStart.y() == -aEnd.y()
+
+def isSymetricXY(line):
+    aStart = geomDataAPI_Point2D(line.attribute("StartPoint"))
+    aEnd   = geomDataAPI_Point2D(line.attribute("EndPoint"))
+    return (aStart.x() == -aEnd.x()) and (aStart.y() == -aEnd.y())
+
+#=========================================================================
+def checkLinesSymetry(aSketchFeature):
+#=========================================================================
+# Checks the lines of rectangle are symetric around the origin
+       aNbSubs = aSketchFeature.numberOfSubs()
+       aNbLines = 0
+       nbAux = 0
+       for i in range (0, aNbSubs):
+               aFeature = objectToFeature(aSketchFeature.subFeature(i))
+               if aFeature.getKind() == "SketchLine":
+                       aLastLine = aFeature
+                       entity = SketchAPI_SketchEntity(aLastLine)
+                       if entity.auxiliary().value(): # auxiliary line
+                               assert isSymetricXY(aLastLine)
+                               nbAux +=1
+                       else:
+                               assert (isSymetricX(aLastLine) or isSymetricY(aLastLine))
+                               aNbLines = aNbLines + 1
+       assert (nbAux == 2)
+       assert (aNbLines == 4)
+       assert (model.dof(aSketchFeature) == 0)
+
+Part_doc = model.activeDocument()
+for feat in Part_doc.allFeatures():
+       if feat.getKind() == "Sketch":
+               sketch = feat
+
+aSketchFeature = featureToCompositeFeature(sketch)
+#=========================================================================
+# Check the lines of rectangle are symetric around the origin
+#=========================================================================
+checkLinesSymetry(aSketchFeature)
+#=========================================================================
+# Change the dimensions of the rectangle
+#=========================================================================
+aSession = ModelAPI_Session.get()
+aSession.startOperation()
+l.setValue(80.)
+h.setValue(55.)
+aSession.finishOperation()
+#=========================================================================
+# Check the lines of rectangle are symetric around the origin
+#=========================================================================
+checkLinesSymetry(aSketchFeature)
+
+assert(model.checkPythonDump())