From: azv Date: Wed, 4 Jun 2014 08:25:10 +0000 (+0400) Subject: Implemented calculation of Sketch attributes according to plane coefficient X-Git-Tag: V_0.4.4~329^2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=44ecac6a42b51e9ab222ad969fafb668f8f64078;p=modules%2Fshaper.git Implemented calculation of Sketch attributes according to plane coefficient --- diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 7deb0ef54..af60900da 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -181,20 +182,31 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape) double anA, aB, aC, aD; aPlane->coefficients(anA, aB, aC, aD); - boost::shared_ptr anAttr; - // temporary solution for main planes only + // calculate attributes of the sketch + boost::shared_ptr aNormDir(new GeomAPI_Dir(anA, aB, aC)); + boost::shared_ptr aCoords = aNormDir->xyz(); + boost::shared_ptr aZero(new GeomAPI_XYZ(0, 0, 0)); + aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero)); + boost::shared_ptr anOrigPnt(new GeomAPI_Pnt(aCoords)); + // X axis is preferable to be dirX on the sketch + const double tol = 1e-7; + bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol; + boost::shared_ptr aTempDir(isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0)); + boost::shared_ptr aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir))); + boost::shared_ptr aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir))); + boost::shared_ptr anOrigin = boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_ORIGIN)); - anOrigin->setValue(0, 0, 0); + anOrigin->setValue(anOrigPnt); boost::shared_ptr aNormal = boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_NORM)); - aNormal->setValue(anA, aB, aC); + aNormal->setValue(aNormDir); boost::shared_ptr aDirX = boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_DIRX)); - aDirX->setValue(aB, aC, anA); + aDirX->setValue(aXDir); boost::shared_ptr aDirY = boost::dynamic_pointer_cast(aData->attribute(SKETCH_ATTR_DIRY)); - aDirY->setValue(aC, anA, aB); + aDirY->setValue(aYDir); boost::shared_ptr aDir = aPlane->direction(); flushUpdated();