Model_Session.h
Model_Data.h
Model_AttributeDouble.h
+ Model_AttributeDoubleArray.h
Model_AttributeDocRef.h
Model_AttributeReference.h
Model_AttributeRefAttr.h
Model_Session.cpp
Model_Data.cpp
Model_AttributeDouble.cpp
+ Model_AttributeDoubleArray.cpp
Model_AttributeDocRef.cpp
Model_AttributeReference.cpp
Model_AttributeRefAttr.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: Model_AttributeDoubleArray.cpp
+// Created: 08 July 2016
+// Author: Dmitry Bobylev
+
+#include "Model_AttributeDoubleArray.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+
+#include <TColStd_HArray1OfReal.hxx>
+
+#include <string>
+
+//==================================================================================================
+int Model_AttributeDoubleArray::size()
+{
+ if (myArray.IsNull() || !myArray->IsValid()) {
+ // this could be on undo and then redo creation of the attribute
+ // in result creation it may be uninitialized
+ myIsInitialized = myLab.FindAttribute(TDataStd_RealArray::GetID(), myArray) == Standard_True;
+ }
+ // checking the validity because attribute (as a field) may be presented,
+ // but without label: it is undoed
+ return (myArray.IsNull() || !myArray->IsValid()) ? 0 : myArray->Length();
+}
+
+//==================================================================================================
+void Model_AttributeDoubleArray::setSize(const int theSize)
+{
+ if (myArray.IsNull() || !myArray->IsValid()) { // create array if it is not done yet
+ if (theSize != 0) { // if size is zero, nothing to do (null array means there is no array)
+ myArray = TDataStd_RealArray::Set(myLab, 0, theSize - 1);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+ } else { // reset the old array
+ if (theSize) {
+ if (theSize != myArray->Length()) { // old data is not keept, a new array is created
+ Handle(TColStd_HArray1OfReal) aNewArray = new TColStd_HArray1OfReal(0, theSize - 1);
+ myArray->ChangeArray(aNewArray);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+ } else { // size is zero => array must be erased
+ if (!myArray.IsNull()) {
+ myArray.Nullify();
+ myLab.ForgetAttribute(TDataStd_RealArray::GetID());
+ owner()->data()->sendAttributeUpdated(this);
+ }
+ }
+ }
+}
+
+//==================================================================================================
+void Model_AttributeDoubleArray::setValue(const int theIndex,
+ const double theValue)
+{
+ if (myArray->Value(theIndex) != theValue) {
+ myArray->SetValue(theIndex, theValue);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+//==================================================================================================
+double Model_AttributeDoubleArray::value(const int theIndex)
+{
+ return myArray->Value(theIndex);
+}
+
+//==================================================================================================
+Model_AttributeDoubleArray::Model_AttributeDoubleArray(TDF_Label& theLabel)
+{
+ myLab = theLabel;
+ // check the attribute could be already presented in this doc (after load document)
+ myIsInitialized =
+ myLab.FindAttribute(TDataStd_RealArray::GetID(), myArray) == Standard_True;
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: Model_AttributeDoubleArray.h
+// Created: 08 July 2016
+// Author: Dmitry Bobylev
+
+#ifndef Model_AttributeDoubleArray_H_
+#define Model_AttributeDoubleArray_H_
+
+#include "Model.h"
+
+#include <ModelAPI_AttributeDoubleArray.h>
+
+#include <TDF_Label.hxx>
+#include <TDataStd_RealArray.hxx>
+
+#include <string>
+
+/// \class Model_AttributeDoubleArray
+/// \ingroup DataModel
+/// \brief API for the attribute that contains several double in the array inside.
+class Model_AttributeDoubleArray: public ModelAPI_AttributeDoubleArray
+{
+public:
+ /// Returns the size of the array (zero means that it is empty)
+ MODEL_EXPORT virtual int size();
+
+ /// Sets the new size of the array. The previous data is erased.
+ MODEL_EXPORT virtual void setSize(const int theSize);
+
+ /// Defines the value of the array by index [0; size-1]
+ MODEL_EXPORT virtual void setValue(const int theIndex,
+ const double theValue);
+
+ /// Returns the value by the index
+ MODEL_EXPORT virtual double value(const int theIndex);
+
+protected:
+ /// Initializes attibutes
+ Model_AttributeDoubleArray(TDF_Label& theLabel);
+
+private:
+ /// The OCCT array that keeps all values.
+ Handle_TDataStd_RealArray myArray;
+
+ /// Stores the label as a field to set array if size is not null (null array is buggy in OCAF)
+ TDF_Label myLab;
+
+ friend class Model_Data;
+};
+
+#endif
#include <Model_AttributeDocRef.h>
#include <Model_AttributeInteger.h>
#include <Model_AttributeDouble.h>
+#include <Model_AttributeDoubleArray.h>
#include <Model_AttributeReference.h>
#include <Model_AttributeRefAttr.h>
#include <Model_AttributeRefList.h>
anAttr = new Model_AttributeRefAttrList(anAttrLab);
} else if (theAttrType == ModelAPI_AttributeIntArray::typeId()) {
anAttr = new Model_AttributeIntArray(anAttrLab);
- }
+ } else if (theAttrType == ModelAPI_AttributeDoubleArray::typeId()) {
+ anAttr = new Model_AttributeDoubleArray(anAttrLab);
+ }
// create also GeomData attributes here because only here the OCAF structure is known
else if (theAttrType == GeomData_Point::typeId()) {
GeomData_Point* anAttribute = new GeomData_Point();
GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefList, reflist);
GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefAttrList, refattrlist);
GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeIntArray, intArray);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeDoubleArray, realArray);
std::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& theID)
{
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDocRef> document(const std::string& theID);
/// Returns the attribute that contains real value with double precision
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID);
+ /// Returns the attribute that contains double values array
+ MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDoubleArray> realArray(const std::string& theID);
/// Returns the attribute that contains integer value
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeInteger>
integer(const std::string& theID);
ModelAPI_AttributeIntArray.h
ModelAPI_AttributeDocRef.h
ModelAPI_AttributeDouble.h
+ ModelAPI_AttributeDoubleArray.h
ModelAPI_AttributeInteger.h
ModelAPI_AttributeRefAttr.h
ModelAPI_AttributeReference.h
ModelAPI_AttributeIntArray.cpp
ModelAPI_AttributeDocRef.cpp
ModelAPI_AttributeDouble.cpp
+ ModelAPI_AttributeDoubleArray.cpp
ModelAPI_AttributeInteger.cpp
ModelAPI_AttributeRefAttr.cpp
ModelAPI_AttributeReference.cpp
%shared_ptr(ModelAPI_Attribute)
%shared_ptr(ModelAPI_AttributeDocRef)
%shared_ptr(ModelAPI_AttributeDouble)
+%shared_ptr(ModelAPI_AttributeDoubleArray)
%shared_ptr(ModelAPI_AttributeInteger)
%shared_ptr(ModelAPI_AttributeIntArray)
%shared_ptr(ModelAPI_AttributeString)
%include "ModelAPI_Attribute.h"
%include "ModelAPI_AttributeDocRef.h"
%include "ModelAPI_AttributeDouble.h"
+%include "ModelAPI_AttributeDoubleArray.h"
%include "ModelAPI_AttributeInteger.h"
%include "ModelAPI_AttributeIntArray.h"
%include "ModelAPI_AttributeString.h"
%include "ModelAPI_Tools.h"
%include "ModelAPI_ResultCompSolid.h"
-// std::list -> []
+// std::list -> []
%template(StringList) std::list<std::string>;
%template(ObjectList) std::list<std::shared_ptr<ModelAPI_Object> >;
%template(ResultList) std::list<std::shared_ptr<ModelAPI_Result> >;
// Attribute casts
%template(modelAPI_AttributeDocRef) shared_ptr_cast<ModelAPI_AttributeDocRef, ModelAPI_Attribute>;
%template(modelAPI_AttributeDouble) shared_ptr_cast<ModelAPI_AttributeDouble, ModelAPI_Attribute>;
+%template(modelAPI_AttributeDoubleArray) shared_ptr_cast<ModelAPI_AttributeDoubleArray, ModelAPI_Attribute>;
%template(modelAPI_AttributeInteger) shared_ptr_cast<ModelAPI_AttributeInteger, ModelAPI_Attribute>;
%template(modelAPI_AttributeIntArray) shared_ptr_cast<ModelAPI_AttributeIntArray, ModelAPI_Attribute>;
%template(modelAPI_AttributeString) shared_ptr_cast<ModelAPI_AttributeString, ModelAPI_Attribute>;
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModelAPI_AttributeDoubleArray.cpp
+// Created: 8 July 2016
+// Author: Dmitry Bobylev
+
+#include "ModelAPI_AttributeDoubleArray.h"
+
+//==================================================================================================
+std::string ModelAPI_AttributeDoubleArray::attributeType()
+{
+ return typeId();
+}
+
+//==================================================================================================
+ModelAPI_AttributeDoubleArray::~ModelAPI_AttributeDoubleArray()
+{
+}
+
+//==================================================================================================
+ModelAPI_AttributeDoubleArray::ModelAPI_AttributeDoubleArray()
+{
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModelAPI_AttributeDoubleArray.h
+// Created: 08 July 2016
+// Author: Dmitry Bobylev
+
+#ifndef ModelAPI_AttributeDoubleArray_H_
+#define ModelAPI_AttributeDoubleArray_H_
+
+#include <ModelAPI.h>
+#include <ModelAPI_Attribute.h>
+
+#include <string>
+
+/// \class ModelAPI_AttributeDoubleArray
+/// \ingroup DataModel
+/// \brief API for the attribute that contains several double in the array inside.
+class ModelAPI_AttributeDoubleArray: public ModelAPI_Attribute
+{
+public:
+ /// Returns the size of the array (zero means that it is empty)
+ MODELAPI_EXPORT virtual int size() = 0;
+
+ /// Sets the new size of the array. The previous data is erased.
+ MODELAPI_EXPORT virtual void setSize(const int theSize) = 0;
+
+ /// Defines the value of the array by index [0; size-1]
+ MODELAPI_EXPORT virtual void setValue(const int theIndex,
+ const double theValue) = 0;
+
+ /// Returns the value by the index
+ MODELAPI_EXPORT virtual double value(const int theIndex) = 0;
+
+ /// Returns the type of this class of attributes
+ MODELAPI_EXPORT static std::string typeId()
+ {
+ return "DoubleArray";
+ }
+
+ /// Returns the type of this class of attributes, not static method
+ MODELAPI_EXPORT virtual std::string attributeType();
+
+ /// To virtually destroy the fields of successors
+ MODELAPI_EXPORT virtual ~ModelAPI_AttributeDoubleArray();
+
+protected:
+ /// Objects are created for features automatically
+ MODELAPI_EXPORT ModelAPI_AttributeDoubleArray();
+};
+
+/// Pointer on double attribute
+typedef std::shared_ptr<ModelAPI_AttributeDoubleArray> AttributeDoubleArrayPtr;
+
+#endif
class ModelAPI_AttributeDocRef;
class ModelAPI_AttributeInteger;
class ModelAPI_AttributeDouble;
+class ModelAPI_AttributeDoubleArray;
class ModelAPI_AttributeReference;
class ModelAPI_AttributeRefAttr;
class ModelAPI_AttributeRefList;
virtual std::shared_ptr<ModelAPI_AttributeDocRef> document(const std::string& theID) = 0;
/// Returns the attribute that contains real value with double precision
virtual std::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID) = 0;
+ /// Returns the attribute that contains double values array
+ virtual std::shared_ptr<ModelAPI_AttributeDoubleArray> realArray(const std::string& theID) = 0;
/// Returns the attribute that contains integer value
virtual std::shared_ptr<ModelAPI_AttributeInteger> integer(const std::string& theID) = 0;
/// Returns the attribute that contains reference to a feature
#include "ModelAPI_Attribute.h"
#include "ModelAPI_AttributeDocRef.h"
#include "ModelAPI_AttributeDouble.h"
+ #include "ModelAPI_AttributeDoubleArray.h"
#include "ModelAPI_AttributeInteger.h"
#include "ModelAPI_AttributeIntArray.h"
#include "ModelAPI_AttributeString.h"