ADD_SUBDIRECTORY (src/ModelAPI)
ADD_SUBDIRECTORY (src/GeomAPI)
ADD_SUBDIRECTORY (src/GeomAlgoAPI)
+ADD_SUBDIRECTORY (src/GeomData)
+ADD_SUBDIRECTORY (src/GeomDataAPI)
ADD_SUBDIRECTORY (src/PartSetPlugin)
ADD_SUBDIRECTORY (src/ConstructionPlugin)
ADD_SUBDIRECTORY (src/SketchPlugin)
const gp_Dir& aDir = impl<gp_Pln>().Axis().Direction();
return boost::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
}
+
+void GeomAPI_Pln::coefficients(double& theA, double& theB, double& theC, double& theD)
+{
+ impl<gp_Pln>().Coefficients(theA, theB, theC, theD);
+}
GeomAPI_Pln(const boost::shared_ptr<GeomAPI_Pnt>& thePoint,
const boost::shared_ptr<GeomAPI_Dir>& theNormal);
- /// Creation of plane by coefficients A * X + B * Y + C * Z + D = 0.0
+ /// Creation of plane by coefficients (Ax+By+Cz+D=0)
GeomAPI_Pln(const double theA, const double theB, const double theC, const double theD);
/// Returns a point of this plane
/// Returns a plane normal
boost::shared_ptr<GeomAPI_Dir> direction();
+
+ /// Returns the plane coefficients (Ax+By+Cz+D=0)
+ void coefficients(double& theA, double& theB, double& theC, double& theD);
};
#endif
)
SET(SWIG_LINK_LIBRARIES
+ GeomAPI
GeomAlgoAPI
${PYTHON_LIBRARIES}
)
#include <gp_Pln.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <TopoDS_Face.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom_Plane.hxx>
boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::shared_ptr<GeomAPI_Dir> theNormal,
aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
return aRes;
}
+
+boost::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_FaceBuilder::plane(
+ boost::shared_ptr<GeomAPI_Shape> theFace)
+{
+ boost::shared_ptr<GeomAPI_Pln> aResult;
+ if (!theFace) return aResult; // bad shape
+ TopoDS_Shape aShape = theFace->impl<TopoDS_Shape>();
+ if (aShape.IsNull()) return aResult; // null shape
+ TopoDS_Face aFace = TopoDS::Face(aShape);
+ if (aFace.IsNull()) return aResult; // not face
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ if (aSurf.IsNull()) return aResult; // no surface
+ Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf);
+ if (aPlane.IsNull()) return aResult; // not planar
+ double aA, aB, aC, aD;
+ aPlane->Coefficients(aA, aB, aC, aD);
+ aResult = boost::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+ return aResult;
+}
#include <GeomAlgoAPI.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Pln.h>
#include <GeomAPI_Dir.h>
#include <boost/shared_ptr.hpp>
/// normal to the plane and size of square
static boost::shared_ptr<GeomAPI_Shape> square(boost::shared_ptr<GeomAPI_Pnt> theCenter,
boost::shared_ptr<GeomAPI_Dir> theNormal, const double theSize);
+
+ /// Returns the plane of the planar face. If it is not planar, returns empty ptr.
+ static boost::shared_ptr<GeomAPI_Pln> plane(boost::shared_ptr<GeomAPI_Shape> theFace);
};
#endif
--- /dev/null
+INCLUDE(Common)
+INCLUDE(FindCAS)
+
+SET(PROJECT_HEADERS
+ GeomData.h
+ GeomData_Point.h
+)
+
+SET(PROJECT_SOURCES
+ GeomData_Point.cpp
+)
+
+ADD_DEFINITIONS(-DGEOMDATA_EXPORTS ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS})
+ADD_LIBRARY(GeomData SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(GeomData ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI Events Config)
+
+INCLUDE_DIRECTORIES(
+ ../ModelAPI
+ ../GeomDataAPI
+ ../Events
+ ../Config
+ ${CAS_INCLUDE_DIRS}
+)
+
+INSTALL(TARGETS GeomData DESTINATION bin)
--- /dev/null
+#ifndef GEOMDATA_H
+#define GEOMDATA_H
+
+#if defined GEOMDATA_EXPORTS
+#if defined WIN32
+#define GEOMDATA_EXPORT __declspec( dllexport )
+#else
+#define GEOMDATA_EXPORT
+#endif
+#else
+#if defined WIN32
+#define GEOMDATA_EXPORT __declspec( dllimport )
+#else
+#define GEOMDATA_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+// File: ModelAPI_AttributeDouble.cxx
+// Created: 2 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#include "GeomData_Point.h"
+
+using namespace std;
+
+void GeomData_Point::setValue(const double theX, const double theY, const double theZ)
+{
+ myCoords->SetValue(0, theX);
+ myCoords->SetValue(1, theY);
+ myCoords->SetValue(2, theZ);
+}
+
+double GeomData_Point::x() const
+{
+ return myCoords->Value(0);
+}
+
+double GeomData_Point::y() const
+{
+ return myCoords->Value(1);
+}
+
+double GeomData_Point::z() const
+{
+ return myCoords->Value(2);
+}
+
+GeomData_Point::GeomData_Point(TDF_Label& theLabel)
+{
+ // check the attribute could be already presented in this doc (after load document)
+ if (!theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords)) {
+ // create attribute: not initialized by value yet, just zero
+ myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);
+ }
+}
--- /dev/null
+// File: GeomData_Point.h
+// Created: 24 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomData_Point_HeaderFile
+#define GeomData_Point_HeaderFile
+
+#include "GeomData.h"
+#include "GeomDataAPI_Point.h"
+#include <TDataStd_RealArray.hxx>
+#include <TDF_Label.hxx>
+
+/**\class GeomData_Point
+ * \ingroup DataModel
+ * \brief Attribute that contains real value with double precision.
+ */
+
+class GeomData_Point : public ModelAPI_Attribute
+{
+ Handle_TDataStd_RealArray myCoords; ///< X, Y and Z doubles as real array attribute [0; 2]
+public:
+ /// Defines the double value
+ virtual void setValue(const double theX, const double theY, const double theZ);
+
+ /// Returns the X double value
+ virtual double x() const;
+ /// Returns the Y double value
+ virtual double y() const;
+ /// Returns the Z double value
+ virtual double z() const;
+
+protected:
+ /// Initializes attributes
+ GeomData_Point(TDF_Label& theLabel);
+};
+
+#endif
--- /dev/null
+FIND_PACKAGE(SWIG REQUIRED)
+INCLUDE(${SWIG_USE_FILE})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+SET(PROJECT_HEADERS
+ GeomDataAPI.h
+ GeomDataAPI_Point.h
+)
+
+SET(CMAKE_SWIG_FLAGS "")
+
+SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(GeomDataAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
+INCLUDE_DIRECTORIES(
+ ../ModelAPI
+)
+
+SET(SWIG_SCRIPTS
+ ${CMAKE_CURRENT_BINARY_DIR}/GeomDataAPI.py
+)
+
+SET(SWIG_LINK_LIBRARIES
+ ModelAPI
+ ${PYTHON_LIBRARIES}
+)
+
+SWIG_ADD_MODULE(GeomDataAPI python GeomDataAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(GeomDataAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+ SET_TARGET_PROPERTIES(_GeomDataAPI PROPERTIES DEBUG_OUTPUT_NAME _GeomDataAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _GeomDataAPI DESTINATION swig)
+INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION swig)
--- /dev/null
+#ifndef GEOMDATAAPI_H
+#define GEOMDATAAPI_H
+
+#if defined GEOMDATAAPI_EXPORTS
+#if defined WIN32
+#define GEOMDATAAPI_EXPORT __declspec( dllexport )
+#else
+#define GEOMDATAAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define GEOMDATAAPI_EXPORT __declspec( dllimport )
+#else
+#define GEOMDATAAPI_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+/* GeomDataAPI.i */
+%module GeomDataAPI
+%{
+ #include "GeomDataAPI.h"
+ #include "GeomDataAPI_Point.h"
+ #include <boost/shared_ptr.hpp>
+%}
+
+// to avoid error on this
+#define GEOMDATAAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_string.i"
+//%include <std_shared_ptr.i>
+
+// boost pointers
+%include <boost_shared_ptr.i>
+%shared_ptr(GeomDataAPI_Point)
+
+// all supported interfaces
+%include "GeomDataAPI_Point.h"
--- /dev/null
+// File: GeomData_AttributeDouble.h
+// Created: 2 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomData_AttributeDouble_HeaderFile
+#define GeomData_AttributeDouble_HeaderFile
+
+#include "GeomDataAPI.h"
+#include <ModelAPI_Attribute.h>
+
+/**\class GeomData_AttributeDouble
+ * \ingroup DataModel
+ * \brief Attribute that contains real value with double precision.
+ */
+
+class GeomDataAPI_Point : public ModelAPI_Attribute
+{
+public:
+ /// Defines the double value
+ virtual void setValue(const double theX, const double theY, const double theZ) = 0;
+
+ /// Returns the X double value
+ virtual double x() = 0;
+ /// Returns the Y double value
+ virtual double y() = 0;
+ /// Returns the Z double value
+ virtual double z() = 0;
+
+ /// Returns the type of this class of attributes
+ static inline std::string type() {return std::string("Point");}
+
+ /// Returns the type of this class of attributes, not static method
+ virtual std::string attributeType() {return type();}
+
+protected:
+ /// Objects are created for features automatically
+ GeomDataAPI_Point()
+ {}
+};
+
+#endif
#include "SketchPlugin_Sketch.h"
#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
void SketchPlugin_Sketch::initAttributes()
{
- //data()->addAttribute(PART_ATTR_DOC_REF, ModelAPI_AttributeDocRef::type());
+ data()->addAttribute(SKETCH_ATTR_PLANE_A, ModelAPI_AttributeDouble::type());
+ data()->addAttribute(SKETCH_ATTR_PLANE_B, ModelAPI_AttributeDouble::type());
+ data()->addAttribute(SKETCH_ATTR_PLANE_C, ModelAPI_AttributeDouble::type());
+ data()->addAttribute(SKETCH_ATTR_PLANE_D, ModelAPI_AttributeDouble::type());
}
void SketchPlugin_Sketch::execute()
#include "SketchPlugin.h"
#include <SketchPlugin_Feature.h>
-
#include <list>
-/// part reference attribute
-const std::string PART_ATTR_DOC_REF = "SketchDocument";
+/// Coefficient A of the sketch plane (Ax+By+Cz+D=0)
+const std::string SKETCH_ATTR_PLANE_A("PlaneA");
+/// Coefficient B of the sketch plane
+const std::string SKETCH_ATTR_PLANE_B("PlaneB");
+/// Coefficient C of the sketch plane
+const std::string SKETCH_ATTR_PLANE_C("PlaneC");
+/// Coefficient D of the sketch plane
+const std::string SKETCH_ATTR_PLANE_D("PlaneD");
/**\class SketchPlugin_Sketch
* \ingroup DataModel
/// \param theShapes the list of result shapes
void addPlane(double theX, double theY, double theZ,
std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
-
};
#endif