ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
ADD_LIBRARY(ConstructionPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(ConstructionPlugin ${PROJECT_LIBRARIES} ModelAPI)
+TARGET_LINK_LIBRARIES(ConstructionPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
INCLUDE_DIRECTORIES(
../ModelAPI
+ ../GeomAPI
+ ../GeomAlgoAPI
)
SET(XML_RESOURCES
#include "ModelAPI_Document.h"
#include "ModelAPI_Data.h"
#include "ModelAPI_AttributeDouble.h"
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Pnt.h>
using namespace std;
data()->addAttribute(POINT_ATTR_Z, ModelAPI_AttributeDouble::type());
}
-// this is for debug only
-#include <iostream>
void ConstructionPlugin_Point::execute()
{
- // TODO: create a real shape for the point using OCC layer
- cout<<"X="<<data()->real(POINT_ATTR_X)->value()<<" Y="<<data()->real(POINT_ATTR_Y)->value()
- <<" Z="<<data()->real(POINT_ATTR_Z)->value()<<endl;
+ boost::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(
+ data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(), data()->real(POINT_ATTR_Z)->value()));
+
+ data()->store(GeomAlgoAPI_PointBuilder::point(aPnt));
}
GeomAlgoAPI_CompoundBuilder.h
GeomAlgoAPI_FaceBuilder.h
GeomAlgoAPI_EdgeBuilder.h
+ GeomAlgoAPI_PointBuilder.h
)
SET(PROJECT_SOURCES
GeomAlgoAPI_CompoundBuilder.cpp
GeomAlgoAPI_FaceBuilder.cpp
GeomAlgoAPI_EdgeBuilder.cpp
+ GeomAlgoAPI_PointBuilder.cpp
)
ADD_DEFINITIONS(-DGEOMALGOAPI_EXPORTS ${CAS_DEFINITIONS})
#include "memory"
#include "GeomAlgoAPI.h"
#include "GeomAlgoAPI_FaceBuilder.h"
+ #include "GeomAlgoAPI_EdgeBuilder.h"
+ #include "GeomAlgoAPI_PointBuilder.h"
%}
// to avoid error on this
// all supported interfaces
%include "GeomAlgoAPI_FaceBuilder.h"
+%include "GeomAlgoAPI_EdgeBuilder.h"
+%include "GeomAlgoAPI_PointBuilder.h"
--- /dev/null
+// File: GeomAlgoAPI_PointBuilder.cpp
+// Created: 02 Jun 2014
+// Author: Mikhail PONIKAROV
+
+
+
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Shape.h>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <TopoDS_Vertex.hxx>
+
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
+ boost::shared_ptr<GeomAPI_Pnt> thePoint)
+{
+ const gp_Pnt& aPnt = thePoint->impl<gp_Pnt>();
+ BRepBuilderAPI_MakeVertex aMaker(aPnt);
+ TopoDS_Vertex aVertex = aMaker.Vertex();
+ boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ aRes->setImpl(new TopoDS_Shape(aVertex));
+ return aRes;
+}
--- /dev/null
+// File: GeomAlgoAPI_PointBuilder.h
+// Created: 02 Jun 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomAlgoAPI_PointBuilder_HeaderFile
+#define GeomAlgoAPI_PointBuilder_HeaderFile
+
+#include <GeomAlgoAPI.h>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_Shape;
+class GeomAPI_Pnt;
+
+/**\class GeomAlgoAPI_PointBuilder
+ * \ingroup DataAlgo
+ * \brief Allows to create face-shapes by different parameters
+ */
+
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_PointBuilder
+{
+public:
+ /// Creates linear edge by two points
+ static boost::shared_ptr<GeomAPI_Shape> point(
+ boost::shared_ptr<GeomAPI_Pnt> thePoint);
+};
+
+#endif
Events
Config
GeomData
+ GeomAPI
${CAS_OCAF}
+ ${CAS_TKCAF}
)
../Config
../GeomData
../GeomDataAPI
+ ../GeomAPI
${CAS_INCLUDE_DIRS}
)
void Model_AttributeBoolean::setValue(bool theValue)
{
- if (myBool->Get() != theValue) {
- myBool->Set(theValue? 1 : 0);
+ Standard_Boolean aValue = theValue ? Standard_True : Standard_False;
+ if (myBool->Get() != aValue) {
+ myBool->Set(aValue);
static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
Events_Loop::loop()->send(aMsg);
bool Model_AttributeBoolean::value()
{
- return (myBool->Get() == 1)? true : false;
+ return myBool->Get() == Standard_True;
}
Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
{
return !myLab.IsNull() && myLab.HasAttribute();
}
+
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <GeomAPI_Shape.h>
+
+void Model_Data::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
+{
+ // the simplest way is to keep this attribute here, on Data
+ // TODO: add naming structure in separated document for shape storage
+ TNaming_Builder aBuilder(myLab);
+ if (!theShape) return; // bad shape
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ if (aShape.IsNull()) return; // null shape inside
+
+ aBuilder.Generated(aShape);
+}
+
+boost::shared_ptr<GeomAPI_Shape> Model_Data::shape()
+{
+ Handle(TNaming_NamedShape) aName;
+ if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
+ TopoDS_Shape aShape = aName->Get();
+ if (!aShape.IsNull()) {
+ boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ aRes->setImpl(new TopoDS_Shape(aShape));
+ return aRes;
+ }
+ }
+ return boost::shared_ptr<GeomAPI_Shape>();
+}
/// Returns true if it is correctly connected t othe data model
MODEL_EXPORT virtual bool isValid();
+ /// Stores the shape (called by the execution method).
+ MODEL_EXPORT virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape);
+ /// Returns the shape-result produced by this feature
+ MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape();
+
/// Initializes object by the attributes: must be called just after the object is created
/// for each attribute of the object
/// \param theID identifier of the attribute that can be referenced by this ID later
class ModelAPI_AttributeRefList;
class ModelAPI_Document;
class ModelAPI_Attribute;
+class GeomAPI_Shape;
/**\class ModelAPI_Data
* \ingroup DataModel
/// Returns true if it is correctly connected t othe data model
virtual bool isValid() = 0;
+ /// Stores the shape (called by the execution method).
+ virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+ /// Returns the shape-result produced by this feature
+ virtual boost::shared_ptr<GeomAPI_Shape> shape() = 0;
+
/// Initializes object by the attributes: must be called just after the object is created
/// for each attribute of the object
/// \param theID identifier of the attribute that can be referenced by this ID later
std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
// create the operation
- ModuleBase_Operation* anOperation;
+ ModuleBase_Operation* anOperation = 0;
if (theCmdId == PartSet_OperationSketch::Type()) {
anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
}
XGUI_Workshop* myWorkshop;
};
-#endif
\ No newline at end of file
+#endif