: ModelHighAPI_Interface(theFeature)
{
if(initialize()) {
- fillAttribute(BuildPlugin_Interpolation::CREATION_METHODE_BY_SELECTION_ID(),mycreationmethod);
+ fillAttribute(BuildPlugin_Interpolation::CREATION_METHOD_BY_SELECTION_ID(),mycreationmethod);
setUseTangents(true);
setTangents(theStartTangent, theEndTangent);
setClosed(theIsClosed);
}
//==================================================================================================
-BuildAPI_Interpolation::BuildAPI_Interpolation(const FeaturePtr& theFeature,
- const std::list<ModelHighAPI_Selection>& theBaseObjects,
- const bool theIsClosed,
- const bool theIsToReorder)
+BuildAPI_Interpolation::BuildAPI_Interpolation(
+ const FeaturePtr& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const bool theIsClosed,
+ const bool theIsToReorder)
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
- fillAttribute(BuildPlugin_Interpolation::CREATION_METHODE_BY_SELECTION_ID(),mycreationmethod);
+ fillAttribute(BuildPlugin_Interpolation::CREATION_METHOD_BY_SELECTION_ID(),mycreationmethod);
setClosed(theIsClosed);
setReorder(theIsToReorder);
setUseTangents(false);
}
BuildAPI_Interpolation::BuildAPI_Interpolation(const FeaturePtr& theFeature,
- const std::string & theXTexpression,
- const std::string & theYTexpression,
- const std::string & theZTexpression,
- const ModelHighAPI_Double& theMinT,
- const ModelHighAPI_Double& theMaxT,
- const ModelHighAPI_Integer& theNbStep)
+ const std::string & theXTexpression,
+ const std::string & theYTexpression,
+ const std::string & theZTexpression,
+ const ModelHighAPI_Double& theMinT,
+ const ModelHighAPI_Double& theMaxT,
+ const ModelHighAPI_Integer& theNbStep)
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
- fillAttribute(BuildPlugin_Interpolation::CREATION_METHODE_ANALYTICAL_ID(),mycreationmethod);
+ fillAttribute(BuildPlugin_Interpolation::CREATION_METHOD_ANALYTICAL_ID(),mycreationmethod);
fillAttribute(theXTexpression, myxt);
fillAttribute(theYTexpression, myyt);
fillAttribute(theZTexpression, myzt);
FeaturePtr aBase = feature();
std::string aPartName = theDumper.name(aBase->document());
- if( aBase->string(BuildPlugin_Interpolation::CREATION_METHODE_ID())->value() ==
- BuildPlugin_Interpolation::CREATION_METHODE_BY_SELECTION_ID() )
+ if( aBase->string(BuildPlugin_Interpolation::CREATION_METHOD_ID())->value() ==
+ BuildPlugin_Interpolation::CREATION_METHOD_BY_SELECTION_ID() )
{
AttributeSelectionListPtr anAttrBaseObjects =
aBase->selectionList(BuildPlugin_Interpolation::BASE_OBJECTS_ID());
theDumper << closed() << ", " << reorder() << ")" << std::endl;
}else{
- theDumper << aBase << " = model.addInterpolation(" << aPartName ;
+ theDumper << aBase << " = model.addInterpolation(" << aPartName ;
AttributeStringPtr XtAttr = xt();
std::string xt = XtAttr->value();
AttributeStringPtr YtAttr = yt();
ModelAPI_AttributeDouble, /** zt expression*/,
numstep, BuildPlugin_Interpolation::NUMSTEP_ID(),
ModelAPI_AttributeInteger, /** zt expression*/,
- creationmethod, BuildPlugin_Interpolation::CREATION_METHODE_ID(),
+ creationmethod, BuildPlugin_Interpolation::CREATION_METHOD_ID(),
ModelAPI_AttributeString, /** zt expression*/)
/// Modify base attribute of the feature.
class ModelAPI_Document;
class ModelAPI_Feature;
class ModelAPI_ResultParameter;
+
class InitializationPlugin_PyInterp;
/**
data()->addAttribute(TANGENT_START_ID(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(TANGENT_END_ID(), ModelAPI_AttributeSelection::typeId());
- data()->addAttribute(CREATION_METHODE_ID(), ModelAPI_AttributeString::typeId());
- data()->addAttribute(CREATION_METHODE_BY_SELECTION_ID(), ModelAPI_AttributeString::typeId());
- data()->addAttribute(CREATION_METHODE_ANALYTICAL_ID(), ModelAPI_AttributeString::typeId());
- data()->addAttribute(CREATION_METHODE_ANALYTICAL_ID(), ModelAPI_AttributeString::typeId());
+ data()->addAttribute(CREATION_METHOD_ID(), ModelAPI_AttributeString::typeId());
+ data()->addAttribute(CREATION_METHOD_BY_SELECTION_ID(), ModelAPI_AttributeString::typeId());
+ data()->addAttribute(CREATION_METHOD_ANALYTICAL_ID(), ModelAPI_AttributeString::typeId());
data()->addAttribute(EXPRESSION_ERROR_ID(), ModelAPI_AttributeString::typeId());
data()->addAttribute(VARIABLE_ID(), ModelAPI_AttributeString::typeId());
data()->addAttribute(VALUE_ID(), ModelAPI_AttributeTables::typeId());
data()->addAttribute(NUMSTEP_ID(), ModelAPI_AttributeInteger::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
- CREATION_METHODE_ANALYTICAL_ID());
+ CREATION_METHOD_ANALYTICAL_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
- CREATION_METHODE_BY_SELECTION_ID());
+ CREATION_METHOD_BY_SELECTION_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VARIABLE_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VALUE_ID());
data()->addAttribute(ARGUMENTS_ID(), ModelAPI_AttributeRefList::typeId());
&& string(XT_ID())->value() !=""
&& string(YT_ID())->value() !=""
&& string(ZT_ID())->value() !=""
- && string(CREATION_METHODE_ID())->value() == CREATION_METHODE_ANALYTICAL_ID()
+ && string(CREATION_METHOD_ID())->value() == CREATION_METHOD_ANALYTICAL_ID()
){
- updateCoods();
+ updateCoordinates();
}
}
-void BuildPlugin_Interpolation::updateCoods()
+void BuildPlugin_Interpolation::updateCoordinates()
{
std::wstring exp;
double aMint = real(MINT_ID())->value();
setError("The minimum value of the parameter must be less than maximum value !!!" );
}
- double scale = (aMaxt - aMint )/aNbrStep;
+ double aScale = (aMaxt - aMint )/aNbrStep;
string(VARIABLE_ID())->setValue("t");
tables(VALUE_ID())->setSize(aNbrStep+1,4);
for( int step = 0; step <= aNbrStep; step++ ){
ModelAPI_AttributeTables::Value aVal;
- aVal.myDouble = step * scale + aMint;
+ aVal.myDouble = step * aScale + aMint;
tables(VALUE_ID())->setValue(aVal,step,0);
}
//=================================================================================================
void BuildPlugin_Interpolation::execute()
{
- if( string(CREATION_METHODE_ID())->value() == CREATION_METHODE_BY_SELECTION_ID() )
+ if( string(CREATION_METHOD_ID())->value() == CREATION_METHOD_BY_SELECTION_ID() )
{
// Get closed flag value
bool isClosed = boolean(CLOSED_ID())->value();
return false;
if (!outErrorMessage.empty()){
- setError("Error: Python interpreter " );
+ setError("Error: Python interpreter " );//+ outErrorMessage);
return false;
}
- AttributeTablesPtr table = tables( VALUE_ID() );
- std::list<std::vector<double> > aCoodPoints;
- for( int step = 0; step < table->rows() ; step++ ){
- std::vector<double> coodPoint;
+ AttributeTablesPtr aTable = tables( VALUE_ID() );
+ std::list<std::vector<double> > aCoordPoints;
+ for( int step = 0; step < aTable->rows() ; step++ ){
+ std::vector<double> aCoordPoint;
ModelAPI_AttributeTables::Value value;
//x
- value = table->value(step, 1);
- coodPoint.push_back( value.myDouble );
+ value = aTable->value(step, 1);
+ aCoordPoint.push_back( value.myDouble );
//y
- value = table->value(step, 2);
- coodPoint.push_back( value.myDouble );
- //Z
- value = table->value(step, 3);
- coodPoint.push_back( value.myDouble );
+ value = aTable->value(step, 2);
+ aCoordPoint.push_back( value.myDouble );
+ //
+ value = aTable->value(step, 3);
+ aCoordPoint.push_back( value.myDouble );
- aCoodPoints.push_back(coodPoint);
+ aCoordPoints.push_back(aCoordPoint);
}
std::list<GeomPointPtr> aPoints;
std::list<GeomVertexPtr> aVertices;
- std::list<std::vector<double> >::const_iterator aItCoodPoints = aCoodPoints.begin();
+ std::list<std::vector<double> >::const_iterator anItCoordPoints = aCoordPoints.begin();
- for( ; aItCoodPoints != aCoodPoints.end(); ++aItCoodPoints ){
+ for( ; anItCoordPoints != aCoordPoints.end(); ++anItCoordPoints ){
- GeomVertexPtr vertex =
- GeomAlgoAPI_PointBuilder::vertex( (*aItCoodPoints)[0],
- (*aItCoodPoints)[1],
- (*aItCoodPoints)[2]);
- aPoints.push_back (vertex->point());
- aVertices.push_back (vertex);
+ GeomVertexPtr aVertex =
+ GeomAlgoAPI_PointBuilder::vertex( (*anItCoordPoints)[0],
+ (*anItCoordPoints)[1],
+ (*anItCoordPoints)[2]);
+ aPoints.push_back (aVertex->point());
+ aVertices.push_back (aVertex);
}
// Create curve from points
aResultBody->generated(anExp.current(), aVertexName);
aVertexIndex++;
}
-
setResult(aResultBody);
-
}
-
}
void BuildPlugin_Interpolation::evaluate(std::string& theError)
return MY_ID;
}
/// Attribute name of creation method.
- inline static const std::string& CREATION_METHODE_ID()
+ inline static const std::string& CREATION_METHOD_ID()
{
- static const std::string MY_CREATION_METHODE_ID("interpolation_method");
- return MY_CREATION_METHODE_ID;
+ static const std::string MY_CREATION_METHOD_ID("interpolation_method");
+ return MY_CREATION_METHOD_ID;
}
/// Attribute name of creation method by selection
- inline static const std::string& CREATION_METHODE_BY_SELECTION_ID()
+ inline static const std::string& CREATION_METHOD_BY_SELECTION_ID()
{
- static const std::string MY_CREATION_METHODE_BY_SELECTION_ID("by_selection");
- return MY_CREATION_METHODE_BY_SELECTION_ID;
+ static const std::string MY_CREATION_METHOD_BY_SELECTION_ID("by_selection");
+ return MY_CREATION_METHOD_BY_SELECTION_ID;
}
/// Attribute name of creation method analytical
- inline static const std::string& CREATION_METHODE_ANALYTICAL_ID()
+ inline static const std::string& CREATION_METHOD_ANALYTICAL_ID()
{
- static const std::string MY_CREATION_METHODE_ANALYTICAL_ID("analytical");
- return MY_CREATION_METHODE_ANALYTICAL_ID;
+ static const std::string MY_CREATION_METHOD_ANALYTICAL_ID("analytical");
+ return MY_CREATION_METHOD_ANALYTICAL_ID;
}
/// Attribute name of base objects.
BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
protected:
- /// Evaluates theExpression and returns its value.
+ /// Evaluates the expression x(t), y(t),z(t) in value table.
void evaluate(std::string& theError);
- void updateCoods();
+ //Update coordinates x,y,z
+ void updateCoordinates();
- std::list<double> aCoodPoints[3];
std::string outErrorMessage;
};
<translation>Tangentes</translation>
</message>
</context>
-
+ <context>
+ <name>Interpolation:analytical</name>
+ <message>
+ <source>Curves parameters</source>
+ <translation>Paramètres de la courbe</translation>
+ </message>
+ <message>
+ <source>X(t) equation</source>
+ <translation>Équation X(t)</translation>
+ </message>
+ <message>
+ <source>Y(t) equation</source>
+ <translation>Équation Y(t)</translation>
+ </message>
+ <message>
+ <source>Z(t) equation</source>
+ <translation>Équation Z(t)</translation>
+ </message>
+ <message>
+ <source>Number of steps</source>
+ <translation>Nombre de pas</translation>
+ </message>
+ </context>
<context>
<name>Polyline:base_objects</name>
<message>
:download:`Download this script <examples/interpolation.py>`
+ .. _tui_create_interpolation_analytical:
+
+Create Interpolation analytical
+===============================
+
+.. literalinclude:: examples/interpolationAnalytical.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/interpolationAnalytical.py>`
+
\ No newline at end of file
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Interpolation_1 = model.addInterpolation(Part_1_doc, "5*sin(t)","5*cos(t)","t*0.2", 0, 25, 100)
+model.do()
+model.end()
Interpolation
=============
-Interpolation feature creates a curve (edge) using vertices already existing in other objects.
+Interpolation feature creates an interpolated curve (edge) based on existing points/vertices or based on analytical mathematical expression.
To create an interpolation in the active part:
The following property panel will be opened:
+.. figure:: images/Interpolation.png
+ :align: center
+
+ Create an interpolation
+
+There are two creation modes of an interpolation:
+
+.. figure:: images/feature_interpolation_by_selection.png
+ :align: left
+ :height: 24px
+
+Interpolation by selection
+
+.. figure:: images/feature_interpolation_analytical.png
+ :align: left
+ :height: 24px
+
+interpolation analytical
+
+Interpolation by selection
+""""""""""""""""""""""""""
+The property panel is shown below.
+
.. figure:: images/Interpolation.png
:align: center
Result of the operation.
**See Also** a sample TUI Script of :ref:`tui_create_interpolation` operation.
+
+Interpolation analytical
+""""""""""""""""""""""""
+
+The property panel is shown below.
+
+.. figure:: images/InterpolationAnalitycal.png
+ :align: center
+
+ Create an interpolation analytical
+
+Select one or several vertices or points in the viewer.
+
+- **Curves parameters** panel allows to define the mathematical expression for creating the interpolated curve.
+ - **X(t) equation** define the expression of X with t variable.
+ - **Y(t) equation** define the expression of Y with t variable.
+ - **Z(t) equation** define the expression of Z with t variable.
+
+- **Min t** define the minimun of t.
+
+- **Max t** define the maximum of t.
+
+- **Number of steps** define the number of steps.
+
+**Apply** button creates an interpolation.
+
+**Cancel** button cancels the operation.
+
+**TUI Commands**:
+
+.. py:function:: model.addInterpolation(Part_doc, xt, yt, zt, mint, maxt, nbSteps)
+
+ :param part: The current part object.
+ :param xt: Expression of x.
+ :param yt: Expression of y.
+ :param zt: Expression of z.
+ :param mint: Minimum value of t
+ :param maxt: Maximum value of t.
+ :param nbSteps: Number of steps.
+ :return: Result object.
+
+Result
+""""""
+
+The result of the operation will be a curve created from analytical expressions for x,y and z as functions of variable t:
+
+.. figure:: images/CreateInterpolationanalitycal.png
+ :align: center
+
+ Result of the operation.
+
+**See Also** a sample TUI Script of :ref:`tui_create_interpolation_analytical` operation.
\ No newline at end of file
if( theFeature->name().substr(0, 6) == L"Interp" )
{
AttributeStringPtr anAttr =theFeature->string(
- BuildPlugin_Interpolation::CREATION_METHODE_ID());
+ BuildPlugin_Interpolation::CREATION_METHOD_ID());
if ( anAttr->isInitialized() )
- if( anAttr->value() == BuildPlugin_Interpolation::CREATION_METHODE_ANALYTICAL_ID())
+ if( anAttr->value() == BuildPlugin_Interpolation::CREATION_METHOD_ANALYTICAL_ID())
return true;
}
/// Static. Returns EventID of the message.
MODELAPI_EXPORT static Events_ID& eventId()
{
- static const char * MY_BUILD_EVALUATION_EVENT_ID("ParameterEvaluationRequest");
+ static const char * MY_BUILD_EVALUATION_EVENT_ID("BuildEvaluationRequest");
static Events_ID anId = Events_Loop::eventByName(MY_BUILD_EVALUATION_EVENT_ID);
return anId;
}