Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Sketch.cpp
index 58ab7cb98af9708399f88d172a257094dd8a7839..365db4ca69b59d5d4aca8311afa65980b1aca50a 100644 (file)
@@ -46,7 +46,6 @@ void SketchPlugin_Sketch::initAttributes()
 {
   data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::type());
   data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::type());
-  data()->addAttribute(SketchPlugin_Sketch::DIRY_ID(), GeomDataAPI_Dir::type());
   data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::type());
   data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type());
   // the selected face, base for the sketcher plane, not obligatory
@@ -66,8 +65,6 @@ void SketchPlugin_Sketch::execute()
       data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       data()->attribute(SketchPlugin_Sketch::NORM_ID()));
 
@@ -89,8 +86,8 @@ void SketchPlugin_Sketch::execute()
           continue;
       }
       // do not include the construction entities in the result
-      if (aFeature->data()->attribute(SketchPlugin_SketchEntity::CONSTRUCTION_ID())) {
-        if (aFeature->data()->boolean(SketchPlugin_SketchEntity::CONSTRUCTION_ID())->value())
+      if (aFeature->data()->attribute(SketchPlugin_SketchEntity::AUXILIARY_ID())) {
+        if (aFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value())
           continue;
       }
 
@@ -117,7 +114,7 @@ void SketchPlugin_Sketch::execute()
   for (; aShapeIt != aFeaturesPreview.end(); ++aShapeIt) {
     aBigWire->addEdge(*aShapeIt);
   }
-  aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir());
+  aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aNorm->dir());
 
 //  GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
 //                                         aFeaturesPreview, aLoops, aWires);
@@ -198,13 +195,14 @@ std::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, const
 {
   std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
       data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      data()->attribute(SketchPlugin_Sketch::NORM_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+  std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
 
   std::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX))
-      ->added(aY->dir()->xyz()->multiplied(theY));
+      ->added(aY->xyz()->multiplied(theY));
 
   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
 }
@@ -214,11 +212,12 @@ std::shared_ptr<GeomAPI_Pnt2d> SketchPlugin_Sketch::to2D(
 {
   std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
       data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      data()->attribute(SketchPlugin_Sketch::NORM_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
-  return thePnt->to2D(aC->pnt(), aX->dir(), aY->dir());
+  std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
+  return thePnt->to2D(aC->pnt(), aX->dir(), aY);
 }
 
 
@@ -250,12 +249,10 @@ std::shared_ptr<GeomAPI_Ax3> SketchPlugin_Sketch::coordinatePlane() const
     aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
     aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-    aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
     aData->attribute(SketchPlugin_Sketch::NORM_ID()));
 
-  return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(aC->pnt(), aX->dir(), aY->dir(), aNorm->dir()));
+  return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(aC->pnt(), aX->dir(), aNorm->dir()));
 }
 
 void SketchPlugin_Sketch::erase()
@@ -309,9 +306,6 @@ void SketchPlugin_Sketch::attributeChanged(const std::string& theID) {
         std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
           data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
         aDirX->setValue(aXDir);
-        std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-          data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
-        aDirY->setValue(aYDir);
         std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
       }
     }