//==================================================================================================
BuildAPI_Interpolation::BuildAPI_Interpolation(const FeaturePtr& theFeature,
- const std::list<ModelHighAPI_Selection>& theBaseObjects,
- const ModelHighAPI_Selection& theStartTangent,
- const ModelHighAPI_Selection& theEndTangent,
- const bool theIsClosed,
- const bool theIsToReorder)
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theStartTangent,
+ const ModelHighAPI_Selection& theEndTangent,
+ const bool theIsClosed,
+ const bool theIsToReorder)
: ModelHighAPI_Interface(theFeature)
{
- if(initialize()) {
+ if (initialize()) {
fillAttribute(BuildPlugin_Interpolation::CREATION_METHOD_BY_SELECTION_ID(),mycreationmethod);
setUseTangents(true);
setTangents(theStartTangent, theEndTangent);
}
//==================================================================================================
-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()) {
FeaturePtr aBase = feature();
std::string aPartName = theDumper.name(aBase->document());
- if( aBase->string(BuildPlugin_Interpolation::CREATION_METHOD_ID())->value() ==
+ if (aBase->string(BuildPlugin_Interpolation::CREATION_METHOD_ID())->value() ==
BuildPlugin_Interpolation::CREATION_METHOD_BY_SELECTION_ID() )
{
AttributeSelectionListPtr anAttrBaseObjects =
}
theDumper << closed() << ", " << reorder() << ")" << std::endl;
- }else{
+ } else {
theDumper << aBase << " = model.addInterpolation(" << aPartName ;
AttributeStringPtr XtAttr = xt();
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_ResultParameter.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
#include <GeomAPI_ShapeExplorer.h>
-#include <ModelAPI_Tools.h>
-
-#include <ModelAPI_Expression.h>
-
#include <algorithm>
-
-#include <iostream>
#include <sstream>
data()->reflist(ARGUMENTS_ID())->setIsArgument(false);
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ARGUMENTS_ID());
- if( string( XT_ID())->value() == ""
+ if ( string( XT_ID())->value() == ""
&& string( YT_ID())->value() == ""
&& string( ZT_ID())->value() == "")
{
}
}
+//=================================================================================================
void BuildPlugin_Interpolation::attributeChanged(const std::string& theID)
{
- if( (theID == XT_ID()
+ if ((theID == XT_ID()
|| theID == YT_ID()
|| theID == ZT_ID()
|| theID == MINT_ID()
}
}
+//=================================================================================================
void BuildPlugin_Interpolation::updateCoordinates()
{
std::wstring exp;
double aMaxt = real(MAXT_ID())->value();
int aNbrStep = integer(NUMSTEP_ID())->value();
- if ( aMaxt < aMint ) {
+ if (aMaxt < aMint) {
setError("The minimum value of the parameter must be less than maximum value !!!" );
}
string(VARIABLE_ID())->setValue("t");
tables(VALUE_ID())->setSize(aNbrStep+1,4);
- for( int step = 0; step <= aNbrStep; step++ ){
+ for (int step = 0; step <= aNbrStep; step++ ){
ModelAPI_AttributeTables::Value aVal;
aVal.myDouble = step * aScale + aMint;
tables(VALUE_ID())->setValue(aVal,step,0);
//=================================================================================================
void BuildPlugin_Interpolation::execute()
{
- if( string(CREATION_METHOD_ID())->value() == CREATION_METHOD_BY_SELECTION_ID() )
+ if (string(CREATION_METHOD_ID())->value() == CREATION_METHOD_BY_SELECTION_ID())
{
// Get closed flag value
bool isClosed = boolean(CLOSED_ID())->value();
setResult(aResultBody);
- }else
- {
- if( string( XT_ID())->value() == ""
+ } else {
+ if (string( XT_ID())->value() == ""
||string( YT_ID())->value() == ""
||string( ZT_ID())->value() == ""
||tables(VALUE_ID())->rows()== 0 )
AttributeTablesPtr aTable = tables( VALUE_ID() );
std::list<std::vector<double> > aCoordPoints;
- for( int step = 0; step < aTable->rows() ; step++ ){
+ for (int step = 0; step < aTable->rows(); step++){
std::vector<double> aCoordPoint;
ModelAPI_AttributeTables::Value value;
//x
std::list<GeomVertexPtr> aVertices;
std::list<std::vector<double> >::const_iterator anItCoordPoints = aCoordPoints.begin();
- for( ; anItCoordPoints != aCoordPoints.end(); ++anItCoordPoints ){
+ for (; anItCoordPoints != aCoordPoints.end(); ++anItCoordPoints){
GeomVertexPtr aVertex =
GeomAlgoAPI_PointBuilder::vertex( (*anItCoordPoints)[0],
}
}
-void BuildPlugin_Interpolation::evaluate(std::string& theError)
+//=================================================================================================
+void BuildPlugin_Interpolation::evaluate(std::string& theError)
{
FeaturePtr aMyPtr = std::dynamic_pointer_cast<ModelAPI_Feature>(data()->owner());
std::shared_ptr<ModelAPI_BuildEvalMessage> aProcessMessage =
/// Creates a new part document if needed.
BUILDPLUGIN_EXPORT virtual void execute();
+ /// Called on change of any argument-attribute of this object.
+ /// \param[in] theID identifier of changed attribute.
BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
protected:
/// Evaluates the expression x(t), y(t),z(t) in value table.
void evaluate(std::string& theError);
- //Update coordinates x,y,z
+ ///Update coordinates x,y,z
void updateCoordinates();
+ ///Output error for python interpreter
std::string outErrorMessage;
};
#include <BuildPlugin_Filling.h>
#include <BuildPlugin_Validators.h>
-
-
-
// the only created instance of this plugin
static BuildPlugin_Plugin* MY_INSTANCE = new BuildPlugin_Plugin();
return true;
}
-
+//=================================================================================================
bool BuildPlugin_ValidatorExpressionInterpolation::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& /*theArguments*/,
Events_InfoMessage& theError) const
Part_5_doc = Part_5.document()
Interpolation_11 = model.addInterpolation(Part_5_doc, "sin(t)","cos(t)","t", 0, 100, 10)
-
-model.checkResult(Interpolation_11, model, 1, [0], [0], [0], [1], [2])
-
+model.do()
+model.testNbResults(Interpolation_11, 1)
+model.end()
# =============================================================================
# Test 13. Check Python dump
# =============================================================================
</box>
<box id="analytical"
title="Curve analytical"
- tooltip="???"
icon="icons/Build/feature_interpolation_analytical.png">
<groupbox title="Curves parameters">
<stringvalue id="xt" label="X(t) equation">
#include <iostream>
#include <algorithm>
-//------------------------------------------------------------------------------
+//=================================================================================================
// Tools
std::wstring toString(double theValue)
return std::set<std::wstring>(theContainer.begin(), theContainer.end());
}
-//------------------------------------------------------------------------------
+//=================================================================================================
InitializationPlugin_EvalListener::InitializationPlugin_EvalListener()
{
myInterp->initialize();
}
+//=================================================================================================
InitializationPlugin_EvalListener::~InitializationPlugin_EvalListener()
{
}
+//=================================================================================================
void InitializationPlugin_EvalListener::processEvent(
const std::shared_ptr<Events_Message>& theMessage)
{
Locale::Convert::toWString(anExprAttr->value());
anExpZ.erase(std::remove(anExpZ.begin(),anExpZ.end(), ' '), anExpZ.end());
- for(int step =0; step < anValueAttr->rows(); step++ ){
+ for (int step =0; step < anValueAttr->rows(); step++){
aVal.myDouble = evaluate(anVar,
anValueAttr->value(step,0).myDouble,
aParam,
anError,
aParamsList,
anIsFirstTime);
- if(!anError.empty()) break;
+ if (!anError.empty()) break;
anValueAttr->setValue(aVal,step,1);
-
aVal.myDouble = evaluate(anVar,
anValueAttr->value(step,0).myDouble,
aParam,
anError,
aParamsList,
anIsFirstTime);
- if(!anError.empty()) break;
+ if (!anError.empty()) break;
anValueAttr->setValue(aVal,step,2);
-
aVal.myDouble = evaluate(anVar,
anValueAttr->value(step,0).myDouble,
aParam,
anError,
aParamsList,
anIsFirstTime);
- if(!anError.empty()) break;
+ if (!anError.empty()) break;
anValueAttr->setValue(aVal,step,3);
- if ( anIsFirstTime )
+ if (anIsFirstTime)
anIsFirstTime = false;
}
-
aMsg->setResults(aParamsList, anError);
}
}
+//=================================================================================================
double InitializationPlugin_EvalListener::evaluate(
std::wstring& theVariable,
double theValueVariable,
std::list<std::wstring> anExprParams = myInterp->compile(theExpression);
// find expression's params in the model
-
std::list<std::wstring>::iterator it = anExprParams.begin();
- for ( ; it != anExprParams.end(); it++) {
+ for (; it != anExprParams.end(); it++) {
double aValue;
ResultParameterPtr aParamRes;
// If variable does not exist python interpreter will generate an error.
*it, aValue, aParamRes, theParameter->document()))
continue;
- if( theIsFirstTime )
+ if (theIsFirstTime)
{
std::list<ResultParameterPtr>::iterator anIter =
std::find(theParamsList.begin(),theParamsList.end(), aParamRes );
- if(anIter == theParamsList.end())
+ if (anIter == theParamsList.end())
theParamsList.push_back(aParamRes);
}
return result;
}
-
+//=================================================================================================
double InitializationPlugin_EvalListener::evaluate(FeaturePtr theParameter,
const std::wstring& theExpression, std::string& theError,
std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
return result;
}
+//=================================================================================================
void InitializationPlugin_EvalListener::processEvaluationEvent(
const std::shared_ptr<Events_Message>& theMessage)
{
}
}
+//=================================================================================================
void InitializationPlugin_EvalListener::initDataModel()
{
myInterp->runString("import salome_iapp;salome_iapp.register_module_in_study(\"Shaper\")");
FeaturePtr myParam; ///< parameters that should be evaluated
bool myIsProcessed; ///< true if results were set
std::string myError; ///< error of processing, empty if there is no error
- /// result of processing, list of parameters in expression found
+ /// result of processing, list of parameters in expression found
std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
public:
send(FeaturePtr theParameter, const void* theSender)
{
std::shared_ptr<ModelAPI_BuildEvalMessage> aMessage =
- std::shared_ptr<ModelAPI_BuildEvalMessage>(
- new ModelAPI_BuildEvalMessage(eventId(), theSender));
+ std::shared_ptr<ModelAPI_BuildEvalMessage>(
+ new ModelAPI_BuildEvalMessage(eventId(), theSender));
aMessage->setParameter(theParameter);
Events_Loop::loop()->send(aMessage);
return aMessage;
MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
/// Sets the results of processing
MODELAPI_EXPORT void setResults(
- const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
- const std::string& theError);
- /// Returns the results of processing: list of parameters found in the expression
+ const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
+ const std::string& theError);
+ /// Returns the results of processing: list of parameters found in the expression
MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
/// Returns true if the expression is processed
MODELAPI_EXPORT bool isProcessed();