SET(PROJECT_HEADERS
GeomAPI.h
GeomAPI_Interface.h
+ GeomAPI_XYZ.h
GeomAPI_Pnt.h
GeomAPI_Dir.h
GeomAPI_Pln.h
SET(PROJECT_SOURCES
GeomAPI_Interface.cpp
+ GeomAPI_XYZ.cpp
GeomAPI_Pnt.cpp
GeomAPI_Dir.cpp
GeomAPI_Pln.cpp
// Created: 23 Apr 2014
// Author: Mikhail PONIKAROV
-#include<GeomAPI_Dir.h>
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_XYZ.h>
-#include<gp_Dir.hxx>
+#include <gp_Dir.hxx>
#define MY_DIR static_cast<gp_Pnt*>(myImpl)
{
return MY_DIR->Z();
}
+
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Dir::xyz()
+{
+ return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_DIR->X(), MY_DIR->Y(), MY_DIR->Z()));
+}
#define GeomAPI_Dir_HeaderFile
#include <GeomAPI_Interface.h>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_XYZ;
/**\class GeomAPI_Dir
* \ingroup DataModel
/// returns Z coordinate
double z() const;
+ /// returns coordinates of the direction
+ const boost::shared_ptr<GeomAPI_XYZ> xyz();
};
#endif
// Author: Mikhail PONIKAROV
#include<GeomAPI_Pnt.h>
+#include<GeomAPI_XYZ.h>
#include<gp_Pnt.hxx>
: GeomAPI_Interface(new gp_Pnt(theX, theY, theZ))
{}
+GeomAPI_Pnt::GeomAPI_Pnt(const boost::shared_ptr<GeomAPI_XYZ>& theCoords)
+ : GeomAPI_Interface(new gp_Pnt(theCoords->x(), theCoords->y(), theCoords->z()))
+{}
+
double GeomAPI_Pnt::x() const
{
return MY_PNT->X();
{
return MY_PNT->SetZ(theZ);
}
+
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Pnt::xyz()
+{
+ return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_PNT->X(), MY_PNT->Y(), MY_PNT->Z()));
+}
#define GeomAPI_Pnt_HeaderFile
#include <GeomAPI_Interface.h>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_XYZ;
/**\class GeomAPI_Pnt
* \ingroup DataModel
public:
/// Creation of point by coordinates
GeomAPI_Pnt(const double theX, const double theY, const double theZ);
+ /// Creation of point by coordinates
+ GeomAPI_Pnt(const boost::shared_ptr<GeomAPI_XYZ>& theCoords);
/// returns X coordinate
double x() const;
void setY(const double theY);
/// sets Z coordinate
void setZ(const double theZ);
+
+ /// returns coordinates of the point
+ const boost::shared_ptr<GeomAPI_XYZ> xyz();
};
#endif
--- /dev/null
+// File: GeomAPI_XYZ.cpp
+// Created: 23 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#include<GeomAPI_XYZ.h>
+
+#include<gp_XYZ.hxx>
+
+#define MY_XYZ static_cast<gp_XYZ*>(myImpl)
+
+GeomAPI_XYZ::GeomAPI_XYZ(const double theX, const double theY, const double theZ)
+ : GeomAPI_Interface(new gp_XYZ(theX, theY, theZ))
+{}
+
+double GeomAPI_XYZ::x() const
+{
+ return MY_XYZ->X();
+}
+
+double GeomAPI_XYZ::y() const
+{
+ return MY_XYZ->Y();
+}
+
+double GeomAPI_XYZ::z() const
+{
+ return MY_XYZ->Z();
+}
+
+void GeomAPI_XYZ::setX(const double theX)
+{
+ return MY_XYZ->SetX(theX);
+}
+
+void GeomAPI_XYZ::setY(const double theY)
+{
+ return MY_XYZ->SetY(theY);
+}
+
+void GeomAPI_XYZ::setZ(const double theZ)
+{
+ return MY_XYZ->SetZ(theZ);
+}
+
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::added(
+ const boost::shared_ptr<GeomAPI_XYZ>& theArg)
+{
+ boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() + theArg->x(),
+ MY_XYZ->Y() + theArg->y(), MY_XYZ->Z() + theArg->z()));
+ return aResult;
+}
+
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::multiplied(const double theArg)
+{
+ boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() * theArg,
+ MY_XYZ->Y() * theArg, MY_XYZ->Z() * theArg));
+ return aResult;
+}
--- /dev/null
+// File: GeomAPI_XYZ.hxx
+// Created: 23 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomAPI_XYZ_HeaderFile
+#define GeomAPI_XYZ_HeaderFile
+
+#include <GeomAPI_Interface.h>
+#include <boost/shared_ptr.hpp>
+
+/**\class GeomAPI_XYZ
+ * \ingroup DataModel
+ * \brief 3 coordinates: they may represent vector or point or something else
+ */
+
+class GEOMAPI_EXPORT GeomAPI_XYZ: public GeomAPI_Interface
+{
+public:
+ /// Creation by coordinates
+ GeomAPI_XYZ(const double theX, const double theY, const double theZ);
+
+ /// returns X coordinate
+ double x() const;
+ /// returns Y coordinate
+ double y() const;
+ /// returns Z coordinate
+ double z() const;
+
+ /// sets X coordinate
+ void setX(const double theX);
+ /// sets Y coordinate
+ void setY(const double theY);
+ /// sets Z coordinate
+ void setZ(const double theZ);
+
+ /// result is sum of coordinates of this and the given argument
+ const boost::shared_ptr<GeomAPI_XYZ> added(const boost::shared_ptr<GeomAPI_XYZ>& theArg);
+ /// result is coordinates multiplied by the argument
+ const boost::shared_ptr<GeomAPI_XYZ> multiplied(const double theArg);
+};
+
+#endif
+
/// Returns the Z double value
GEOMDATA_EXPORT virtual double z() const;
/// Returns the direction of this attribute
- GEOMDATA_EXPORT boost::shared_ptr<GeomAPI_Dir> dir();
+ GEOMDATA_EXPORT virtual boost::shared_ptr<GeomAPI_Dir> dir();
protected:
/// Initializes attributes
#include "GeomData_Point.h"
#include "Model_Events.h"
#include <Events_Loop.h>
+#include <GeomAPI_Pnt.h>
using namespace std;
return myCoords->Value(2);
}
+boost::shared_ptr<GeomAPI_Pnt> GeomData_Point::pnt()
+{
+ boost::shared_ptr<GeomAPI_Pnt> aResult(new GeomAPI_Pnt(
+ myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
+ return aResult;
+}
+
GeomData_Point::GeomData_Point(TDF_Label& theLabel)
{
// check the attribute could be already presented in this doc (after load document)
GEOMDATA_EXPORT virtual double y() const;
/// Returns the Z double value
GEOMDATA_EXPORT virtual double z() const;
+ /// Returns the 3D point
+ GEOMDATA_EXPORT virtual boost::shared_ptr<GeomAPI_Pnt> pnt();
protected:
/// Initializes attributes
#include "GeomDataAPI.h"
#include <ModelAPI_Attribute.h>
+class GeomAPI_Dir;
+
/**\class GeomDataAPI_Dir
* \ingroup DataModel
* \brief Attribute that contains 3D direction coordinates.
virtual double y() const = 0;
/// Returns the Z double value
virtual double z() const = 0;
+ /// Returns the direction of this attribute
+ virtual boost::shared_ptr<GeomAPI_Dir> dir() = 0;
/// Returns the type of this class of attributes
static inline std::string type() {return std::string("Dir");}
#include "GeomDataAPI.h"
#include <ModelAPI_Attribute.h>
+class GeomAPI_Pnt;
+
/**\class GeomDataAPI_Point
* \ingroup DataModel
* \brief Attribute that contains 3D point coordinates.
virtual double y() const = 0;
/// Returns the Z double value
virtual double z() const = 0;
+ /// Returns the 3D point
+ virtual boost::shared_ptr<GeomAPI_Pnt> pnt() = 0;
/// Returns the type of this class of attributes
static inline std::string type() {return std::string("Point");}
Model_Document.h
Model_PluginManager.h
Model_Data.h
- Model_Iterator.h
Model_AttributeDouble.h
Model_AttributeDocRef.h
Model_Events.h
Model_Document.cpp
Model_PluginManager.cpp
Model_Data.cpp
- Model_Iterator.cpp
Model_AttributeDouble.cpp
Model_AttributeDocRef.cpp
Model_Events.cpp
TDF_Label label() {return myLab;}
friend class Model_Document;
- friend class Model_Iterator;
public:
/// Returns the name of the feature visible by the user in the object browser
#include <Model_Data.h>
#include <Model_Application.h>
#include <Model_PluginManager.h>
-#include <Model_Iterator.h>
#include <Model_Events.h>
#include <Events_Loop.h>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Comment.hxx>
#include <TDF_ChildIDIterator.hxx>
+#include <TDataStd_ReferenceArray.hxx>
+#include <TDataStd_HLabelArray1.hxx>
#include <climits>
static const int UNDO_LIMIT = 10; // number of possible undo operations
static const int TAG_GENERAL = 1; // general properties tag
-static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (Root for Model_DatasMgr)
-static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for Model_History)
+static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (features)
+static const int TAG_HISTORY = 3; // tag of the history sub-tree (python dump)
using namespace std;
boost::shared_ptr<ModelAPI_Feature> Model_Document::addFeature(string theID)
{
- boost::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
+ boost::shared_ptr<ModelAPI_Feature> aFeature =
+ ModelAPI_PluginManager::get()->createFeature(theID);
if (aFeature) {
boost::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd())->addFeature(aFeature);
} else {
boost::shared_ptr<Model_Data> aData(new Model_Data);
aData->setFeature(theFeature);
aData->setLabel(anObjLab);
- boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
+ boost::shared_ptr<ModelAPI_Document> aThis =
+ Model_Application::getApplication()->getDocument(myID);
theFeature->setData(aData);
theFeature->setDoc(aThis);
setUniqueName(theFeature);
// put index of the feature in the group in the tree
TDataStd_Integer::Set(anObjLab, myFeatures[aGroup].size());
myFeatures[aGroup].push_back(theFeature);
+ // store feature in the history of features array
+ Handle(TDataStd_ReferenceArray) aRefs;
+ if (!groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
+ aRefs = TDataStd_ReferenceArray::Set(groupLabel(FEATURES_GROUP), 0, 0);
+ aRefs->SetValue(0, anObjLab);
+ } else { // extend array by one more element
+ Handle(TDataStd_HLabelArray1) aNewArray =
+ new TDataStd_HLabelArray1(aRefs->Lower(), aRefs->Upper() + 1);
+ for(int a = aRefs->Lower(); a < aRefs->Upper(); a++) {
+ aNewArray->SetValue(a, aRefs->Value(a));
+ }
+ aNewArray->SetValue(aRefs->Upper() + 1, anObjLab);
+ aRefs->SetInternalArray(aNewArray);
+ }
// event: feature is added
static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
if (theFeature->document().get() != this) {
return theFeature->document()->featureIndex(theFeature);
}
- boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
+ boost::shared_ptr<Model_Data> aData =
+ boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
Handle(TDataStd_Integer) aFeatureIndex;
if (aData->label().FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) {
return aFeatureIndex->Get();
return Model_Application::getApplication()->getDocument(theDocID);
}
-boost::shared_ptr<ModelAPI_Iterator> Model_Document::featuresIterator(const string theGroup)
+boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
+ const string& theGroupID, const int theIndex)
{
- boost::shared_ptr<Model_Document> aThis(Model_Application::getApplication()->getDocument(myID));
- // create an empty iterator for not existing group
- // (to avoidance of attributes management outside the transaction)
- if (myGroups.find(theGroup) == myGroups.end())
- return boost::shared_ptr<ModelAPI_Iterator>(new Model_Iterator());
- return boost::shared_ptr<ModelAPI_Iterator>(new Model_Iterator(aThis, groupLabel(theGroup)));
+ if (theGroupID == FEATURES_GROUP) { // history is just a references array
+ Handle(TDataStd_ReferenceArray) aRefs;
+ if (groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
+ if (aRefs->Lower() <= theIndex && aRefs->Upper() >= theIndex) {
+ TDF_Label aFeatureLab = aRefs->Value(theIndex);
+ return feature(aFeatureLab);
+ }
+ }
+ } else { // one of the group
+ map<string, vector<boost::shared_ptr<ModelAPI_Feature> > >::iterator aGroup =
+ myFeatures.find(theGroupID);
+ if (aGroup != myFeatures.end() && (int)(aGroup->second.size()) > theIndex) {
+ return aGroup->second[theIndex];
+ }
+ }
+ // not found
+ return boost::shared_ptr<ModelAPI_Feature>();
}
-boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(const string& theGroupID, const int theIndex)
+int Model_Document::size(const string& theGroupID)
{
- // TODO: optimize this method
- boost::shared_ptr<ModelAPI_Iterator> anIter = featuresIterator(theGroupID);
- for(int a = 0; a != theIndex && anIter->more(); anIter->next()) a++;
- return anIter->more() ? anIter->current() : boost::shared_ptr<ModelAPI_Feature>();
+ if (theGroupID == FEATURES_GROUP) { // history is just a references array
+ Handle(TDataStd_ReferenceArray) aRefs;
+ if (groupLabel(FEATURES_GROUP).FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs))
+ return aRefs->Length();
+ } else { // one of the group
+ map<string, vector<boost::shared_ptr<ModelAPI_Feature> > >::iterator aGroup =
+ myFeatures.find(theGroupID);
+ if (aGroup != myFeatures.end())
+ return aGroup->second.size();
+ }
+ // group is not found
+ return 0;
}
const vector<string>& Model_Document::getGroups() const
{
myDoc->SetUndoLimit(UNDO_LIMIT);
myTransactionsAfterSave = 0;
- // to avoid creation of tag outside of the transaction (by iterator, for example)
- /*
- if (!myDoc->Main().FindChild(TAG_OBJECTS).IsAttribute(TDF_TagSource::GetID()))
- TDataStd_Comment::Set(myDoc->Main().FindChild(TAG_OBJECTS).NewChild(), "");
- */
}
TDF_Label Model_Document::groupLabel(const string theGroup)
void Model_Document::setUniqueName(boost::shared_ptr<ModelAPI_Feature> theFeature)
{
// first count all objects of such kind to start with index = count + 1
- int aNumObjects = 0;
- boost::shared_ptr<ModelAPI_Iterator> anIter = featuresIterator(theFeature->getGroup());
- for(; anIter->more(); anIter->next()) {
- if (anIter->currentKind() == theFeature->getKind())
+ int a, aNumObjects = 0;
+ int aSize = size(theFeature->getGroup());
+ for(a = 0; a < aSize; a++) {
+ if (feature(theFeature->getGroup(), a)->getKind() == theFeature->getKind())
aNumObjects++;
}
// generate candidate name
aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
string aName = aNameStream.str();
// check this is unique, if not, increase index by 1
- for(anIter = featuresIterator(theFeature->getGroup()); anIter->more();) {
- if (anIter->currentName() == aName) {
+ for(a = 0; a < aSize;) {
+ if (feature(theFeature->getGroup(), a)->data()->getName() == aName) {
aNumObjects++;
stringstream aNameStream;
aNameStream<<theFeature->getKind()<<"_"<<aNumObjects + 1;
// reinitialize iterator to make sure a new name is unique
- anIter = featuresIterator(theFeature->getGroup());
- } else anIter->next();
+ a = 0;
+ } else a++;
}
theFeature->data()->setName(aName);
//! Adds a new sub-document by the identifier, or returns existing one if it is already exist
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
- //! Creates an iterator of the features by the specific groups
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Iterator> featuresIterator(
- const std::string theGroup);
-
+ ///! Returns the id of hte document
MODEL_EXPORT virtual const std::string& id() const {return myID;}
//! Returns the feature in the group by the index (started from zero)
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
feature(const std::string& theGroupID, const int theIndex);
+ //! Returns the number of features in the group
+ MODEL_EXPORT virtual int size(const std::string& theGroupID);
+
///! Returns the vector of groups already added to the document
MODEL_EXPORT virtual const std::vector<std::string>& getGroups() const;
+++ /dev/null
-// File: Model_Iterator.hxx
-// Created: 1 Apr 2014
-// Author: Mikhail PONIKAROV
-
-#include "Model_Iterator.h"
-#include "Model_Document.h"
-#include "ModelAPI_Feature.h"
-#include "Model_Data.h"
-#include <TDataStd_Comment.hxx>
-#include <TDataStd_Name.hxx>
-
-using namespace std;
-
-void Model_Iterator::next()
-{
- return myIter.Next();
-}
-
-bool Model_Iterator::more()
-{
- return myIter.More() == Standard_True;
-}
-
-boost::shared_ptr<ModelAPI_Feature> Model_Iterator::current()
-{
- TDF_Label aLab = myIter.Value()->Label();
- return myDoc->feature(aLab);
-}
-
-string Model_Iterator::currentKind()
-{
- return string(TCollection_AsciiString(
- Handle(TDataStd_Comment)::DownCast(myIter.Value())->Get()).ToCString());
-}
-
-string Model_Iterator::currentName()
-{
- TDF_Label aLab = myIter.Value()->Label();
- Handle(TDataStd_Name) aName;
- if (aLab.FindAttribute(TDataStd_Name::GetID(), aName))
- return string(TCollection_AsciiString(aName->Get()).ToCString());
- return ""; // name is not found
-}
-
-int Model_Iterator::numIterationsLeft()
-{
- int aResult = 0;
- TDF_ChildIDIterator aTempIter(myIter);
- for(; aTempIter.More(); aTempIter.Next())
- aResult++;
- return aResult;
-}
-
-bool Model_Iterator::isEqual(boost::shared_ptr<ModelAPI_Feature> theFeature)
-{
- return (myIter.Value()->Label() ==
- boost::dynamic_pointer_cast<Model_Data>(theFeature->data())->label()) == Standard_True;
-
-}
-
-Model_Iterator::Model_Iterator()
-{
-}
-
-Model_Iterator::Model_Iterator(boost::shared_ptr<Model_Document> theDoc, TDF_Label theLab)
- : myDoc(theDoc), myIter(theLab, TDataStd_Comment::GetID(), Standard_False)
-{}
+++ /dev/null
-// File: Model_Iterator.h
-// Created: 1 Apr 2014
-// Author: Mikhail PONIKAROV
-
-#ifndef Model_Iterator_HeaderFile
-#define Model_Iterator_HeaderFile
-
-#include "Model.h"
-#include "ModelAPI_Iterator.h"
-#include <TDF_Label.hxx>
-#include <TDF_ChildIDIterator.hxx>
-
-class Model_Document;
-
-/**\class Model_Iterator
- * \ingroup DataModel
- * \brief Allows to iterate features of the document. Is created by the document
- * (see method featuresIterator).
- */
-
-class Model_Iterator : public ModelAPI_Iterator
-{
- boost::shared_ptr<Model_Document> myDoc; ///< the document of iterated objects
- TDF_ChildIDIterator myIter; ///< iterator of the features-labels
-public:
- /// Iterates to the next feature
- MODEL_EXPORT virtual void next();
- /// Returns true if the current iteration is valid and next iteration is possible
- MODEL_EXPORT virtual bool more();
- /// Returns the currently iterated feature
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> current();
- /// Returns the kind of the current feature (faster than Current()->getKind())
- MODEL_EXPORT virtual std::string currentKind();
- /// Returns the name of the current feature (faster than Current()->getName())
- MODEL_EXPORT virtual std::string currentName();
- /// Don't changes the current position of iterator. Not fast: iterates the left items.
- /// \returns number of left iterations
- MODEL_EXPORT virtual int numIterationsLeft();
-
- /// Compares the current feature with the given one
- /// \returns true if given feature equals to the current one
- MODEL_EXPORT virtual bool isEqual(boost::shared_ptr<ModelAPI_Feature> theFeature);
-
-protected:
- /// Creates an empty iterator that alway returns More false
- Model_Iterator();
- /// Initializes iterator
- /// \param theDoc document where the iteration is performed
- /// \param theLab label of the features group to iterate
- Model_Iterator(boost::shared_ptr<Model_Document> theDoc, TDF_Label theLab);
-
- friend class Model_Document;
-};
-
-#endif
ModelAPI_PluginManager.h
ModelAPI_Plugin.h
ModelAPI_Feature.h
- ModelAPI_Iterator.h
ModelAPI_Data.h
ModelAPI_Document.h
ModelAPI_Attribute.h
#include "ModelAPI_Attribute.h"
#include "ModelAPI_AttributeDocRef.h"
#include "ModelAPI_AttributeDouble.h"
- #include "ModelAPI_Iterator.h"
%}
// to avoid error on this
%shared_ptr(ModelAPI_Attribute)
%shared_ptr(ModelAPI_AttributeDocRef)
%shared_ptr(ModelAPI_AttributeDouble)
-%shared_ptr(ModelAPI_Iterator)
// all supported interfaces
%include "ModelAPI_Document.h"
%include "ModelAPI_Attribute.h"
%include "ModelAPI_AttributeDocRef.h"
%include "ModelAPI_AttributeDouble.h"
-%include "ModelAPI_Iterator.h"
/// To virtually destroy the fields of successors
MODELAPI_EXPORT virtual ~ModelAPI_Attribute() {}
+ /// Sets the owner of this attribute
MODELAPI_EXPORT void setFeature(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
{myFeature = theFeature;}
+ /// Returns the owner of this attribute
MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Feature>& feature()
{return myFeature;}
protected:
#include <vector>
class ModelAPI_Feature;
-class ModelAPI_Iterator;
/// Common groups identifiers
/// Group of parameters
static const std::string CONSTRUCTIONS_GROUP = "Construction";
/// Group of parts
static const std::string PARTS_GROUP = "Parts";
-/// Group of sketches
-static const std::string SKETCHS_GROUP = "Sketchs";
+/// All created fetaures of the document (a history)
+static const std::string FEATURES_GROUP = "Features";
/**\class Model_Document
* \ingroup DataModel
///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
- ///! Creates an iterator of the features by the specific groups
- MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Iterator> featuresIterator(
- const std::string theGroup) = 0;
-
///! Returns the id of hte document
MODELAPI_EXPORT virtual const std::string& id() const = 0;
MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
feature(const std::string& theGroupID, const int theIndex) = 0;
+ //! Returns the number of features in the group
+ MODELAPI_EXPORT virtual int size(const std::string& theGroupID) = 0;
+
//! Returns the index of feature in the group (zero based)
MODELAPI_EXPORT virtual int featureIndex(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+++ /dev/null
-// File: ModelAPI_Iterator.hxx
-// Created: 1 Apr 2014
-// Author: Mikhail PONIKAROV
-
-#ifndef ModelAPI_Iterator_HeaderFile
-#define ModelAPI_Iterator_HeaderFile
-
-#include "ModelAPI.h"
-#include <string>
-#include <boost/shared_ptr.hpp>
-
-class ModelAPI_Feature;
-class ModelAPI_Document;
-
-/**\class ModelAPI_Iterator
- * \ingroup DataModel
- * \brief Allows to iterate features of the document. Is created by the document
- * (see method featuresIterator).
- */
-
-class MODELAPI_EXPORT ModelAPI_Iterator
-{
-public:
- /// Iterates to the next feature
- virtual void next() = 0;
- /// Returns true if the current iteration is valid and next iteration is possible
- virtual bool more() = 0;
- /// Returns the currently iterated feature
- virtual boost::shared_ptr<ModelAPI_Feature> current() = 0;
- /// Returns the kind of the current feature (faster than Current()->getKind())
- virtual std::string currentKind() = 0;
- /// Returns the name of the current feature (faster than Current()->getName())
- virtual std::string currentName() = 0;
- /// Don't changes the current position of iterator. Not fast: iterates the left items.
- /// \returns number of left iterations
- virtual int numIterationsLeft() = 0;
- /// Compares the current feature with the given one
- /// \returns true if given feature equals to the current one
- virtual bool isEqual(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
-
- /// To virtually destroy the fields of successors
- virtual ~ModelAPI_Iterator() {}
-
-protected:
- /// Use plugin manager for features creation: this method is
- /// defined here only for SWIG-wrapping
- ModelAPI_Iterator()
- {}
-};
-
-#endif
#include <ModelAPI_Data.h>
// to avoid unresolved ModelAPI_Plugin()
#include <ModelAPI_Plugin.h>
-// to avoid unresolved ModelAPI_Iterator()
-#include <ModelAPI_Iterator.h>
-// to avoid unresolved ModelAPI_Iterator()
-#include <ModelAPI_Iterator.h>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_AttributeDouble.h>
#include "ModelAPI_PluginManager.h"
#include "ModelAPI_Document.h"
#include "ModelAPI_Data.h"
-#include "ModelAPI_Iterator.h"
#include "ModelAPI_AttributeDocRef.h"
using namespace std;
#include "SketchPlugin_Sketch.h"
#include <ModelAPI_Data.h>
+#include <GeomAPI_XYZ.h>
#include <GeomDataAPI_Dir.h>
#include <GeomDataAPI_Point.h>
#include <GeomAlgoAPI_FaceBuilder.h>
boost::shared_ptr<GeomDataAPI_Dir> aY =
boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SKETCH_ATTR_DIRY));
- return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(
- aC->x() + aX->x() * theX + aY->x() * theY,
- aC->y() + aX->y() * theX + aY->y() * theY,
- aC->z() + aX->z() * theX + aY->z() * theY));
+ boost::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(
+ aX->dir()->xyz()->multiplied(theX))->added(aY->dir()->xyz()->multiplied(theY));
+
+ return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
}
#include "XGUI_PartDataModel.h"
#include <ModelAPI_PluginManager.h>
-#include <ModelAPI_Iterator.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
// Reset whole tree **************************
} else {
beginResetModel();
- int aNbParts = myDocument->featuresIterator(PARTS_GROUP)->numIterationsLeft();
+ int aNbParts = myDocument->size(PARTS_GROUP);
if (myPartModels.size() != aNbParts) { // resize internal models
while (myPartModels.size() > aNbParts) {
delete myPartModels.last();
{
int aPos = myModel->rowCount(QModelIndex());
return createIndex(aPos, columnCount() - 1, 0);
-}
\ No newline at end of file
+}
#include "XGUI_PartDataModel.h"
#include <ModelAPI_PluginManager.h>
-#include <ModelAPI_Iterator.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
return 2;
if (theParent.internalId() == ParamsFolder)
- return myDocument->featuresIterator(PARAMETERS_GROUP)->numIterationsLeft();
+ return myDocument->size(PARAMETERS_GROUP);
if (theParent.internalId() == ConstructFolder)
- return myDocument->featuresIterator(CONSTRUCTIONS_GROUP)->numIterationsLeft();
+ return myDocument->size(CONSTRUCTIONS_GROUP);
return 0;
}
case MyRoot:
return 3;
case ParamsFolder:
- return featureDocument()->featuresIterator(PARAMETERS_GROUP)->numIterationsLeft();
+ return featureDocument()->size(PARAMETERS_GROUP);
case ConstructFolder:
- return featureDocument()->featuresIterator(CONSTRUCTIONS_GROUP)->numIterationsLeft();
+ return featureDocument()->size(CONSTRUCTIONS_GROUP);
case BodiesFolder:
return 0;
}