#include "ModelAPI_Session.h"
#include "ModelAPI_Object.h"
#include "ModelAPI_Feature.h"
+ #include "ModelAPI_CompositeFeature.h"
#include "ModelAPI_Data.h"
#include "ModelAPI_Attribute.h"
#include "ModelAPI_AttributeDocRef.h"
#include "ModelAPI_ResultBody.h"
#include "ModelAPI_ResultPart.h"
- template<class T> boost::shared_ptr<T> castTo(boost::shared_ptr<ModelAPI_Result> theObject)
+ template<class T1, class T2>
+ boost::shared_ptr<T1> boost_cast(boost::shared_ptr<T2> theObject)
{
- return boost::dynamic_pointer_cast<T>(theObject);
+ return boost::dynamic_pointer_cast<T1>(theObject);
}
-
%}
// to avoid error on this
%shared_ptr(ModelAPI_Session)
%shared_ptr(ModelAPI_Object)
%shared_ptr(ModelAPI_Feature)
+%shared_ptr(ModelAPI_CompositeFeature)
%shared_ptr(ModelAPI_Data)
%shared_ptr(ModelAPI_Attribute)
%shared_ptr(ModelAPI_AttributeDocRef)
%include "ModelAPI_Session.h"
%include "ModelAPI_Object.h"
%include "ModelAPI_Feature.h"
+%include "ModelAPI_CompositeFeature.h"
%include "ModelAPI_Data.h"
%include "ModelAPI_Attribute.h"
%include "ModelAPI_AttributeDocRef.h"
%template(ObjectList) std::list<boost::shared_ptr<ModelAPI_Object> >;
%template(ResultList) std::list<boost::shared_ptr<ModelAPI_Result> >;
-template<class T> boost::shared_ptr<T> castTo(boost::shared_ptr<ModelAPI_Result> theObject);
-%template(modelAPI_ResultConstruction) castTo<ModelAPI_ResultConstruction>;
-%template(modelAPI_ResultBody) castTo<ModelAPI_ResultBody>;
-%template(modelAPI_ResultPart) castTo<ModelAPI_ResultPart>;
+template<class T1, class T2> boost::shared_ptr<T1> boost_cast(boost::shared_ptr<T2> theObject);
+%template(modelAPI_CompositeFeature) boost_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
+%template(modelAPI_ResultConstruction) boost_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
+%template(modelAPI_ResultBody) boost_cast<ModelAPI_ResultBody, ModelAPI_Result>;
+%template(modelAPI_ResultPart) boost_cast<ModelAPI_ResultPart, ModelAPI_Result>;
+
+
# Initialization of the test
#=========================================================================
-__updated__ = "2014-07-29"
+__updated__ = "2014-10-28"
def distance(pointA, pointB):
# Creation of a sketch
#=========================================================================
aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
aSketchFeatureData = aSketchFeature.data()
origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
origin.setValue(0, 0, 0)
# Create a point and a line
#=========================================================================
aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
-aSketchPoint = aDocument.addFeature("SketchPoint")
-aSketchReflist.append(aSketchPoint)
+aSketchPoint = aSketchFeature.addFeature("SketchPoint")
aSketchPointData = aSketchPoint.data()
aSketchPointCoords = geomDataAPI_Point2D(
aSketchPointData.attribute("PointCoordindates"))
aSketchPointCoords.setValue(50., 50.)
-aSketchLine = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLine)
+aSketchLine = aSketchFeature.addFeature("SketchLine")
aLineAStartPoint = geomDataAPI_Point2D(
aSketchLine.data().attribute("StartPoint"))
aLineAEndPoint = geomDataAPI_Point2D(aSketchLine.data().attribute("EndPoint"))
#=========================================================================
assert (distance(aSketchPointCoords, aLineAStartPoint) != 25.)
aSession.startOperation()
-aConstraint = aDocument.addFeature("SketchConstraintDistance")
-aSketchReflist.append(aConstraint)
+aConstraint = aSketchFeature.addFeature("SketchConstraintDistance")
aConstraintData = aConstraint.data()
aDistance = aConstraintData.real("ConstraintValue")
refattrA = aConstraintData.refattr("ConstraintEntityA")
# Initialization of the test
#=========================================================================
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
aSession = ModelAPI_Session.get()
aDocument = aSession.moduleDocument()
# Creation of a sketch
#=========================================================================
aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
aSketchFeatureData = aSketchFeature.data()
origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
origin.setValue(0, 0, 0)
# Create a line with length 100
#=========================================================================
aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
-aSketchLineA = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLineA)
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
aLineAStartPoint = geomDataAPI_Point2D(
aSketchLineA.data().attribute("StartPoint"))
aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.data().attribute("EndPoint"))
# Make a constraint to keep the length
#=========================================================================
aSession.startOperation()
-aLengthConstraint = aDocument.addFeature("SketchConstraintLength")
-aSketchReflist.append(aLengthConstraint)
+aLengthConstraint = aSketchFeature.addFeature("SketchConstraintLength")
aConstraintData = aLengthConstraint.data()
refattrA = aConstraintData.refattr("ConstraintEntityA")
aLength = aConstraintData.real("ConstraintValue")
# Initialization of the test
#=========================================================================
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
aSession = ModelAPI_Session.get()
aDocument = aSession.moduleDocument()
# Creation of a sketch
#=========================================================================
aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
aSketchFeatureData = aSketchFeature.data()
origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
origin.setValue(0, 0, 0)
# Create two lines which are not parallel
#=========================================================================
aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
# line A
-aSketchLineA = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLineA)
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
aLineAStartPoint = geomDataAPI_Point2D(
aSketchLineA.data().attribute("StartPoint"))
aLineAEndPoint = geomDataAPI_Point2D(
aSketchLineA.data().attribute("EndPoint"))
-aSketchLineB = aDocument.addFeature("SketchLine")
+aSketchLineB = aSketchFeature.addFeature("SketchLine")
aLineAStartPoint.setValue(0., 25)
aLineAEndPoint.setValue(85., 25)
# line B
-aSketchReflist.append(aSketchLineB)
aLineBStartPoint = geomDataAPI_Point2D(
aSketchLineB.data().attribute("StartPoint"))
aLineBEndPoint = geomDataAPI_Point2D(
#=========================================================================
for eachFeature in [aSketchLineA, aSketchLineB]:
aSession.startOperation()
- aLengthConstraint = aDocument.addFeature("SketchConstraintLength")
- aSketchReflist.append(aLengthConstraint)
+ aLengthConstraint = aSketchFeature.addFeature("SketchConstraintLength")
aLengthConstraintData = aLengthConstraint.data()
refattrA = aLengthConstraintData.refattr("ConstraintEntityA")
aResultA = modelAPI_ResultConstruction(eachFeature.firstResult())
# Link lines with parallel constraint
#=========================================================================
aSession.startOperation()
-aParallelConstraint = aDocument.addFeature("SketchConstraintParallel")
-aSketchReflist.append(aParallelConstraint)
+aParallelConstraint = aSketchFeature.addFeature("SketchConstraintParallel")
aConstraintData = aParallelConstraint.data()
refattrA = aConstraintData.refattr("ConstraintEntityA")
refattrB = aConstraintData.refattr("ConstraintEntityB")
# Initialization of the test
#=========================================================================
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
aSession = ModelAPI_Session.get()
aDocument = aSession.moduleDocument()
# Creation of a sketch
#=========================================================================
aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
aSketchFeatureData = aSketchFeature.data()
origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
origin.setValue(0, 0, 0)
# Create two lines which are already perpendicular
#=========================================================================
aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
# line A
-aSketchLineA = aDocument.addFeature("SketchLine")
-aSketchReflist.append(aSketchLineA)
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
aLineAStartPoint = geomDataAPI_Point2D(
aSketchLineA.data().attribute("StartPoint"))
aLineAEndPoint = geomDataAPI_Point2D(
aSketchLineA.data().attribute("EndPoint"))
-aSketchLineB = aDocument.addFeature("SketchLine")
+# line B
+aSketchLineB = aSketchFeature.addFeature("SketchLine")
aLineAStartPoint.setValue(0., 25)
aLineAEndPoint.setValue(85., 25)
-# line B
-aSketchReflist.append(aSketchLineB)
aLineBStartPoint = geomDataAPI_Point2D(
aSketchLineB.data().attribute("StartPoint"))
aLineBEndPoint = geomDataAPI_Point2D(
for eachFeature in [aSketchLineA, aSketchLineB]:
aSession.startOperation()
- aLengthConstraint = aDocument.addFeature("SketchConstraintLength")
- aSketchReflist.append(aLengthConstraint)
+ aLengthConstraint = aSketchFeature.addFeature("SketchConstraintLength")
aLengthConstraintData = aLengthConstraint.data()
refattrA = aLengthConstraintData.refattr("ConstraintEntityA")
aResultA = modelAPI_ResultConstruction(eachFeature.firstResult())
# Link lines with perpendicular constraint
#=========================================================================
aSession.startOperation()
-aPerpendicularConstraint = aDocument.addFeature(
+aPerpendicularConstraint = aSketchFeature.addFeature(
"SketchConstraintPerpendicular")
-aSketchReflist.append(aPerpendicularConstraint)
aConstraintData = aPerpendicularConstraint.data()
refattrA = aConstraintData.refattr("ConstraintEntityA")
refattrB = aConstraintData.refattr("ConstraintEntityB")
# Initialization of the test
#=========================================================================
-__updated__ = "2014-09-26"
+__updated__ = "2014-10-28"
aSession = ModelAPI_Session.get()
aDocument = aSession.moduleDocument()
# Creation of a sketch
#=========================================================================
aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
aSketchFeatureData = aSketchFeature.data()
origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
origin.setValue(0, 0, 0)
# Creation of an arc and a circle
#=========================================================================
aSession.startOperation()
-aSketchReflist = aSketchFeatureData.reflist("Features")
-aSketchArc = aDocument.addFeature("SketchArc")
-aSketchReflist.append(aSketchArc)
+aSketchArc = aSketchFeature.addFeature("SketchArc")
aSketchArcData = aSketchArc.data()
anArcCentr = geomDataAPI_Point2D(aSketchArcData.attribute("ArcCenter"))
anArcCentr.setValue(10., 10.)
aSession.finishOperation()
# Circle
aSession.startOperation()
-aSketchCircle = aDocument.addFeature("SketchCircle")
-aSketchReflist.append(aSketchCircle)
+aSketchCircle = aSketchFeature.addFeature("SketchCircle")
aSketchCircleData = aSketchCircle.data()
anCircleCentr = geomDataAPI_Point2D(
aSketchCircleData.attribute("CircleCenter"))
# Make a constraint to keep the radius of the arc
#=========================================================================
aSession.startOperation()
-aConstraint = aDocument.addFeature("SketchConstraintRadius")
-aSketchReflist.append(aConstraint)
+aConstraint = aSketchFeature.addFeature("SketchConstraintRadius")
aConstraintData = aConstraint.data()
aRadius = aConstraintData.real("ConstraintValue")
aRefObject = aConstraintData.refattr("ConstraintEntityA")
# Make a constraint to keep the radius of the circle
#=========================================================================
aSession.startOperation()
-aConstraint = aDocument.addFeature("SketchConstraintRadius")
-aSketchReflist.append(aConstraint)
+aConstraint = aSketchFeature.addFeature("SketchConstraintRadius")
aConstraintData = aConstraint.data()
aRadius = aConstraintData.real("ConstraintValue")
aRefObject = aConstraintData.refattr("ConstraintEntityA")
from GeomDataAPI import *
from ModelAPI import *
-__updated__ = "2014-07-25"
+__updated__ = "2014-10-28"
aSession = ModelAPI_Session.get()
aDocument = aSession.moduleDocument()
# Creation of a sketch
#=========================================================================
aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
+#aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
aSketchFeatureData = aSketchFeature.data()
origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
origin.setValue(0, 0, 0)
#=========================================================================
# Creation of an arc
# 1. Test SketchPlugin_Arc attributes
-# 2.
+# 2.
#=========================================================================
aSession.startOperation()
aSketchReflist = aSketchFeatureData.reflist("Features")
assert (not aSketchReflist.isInitialized())
assert (aSketchReflist.size() == 0)
assert (len(aSketchReflist.list()) == 0)
-aSketchArc = aDocument.addFeature("SketchArc")
+aSketchArc = aSketchFeature.addFeature("SketchArc")
assert (aSketchArc.getKind() == "SketchArc")
-aSketchReflist.append(aSketchArc)
aSketchArcData = aSketchArc.data()
anArcCentr = geomDataAPI_Point2D(aSketchArcData.attribute("ArcCenter"))
assert (anArcCentr.x() == 0)
assert (anArcCentr.y() == 0)
assert (not anArcCentr.isInitialized())
-anArcCentr.setValue(10.,10.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArcData.attribute("ArcStartPoint"))
+anArcCentr.setValue(10., 10.)
+anArcStartPoint = geomDataAPI_Point2D(
+ aSketchArcData.attribute("ArcStartPoint"))
assert (anArcStartPoint.x() == 0)
assert (anArcStartPoint.y() == 0)
assert (not anArcStartPoint.isInitialized())
assert (anArcStartPoint.y() == 50.0)
assert (anArcEndPoint.x() == 50.0)
assert (anArcEndPoint.y() == 0.0)
-#===============================================================================
+#=========================================================================
# Edit the arc:
# 1. Move whole arc
-# 2. Change the start point
-#===============================================================================
+# 2. Change the start point
+#=========================================================================
aSession.startOperation()
deltaX, deltaY = 5., 10.
anArcCentr.setValue(anArcCentr.x() + deltaX, anArcCentr.y() + deltaY)
-anArcStartPoint.setValue(anArcStartPoint.x() + deltaX, anArcStartPoint.y() + deltaY)
+anArcStartPoint.setValue(
+ anArcStartPoint.x() + deltaX, anArcStartPoint.y() + deltaY)
anArcEndPoint.setValue(anArcEndPoint.x() + deltaX, anArcEndPoint.y() + deltaY)
aSession.finishOperation()
assert (anArcCentr.x() == 15)
assert (anArcEndPoint.x() != aPrevEndPointX)
assert (anArcEndPoint.y() != aPrevEndPointY)
#=========================================================================
-# Check results of the Arc
+# Check results of the Arc
#=========================================================================
aResult = aSketchArc.firstResult()
aResultConstruction = modelAPI_ResultConstruction(aResult)
aShape = aResultConstruction.shape()
assert (aShape is not None)
assert (not aShape.isNull())
-#===============================================================================
+#=========================================================================
# Create a circle
# 1. Test SketchPlugin_Circle.h attributes
# 2. ModelAPI_AttributeDouble attribute
-#===============================================================================
+#=========================================================================
aSession.startOperation()
aSketchReflist = aSketchFeatureData.reflist("Features")
# Arc is already added
assert (aSketchReflist.size() == 1)
assert (len(aSketchReflist.list()) == 1)
-aSketchCircle = aDocument.addFeature("SketchCircle")
+aSketchCircle = aSketchFeature.addFeature("SketchCircle")
assert (aSketchCircle.getKind() == "SketchCircle")
-aSketchReflist.append(aSketchCircle)
aSketchCircleData = aSketchCircle.data()
-anCircleCentr = geomDataAPI_Point2D(aSketchCircleData.attribute("CircleCenter"))
+anCircleCentr = geomDataAPI_Point2D(
+ aSketchCircleData.attribute("CircleCenter"))
assert (anCircleCentr.x() == 0)
assert (anCircleCentr.y() == 0)
assert (not anCircleCentr.isInitialized())
-aCircleRadius = aSketchCircleData.real("CircleRadius");
+aCircleRadius = aSketchCircleData.real("CircleRadius")
assert (type(aCircleRadius) == ModelAPI_AttributeDouble)
# ModelAPI_AttributeDouble.type() is checked in ModelAPI_TestConstants
assert (aCircleRadius.attributeType() == ModelAPI_AttributeDouble.type())
assert (anCircleCentr.y() == -25)
assert (aCircleRadius.value() == 25)
aSession.finishOperation()
-#===============================================================================
+#=========================================================================
# Edit the Cricle
# 1. Check that changing the centr of a circle does not affects radius
# 2. and vise versa; also check that int is acceptable as well as a real
-#===============================================================================
+#=========================================================================
aSession.startOperation()
anCircleCentr.setValue(10, 60)
aSession.finishOperation()
assert (anCircleCentr.x() == 10)
assert (anCircleCentr.y() == 60)
assert (aCircleRadius.value() == 20)
-#===============================================================================
+#=========================================================================
# End of test
-#===============================================================================
+#=========================================================================
from GeomDataAPI import *
from ModelAPI import *
-__updated__ = "2014-07-24"
+__updated__ = "2014-10-28"
aSession = ModelAPI_Session.get()
aDocument = aSession.moduleDocument()
# Creation of a sketch
#=========================================================================
aSession.startOperation()
-aSketchFeature = aDocument.addFeature("Sketch")
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
assert (aSketchFeature.getKind() == "Sketch")
aSketchFeatureData = aSketchFeature.data()
origin = geomDataAPI_Point(aSketchFeatureData.attribute("Origin"))
assert (not aSketchReflist.isInitialized())
assert(aSketchReflist.size() == 0)
assert (len(aSketchReflist.list()) == 0)
-aSketchPoint = aDocument.addFeature("SketchPoint")
+# aSketchPoint = aDocument.addFeature("SketchPoint")
+aSketchPoint = aSketchFeature.addFeature("SketchPoint")
assert (aSketchPoint.getKind() == "SketchPoint")
-aSketchReflist.append(aSketchPoint)
aSketchPointData = aSketchPoint.data()
coords = geomDataAPI_Point2D(aSketchPointData.attribute("PointCoordindates"))
assert (coords.x() == 0)
coords = geomDataAPI_Point2D(aSketchPointData.attribute("PointCoordindates"))
assert (coords.x() == 10.0)
assert (coords.y() == 10.0)
-#===============================================================================
+#=========================================================================
# Creation of a line
-#===============================================================================
+#=========================================================================
aSession.startOperation()
-aSketchLine = aDocument.addFeature("SketchLine")
+# aSketchLine = aDocument.addFeature("SketchLine")
+aSketchLine = aSketchFeature.addFeature("SketchLine")
assert (aSketchLine.getKind() == "SketchLine")
-aSketchReflist.append(aSketchLine)
assert (aSketchReflist.size() == 2)
assert (len(aSketchReflist.list()) == 2)
aSketchLineData = aSketchLine.data()
aLineStartPoint = geomDataAPI_Point2D(aSketchLineData.attribute("StartPoint"))
-aLineEndPoint= geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
assert (aLineStartPoint.x() == 0)
assert (aLineStartPoint.y() == 0)
assert (not aLineStartPoint.isInitialized())
# check that values have been changed
aSketchLineData = aSketchLine.data()
aLineStartPoint = geomDataAPI_Point2D(aSketchLineData.attribute("StartPoint"))
-aLineEndPoint= geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
+aLineEndPoint = geomDataAPI_Point2D(aSketchLineData.attribute("EndPoint"))
assert (aLineStartPoint.x() == 50.0)
assert (aLineStartPoint.y() == 50.0)
assert (aLineEndPoint.x() == 60.0)
assert (aLineEndPoint.y() == 60.0)
-#===============================================================================
+#=========================================================================
# Check the results
-#===============================================================================
+#=========================================================================
aResult = aSketchLine.firstResult()
+assert (aResult is not None)
aResultConstruction = modelAPI_ResultConstruction(aResult)
aShape = aResultConstruction.shape()
assert (aShape is not None)