#endif // CollectionAPI_swig_H_
%}
+%{
+ #include "ModelHighAPI_swig.h"
+
+ // fix for SWIG v2.0.4
+ #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
+%}
+
%include "doxyhelp.i"
// import other modules
// standard definitions
%include "typemaps.i"
+%include "std_list.i"
+%include "std_string.i"
%include "std_shared_ptr.i"
+%template(StringList) std::list<std::string>;
+%template(IntegerList) std::list<int>;
+%template(DoubleList) std::list<double>;
+%template(BooleanList) std::list<bool>;
+%template(StringListList) std::list<std::list<std::string> >;
+%template(IntegerListList) std::list<std::list<int> >;
+%template(DoubleListList) std::list<std::list<double> >;
+%template(BooleanListList) std::list<std::list<bool> >;
+
// shared pointers
%shared_ptr(CollectionAPI_Group)
%shared_ptr(CollectionAPI_Field)
#include <ModelHighAPI_Integer.h>
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
-#include <ModelHighAPI_ComponentValue.h>
#include <ModelAPI_AttributeTables.h>
#include <ModelAPI_AttributeStringArray.h>
void CollectionAPI_Field::setValuesType(const std::string& theType)
{
fillAttribute(int(valueTypeByStr(theType)), myvaluesType);
+ myvalues->setType(valueTypeByStr(theType));
execute();
}
void CollectionAPI_Field::setStepsNum(const ModelHighAPI_Integer& theSteps)
{
fillAttribute(theSteps, mystepsNum);
+ mystamps->setSize(theSteps.intValue());
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();
+#define addStepImplementation(type, fieldType, type2, fieldType2, type3, fieldType3) \
+void CollectionAPI_Field::addStep(const ModelHighAPI_Integer& theStepNum, \
+ const ModelHighAPI_Integer& theStamp, \
+ const std::list<std::list<type> >& theComponents) \
+{ \
+ myvalues->setSize(myselection->size() + 1, \
+ mycomponentsNum->value(), mystepsNum->value()); \
+ mystamps->setValue(theStepNum.intValue(), theStamp.intValue()); \
+ int aRowIndex = 0; \
+ std::list<std::list<type> >::const_iterator \
+ aRowsIter = theComponents.begin(); \
+ for(; aRowsIter != theComponents.end(); aRowsIter++, aRowIndex++) { \
+ int aColIndex = 0; \
+ std::list<type>::const_iterator aColIter = aRowsIter->begin(); \
+ for(; aColIter != aRowsIter->end(); aColIter++, aColIndex++) { \
+ ModelAPI_AttributeTables::Value aVal; \
+ aVal.fieldType = *aColIter; \
+ aVal.fieldType2 = type2(*aColIter); \
+ aVal.fieldType3 = type3(*aColIter); \
+ myvalues->setValue(aVal, aRowIndex, aColIndex, theStepNum.intValue()); \
+ } \
+ } \
+ execute(); \
}
+addStepImplementation(double, myDouble, int, myInt, bool, myBool);
+addStepImplementation(int, myInt, double, myDouble, bool, myBool);
+addStepImplementation(bool, myBool, int, myInt, double, myDouble);
+addStepImplementation(std::string, myStr, std::string, myStr, std::string, myStr);
+
//=================================================================================================
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()))<<", "
+ theDumper<<aBase<<" = model.addField("<<aDocName<<", "<<mystepsNum->value()<<", \""
+ <<strByValueType(ModelAPI_AttributeTables::ValueType(myvaluesType->value()))<<"\", "
<<mycomponentsNum->value()<<", ";
theDumper<<mycomponentsNames<<", ";
theDumper<<myselection<<")"<<std::endl;
for(int aCol = 0; aCol < myvalues->columns(); aCol++) {
if (aCol != 0)
theDumper<<", ";
- switch(myvalues->type()) {
+ switch(myvaluesType->value()) {
case ModelAPI_AttributeTables::BOOLEAN:
theDumper<<myvalues->value(aRow, aCol, aStep).myBool;
break;
theDumper<<myvalues->value(aRow, aCol, aStep).myDouble;
break;
case ModelAPI_AttributeTables::STRING:
- theDumper<<myvalues->value(aRow, aCol, aStep).myStr;
+ theDumper<<'"'<<myvalues->value(aRow, aCol, aStep).myStr<<'"';
break;
}
}
theDumper<<"]";
}
- theDumper<<")"<<std::endl;
+ theDumper<<"])"<<std::endl;
}
}
//=================================================================================================
FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Integer& theStepsNum,
- std::string& theComponentType,
+ const std::string& theComponentType,
const int theComponentsNum,
const std::list<std::string>& theComponentNames,
const std::list<ModelHighAPI_Selection>& theSelectionList)
/// Set stamps identifiers
COLLECTIONAPI_EXPORT
void setStamps(const std::list<ModelHighAPI_Integer>& theStamps);
- /// Sets the values of specific step
+ /// Sets the double values of specific step
COLLECTIONAPI_EXPORT
void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
- const std::list<std::list<ModelHighAPI_ComponentValue> >& theComponents);
+ const std::list<std::list<double> >& theComponents);
+ /// Sets the integer values of specific step
+ COLLECTIONAPI_EXPORT
+ void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
+ const std::list<std::list<int> >& theComponents);
+ /// Sets the string values of specific step
+ COLLECTIONAPI_EXPORT
+ void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
+ const std::list<std::list<std::string> >& theComponents);
+ /// Sets the boolean values of specific step
+ COLLECTIONAPI_EXPORT
+ void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
+ const std::list<std::list<bool> >& theComponents);
/// Dump wrapped feature
COLLECTIONAPI_EXPORT
COLLECTIONAPI_EXPORT
FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Integer& theStepsNum,
- std::string& theComponentType,
+ const std::string& theComponentType,
const int theComponentsNum,
const std::list<std::string>& theComponentNames,
const std::list<ModelHighAPI_Selection>& theSelectionList);
ADD_UNIT_TESTS(
TestGroup.py
+ TestField.py
)
class CollectionPlugin_Field : public ModelAPI_Feature
{
public:
- /// Extrusion kind
+ /// Feature kind
inline static const std::string& ID()
{
static const std::string MY_FIELD_ID("Field");
--- /dev/null
+"""
+ TestBoolean.py
+ Unit test of FeaturesPlugin_Group class
+
+ class FeaturesPlugin_Group
+ static const std::string MY_GROUP_ID("Group");
+ static const std::string MY_GROUP_LIST_ID("group_list");
+
+ data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+# Create a part for extrusions & boolean
+aSession.startOperation()
+aPartFeature = aSession.moduleDocument().addFeature("Part")
+aSession.finishOperation()
+aPart = aSession.activeDocument()
+#=========================================================================
+# Create a sketch with triangle and extrude it
+#=========================================================================
+aSession.startOperation()
+aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine")
+aSketchLineB = aTriangleSketchFeature.addFeature("SketchLine")
+aSketchLineC = aTriangleSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
+aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
+aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
+aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint"))
+aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint"))
+aLineAStartPoint.setValue(-100., 0.)
+aLineAEndPoint.setValue(100., 0.)
+aLineBStartPoint.setValue(100., 0.)
+aLineBEndPoint.setValue(0., 173.2)
+aLineCStartPoint.setValue(0., 173.2)
+aLineCEndPoint.setValue(-100., 0.)
+aSession.finishOperation()
+# Build sketch faces
+aSession.startOperation()
+aSketchResult = aTriangleSketchFeature.firstResult()
+aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
+origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir()
+norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir()
+aSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces)
+# Create extrusion on them
+anExtrusionFt = aPart.addFeature("Extrusion")
+anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0])
+anExtrusionFt.string("CreationMethod").setValue("BySizes")
+anExtrusionFt.real("to_size").setValue(50)
+anExtrusionFt.real("from_size").setValue(50)
+anExtrusionFt.real("to_offset").setValue(0) #TODO: remove
+anExtrusionFt.real("from_offset").setValue(0) #TODO: remove
+anExtrusionFt.execute()
+aSession.finishOperation()
+anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult())
+#=========================================================================
+# Create doubles field on vertices
+#=========================================================================
+aSession.startOperation()
+aField = aSession.activeDocument().addFeature("Field")
+aSelectionListAttr = aField.selectionList("selected")
+aSelectionListAttr.setSelectionType("vertex")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1")
+aField.integer("components_nb").setValue(2) # two components
+aComponentNames = aField.stringArray("components_names")
+aComponentNames.setSize(2)
+aComponentNames.setValue(0, "temperatue")
+aComponentNames.setValue(1, "porosity")
+aField.integer("type").setValue(2) # double
+aField.integer("steps_nb").setValue(1) # one step
+aStamps = aField.intArray("stamps")
+aStamps.setSize(1)
+aStamps.setValue(0, 10)
+aTables = aField.tables("values")
+aTables.setType(2)
+aTables.setSize(1 + 3, 2, 1) # default row + number of selected, number of compoents, number of steps (tables)
+aTables.setValue(20, 0, 0, 0) # value, index of selection, index of component, index of step
+aTables.setValue(35, 1, 0, 0)
+aTables.setValue(27, 2, 0, 0)
+aTables.setValue(28, 3, 0, 0)
+aTables.setValue(0.5, 0, 1, 0)
+aTables.setValue(0.55, 1, 1, 0)
+aTables.setValue(0.39, 2, 1, 0)
+aTables.setValue(0.40, 3, 1, 0)
+aSession.finishOperation()
+#=========================================================================
+# Create strings field on faces
+#=========================================================================
+aSession.startOperation()
+aField = aSession.activeDocument().addFeature("Field")
+aSelectionListAttr = aField.selectionList("selected")
+aSelectionListAttr.setSelectionType("face")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
+aField.integer("components_nb").setValue(1) # one component
+aComponentNames = aField.stringArray("components_names")
+aComponentNames.setSize(1)
+aComponentNames.setValue(0, "description")
+aField.integer("type").setValue(3) # string
+aField.integer("steps_nb").setValue(2) # two steps
+aStamps = aField.intArray("stamps")
+aStamps.setSize(2)
+aStamps.setValue(0, 1)
+aStamps.setValue(1, 3)
+aTables = aField.tables("values")
+aTables.setType(3)
+aTables.setSize(1 + 1, 1, 2) # default row + number of selected, number of compoents, number of steps (tables)
+aTables.setValue("-default-", 0, 0, 0) # value, index of selection, index of component, index of step
+aTables.setValue("-default-", 0, 0, 1)
+aTables.setValue("Face one", 1, 0, 0)
+aTables.setValue("Face two", 1, 0, 1)
+aSession.finishOperation()
+
+aFieldResult = aField.firstResult()
+assert(aFieldResult)
+#=========================================================================
+# Create integer field on faces
+#=========================================================================
+aSession.startOperation()
+aField = aSession.activeDocument().addFeature("Field")
+aSelectionListAttr = aField.selectionList("selected")
+aSelectionListAttr.setSelectionType("face")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
+aField.integer("components_nb").setValue(1) # one component
+aComponentNames = aField.stringArray("components_names")
+aComponentNames.setSize(1)
+aComponentNames.setValue(0, "description")
+aField.integer("type").setValue(1) # integer
+aField.integer("steps_nb").setValue(1) # one step
+aStamps = aField.intArray("stamps")
+aStamps.setSize(1)
+aStamps.setValue(0, 0)
+aTables = aField.tables("values")
+aTables.setType(1)
+aTables.setSize(1 + 1, 1, 1) # default row + number of selected, number of compoents, number of steps (tables)
+aTables.setValue(0, 0, 0, 0) # value, index of selection, index of component, index of step
+aTables.setValue(2, 1, 0, 0)
+aSession.finishOperation()
+
+aFieldResult = aField.firstResult()
+assert(aFieldResult)
+
+#=========================================================================
+# Create Boolean field on faces
+#=========================================================================
+aSession.startOperation()
+aField = aSession.activeDocument().addFeature("Field")
+aSelectionListAttr = aField.selectionList("selected")
+aSelectionListAttr.setSelectionType("face")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3")
+aField.integer("components_nb").setValue(1) # one component
+aComponentNames = aField.stringArray("components_names")
+aComponentNames.setSize(1)
+aComponentNames.setValue(0, "description")
+aField.integer("type").setValue(0) # boolean
+aField.integer("steps_nb").setValue(1) # one step
+aStamps = aField.intArray("stamps")
+aStamps.setSize(1)
+aStamps.setValue(0, 0)
+aTables = aField.tables("values")
+aTables.setType(0)
+aTables.setSize(1 + 1, 1, 1) # default row + number of selected, number of compoents, number of steps (tables)
+aTables.setValue(True, 0, 0, 0) # value, index of selection, index of component, index of step
+aTables.setValue(False, 1, 0, 0)
+aSession.finishOperation()
+
+aFieldResult = aField.firstResult()
+assert(aFieldResult)
+
+import model
+assert(model.checkPythonDump())
%shared_ptr(ModelAPI_ResultParameter)
%shared_ptr(ModelAPI_ResultCompSolid)
+%typecheck(SWIG_TYPECHECK_POINTER) const ModelAPI_AttributeTables::Value {
+ $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input) || PyBool_Check($input)) ? 1 : 0;
+}
+
+// Tables Value reading as int, double, boolean or string
+%typemap(in) const ModelAPI_AttributeTables::Value {
+ if (PyInt_Check($input)) {
+ $1.myInt = int(PyInt_AsLong($input));
+ $1.myDouble = double(PyInt_AsLong($input));
+ $1.myBool = PyInt_AsLong($input) != 0;
+ } else if (PyFloat_Check($input)) {
+ $1.myInt = int(PyFloat_AsDouble($input));
+ $1.myDouble = PyFloat_AsDouble($input);
+ } else if (PyBool_Check($input)) {
+ $1.myBool = $input == Py_True;
+ } else if (PyString_Check($input)) {
+ $1.myStr = PyString_AsString($input);
+ } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
+ } else {
+ PyErr_SetString(PyExc_ValueError, "Tables value must be int, double, string or bool.");
+ return NULL;
+ }
+}
+
// all supported interfaces
%include "ModelAPI_Entity.h"
%include "ModelAPI_Document.h"
{
return data()->integer(theID);
}
+ /// Returns the integer array attribute by the identifier
+ inline std::shared_ptr<ModelAPI_AttributeIntArray> intArray(const std::string& theID)
+ {
+ return data()->intArray(theID);
+ }
/// Returns the reference attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID)
{
{
return data()->string(theID);
}
+ /// Returns the string array attribute by the identifier
+ inline std::shared_ptr<ModelAPI_AttributeStringArray> stringArray(const std::string& theID)
+ {
+ return data()->stringArray(theID);
+ }
+ /// Returns the tables attribute by the identifier
+ inline std::shared_ptr<ModelAPI_AttributeTables> tables(const std::string& theID)
+ {
+ return data()->tables(theID);
+ }
/// Returns the attribute by the identifier
inline std::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID)
{
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
%template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
%template(RefList) std::list<ModelHighAPI_Reference>;
+
// fix compilarion error: ‘res*’ was not declared in this scope
%typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
%typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
%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_ */
{
myDumpBuffer<<"[";
for(int anIndex = 0; anIndex < theArray->size(); ++anIndex) {
-
- myDumpBuffer<<"\""<<theArray->value(anIndex)<<"\"";
if (anIndex != 0)
myDumpBuffer<<", ";
+
+ myDumpBuffer<<"\""<<theArray->value(anIndex)<<"\"";
}
myDumpBuffer<<"]";
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeStringArray.h>
#include <ModelAPI_AttributeDoubleArray.h>
+#include <ModelAPI_AttributeTables.h>
#include <ModelAPI_Validator.h>
#include <GeomDataAPI_Dir.h>
std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(theAttr);
for(int a = 0; a < anAttr->size(); a++)
aResult<<anAttr->value(a)<<" ";
+ } else if (aType == ModelAPI_AttributeStringArray::typeId()) {
+ AttributeStringArrayPtr anAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeStringArray>(theAttr);
+ for(int a = 0; a < anAttr->size(); a++)
+ aResult<<"'"<<anAttr->value(a)<<"'"<<" ";
+ } else if (aType == ModelAPI_AttributeTables::typeId()) {
+ AttributeTablesPtr anAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeTables>(theAttr);
+ aResult<<anAttr->tables()<<"x"<<anAttr->rows()<<"x"<<anAttr->columns()<<" ";
+ for(int aTab = 0; aTab < anAttr->tables(); aTab++) {
+ for(int aRow = 0; aRow < anAttr->rows(); aRow++) {
+ for( int aCol = 0; aCol < anAttr->columns(); aCol++) {
+ switch(anAttr->type()) {
+ case ModelAPI_AttributeTables::BOOLEAN:
+ aResult<<anAttr->value(aRow, aCol, aTab).myBool<<" ";
+ break;
+ case ModelAPI_AttributeTables::INTEGER:
+ aResult<<anAttr->value(aRow, aCol, aTab).myInt<<" ";
+ break;
+ case ModelAPI_AttributeTables::DOUBLE:
+ aResult<<anAttr->value(aRow, aCol, aTab).myDouble<<" ";
+ break;
+ case ModelAPI_AttributeTables::STRING:
+ aResult<<"'"<<anAttr->value(aRow, aCol, aTab).myStr.c_str()<<"' ";
+ break;
+ }
+ }
+ }
+ }
} else if (aType == GeomDataAPI_Point::typeId()) {
AttributePointPtr anAttr = std::dynamic_pointer_cast<GeomDataAPI_Point>(theAttr);
double aValues[3] = {anAttr->x(), anAttr->y(), anAttr->z()};
#include "ModelHighAPI_RefAttr.h"
#include "ModelHighAPI_Reference.h"
#include "ModelHighAPI_Selection.h"
- #include "ModelHighAPI_ComponentValue.h"
#include "ModelHighAPI_Services.h"
#include "ModelHighAPI_Tools.h"
"""Package for Collection plugin for the Parametric Geometry API of the Modeler.
"""
-from CollectionAPI import addGroup
+from CollectionAPI import addGroup, addField