ADD_SUBDIRECTORY (src/ExchangePlugin)
ADD_SUBDIRECTORY (src/GeomValidators)
ADD_SUBDIRECTORY (src/InitializationPlugin)
+ADD_SUBDIRECTORY (src/ParametersPlugin)
IF(${HAVE_SALOME})
ADD_SUBDIRECTORY (src/NewGeom)
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
<plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
<plugin script="ConnectorPlugin" configuration="plugin-Connector.xml" dependency="Geometry"/>
+ <plugin library="ParametersPlugin" configuration="plugin-Parameters.xml"/>
<plugin library="SketchSolver"/>
<plugin library="GeomValidators"/>
<plugin library="DFBrowser" internal="true"/>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeBoolean.h>
#include <GeomAPI_Face.h>
#include <GeomAPI_Pln.h>
{
data()->addAttribute(FeaturesPlugin_Placement::BASE_FACE_ID(), ModelAPI_AttributeSelection::type());
data()->addAttribute(FeaturesPlugin_Placement::ATTRACT_FACE_ID(), ModelAPI_AttributeSelection::type());
+ data()->addAttribute(FeaturesPlugin_Placement::REVERSE_ID(), ModelAPI_AttributeBoolean::type());
+ data()->addAttribute(FeaturesPlugin_Placement::CENTERING_ID(), ModelAPI_AttributeBoolean::type());
}
void FeaturesPlugin_Placement::execute()
return;
}
- std::shared_ptr<GeomAPI_Pln> aBasePlane = aBaseFace1->getPlane();
- std::shared_ptr<GeomAPI_Pln> aSlavePlane = aSlaveFace1->getPlane();
+ // Flags of the Placement
+ AttributeBooleanPtr aBoolAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(
+ data()->attribute(FeaturesPlugin_Placement::REVERSE_ID()));
+ bool isReverse = aBoolAttr->value();
+ aBoolAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(
+ data()->attribute(FeaturesPlugin_Placement::CENTERING_ID()));
+ bool isCentering = aBoolAttr->value();
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
- GeomAlgoAPI_Placement aFeature(aSlaveObject, aSlavePlane, aBasePlane);
+ GeomAlgoAPI_Placement aFeature(aSlaveObject, aBaseFaceContext, aSlaveFace1, aBaseFace1, isReverse, isCentering);
if(!aFeature.isDone()) {
static const std::string aFeatureError = "Placement algorithm failed";
setError(aFeatureError);
static const std::string MY_ATTRACT_FACE_ID("placement_attractable_face");
return MY_ATTRACT_FACE_ID;
}
+ /// attribute name of flag of reverse direction
+ inline static const std::string& REVERSE_ID()
+ {
+ static const std::string MY_REVERSE_ID("placement_reverse_direction");
+ return MY_REVERSE_ID;
+ }
+ /// attribute name of flag of centering position
+ inline static const std::string& CENTERING_ID()
+ {
+ static const std::string MY_CENTERING_ID("placement_centering");
+ return MY_CENTERING_ID;
+ }
/// Returns the kind of a feature
FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
shape_types="face"
/>
<shape_selector id="placement_attractable_face"
- label="Select a face"
- icon=":icons/cut_shape.png"
- tooltip="Select a face of moved object"
- shape_types="face"
- concealment="true" >
- <validator id="PartSet_DifferentObjects"/>
+ label="Select a face"
+ icon=":icons/cut_shape.png"
+ tooltip="Select a face of moved object"
+ shape_types="face"
+ concealment="true" >
+ <validator id="PartSet_DifferentObjects"/>
</shape_selector>
+ <boolvalue id="placement_reverse_direction"
+ label="Reverse"
+ default="false"
+ tooltip="Reverse placement direction"/>
+ <boolvalue id="placement_centering"
+ label="Centering"
+ default="false"
+ tooltip="Center faces under placement"/>
</source>
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:
#include <GeomAlgoAPI_DFLoader.h>
#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Pln.h>
#include <BRepBuilderAPI_Transform.hxx>
#include <gp_Trsf.hxx>
#include <gp_Quaternion.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepCheck_Analyzer.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
#include <GProp_GProps.hxx>
#include <BRepGProp.hxx>
#include <Precision.hxx>
+
#define DEB_PLACEMENT 1
GeomAlgoAPI_Placement::GeomAlgoAPI_Placement(
- std::shared_ptr<GeomAPI_Shape> theAttractiveFace,
- std::shared_ptr<GeomAPI_Pln> theSourcePlane,
- std::shared_ptr<GeomAPI_Pln> theDestPlane)
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Shape> theDestShape,
+ std::shared_ptr<GeomAPI_Face> theSourcePlane,
+ std::shared_ptr<GeomAPI_Face> theDestPlane,
+ bool theIsReverse,
+ bool theIsCentering)
: myDone(false),
myShape(new GeomAPI_Shape())
{
- build(theAttractiveFace, theSourcePlane, theDestPlane);
+ build(theSourceShape, theDestShape, theSourcePlane, theDestPlane, theIsReverse, theIsCentering);
}
void GeomAlgoAPI_Placement::build(
- const std::shared_ptr<GeomAPI_Shape>& theAttractiveShape,
- const std::shared_ptr<GeomAPI_Pln>& theSourcePlane,
- const std::shared_ptr<GeomAPI_Pln>& theDestPlane)
+ const std::shared_ptr<GeomAPI_Shape>& theSourceShape,
+ const std::shared_ptr<GeomAPI_Shape>& theDestShape,
+ const std::shared_ptr<GeomAPI_Face>& theSourcePlane,
+ const std::shared_ptr<GeomAPI_Face>& theDestPlane,
+ bool theIsReverse,
+ bool theIsCentering)
{
- std::shared_ptr<GeomAPI_Dir> aSourceDir = theSourcePlane->direction();
- std::shared_ptr<GeomAPI_Pnt> aSourceLoc = theSourcePlane->location();
- std::shared_ptr<GeomAPI_Dir> aDestDir = theDestPlane->direction();
- std::shared_ptr<GeomAPI_Pnt> aDestLoc = theDestPlane->location();
+ std::shared_ptr<GeomAPI_Pln> aSourcePlane = theSourcePlane->getPlane();
+ std::shared_ptr<GeomAPI_Pln> aDestPlane = theDestPlane->getPlane();
+ std::shared_ptr<GeomAPI_Dir> aSourceDir = aSourcePlane->direction();
+ std::shared_ptr<GeomAPI_Pnt> aSourceLoc = aSourcePlane->location();
+ std::shared_ptr<GeomAPI_Dir> aDestDir = aDestPlane->direction();
+ std::shared_ptr<GeomAPI_Pnt> aDestLoc = aDestPlane->location();
+
+ // Initial shapes
+ const TopoDS_Shape& aSourceShape = theSourceShape->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aDestShape = theDestShape->impl<TopoDS_Shape>();
// Calculate transformation
gp_Trsf aTrsf;
gp_Vec aSrcDir(aSourceDir->x(), aSourceDir->y(), aSourceDir->z());
gp_Vec aDstDir(aDestDir->x(), aDestDir->y(), aDestDir->z());
+ // Check the material of the solids to be on the correct side
+ BRepClass3d_SolidClassifier aClassifier;
+ aClassifier.Load(aSourceShape);
+ static const double aTransStep = 10. * Precision::Confusion();
+ gp_Pnt aPoint(aSourceLoc->x(), aSourceLoc->y(), aSourceLoc->z());
+ aPoint.Translate(aSrcDir * aTransStep);
+ aClassifier.Perform(aPoint, Precision::Confusion());
+ if ((aClassifier.State() == TopAbs_OUT && !theIsReverse) ||
+ (aClassifier.State() == TopAbs_IN && theIsReverse))
+ aSrcDir.Reverse();
+ aClassifier.Load(aDestShape);
+ aPoint.SetCoord(aDestLoc->x(), aDestLoc->y(), aDestLoc->z());
+ aPoint.Translate(aDstDir * aTransStep);
+ aClassifier.Perform(aPoint, Precision::Confusion());
+ if (aClassifier.State() == TopAbs_IN)
+ aDstDir.Reverse();
+ // Calculate rotation
gp_Quaternion aRot(aSrcDir, aDstDir);
aTrsf.SetRotation(aRot);
- gp_Vec aSrcCenter(aSourceLoc->x(), aSourceLoc->y(), aSourceLoc->z());
- aSrcCenter.Transform(aTrsf);
- gp_Vec aTrans(aDestLoc->x() - aSrcCenter.X(),
- aDestLoc->y() - aSrcCenter.Y(),
- aDestLoc->z() - aSrcCenter.Z());
+ // Calculate translation
+ gp_Vec aSrcLoc(aSourceLoc->x(), aSourceLoc->y(), aSourceLoc->z());
+ gp_Vec aDstLoc(aDestLoc->x(), aDestLoc->y(), aDestLoc->z());
+ if (!theIsCentering)
+ aDstLoc = aSrcLoc + gp_Vec(aDstDir) * (aDstLoc-aSrcLoc).Dot(aDstDir);
+ aSrcLoc.Transform(aTrsf);
+ gp_Vec aTrans = aDstLoc - aSrcLoc;
aTrsf.SetTransformation(aRot, aTrans);
// Transform the shape with copying it
- const TopoDS_Shape& aShape = theAttractiveShape->impl<TopoDS_Shape>();
- BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aShape, aTrsf, true);
+ BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aSourceShape, aTrsf, true);
if(aBuilder) {
setImpl(aBuilder);
myDone = aBuilder->IsDone() == Standard_True;
#include <GeomAlgoAPI.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_Dir.h>
-#include <GeomAPI_Pln.h>
+#include <GeomAPI_Face.h>
#include <GeomAlgoAPI_MakeShape.h>
#include <GeomAPI_DataMapOfShapeShape.h>
#include <memory>
public:
/** \brief Creates an object which is obtained from current object by transformation calculated
* as a movement of the source plane to be coincident with the destination plane
- * \param[in] theAttractiveShape shape to be moved
- * \param[in] theSourcePlane plane on the shape to be made coincident with destination plane
- * \param[in] theDestPlane destination plane
+ * \param[in] theSourceShape shape to be moved
+ * \param[in] theDestShape invariabt shape
+ * \param[in] theSourcePlane plane on the shape to be made coincident with destination plane
+ * \param[in] theDestPlane destination plane
+ * \param[in] theIsReverse indicates that the solid materials should be on the same side against the destination plane
+ * \param[in] theIsCentering indicates the planes should be centered
*/
- GEOMALGOAPI_EXPORT GeomAlgoAPI_Placement(std::shared_ptr<GeomAPI_Shape> theAttractiveShape,
- std::shared_ptr<GeomAPI_Pln> theSourcePlane,
- std::shared_ptr<GeomAPI_Pln> theDestPlane);
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Placement(std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Shape> theDestShape,
+ std::shared_ptr<GeomAPI_Face> theSourcePlane,
+ std::shared_ptr<GeomAPI_Face> theDestPlane,
+ bool theIsReverse = false,
+ bool theIsCentering = false);
/// Returns True if algorithm succeed
GEOMALGOAPI_EXPORT const bool isDone() const
private:
/// builds resulting shape
- void build(const std::shared_ptr<GeomAPI_Shape>& theAttractiveShape,
- const std::shared_ptr<GeomAPI_Pln>& theSourcePlane,
- const std::shared_ptr<GeomAPI_Pln>& theDestPlane);
+ void build(const std::shared_ptr<GeomAPI_Shape>& theSourceShape,
+ const std::shared_ptr<GeomAPI_Shape>& theDestShape,
+ const std::shared_ptr<GeomAPI_Face>& theSourcePlane,
+ const std::shared_ptr<GeomAPI_Face>& theDestPlane,
+ bool theIsReverse,
+ bool theIsCentering);
/// fields
bool myDone;
// 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()
public:
/// Constructor
/// \param theParent the parent object
- /// \param theData the widget configuation. The attribute of the model widget is obtained from
+ /// \param theData the widget configuration.
/// \param theParentId is Id of a parent of the current attribute
ModuleBase_WidgetLineEdit(QWidget* theParent,
const Config_WidgetAPI* theData,
bool ModuleBase_WidgetMultiSelector::storeValueCustom() const
{
// the value is stored on the selection changed signal processing
- return true;
+ // A rare case when plugin was not loaded.
+ if(!myFeature)
+ return false;
+ DataPtr aData = myFeature->data();
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aData->attribute(attributeID()));
+
+ if (aSelectionListAttr) {
+ // Store shapes type
+ TopAbs_ShapeEnum aCurrentType =
+ ModuleBase_WidgetShapeSelector::shapeType(myTypeCombo->currentText());
+ aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
+ }
+ return true;
}
//********************************************************************
if (aSelectionListAttr) {
// Restore shape type
setCurrentShapeType(
- ModuleBase_WidgetShapeSelector::shapeType(aSelectionListAttr->selectionType().c_str()));
+ ModuleBase_WidgetShapeSelector::shapeType(aSelectionListAttr->selectionType().c_str()));
updateSelectionList(aSelectionListAttr);
return true;
}
--- /dev/null
+INCLUDE(Common)
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
+ ${PROJECT_SOURCE_DIR}/src/Config
+ ${PROJECT_SOURCE_DIR}/src/ModelAPI
+)
+
+SET(PROJECT_HEADERS
+ ParametersPlugin.h
+ ParametersPlugin_Plugin.h
+ ParametersPlugin_Parameter.h
+)
+
+SET(PROJECT_SOURCES
+ ParametersPlugin_Plugin.cpp
+ ParametersPlugin_Parameter.cpp
+)
+
+SET(XML_RESOURCES
+ plugin-Parameters.xml
+)
+
+SET(PROJECT_LIBRARIES
+ Events
+ Config
+ ModelAPI
+)
+
+ADD_DEFINITIONS(-DPARAMETERSPLUGIN_EXPORTS)
+ADD_LIBRARY(ParametersPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+
+TARGET_LINK_LIBRARIES(ParametersPlugin ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS ParametersPlugin DESTINATION plugins)
+INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef PARAMETERSPLUGIN_H
+#define PARAMETERSPLUGIN_H
+
+#if defined PARAMETERSPLUGIN_EXPORTS
+#if defined WIN32
+#define PARAMETERSPLUGIN_EXPORT __declspec( dllexport )
+#else
+#define PARAMETERSPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define PARAMETERSPLUGIN_EXPORT __declspec( dllimport )
+#else
+#define PARAMETERSPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: ParametersPlugin_Parameter.cpp
+// Created: 23 MArch 2015
+// Author: sbh
+
+#include "ParametersPlugin_Parameter.h"
+#include <ModelAPI_AttributeString.h>
+
+ParametersPlugin_Parameter::ParametersPlugin_Parameter()
+{
+}
+
+void ParametersPlugin_Parameter::initAttributes()
+{
+ data()->addAttribute(ParametersPlugin_Parameter::VARIABLE_ID(), ModelAPI_AttributeString::type());
+ data()->addAttribute(ParametersPlugin_Parameter::EXPRESSION_ID(), ModelAPI_AttributeString::type());
+}
+
+void ParametersPlugin_Parameter::execute()
+{
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: ParametersPlugin_Parameter.h
+// Created: 23 MArch 2015
+// Author: sbh
+
+#ifndef PARAMETERSPLUGIN_PARAMETER_H_
+#define PARAMETERSPLUGIN_PARAMETER_H_
+
+#include "ParametersPlugin.h"
+#include <ModelAPI_Feature.h>
+
+class ParametersPlugin_Parameter : public ModelAPI_Feature
+{
+ public:
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_EXTRUSION_ID("Parameter");
+ return MY_EXTRUSION_ID;
+ }
+ /// attribute name of references sketch entities list, it should contain a sketch result or
+ /// a pair a sketch result to sketch face
+ inline static const std::string& VARIABLE_ID()
+ {
+ static const std::string MY_VARIABLE_ID("variable");
+ return MY_VARIABLE_ID;
+ }
+
+ /// attribute name of extrusion size
+ inline static const std::string& EXPRESSION_ID()
+ {
+ static const std::string MY_EXPRESSION_ID("expression");
+ return MY_EXPRESSION_ID;
+ }
+
+ /// Returns the kind of a feature
+ PARAMETERSPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = ParametersPlugin_Parameter::ID();
+ return MY_KIND;
+ }
+
+ /// Creates a new part document if needed
+ PARAMETERSPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ PARAMETERSPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Use plugin manager for features creation
+ ParametersPlugin_Parameter();
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include <ParametersPlugin_Plugin.h>
+#include <ParametersPlugin_Parameter.h>
+
+#include <ModelAPI_Session.h>
+
+#include <memory>
+
+// the only created instance of this plugin
+static ParametersPlugin_Plugin* MY_PARAMETERSPLUGIN_INSTANCE = new ParametersPlugin_Plugin();
+
+ParametersPlugin_Plugin::ParametersPlugin_Plugin()
+{
+ // register this plugin
+ SessionPtr aSession = ModelAPI_Session::get();
+ aSession->registerPlugin(this);
+}
+
+FeaturePtr ParametersPlugin_Plugin::createFeature(std::string theFeatureID)
+{
+ // TODO: register some features
+ if (theFeatureID == ParametersPlugin_Parameter::ID()) {
+ return FeaturePtr(new ParametersPlugin_Parameter);
+ }
+ return FeaturePtr();
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef PARAMETERSPLUGIN_PLUGIN_H_
+#define PARAMETERSPLUGIN_PLUGIN_H_
+
+#include <ParametersPlugin.h>
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+/**\class ParametersPlugin_Plugin
+ * TODO: Add documentation
+ */
+class PARAMETERSPLUGIN_EXPORT ParametersPlugin_Plugin : public ModelAPI_Plugin
+{
+ public:
+ /// Creates the feature object of this plugin by the feature string ID
+ virtual FeaturePtr createFeature(std::string theFeatureID);
+
+ public:
+ ParametersPlugin_Plugin();
+};
+
+#endif
+
--- /dev/null
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<plugin>
+ <workbench id="Part">
+ <group id="Parameters">
+ <feature id="Parameter" title="New Variable" tooltip="Creates a variable" icon=":pictures/expression.png">
+ <stringvalue id="variable" label="Name"/>
+ <stringvalue id="expression" icon="Value"/>
+ </feature>
+ </group>
+ </workbench>
+</plugin>
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
<file>pictures/module.png</file>
<file>pictures/shading.png</file>
<file>pictures/wireframe.png</file>
+ <file>pictures/expression.png</file>
</qresource>
</RCC>