From: azv Date: Tue, 24 Mar 2015 11:26:30 +0000 (+0300) Subject: Remove DirY from Sketch attributes X-Git-Tag: V_1.1.0~85^2~9^2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b5f5aaabb45923b4964fcf6bdae979fae9d1bfb9;p=modules%2Fshaper.git Remove DirY from Sketch attributes --- diff --git a/src/GeomAPI/GeomAPI_Ax3.cpp b/src/GeomAPI/GeomAPI_Ax3.cpp index d7950b585..892869a4c 100644 --- a/src/GeomAPI/GeomAPI_Ax3.cpp +++ b/src/GeomAPI/GeomAPI_Ax3.cpp @@ -25,13 +25,11 @@ GeomAPI_Ax3::GeomAPI_Ax3() GeomAPI_Ax3::GeomAPI_Ax3(std::shared_ptr theOrigin, std::shared_ptr theDirX, - std::shared_ptr theDirY, std::shared_ptr theNorm) : GeomAPI_Interface(new gp_Ax3(theOrigin->impl(), theNorm->impl(), theDirX->impl())) { - MY_AX3->SetYDirection(theDirY->impl()); } void GeomAPI_Ax3::setOrigin(const std::shared_ptr& theOrigin) diff --git a/src/GeomAPI/GeomAPI_Ax3.h b/src/GeomAPI/GeomAPI_Ax3.h index 67bde43ef..6a554e2b3 100644 --- a/src/GeomAPI/GeomAPI_Ax3.h +++ b/src/GeomAPI/GeomAPI_Ax3.h @@ -29,7 +29,6 @@ public: /// \param theNorm direction of normal vector GeomAPI_Ax3(std::shared_ptr theOrigin, std::shared_ptr theDirX, - std::shared_ptr theDirY, std::shared_ptr theNorm); /// Sets origin point diff --git a/src/GeomAPI/GeomAPI_PlanarEdges.cpp b/src/GeomAPI/GeomAPI_PlanarEdges.cpp index f7757cf7e..619716256 100644 --- a/src/GeomAPI/GeomAPI_PlanarEdges.cpp +++ b/src/GeomAPI/GeomAPI_PlanarEdges.cpp @@ -93,8 +93,7 @@ std::shared_ptr GeomAPI_PlanarEdges::norm() const void GeomAPI_PlanarEdges::setPlane(const std::shared_ptr& theOrigin, const std::shared_ptr& theDirX, - const std::shared_ptr& theDirY, const std::shared_ptr& theNorm) { - myPlane = std::shared_ptr(new GeomAPI_Ax3(theOrigin, theDirX, theDirY, theNorm)); + myPlane = std::shared_ptr(new GeomAPI_Ax3(theOrigin, theDirX, theNorm)); } \ No newline at end of file diff --git a/src/GeomAPI/GeomAPI_PlanarEdges.h b/src/GeomAPI/GeomAPI_PlanarEdges.h index 1eddd16c8..c26ad2505 100644 --- a/src/GeomAPI/GeomAPI_PlanarEdges.h +++ b/src/GeomAPI/GeomAPI_PlanarEdges.h @@ -61,7 +61,6 @@ class GeomAPI_PlanarEdges : public GeomAPI_Shape /// \param theNorm normal direction of the plane axis GEOMAPI_EXPORT void setPlane(const std::shared_ptr& theOrigin, const std::shared_ptr& theDirX, - const std::shared_ptr& theDirY, const std::shared_ptr& theNorm); private: diff --git a/src/GeomData/GeomData_Dir.cpp b/src/GeomData/GeomData_Dir.cpp index d36e8a8f5..d5272dda2 100644 --- a/src/GeomData/GeomData_Dir.cpp +++ b/src/GeomData/GeomData_Dir.cpp @@ -5,7 +5,8 @@ // Author: Mikhail PONIKAROV #include "GeomData_Dir.h" -#include "GeomAPI_Dir.h" +#include +#include #include #include #include @@ -49,6 +50,12 @@ std::shared_ptr GeomData_Dir::dir() new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2))); } +std::shared_ptr GeomData_Dir::xyz() +{ + return std::shared_ptr( + new GeomAPI_XYZ(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2))); +} + GeomData_Dir::GeomData_Dir(TDF_Label& theLabel) { myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True; diff --git a/src/GeomData/GeomData_Dir.h b/src/GeomData/GeomData_Dir.h index 0080ffbc6..debd40055 100644 --- a/src/GeomData/GeomData_Dir.h +++ b/src/GeomData/GeomData_Dir.h @@ -14,6 +14,7 @@ #include class GeomAPI_Dir; +class GeomAPI_XYZ; /**\class GeomData_Dir * \ingroup DataModel @@ -36,6 +37,8 @@ class GeomData_Dir : public GeomDataAPI_Dir GEOMDATA_EXPORT virtual double z() const; /// Returns the direction of this attribute GEOMDATA_EXPORT virtual std::shared_ptr dir(); + /// Returns the coordinates of this attribute + GEOMDATA_EXPORT virtual std::shared_ptr xyz(); protected: /// Initializes attributes diff --git a/src/GeomDataAPI/GeomDataAPI_Dir.h b/src/GeomDataAPI/GeomDataAPI_Dir.h index 968edb232..85d4b3a8c 100644 --- a/src/GeomDataAPI/GeomDataAPI_Dir.h +++ b/src/GeomDataAPI/GeomDataAPI_Dir.h @@ -11,6 +11,7 @@ #include class GeomAPI_Dir; +class GeomAPI_XYZ; /**\class GeomDataAPI_Dir * \ingroup DataModel @@ -33,6 +34,8 @@ class GeomDataAPI_Dir : public ModelAPI_Attribute virtual double z() const = 0; /// Returns the direction of this attribute virtual std::shared_ptr dir() = 0; + /// Returns the coordinates of this attribute + virtual std::shared_ptr xyz() = 0; /// Returns the type of this class of attributes static inline std::string type() diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 56f1ac3fc..f7c4ab57f 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -99,8 +99,9 @@ Handle(V3d_View) theView, std::shared_ptr aX = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr anY = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::DIRY_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr anY = aNorm->xyz()->cross(aX->xyz()); gp_Pnt anOriginPnt(anOrigin->x(), anOrigin->y(), anOrigin->z()); gp_Vec aVec(anOriginPnt, thePoint); @@ -138,13 +139,14 @@ std::shared_ptr PartSet_Tools::convertTo3D(const double theX, const aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); std::shared_ptr aX = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::DIRY_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); std::shared_ptr aPnt2d = std::shared_ptr(new GeomAPI_Pnt2d(theX, theY)); - return aPnt2d->to3D(aC->pnt(), aX->dir(), aY->dir()); + return aPnt2d->to3D(aC->pnt(), aX->dir(), aY); } ObjectPtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView, @@ -417,14 +419,16 @@ std::shared_ptr PartSet_Tools::point3D(std::shared_ptrdata(); std::shared_ptr aC = std::dynamic_pointer_cast( - theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); std::shared_ptr aX = std::dynamic_pointer_cast( - theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - theSketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID())); + aData->attribute(SketchPlugin_Sketch::DIRX_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); - return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir()); + return thePoint2D->to3D(aC->pnt(), aX->dir(), aY); } ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 96435f627..d47fadecd 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -287,9 +287,6 @@ std::shared_ptr PartSet_WidgetSketchLabel::setSketchPlane(const Top std::shared_ptr aDirX = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Sketch::DIRX_ID())); aDirX->setValue(aXDir); - std::shared_ptr aDirY = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::DIRY_ID())); - aDirY->setValue(aYDir); std::shared_ptr aDir = aPlane->direction(); return aDir; } diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 466024127..365db4ca6 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -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 aDirX = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aDirY = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRY_ID())); std::shared_ptr aNorm = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::NORM_ID())); @@ -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 SketchPlugin_Sketch::to3D(const double theX, const { std::shared_ptr aC = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::NORM_ID())); std::shared_ptr aX = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRY_ID())); + std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); std::shared_ptr 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(new GeomAPI_Pnt(aSum)); } @@ -214,11 +212,12 @@ std::shared_ptr SketchPlugin_Sketch::to2D( { std::shared_ptr aC = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + std::shared_ptr aNorm = std::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::NORM_ID())); std::shared_ptr aX = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRY_ID())); - return thePnt->to2D(aC->pnt(), aX->dir(), aY->dir()); + std::shared_ptr aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); + return thePnt->to2D(aC->pnt(), aX->dir(), aY); } @@ -250,12 +249,10 @@ std::shared_ptr SketchPlugin_Sketch::coordinatePlane() const aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); std::shared_ptr aX = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Sketch::DIRX_ID())); - std::shared_ptr aY = std::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Sketch::DIRY_ID())); std::shared_ptr aNorm = std::dynamic_pointer_cast( aData->attribute(SketchPlugin_Sketch::NORM_ID())); - return std::shared_ptr(new GeomAPI_Ax3(aC->pnt(), aX->dir(), aY->dir(), aNorm->dir())); + return std::shared_ptr(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 aDirX = std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Sketch::DIRX_ID())); aDirX->setValue(aXDir); - std::shared_ptr aDirY = std::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::DIRY_ID())); - aDirY->setValue(aYDir); std::shared_ptr aDir = aPlane->direction(); } } diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 43a6e3707..0c88f0d8f 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -44,12 +44,6 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I static const std::string MY_DIRX_ID("DirX"); return MY_DIRX_ID; } - /// Vector Y inside of the sketch plane - inline static const std::string& DIRY_ID() - { - static const std::string MY_DIRY_ID("DirY"); - return MY_DIRY_ID; - } /// Vector Z, normal to the sketch plane inline static const std::string& NORM_ID() { diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index c1f07f72b..b650cbdab 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -1299,14 +1299,15 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntityFeature(FeaturePtr theEnt // Purpose: create/update the normal of workplane // ============================================================================ Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal( - std::shared_ptr theDirX, std::shared_ptr theDirY, + std::shared_ptr theDirX, std::shared_ptr theNorm) { + std::shared_ptr aNorm = std::dynamic_pointer_cast(theNorm); std::shared_ptr aDirX = std::dynamic_pointer_cast(theDirX); - std::shared_ptr aDirY = std::dynamic_pointer_cast(theDirY); - if (!aDirX || !aDirY || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) - || (fabs(aDirY->x()) + fabs(aDirY->y()) + fabs(aDirY->z()) < tolerance)) + if (!aDirX || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance)) return SLVS_E_UNKNOWN; + // calculate Y direction + std::shared_ptr aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aDirX->dir()))); // quaternion parameters of normal vector double qw, qx, qy, qz; @@ -1370,14 +1371,12 @@ bool SketchSolver_ConstraintGroup::updateWorkplane() // Get parameters of workplane std::shared_ptr aDirX = mySketch->data()->attribute( SketchPlugin_Sketch::DIRX_ID()); - std::shared_ptr aDirY = mySketch->data()->attribute( - SketchPlugin_Sketch::DIRY_ID()); std::shared_ptr aNorm = mySketch->data()->attribute( SketchPlugin_Sketch::NORM_ID()); std::shared_ptr anOrigin = mySketch->data()->attribute( SketchPlugin_Sketch::ORIGIN_ID()); // Transform them into SolveSpace format - Slvs_hEntity aNormalWP = changeNormal(aDirX, aDirY, aNorm); + Slvs_hEntity aNormalWP = changeNormal(aDirX, aNorm); if (!aNormalWP) return false; Slvs_hEntity anOriginWP = changeEntity(anOrigin); diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.h b/src/SketchSolver/SketchSolver_ConstraintGroup.h index 5c6f965e3..e24d93a7d 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.h +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.h @@ -156,12 +156,10 @@ protected: * on the plane transversed to created normal. * * \param[in] theDirX first coordinate axis of the plane - * \param[in] theDirY second coordinate axis of the plane * \param[in] theNorm attribute for the normal (used to identify newly created entity) * \return identifier of created or updated normal */ Slvs_hEntity changeNormal(std::shared_ptr theDirX, - std::shared_ptr theDirY, std::shared_ptr theNorm); /** \brief Adds or updates a parameter in the group