GeomAPI_Ax3::GeomAPI_Ax3(std::shared_ptr<GeomAPI_Pnt> theOrigin,
std::shared_ptr<GeomAPI_Dir> theDirX,
- std::shared_ptr<GeomAPI_Dir> theDirY,
std::shared_ptr<GeomAPI_Dir> theNorm)
: GeomAPI_Interface(new gp_Ax3(theOrigin->impl<gp_Pnt>(),
theNorm->impl<gp_Dir>(),
theDirX->impl<gp_Dir>()))
{
- MY_AX3->SetYDirection(theDirY->impl<gp_Dir>());
}
void GeomAPI_Ax3::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
/// \param theNorm direction of normal vector
GeomAPI_Ax3(std::shared_ptr<GeomAPI_Pnt> theOrigin,
std::shared_ptr<GeomAPI_Dir> theDirX,
- std::shared_ptr<GeomAPI_Dir> theDirY,
std::shared_ptr<GeomAPI_Dir> theNorm);
/// Sets origin point
void GeomAPI_PlanarEdges::setPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
const std::shared_ptr<GeomAPI_Dir>& theDirX,
- const std::shared_ptr<GeomAPI_Dir>& theDirY,
const std::shared_ptr<GeomAPI_Dir>& theNorm)
{
- myPlane = std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(theOrigin, theDirX, theDirY, theNorm));
+ myPlane = std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(theOrigin, theDirX, theNorm));
}
\ No newline at end of file
/// \param theNorm normal direction of the plane axis
GEOMAPI_EXPORT void setPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
const std::shared_ptr<GeomAPI_Dir>& theDirX,
- const std::shared_ptr<GeomAPI_Dir>& theDirY,
const std::shared_ptr<GeomAPI_Dir>& theNorm);
private:
// Author: Mikhail PONIKAROV
#include "GeomData_Dir.h"
-#include "GeomAPI_Dir.h"
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_XYZ.h>
#include <gp_Dir.hxx>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
}
+std::shared_ptr<GeomAPI_XYZ> GeomData_Dir::xyz()
+{
+ return std::shared_ptr<GeomAPI_XYZ>(
+ 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;
#include <memory>
class GeomAPI_Dir;
+class GeomAPI_XYZ;
/**\class GeomData_Dir
* \ingroup DataModel
GEOMDATA_EXPORT virtual double z() const;
/// Returns the direction of this attribute
GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_Dir> dir();
+ /// Returns the coordinates of this attribute
+ GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_XYZ> xyz();
protected:
/// Initializes attributes
#include <ModelAPI_Attribute.h>
class GeomAPI_Dir;
+class GeomAPI_XYZ;
/**\class GeomDataAPI_Dir
* \ingroup DataModel
virtual double z() const = 0;
/// Returns the direction of this attribute
virtual std::shared_ptr<GeomAPI_Dir> dir() = 0;
+ /// Returns the coordinates of this attribute
+ virtual std::shared_ptr<GeomAPI_XYZ> xyz() = 0;
/// Returns the type of this class of attributes
static inline std::string type()
std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
- std::shared_ptr<GeomDataAPI_Dir> anY = 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()));
+ std::shared_ptr<GeomAPI_XYZ> anY = aNorm->xyz()->cross(aX->xyz());
gp_Pnt anOriginPnt(anOrigin->x(), anOrigin->y(), anOrigin->z());
gp_Vec aVec(anOriginPnt, thePoint);
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()));
+ std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
std::shared_ptr<GeomAPI_Pnt2d> aPnt2d =
std::shared_ptr<GeomAPI_Pnt2d>(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,
if (!theSketch || !thePoint2D)
return aPoint;
+ DataPtr aData = theSketch->data();
std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
- theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
- std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- theSketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+ aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ std::shared_ptr<GeomAPI_Dir> 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,
std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
aDirX->setValue(aXDir);
- std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
- aDirY->setValue(aYDir);
std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
return aDir;
}
{
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
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()));
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);
{
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));
}
{
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);
}
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()
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();
}
}
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()
{
// Purpose: create/update the normal of workplane
// ============================================================================
Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal(
- std::shared_ptr<ModelAPI_Attribute> theDirX, std::shared_ptr<ModelAPI_Attribute> theDirY,
+ std::shared_ptr<ModelAPI_Attribute> theDirX,
std::shared_ptr<ModelAPI_Attribute> theNorm)
{
+ std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(theNorm);
std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(theDirX);
- std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(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<GeomAPI_Dir> aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aDirX->dir())));
// quaternion parameters of normal vector
double qw, qx, qy, qz;
// Get parameters of workplane
std::shared_ptr<ModelAPI_Attribute> aDirX = mySketch->data()->attribute(
SketchPlugin_Sketch::DIRX_ID());
- std::shared_ptr<ModelAPI_Attribute> aDirY = mySketch->data()->attribute(
- SketchPlugin_Sketch::DIRY_ID());
std::shared_ptr<ModelAPI_Attribute> aNorm = mySketch->data()->attribute(
SketchPlugin_Sketch::NORM_ID());
std::shared_ptr<ModelAPI_Attribute> 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);
* 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<ModelAPI_Attribute> theDirX,
- std::shared_ptr<ModelAPI_Attribute> theDirY,
std::shared_ptr<ModelAPI_Attribute> theNorm);
/** \brief Adds or updates a parameter in the group