]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into azv/SketchSolver_Refactoring
authorazv <azv@opencascade.com>
Wed, 1 Mar 2017 07:11:39 +0000 (10:11 +0300)
committerazv <azv@opencascade.com>
Wed, 1 Mar 2017 07:11:39 +0000 (10:11 +0300)
make.sh
src/GeomAPI/GeomAPI_Shape.cpp
src/GeomAPI/GeomAPI_Shape.h
src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Symmetry.cpp

diff --git a/make.sh b/make.sh
index 8aac14dde9aab41e773abef99ff1568894968c4a..eb82fb25c014c4661c798935de644b7d1dbd07e2 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -13,6 +13,10 @@ while [[ $# > 0 ]]; do
       USE_TEST_COVERAGE=ON
       shift
       ;;
+    models|test-models)
+      ADD_MODELS_TESTS=TRUE
+      shift
+      ;;
     *)
       shift
       ;;
@@ -24,6 +28,7 @@ source env.sh
 CMAKE_ARGS=""
 CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Release}"
 CMAKE_ARGS="${CMAKE_ARGS} -DUSE_TEST_COVERAGE=${USE_TEST_COVERAGE:-OFF}"
+CMAKE_ARGS="${CMAKE_ARGS} -DADD_MODELS_TESTS=${ADD_MODELS_TESTS:-FALSE}"
 CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=${SHAPER_ROOT_DIR}"
 CMAKE_ARGS="${CMAKE_ARGS} ${SOURCES_DIR}"
 
index 6c0c7f27af4498c208f01eda6ac269b77f435288..d79e365b42b00b502f6c65a26294212cb89b55de 100644 (file)
@@ -7,6 +7,7 @@
 #include "GeomAPI_Shape.h"
 
 #include <BRep_Tool.hxx>
+#include <BRepAlgoAPI_Common.hxx>
 #include <BRepBndLib.hxx>
 #include <BRepBuilderAPI_FindPlane.hxx>
 #include <BRepTools.hxx>
@@ -429,3 +430,25 @@ std::string GeomAPI_Shape::getShapeStream() const
   BRepTools::Write(aShape, aStream);
   return aStream.str();
 }
+
+GeomShapePtr GeomAPI_Shape::intersect(const GeomShapePtr theShape) const
+{
+  const TopoDS_Shape& aShape1 = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  const TopoDS_Shape& aShape2 = theShape->impl<TopoDS_Shape>();
+
+  BRepAlgoAPI_Common aCommon(aShape1, aShape2);
+  if (!aCommon.IsDone())
+    return GeomShapePtr();
+
+  TopoDS_Shape aResult = aCommon.Shape();
+  if (aResult.ShapeType() == TopAbs_COMPOUND) {
+    NCollection_List<TopoDS_Shape> aSubs;
+    addSimpleToList(aResult, aSubs);
+    if (aSubs.Size() == 1)
+      aResult = aSubs.First();
+  }
+
+  GeomShapePtr aResShape(new GeomAPI_Shape);
+  aResShape->setImpl(new TopoDS_Shape(aResult));
+  return aResShape;
+}
index 093779c7b2fc5b5142d9c53b7904f3ec8dc006ca..1c7f2c7f849e06a1ff6fa0640224799a82434ad7 100644 (file)
@@ -120,6 +120,10 @@ public:
   /// Returns the shape as BRep stream
   GEOMAPI_EXPORT
   std::string getShapeStream() const;
+
+  /// Returns intersection of shapes
+  GEOMAPI_EXPORT
+  std::shared_ptr<GeomAPI_Shape> intersect(const std::shared_ptr<GeomAPI_Shape> theShape) const;
 };
 
 //! Pointer on list of shapes
index bfdd1d0a48faf487fb06d3f1fbf2fed360403c6d..8f6d28a9f1d97556dd87b7eb5f225708362507d9 100644 (file)
@@ -39,11 +39,11 @@ GeomAlgoAPI_Scale::GeomAlgoAPI_Scale(std::shared_ptr<GeomAPI_Shape> theSourceSha
 bool GeomAlgoAPI_Scale::check()
 {
   if (!mySourceShape) {
-    myError = "Scale builder :: source shape is invalid.";
+    myError = "Scale builder :: source shape is not valid.";
     return false;
   }
   if (!myCenterPoint) {
-    myError = "Scale builder :: center point is invalid.";
+    myError = "Scale builder :: center point is not valid.";
     return false;
   }
   switch (myMethodType) {
index f5baf287d1ecfa6022197313eba7c13d6db7d924..bf87fe8b35ffaf8167575bbb3872bef0b9b8199f 100644 (file)
@@ -41,33 +41,33 @@ bool GeomAlgoAPI_Symmetry::check()
   switch (myMethodType) {
     case BY_POINT: {
       if (!myPoint) {
-        myError = "Symmetry builder :: point is invalid.";
+        myError = "Symmetry builder :: point is not valid.";
         return false;
       }
       if (!mySourceShape) {
-        myError = "Symmetry builder :: source shape is invalid.";
+        myError = "Symmetry builder :: source shape is not valid.";
         return false;
       }
       return true;
     }
     case BY_AXIS: {
       if (!myAxis) {
-        myError = "Symmetry builder :: axis is invalid.";
+        myError = "Symmetry builder :: axis is not valid.";
         return false;
       }
       if (!mySourceShape) {
-        myError = "Symmetry builder :: source shape is invalid.";
+        myError = "Symmetry builder :: source shape is not valid.";
         return false;
       }
       return true;
     }
     case BY_PLANE: {
       if (!myPlane) {
-        myError = "Symmetry builder :: plane is invalid.";
+        myError = "Symmetry builder :: plane is not valid.";
         return false;
       }
       if (!mySourceShape) {
-        myError = "Symmetry builder :: source shape is invalid.";
+        myError = "Symmetry builder :: source shape is not valid.";
         return false;
       }
       return true;
@@ -134,4 +134,4 @@ void GeomAlgoAPI_Symmetry::build()
   aShape->setImpl(new TopoDS_Shape(aResult));
   setShape(aShape);
   setDone(true);
-}
\ No newline at end of file
+}