SET(PROJECT_HEADERS
CollectionAPI.h
CollectionAPI_Group.h
+ CollectionAPI_Field.h
)
SET(PROJECT_SOURCES
CollectionAPI_Group.cpp
+ CollectionAPI_Field.cpp
)
SET(PROJECT_LIBRARIES
#include "CollectionAPI.h"
#include "CollectionAPI_Group.h"
+ #include "CollectionAPI_Field.h"
#endif // CollectionAPI_swig_H_
%}
// shared pointers
%shared_ptr(CollectionAPI_Group)
+%shared_ptr(CollectionAPI_Field)
// all supported interfaces
%include "CollectionAPI_Group.h"
+%include "CollectionAPI_Field.h"
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: CollectionAPI_Field.cpp
+// Created: 16 Nov 2016
+// Author: Mikhail Ponikarov
+
+#include "CollectionAPI_Field.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Integer.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+#include <ModelHighAPI_ComponentValue.h>
+#include <ModelAPI_AttributeTables.h>
+#include <ModelAPI_AttributeStringArray.h>
+
+#include <algorithm> // for std::transform
+
+//=================================================================================================
+CollectionAPI_Field::CollectionAPI_Field(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//=================================================================================================
+CollectionAPI_Field::~CollectionAPI_Field()
+{
+}
+
+//=================================================================================================
+void CollectionAPI_Field::setSelection(const std::list<ModelHighAPI_Selection>& theFieldList)
+{
+ fillAttribute(theFieldList, myselection);
+ execute();
+}
+
+//=================================================================================================
+void CollectionAPI_Field::setComponentsNum(const ModelHighAPI_Integer& theNum)
+{
+ fillAttribute(theNum, mycomponentsNum);
+ execute();
+}
+
+//=================================================================================================
+void CollectionAPI_Field::setComponentsNames(const std::list<std::string>& theNames)
+{
+ fillAttribute(theNames, mycomponentsNames);
+ execute();
+}
+
+//=================================================================================================
+void CollectionAPI_Field::setValuesType(const std::string& theType)
+{
+ fillAttribute(int(valueTypeByStr(theType)), myvaluesType);
+ execute();
+}
+
+//=================================================================================================
+void CollectionAPI_Field::setStepsNum(const ModelHighAPI_Integer& theSteps)
+{
+ fillAttribute(theSteps, mystepsNum);
+ execute();
+}
+
+//=================================================================================================
+void CollectionAPI_Field::setStamps(const std::list<ModelHighAPI_Integer>& theStamps)
+{
+ fillAttribute(theStamps, mystamps);
+ execute();
+}
+
+//=================================================================================================
+void CollectionAPI_Field::addStep(const ModelHighAPI_Integer& theStepNum,
+ const ModelHighAPI_Integer& theStamp,
+ const std::list<std::list<ModelHighAPI_ComponentValue> >& theComponents)
+{
+ // set the table size to be sure the values are up to date
+ myvalues->setSize(myselection->size() + 1 /* with defaults */,
+ mycomponentsNum->value(), mystepsNum->value());
+
+ // set values one by one
+ int aRowIndex = 0;
+ std::list<std::list<ModelHighAPI_ComponentValue> >::const_iterator
+ aRowsIter = theComponents.begin();
+ for(; aRowsIter != theComponents.end(); aRowsIter++, aRowIndex++) {
+ int aColIndex = 0;
+ std::list<ModelHighAPI_ComponentValue>::const_iterator aColIter = aRowsIter->begin();
+ for(; aColIter != aRowsIter->end(); aColIter++, aColIndex++) {
+ aColIter->fill(myvalues, theStepNum.intValue(), aColIndex, aRowIndex);
+ }
+ }
+ execute();
+}
+
+//=================================================================================================
+void CollectionAPI_Field::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ theDumper<<aBase<<" = model.addField("<<aDocName<<", "<<mystepsNum<<", "
+ <<strByValueType(ModelAPI_AttributeTables::ValueType(myvaluesType->value()))<<", "
+ <<mycomponentsNum->value()<<", ";
+ theDumper<<mycomponentsNames<<", ";
+ theDumper<<myselection<<")"<<std::endl;
+ // set values step by step
+ for(int aStep = 0; aStep < myvalues->tables(); aStep++) {
+ theDumper<<aBase<<".addStep("<<aStep<<", "<<mystamps->value(aStep)<<", [";
+ for(int aRow = 0; aRow < myvalues->rows(); aRow++) {
+ if (aRow != 0)
+ theDumper<<", ";
+ theDumper<<"[";
+ for(int aCol = 0; aCol < myvalues->columns(); aCol++) {
+ if (aCol != 0)
+ theDumper<<", ";
+ switch(myvalues->type()) {
+ case ModelAPI_AttributeTables::BOOLEAN:
+ theDumper<<myvalues->value(aRow, aCol, aStep).myBool;
+ break;
+ case ModelAPI_AttributeTables::INTEGER:
+ theDumper<<myvalues->value(aRow, aCol, aStep).myInt;
+ break;
+ case ModelAPI_AttributeTables::DOUBLE:
+ theDumper<<myvalues->value(aRow, aCol, aStep).myDouble;
+ break;
+ case ModelAPI_AttributeTables::STRING:
+ theDumper<<myvalues->value(aRow, aCol, aStep).myStr;
+ break;
+ }
+ }
+ theDumper<<"]";
+ }
+ theDumper<<")"<<std::endl;
+ }
+}
+
+//=================================================================================================
+FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Integer& theStepsNum,
+ std::string& theComponentType,
+ const int theComponentsNum,
+ const std::list<std::string>& theComponentNames,
+ const std::list<ModelHighAPI_Selection>& theSelectionList)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(CollectionAPI_Field::ID());
+ std::shared_ptr<CollectionAPI_Field> aField(new CollectionAPI_Field(aFeature));
+ aField->setStepsNum(theStepsNum);
+ aField->setValuesType(theComponentType);
+ aField->setComponentsNum(theComponentsNum);
+ aField->setComponentsNames(theComponentNames);
+ aField->setSelection(theSelectionList);
+
+ return aField;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: CollectionAPI_Field.h
+// Created: 16 Nov 2016
+// Author: Mikhail Ponikarov
+
+#ifndef CollectionAPI_Field_H_
+#define CollectionAPI_Field_H_
+
+#include "CollectionAPI.h"
+
+#include <CollectionPlugin_Field.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Dumper;
+class ModelHighAPI_Selection;
+class ModelHighAPI_Integer;
+class ModelHighAPI_ComponentValue;
+
+/// \class CollectionAPI_Field
+/// \inField CPPHighAPI
+/// \brief Interface for Field feature.
+class CollectionAPI_Field: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ COLLECTIONAPI_EXPORT
+ explicit CollectionAPI_Field(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Destructor.
+ COLLECTIONAPI_EXPORT
+ virtual ~CollectionAPI_Field();
+
+ INTERFACE_7(CollectionPlugin_Field::ID(),
+ selection, CollectionPlugin_Field::SELECTED_ID(),
+ ModelAPI_AttributeSelectionList, /** Field selection list*/,
+ componentsNum, CollectionPlugin_Field::COMPONENTS_NB_ID(),
+ ModelAPI_AttributeInteger, /** Number of components integer */,
+ componentsNames, CollectionPlugin_Field::COMPONENTS_NAMES_ID(),
+ ModelAPI_AttributeStringArray, /** Names of components list of strings */,
+ valuesType, CollectionPlugin_Field::VALUES_TYPE_ID(),
+ ModelAPI_AttributeInteger, /** Type of the values enumeration */,
+ stepsNum, CollectionPlugin_Field::STEPS_NB_ID(),
+ ModelAPI_AttributeInteger, /** Number of steps integer */,
+ stamps, CollectionPlugin_Field::STAMPS_ID(),
+ ModelAPI_AttributeIntArray, /** Identifiers of stamps */,
+ values, CollectionPlugin_Field::VALUES_ID(), ModelAPI_AttributeTables /** Table of values */,
+ )
+
+ /// Set selected objects.
+ COLLECTIONAPI_EXPORT
+ void setSelection(const std::list<ModelHighAPI_Selection>& theFieldList);
+ /// Set number of components
+ COLLECTIONAPI_EXPORT
+ void setComponentsNum(const ModelHighAPI_Integer& theNum);
+ /// Set names of components
+ COLLECTIONAPI_EXPORT
+ void setComponentsNames(const std::list<std::string>& theNames);
+ /// Set type of values
+ COLLECTIONAPI_EXPORT
+ void setValuesType(const std::string& theType);
+ /// Set number of steps
+ COLLECTIONAPI_EXPORT
+ void setStepsNum(const ModelHighAPI_Integer& theSteps);
+ /// Set stamps identifiers
+ COLLECTIONAPI_EXPORT
+ void setStamps(const std::list<ModelHighAPI_Integer>& theStamps);
+ /// Sets the values of specific step
+ COLLECTIONAPI_EXPORT
+ void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
+ const std::list<std::list<ModelHighAPI_ComponentValue> >& theComponents);
+
+ /// Dump wrapped feature
+ COLLECTIONAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on Field object.
+typedef std::shared_ptr<CollectionAPI_Field> FieldPtr;
+
+/// \inField CPPHighAPI
+/// \brief Create Field feature.
+COLLECTIONAPI_EXPORT
+FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Integer& theStepsNum,
+ std::string& theComponentType,
+ const int theComponentsNum,
+ const std::list<std::string>& theComponentNames,
+ const std::list<ModelHighAPI_Selection>& theSelectionList);
+
+#endif // CollectionAPI_Field_H_
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_AttributeTables.h>
+#include <ModelAPI_ResultField.h>
CollectionPlugin_Field::CollectionPlugin_Field()
{
void CollectionPlugin_Field::execute()
{
if (results().empty() || firstResult()->isDisabled()) { // just create result if not exists
- //ResultPtr aField = document()->createField(data());
- //setResult(aField);
+ ResultPtr aField = document()->createField(data());
+ setResult(aField);
}
}
Model_ResultCompSolid.h
Model_ResultConstruction.h
Model_ResultPart.h
+ Model_ResultField.h
Model_ResultGroup.h
Model_ResultParameter.h
Model_FeatureValidator.h
Model_ResultCompSolid.cpp
Model_ResultConstruction.cpp
Model_ResultPart.cpp
+ Model_ResultField.cpp
Model_ResultGroup.cpp
Model_ResultParameter.cpp
Model_FeatureValidator.cpp
}
}
-const ModelAPI_AttributeTables::ValueType& Model_AttributeTables::type(ValueType) const
+const ModelAPI_AttributeTables::ValueType& Model_AttributeTables::type() const
{
return myType;
}
/// Defines the tyoe of values in the table. If it differs from the current, erases the content.
MODEL_EXPORT virtual void setType(ValueType theType);
/// Defines the tyoe of values in the table. If it differs from the current, erases the content.
- MODEL_EXPORT virtual const ValueType& type(ValueType) const;
+ MODEL_EXPORT virtual const ValueType& type() const;
/// Defines the value by the index in the tables set (indexes are zero-based).
MODEL_EXPORT virtual void setValue(
const Value theValue, const int theRow, const int theColumn, const int theTable = 0);
return myObjs->createGroup(theFeatureData, theIndex);
}
+std::shared_ptr<ModelAPI_ResultField> Model_Document::createField(
+ const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+ return myObjs->createField(theFeatureData, theIndex);
+}
+
std::shared_ptr<ModelAPI_ResultParameter> Model_Document::createParameter(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
/// Creates a group result
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+ /// Creates a field result
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultField> createField(
+ const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
/// Creates a parameter result
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultParameter> createParameter(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
#include <Model_ResultBody.h>
#include <Model_ResultCompSolid.h>
#include <Model_ResultGroup.h>
+#include <Model_ResultField.h>
#include <Model_ResultParameter.h>
#include <ModelAPI_Validator.h>
#include <ModelAPI_CompositeFeature.h>
return aResult;
}
+std::shared_ptr<ModelAPI_ResultField> Model_Objects::createField(
+ const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+ TDF_Label aLab = resultLabel(theFeatureData, theIndex);
+ TDataStd_Comment::Set(aLab, ModelAPI_ResultField::group().c_str());
+ ObjectPtr anOldObject = object(aLab);
+ std::shared_ptr<ModelAPI_ResultField> aResult;
+ if (anOldObject.get()) {
+ aResult = std::dynamic_pointer_cast<ModelAPI_ResultField>(anOldObject);
+ }
+ if (!aResult.get()) {
+ aResult = std::shared_ptr<ModelAPI_ResultField>(new Model_ResultField(theFeatureData));
+ storeResult(theFeatureData, aResult, theIndex);
+ }
+ return aResult;
+}
+
std::shared_ptr<ModelAPI_ResultParameter> Model_Objects::createParameter(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
break;
} else if (aGroup->Get() == ModelAPI_ResultGroup::group().c_str()) {
aNewBody = createGroup(theFeature->data(), aResIndex);
+ } else if (aGroup->Get() == ModelAPI_ResultField::group().c_str()) {
+ aNewBody = createField(theFeature->data(), aResIndex);
} else if (aGroup->Get() == ModelAPI_ResultParameter::group().c_str()) {
theFeature->attributeChanged("expression"); // just produce a value
break;
/// Creates a group result
std::shared_ptr<ModelAPI_ResultGroup> createGroup(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+ /// Creates a field result
+ std::shared_ptr<ModelAPI_ResultField> createField(
+ const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
/// Creates a parameter result
std::shared_ptr<ModelAPI_ResultParameter> createParameter(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: Model_ResultField.cpp
+// Created: 08 Jul 2014
+// Author: Mikhail PONIKAROV
+
+#include <Model_ResultField.h>
+#include <ModelAPI_AttributeSelectionList.h>
+
+#include <GeomAlgoAPI_CompoundBuilder.h>
+
+#include <Config_PropManager.h>
+
+Model_ResultField::Model_ResultField(std::shared_ptr<ModelAPI_Data> theOwnerData)
+{
+ myOwnerData = theOwnerData;
+}
+
+void Model_ResultField::colorConfigInfo(std::string& theSection, std::string& theName,
+ std::string& theDefault)
+{
+ theSection = "Visualization";
+ theName = "result_field_color";
+ theDefault = DEFAULT_COLOR();
+}
+
+std::shared_ptr<GeomAPI_Shape> Model_ResultField::shape()
+{
+ std::shared_ptr<GeomAPI_Shape> aResult;
+ if (myOwnerData) {
+ AttributeSelectionListPtr aList = myOwnerData->selectionList("selected");
+ if (aList) {
+ std::list<std::shared_ptr<GeomAPI_Shape> > aSubs;
+ for(int a = aList->size() - 1; a >= 0; a--) {
+ std::shared_ptr<GeomAPI_Shape> aSelection = aList->value(a)->value();
+ if (aSelection && !aSelection->isNull()) {
+ aSubs.push_back(aSelection);
+ }
+ }
+ if (!aSubs.empty()) {
+ aResult = GeomAlgoAPI_CompoundBuilder::compound(aSubs);
+ }
+ }
+ }
+ return aResult;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: Model_ResultField.h
+// Created: 16 Nov 2016
+// Author: Mikhail PONIKAROV
+
+#ifndef Model_ResultField_H_
+#define Model_ResultField_H_
+
+#include "Model.h"
+#include <ModelAPI_ResultField.h>
+
+/**\class Model_ResultField
+ * \ingroup DataModel
+ * \brief The fields result.
+ *
+ * Provides a compound of selected elements, without storage, one the fly.
+ */
+class Model_ResultField : public ModelAPI_ResultField
+{
+ std::shared_ptr<ModelAPI_Data> myOwnerData; ///< data of owner of this result
+public:
+
+ /// Retuns the parameters of color definition in the resources config manager
+ MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
+ std::string& theDefault);
+
+ /// Returns the compound of selected entities
+ MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
+
+ /// Removes the stored builders
+ MODEL_EXPORT virtual ~Model_ResultField() {}
+
+protected:
+ /// Makes a body on the given feature data
+ Model_ResultField(std::shared_ptr<ModelAPI_Data> theOwnerData);
+
+ friend class Model_Objects;
+};
+
+#endif
ModelAPI_ResultBody.h
ModelAPI_ResultCompSolid.h
ModelAPI_ResultConstruction.h
+ ModelAPI_ResultField.h
ModelAPI_ResultGroup.h
ModelAPI_ResultParameter.h
ModelAPI_ResultPart.h
ModelAPI_ResultBody.cpp
ModelAPI_ResultCompSolid.cpp
ModelAPI_ResultConstruction.cpp
+ ModelAPI_ResultField.cpp
ModelAPI_ResultGroup.cpp
ModelAPI_ResultPart.cpp
ModelAPI_ResultParameter.cpp
%shared_ptr(ModelAPI_ResultBody)
%shared_ptr(ModelAPI_ResultPart)
%shared_ptr(ModelAPI_ResultGroup)
+%shared_ptr(ModelAPI_ResultField)
%shared_ptr(ModelAPI_ResultParameter)
%shared_ptr(ModelAPI_ResultCompSolid)
%include "ModelAPI_ResultBody.h"
%include "ModelAPI_ResultPart.h"
%include "ModelAPI_ResultGroup.h"
+%include "ModelAPI_ResultField.h"
%include "ModelAPI_ResultParameter.h"
%include "ModelAPI_Tools.h"
%include "ModelAPI_ResultCompSolid.h"
%template(modelAPI_ResultPart) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_Result>;
%template(modelAPI_ResultParameter) shared_ptr_cast<ModelAPI_ResultParameter, ModelAPI_Result>;
%template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultGroup>;
+%template(modelAPI_ResultField) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultField>;
%template(modelAPI_ResultCompSolid) shared_ptr_cast<ModelAPI_ResultCompSolid, ModelAPI_ResultBody>;
// Attribute casts
/// Defines the tyoe of values in the table. If it differs from the current, erases the content.
MODELAPI_EXPORT virtual void setType(ValueType theType) = 0;
/// Defines the tyoe of values in the table. If it differs from the current, erases the content.
- MODELAPI_EXPORT virtual const ValueType& type(ValueType) const = 0;
+ MODELAPI_EXPORT virtual const ValueType& type() const = 0;
/// Defines the value by the index in the tables set (indexes are zero-based).
MODELAPI_EXPORT virtual void setValue(
- const Value theValue, const int theRow, const int theColumn, const int theTable = 1) = 0;
+ const Value theValue, const int theRow, const int theColumn, const int theTable = 0) = 0;
/// Returns the value by the index (indexes are zero-based).
MODELAPI_EXPORT virtual Value value(
- const int theRow, const int theColumn, const int theTable = 1) = 0;
+ const int theRow, const int theColumn, const int theTable = 0) = 0;
/// Returns the type of this class of attributes
MODELAPI_EXPORT static std::string typeId()
class ModelAPI_ResultBody;
class ModelAPI_ResultPart;
class ModelAPI_ResultGroup;
+class ModelAPI_ResultField;
class ModelAPI_ResultParameter;
class ModelAPI_Data;
class GeomAPI_Shape;
//! Creates a group result
virtual std::shared_ptr<ModelAPI_ResultGroup> createGroup(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+ //! Creates a field result
+ virtual std::shared_ptr<ModelAPI_ResultField> createField(
+ const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
//! Creates a parameter result
virtual std::shared_ptr<ModelAPI_ResultParameter> createParameter(
const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModelAPI_ResultField.cpp
+// Created: 16 Nov 2016
+// Author: Mikhail PONIKAROV
+
+#include "ModelAPI_ResultField.h"
+
+ModelAPI_ResultField::~ModelAPI_ResultField()
+{
+
+}
+
+std::string ModelAPI_ResultField::groupName()
+{
+ return group();
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModelAPI_ResultField.hxx
+// Created: 16 Nov 2016
+// Author: Mikhail PONIKAROV
+
+#ifndef ModelAPI_ResultField_H_
+#define ModelAPI_ResultField_H_
+
+#include "ModelAPI_Result.h"
+#include <GeomAPI_Shape.h>
+#include <memory>
+#include <string>
+
+/**\class ModelAPI_ResultField
+ * \ingroup DataModel
+ * \brief The fields result.
+ *
+ * Provides a compound of selected elements, without storage, one the fly.
+ */
+class ModelAPI_ResultField : public ModelAPI_Result
+{
+public:
+ MODELAPI_EXPORT virtual ~ModelAPI_ResultField();
+ /// Returns the group identifier of this result
+ MODELAPI_EXPORT virtual std::string groupName();
+
+ /// Returns the group identifier of this result
+ inline static std::string group()
+ {
+ static std::string MY_GROUP = "Fields";
+ return MY_GROUP;
+ }
+
+ /// default color for a result body
+ inline static const std::string& DEFAULT_COLOR()
+ {
+ static const std::string RESULT_GROUP_COLOR("150,150,180");
+ return RESULT_GROUP_COLOR;
+ }
+
+};
+
+//! Pointer on feature object
+typedef std::shared_ptr<ModelAPI_ResultField> ResultFieldPtr;
+
+#endif
#include "ModelAPI_ResultPart.h"
#include "ModelAPI_ResultParameter.h"
#include "ModelAPI_ResultGroup.h"
+ #include "ModelAPI_ResultField.h"
#include "ModelAPI_Tools.h"
#include "ModelAPI_ResultCompSolid.h"
ModelHighAPI_RefAttr.h
ModelHighAPI_Reference.h
ModelHighAPI_Selection.h
+ ModelHighAPI_ComponentValue.h
ModelHighAPI_Services.h
ModelHighAPI_Tools.h
ModelHighAPI_FeatureStore.h
ModelHighAPI_RefAttr.cpp
ModelHighAPI_Reference.cpp
ModelHighAPI_Selection.cpp
+ ModelHighAPI_ComponentValue.cpp
ModelHighAPI_Services.cpp
ModelHighAPI_Tools.cpp
ModelHighAPI_FeatureStore.cpp
%include "ModelHighAPI_RefAttr.h"
%include "ModelHighAPI_Reference.h"
%include "ModelHighAPI_Selection.h"
+%include "ModelHighAPI_ComponentValue.h"
%include "ModelHighAPI_Services.h"
%include "ModelHighAPI_Macro.h"
%include "ModelHighAPI_Tools.h"
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Name : ModelHighAPI_ComponentValue.cpp
+// Purpose:
+//
+// History:
+// 29/03/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ModelHighAPI_ComponentValue.h"
+
+#include <ModelAPI_AttributeInteger.h>
+
+#include <sstream>
+
+//--------------------------------------------------------------------------------------
+ModelHighAPI_ComponentValue::ModelHighAPI_ComponentValue(const bool theValue)
+ : myType(ModelAPI_AttributeTables::BOOLEAN)
+{
+ // initialize everything since in python there may be problem with correct typification
+ myValue.myBool = theValue;
+ myValue.myInt = theValue ? 1 : 0;
+ myValue.myDouble = theValue ? 1. : 0.;
+ myValue.myStr = theValue ? "True" : "False";
+}
+//--------------------------------------------------------------------------------------
+ModelHighAPI_ComponentValue::ModelHighAPI_ComponentValue(const int theValue)
+ : myType(ModelAPI_AttributeTables::INTEGER)
+{
+ // initialize everything since in python there may be problem with correct typification
+ myValue.myBool = theValue == 0 ? false : true;
+ myValue.myInt = theValue;
+ myValue.myDouble = theValue;
+ std::ostringstream s;
+ s << theValue;
+ myValue.myStr = s.str();
+}
+//--------------------------------------------------------------------------------------
+ModelHighAPI_ComponentValue::ModelHighAPI_ComponentValue(const double theValue)
+ : myType(ModelAPI_AttributeTables::DOUBLE)
+{
+ // initialize everything since in python there may be problem with correct typification
+ myValue.myBool = theValue == 0. ? false : true;
+ myValue.myInt = int(theValue);
+ myValue.myDouble = theValue;
+ std::ostringstream s;
+ s << theValue;
+ myValue.myStr = s.str();
+}
+//--------------------------------------------------------------------------------------
+ModelHighAPI_ComponentValue::ModelHighAPI_ComponentValue(const std::string& theValue)
+ : myType(ModelAPI_AttributeTables::STRING)
+{
+ myValue.myBool = (theValue.empty() || theValue == "False" || theValue == "0") ? false : true;
+
+ std::stringstream stream1(theValue);
+ myValue.myInt = 0;
+ stream1 >> myValue.myInt;
+ std::stringstream stream2(theValue);
+ myValue.myDouble = 0.;
+ stream2 >> myValue.myDouble;
+
+ myValue.myStr = theValue;
+}
+
+//--------------------------------------------------------------------------------------
+ModelHighAPI_ComponentValue::~ModelHighAPI_ComponentValue()
+{
+}
+
+//--------------------------------------------------------------------------------------
+void ModelHighAPI_ComponentValue::fill(const std::shared_ptr<ModelAPI_AttributeTables>& theAttr,
+ const int theTable, const int theColumn, const int theRow) const
+{
+ theAttr->setValue(myValue, theRow, theColumn, theTable);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Name : ModelHighAPI_ComponentValue.h
+// Purpose:
+//
+// History:
+// 16/11/16 - Mikhail Ponikarov - Creation of the file
+
+#ifndef SRC_MODELHIGHAPI_ModelHighAPI_ComponentValue_H_
+#define SRC_MODELHIGHAPI_ModelHighAPI_ComponentValue_H_
+
+//--------------------------------------------------------------------------------------
+#include "ModelHighAPI.h"
+
+#include <ModelAPI_AttributeTables.h>
+
+//--------------------------------------------------------------------------------------
+/**\class ModelHighAPI_ComponentValue
+ * \ingroup CPPHighAPI
+ * \brief Class for filling ModelAPI_AttributeTable elements
+ */
+class ModelHighAPI_ComponentValue
+{
+public:
+ /// Constructor for Boolean
+ MODELHIGHAPI_EXPORT ModelHighAPI_ComponentValue(const bool theValue = false);
+ /// Constructor for int
+ MODELHIGHAPI_EXPORT ModelHighAPI_ComponentValue(const int theValue);
+ /// Constructor for double
+ MODELHIGHAPI_EXPORT ModelHighAPI_ComponentValue(const double theValue);
+ /// Constructor for std::string
+ MODELHIGHAPI_EXPORT ModelHighAPI_ComponentValue(const std::string & theValue);
+ /// Destructor
+ MODELHIGHAPI_EXPORT virtual ~ModelHighAPI_ComponentValue();
+
+ /// Sets value to the table
+ MODELHIGHAPI_EXPORT virtual void fill(const std::shared_ptr<ModelAPI_AttributeTables>& theAttr,
+ const int theTable, const int theColumn, const int theRow) const;
+
+private:
+ ModelAPI_AttributeTables::ValueType myType; ///< type of the value set
+ ModelAPI_AttributeTables::Value myValue; ///< value itself
+};
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_MODELHIGHAPI_ModelHighAPI_ComponentValue_H_ */
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeStringArray.h>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Entity.h>
return *this;
}
+ModelHighAPI_Dumper& ModelHighAPI_Dumper::operator<<(
+ const std::shared_ptr<ModelAPI_AttributeStringArray>& theArray)
+{
+ myDumpBuffer<<"[";
+ for(int anIndex = 0; anIndex < theArray->size(); ++anIndex) {
+
+ myDumpBuffer<<"\""<<theArray->value(anIndex)<<"\"";
+ if (anIndex != 0)
+ myDumpBuffer<<", ";
+ }
+
+ myDumpBuffer<<"]";
+ return *this;
+}
+
/// Dump std::endl
-MODELHIGHAPI_EXPORT
ModelHighAPI_Dumper& operator<<(ModelHighAPI_Dumper& theDumper,
std::basic_ostream<char>& (*theEndl)(std::basic_ostream<char>&))
{
class ModelAPI_AttributeSelection;
class ModelAPI_AttributeSelectionList;
class ModelAPI_AttributeString;
+class ModelAPI_AttributeStringArray;
class ModelAPI_CompositeFeature;
class ModelAPI_Document;
class ModelAPI_Entity;
/// Dump AttributeReference
MODELHIGHAPI_EXPORT ModelHighAPI_Dumper&
operator<<(const std::shared_ptr<ModelAPI_AttributeReference>& theReference);
+ /// Dump AttributeStringArray
+ MODELHIGHAPI_EXPORT ModelHighAPI_Dumper&
+ operator<<(const std::shared_ptr<ModelAPI_AttributeStringArray>& theArray);
/// Clear dump buffer
MODELHIGHAPI_EXPORT
case VT_STRING: theAttribute->setText(myString); return;
}
}
+
+int ModelHighAPI_Integer::intValue() const
+{
+ // needed for array of integer, which supports no text
+ return myInt;
+}
public:
/// Constructor for int
MODELHIGHAPI_EXPORT
- ModelHighAPI_Integer(int theValue = 0.);
+ ModelHighAPI_Integer(int theValue = 0);
/// Constructor for std::string
MODELHIGHAPI_EXPORT
ModelHighAPI_Integer(const std::string & theValue);
MODELHIGHAPI_EXPORT
virtual void fillAttribute(const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute) const;
+ /// Returns a value (must be used only for attributes which support no text)
+ MODELHIGHAPI_EXPORT virtual int intValue() const;
+
private:
enum VariantType { VT_INT, VT_STRING } myVariantType;
int myInt;
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeStringArray.h>
#include <ModelAPI_AttributeDoubleArray.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Tools.h>
{
theAttribute->setValue(theValue);
}
+
+//--------------------------------------------------------------------------------------
void fillAttribute(const char * theValue,
const std::shared_ptr<ModelAPI_AttributeString> & theAttribute)
{
theAttribute->setValue(theValue);
}
+//--------------------------------------------------------------------------------------
+void fillAttribute(const std::list<std::string> & theValue,
+ const std::shared_ptr<ModelAPI_AttributeStringArray> & theAttribute)
+{
+ theAttribute->setSize(int(theValue.size()));
+
+ int anIndex = 0;
+ for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex)
+ theAttribute->setValue(anIndex, *it);
+}
+
+//--------------------------------------------------------------------------------------
+void fillAttribute(const std::list<ModelHighAPI_Integer> & theValue,
+ const std::shared_ptr<ModelAPI_AttributeIntArray> & theAttribute)
+{
+ theAttribute->setSize(int(theValue.size()));
+
+ int anIndex = 0;
+ for (auto it = theValue.begin(); it != theValue.end(); ++it, ++anIndex)
+ theAttribute->setValue(anIndex, it->intValue()); // use only values, no text support in array
+}
+
//==================================================================================================
GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr)
{
return aShapeType;
}
+//--------------------------------------------------------------------------------------
+ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTypeStr)
+{
+ std::string aType = theValueTypeStr;
+ std::transform(aType.begin(), aType.end(), aType.begin(), ::tolower);
+ if (aType == "boolean")
+ return ModelAPI_AttributeTables::BOOLEAN;
+ else if (aType == "integer")
+ return ModelAPI_AttributeTables::INTEGER;
+ else if (aType == "string")
+ return ModelAPI_AttributeTables::STRING;
+ return ModelAPI_AttributeTables::DOUBLE; // default
+}
+
+//--------------------------------------------------------------------------------------
+std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType)
+{
+ switch(theType) {
+ case ModelAPI_AttributeTables::BOOLEAN: return "BOOLEAN";
+ case ModelAPI_AttributeTables::INTEGER: return "INTEGER";
+ case ModelAPI_AttributeTables::DOUBLE: return "DOUBLE";
+ case ModelAPI_AttributeTables::STRING: return "STRING";
+ }
+ return ""; // bad case
+}
+
/// stores the features information, recoursively stores sub-documetns features
std::string storeFeatures(const std::string& theDocName, DocumentPtr theDoc,
std::map<std::string, std::map<std::string, ModelHighAPI_FeatureStore> >& theStore,
//--------------------------------------------------------------------------------------
#include "ModelHighAPI.h"
+#include <ModelAPI_AttributeTables.h>
#include <GeomAPI_Shape.h>
class ModelAPI_AttributeSelection;
class ModelAPI_AttributeSelectionList;
class ModelAPI_AttributeString;
+class ModelAPI_AttributeStringArray;
class ModelAPI_Object;
//--------------------------------------------------------------------------------------
class ModelHighAPI_Double;
void fillAttribute(const char * theValue,
const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::list<std::string> & theValue,
+ const std::shared_ptr<ModelAPI_AttributeStringArray> & theAttribute);
+
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::list<ModelHighAPI_Integer> & theValue,
+ const std::shared_ptr<ModelAPI_AttributeIntArray> & theAttribute);
+
MODELHIGHAPI_EXPORT
GeomAPI_Shape::ShapeType shapeTypeByStr(std::string theShapeTypeStr);
MODELHIGHAPI_EXPORT
GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
+MODELHIGHAPI_EXPORT
+ModelAPI_AttributeTables::ValueType valueTypeByStr(const std::string& theValueTypeStr);
+
+MODELHIGHAPI_EXPORT
+std::string strByValueType(const ModelAPI_AttributeTables::ValueType theType);
+
/// Performs the high level API dump, then closes all and executes the script:
/// model must be recreated fully, with all attributes
/// \returns true if check is well done
#include "ModelHighAPI_RefAttr.h"
#include "ModelHighAPI_Reference.h"
#include "ModelHighAPI_Selection.h"
+ #include "ModelHighAPI_ComponentValue.h"
#include "ModelHighAPI_Services.h"
#include "ModelHighAPI_Tools.h"