Salome HOME
Issue #2215: Wrong cut result between a compsolid and a box
[modules/shaper.git] / src / ConstructionAPI / ConstructionAPI_Point.cpp
index ef2ccc8100f05a2b888c5aa240aa8b23197d84e3..2656c55dc23528881c5478826f72b9b76ec86ae2 100644 (file)
@@ -1,21 +1,31 @@
-// Name   : ConstructionAPI_Point.cpp
-// Purpose: 
+// Copyright (C) 2014-2017  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<mailto:webmaster.salome@opencascade.com>
 //
-// History:
-// 29/03/16 - Sergey POKHODENKO - Creation of the file
 
 #include "ConstructionAPI_Point.h"
 
 #include <GeomAPI_Shape.h>
 
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
 
-#include <algorithm>
-
-static GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr);
-static GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
-
 //==================================================================================================
 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature)
 : ModelHighAPI_Interface(theFeature)
@@ -35,7 +45,7 @@ ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feat
   }
 }
 
-//==================================================================================================
+/*//==================================================================================================
 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                              const ModelHighAPI_Selection& theEdge,
                                              const ModelHighAPI_Double& theDistanceValue,
@@ -69,7 +79,7 @@ ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feat
       setByLineAndPlaneIntersection(theObject1, theObject2);
     }
   }
-}
+}*/
 
 //==================================================================================================
 ConstructionAPI_Point::~ConstructionAPI_Point()
@@ -82,15 +92,15 @@ void ConstructionAPI_Point::setByXYZ(const ModelHighAPI_Double& theX,
                                      const ModelHighAPI_Double& theY,
                                      const ModelHighAPI_Double& theZ)
 {
-  fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
+  //fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
   fillAttribute(theX, myx);
   fillAttribute(theY, myy);
   fillAttribute(theZ, myz);
 
-  execute();
+  execute(false);
 }
 
-//==================================================================================================
+/*//==================================================================================================
 void ConstructionAPI_Point::setByDistanceOnEdge(const ModelHighAPI_Selection& theEdge,
                                                 const ModelHighAPI_Double& theDistanceValue,
                                                 const bool theDistancePercent,
@@ -136,6 +146,21 @@ void ConstructionAPI_Point::setByLineAndPlaneIntersection(const ModelHighAPI_Sel
   fillAttribute(theFace, myintersectionPlane);
 
   execute();
+}*/
+
+//==================================================================================================
+void ConstructionAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  // TODO: all types of points
+
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  AttributeDoublePtr anAttrX = aBase->real(ConstructionPlugin_Point::X());
+  AttributeDoublePtr anAttrY = aBase->real(ConstructionPlugin_Point::Y());
+  AttributeDoublePtr anAttrZ = aBase->real(ConstructionPlugin_Point::Z());
+  theDumper << aBase << " = model.addPoint(" << aDocName << ", "
+            << anAttrX << ", " << anAttrY << ", " << anAttrZ << ")" << std::endl;
 }
 
 //==================================================================================================
@@ -144,12 +169,11 @@ PointPtr addPoint(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const ModelHighAPI_Double& theY,
                   const ModelHighAPI_Double& theZ)
 {
-  // TODO(spo): check that thePart is not empty
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
   return PointPtr(new ConstructionAPI_Point(aFeature, theX, theY, theZ));
 }
 
-//==================================================================================================
+/*//==================================================================================================
 PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
                   const ModelHighAPI_Selection& theEdge,
                   const ModelHighAPI_Double& theDistanceValue,
@@ -169,64 +193,4 @@ PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
   // TODO(spo): check that thePart is not empty
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
   return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2));
-}
-
-//==================================================================================================
-GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr)
-{
-  GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
-
-  std::string aShapeTypeStr = theShapeTypeStr;
-  std::transform(aShapeTypeStr.begin(), aShapeTypeStr.end(), aShapeTypeStr.begin(), ::tolower);
-
-  if(theShapeTypeStr == "compound") {
-    aShapeType = GeomAPI_Shape::COMPOUND;
-  } else if(theShapeTypeStr == "compsolid") {
-    aShapeType = GeomAPI_Shape::COMPSOLID;
-  } else if(theShapeTypeStr == "solid") {
-    aShapeType = GeomAPI_Shape::SOLID;
-  } else if(theShapeTypeStr == "shell") {
-    aShapeType = GeomAPI_Shape::SHELL;
-  } else if(theShapeTypeStr == "face") {
-    aShapeType = GeomAPI_Shape::FACE;
-  } else if(theShapeTypeStr == "wire") {
-    aShapeType = GeomAPI_Shape::WIRE;
-  } else if(theShapeTypeStr == "edge") {
-    aShapeType = GeomAPI_Shape::EDGE;
-  } else if(theShapeTypeStr == "vertex") {
-    aShapeType = GeomAPI_Shape::VERTEX;
-  } else if(theShapeTypeStr == "shape") {
-    aShapeType = GeomAPI_Shape::SHAPE;
-  }
-
-  return aShapeType;
-}
-
-//==================================================================================================
-GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection)
-{
-  GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
-
-  switch(theSelection.variantType()) {
-    case ModelHighAPI_Selection::VT_ResultSubShapePair: {
-      ResultSubShapePair aPair = theSelection.resultSubShapePair();
-      GeomShapePtr aShape = aPair.second;
-      if(!aShape.get()) {
-        aShape = aPair.first->shape();
-      }
-      if(!aShape.get()) {
-        return aShapeType;
-      }
-      aShapeType = aShape->shapeType();
-      break;
-    }
-    case ModelHighAPI_Selection::VT_TypeSubShapeNamePair: {
-      TypeSubShapeNamePair aPair = theSelection.typeSubShapeNamePair();
-      std::string aType = aPair.first;
-      aShapeType = shapeTypeByStr(aType);
-      break;
-    }
-  }
-
-  return aShapeType;
-}
+}*/