#include "ConstructionAPI_Point.h"
+#include <GeomAPI_Shape.h>
+
+#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
+#include <algorithm>
+
+static GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr);
+static GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
+
//==================================================================================================
ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature)
: ModelHighAPI_Interface(theFeature)
: ModelHighAPI_Interface(theFeature)
{
if(initialize()) {
- /// If first object is vertex and second object is face then set by projection.
- /// TODO: check
- setByProjection(theObject1, theObject2);
+ GeomAPI_Shape::ShapeType aType1 = getShapeType(theObject1);
+ GeomAPI_Shape::ShapeType aType2 = getShapeType(theObject2);
+
+ if(aType1 == GeomAPI_Shape::VERTEX && aType2 == GeomAPI_Shape::FACE) {
+ // If first object is vertex and second object is face then set by projection.
+ setByProjection(theObject1, theObject2);
+ } else if(aType1 == GeomAPI_Shape::EDGE && aType2 == GeomAPI_Shape::EDGE) {
+ // If both objects are edges then set by lines intersection.
+ setByLinesIntersection(theObject1, theObject2);
+ } else if(aType1 == GeomAPI_Shape::EDGE && aType2 == GeomAPI_Shape::FACE) {
+ // If first object is edge and second object is face then set by line and plane intersection.
+ setByLineAndPlaneIntersection(theObject1, theObject2);
+ }
}
}
//==================================================================================================
void ConstructionAPI_Point::setByProjection(const ModelHighAPI_Selection& theVertex,
- const ModelHighAPI_Selection& thePlane)
+ const ModelHighAPI_Selection& theFace)
{
fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION(), mycreationMethod);
fillAttribute(theVertex, mypoint);
- fillAttribute(thePlane, myplane);
+ fillAttribute(theFace, myplane);
+
+ execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Point::setByLinesIntersection(const ModelHighAPI_Selection& theEdge1,
+ const ModelHighAPI_Selection& theEdge2)
+{
+ fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_LINES_INTERSECTION(), mycreationMethod);
+ fillAttribute(theEdge1, myfirstLine);
+ fillAttribute(theEdge2, mysecondLine);
+
+ execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Point::setByLineAndPlaneIntersection(const ModelHighAPI_Selection& theEdge,
+ const ModelHighAPI_Selection& theFace)
+{
+ fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION(), mycreationMethod);
+ fillAttribute(theEdge, myintersectionLine);
+ fillAttribute(theFace, myintersectionPlane);
execute();
}
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2));
}
+
+//==================================================================================================
+GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr)
+{
+ GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
+
+ std::string aShapeTypeStr = theShapeTypeStr;
+ std::transform(aShapeTypeStr.begin(), aShapeTypeStr.end(), aShapeTypeStr.begin(), ::tolower);
+
+ if(theShapeTypeStr == "compound") {
+ aShapeType = GeomAPI_Shape::COMPOUND;
+ } else if(theShapeTypeStr == "compsolid") {
+ aShapeType = GeomAPI_Shape::COMPSOLID;
+ } else if(theShapeTypeStr == "solid") {
+ aShapeType = GeomAPI_Shape::SOLID;
+ } else if(theShapeTypeStr == "shell") {
+ aShapeType = GeomAPI_Shape::SHELL;
+ } else if(theShapeTypeStr == "face") {
+ aShapeType = GeomAPI_Shape::FACE;
+ } else if(theShapeTypeStr == "wire") {
+ aShapeType = GeomAPI_Shape::WIRE;
+ } else if(theShapeTypeStr == "edge") {
+ aShapeType = GeomAPI_Shape::EDGE;
+ } else if(theShapeTypeStr == "vertex") {
+ aShapeType = GeomAPI_Shape::VERTEX;
+ } else if(theShapeTypeStr == "shape") {
+ aShapeType = GeomAPI_Shape::SHAPE;
+ }
+
+ return aShapeType;
+}
+
+//==================================================================================================
+GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection)
+{
+ GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
+
+ switch(theSelection.variantType()) {
+ case ModelHighAPI_Selection::VT_ResultSubShapePair: {
+ ResultSubShapePair aPair = theSelection.resultSubShapePair();
+ GeomShapePtr aShape = aPair.second;
+ if(!aShape.get()) {
+ aShape = aPair.first->shape();
+ }
+ if(!aShape.get()) {
+ return aShapeType;
+ }
+ aShapeType = aShape->shapeType();
+ break;
+ }
+ case ModelHighAPI_Selection::VT_TypeSubShapeNamePair: {
+ TypeSubShapeNamePair aPair = theSelection.typeSubShapeNamePair();
+ std::string aType = aPair.first;
+ aShapeType = shapeTypeByStr(aType);
+ break;
+ }
+ }
+
+ return aShapeType;
+}
CONSTRUCTIONAPI_EXPORT
virtual ~ConstructionAPI_Point();
- INTERFACE_10(ConstructionPlugin_Point::ID(),
+ INTERFACE_14(ConstructionPlugin_Point::ID(),
creationMethod, ConstructionPlugin_Point::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */,
x, ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble, /** X attribute */,
y, ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble, /** Y attribute */,
distancePercent, ConstructionPlugin_Point::DISTANCE_PERCENT(), ModelAPI_AttributeBoolean, /** Distance percent attribute */,
reverse, ConstructionPlugin_Point::REVERSE(), ModelAPI_AttributeBoolean, /** Reverse attribute */,
point, ConstructionPlugin_Point::POINT(), ModelAPI_AttributeSelection, /** Point attribute */,
- plane, ConstructionPlugin_Point::PLANE(), ModelAPI_AttributeSelection, /** Plane attribute */
+ plane, ConstructionPlugin_Point::PLANE(), ModelAPI_AttributeSelection, /** Plane attribute */,
+ firstLine, ConstructionPlugin_Point::FIRST_LINE(), ModelAPI_AttributeSelection, /** First line attribute */,
+ secondLine, ConstructionPlugin_Point::SECOND_LINE(), ModelAPI_AttributeSelection, /** Second line attribute */,
+ intersectionLine, ConstructionPlugin_Point::INTERSECTION_LINE(), ModelAPI_AttributeSelection, /** Intersection line attribute */,
+ intersectionPlane, ConstructionPlugin_Point::INTERSECTION_PLANE(), ModelAPI_AttributeSelection, /** Intersection plane attribute */
)
/// Set point values.
/// Set point and plane for projection.
CONSTRUCTIONAPI_EXPORT
void setByProjection(const ModelHighAPI_Selection& theVertex,
- const ModelHighAPI_Selection& thePlane);
+ const ModelHighAPI_Selection& theFace);
+
+ /// Set lines for intersections.
+ CONSTRUCTIONAPI_EXPORT
+ void setByLinesIntersection(const ModelHighAPI_Selection& theEdge1,
+ const ModelHighAPI_Selection& theEdge2);
+
+ /// Set line and plane for intersections.
+ CONSTRUCTIONAPI_EXPORT
+ void setByLineAndPlaneIntersection(const ModelHighAPI_Selection& theEdge,
+ const ModelHighAPI_Selection& theFace);
};
/// Pointer on Point object.
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
aFactory->registerValidator("ConstructionPlugin_ValidatorPointLines",
new ConstructionPlugin_ValidatorPointLines());
+ aFactory->registerValidator("ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel",
+ new ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel());
// register this plugin
ModelAPI_Session::get()->registerPlugin(this);
data()->addAttribute(FIRST_LINE(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(SECOND_LINE(), ModelAPI_AttributeSelection::typeId());
+
+ data()->addAttribute(INTERSECTION_LINE(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(INTERSECTION_PLANE(), ModelAPI_AttributeSelection::typeId());
}
//==================================================================================================
} else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION()) {
aShape = createByProjection();
} else if(aCreationMethod == CREATION_METHOD_BY_LINES_INTERSECTION()) {
- aShape = createByIntersection();
+ aShape = createByLinesIntersection();
+ } else if(aCreationMethod == CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()) {
+ aShape = createByLineAndPlaneIntersection();
}
if(aShape.get()) {
}
//==================================================================================================
-std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByIntersection()
+std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByLinesIntersection()
{
// Get first line.
AttributeSelectionPtr aFirstLineSelection= selection(FIRST_LINE());
return GeomAlgoAPI_PointBuilder::vertexByIntersection(aFirstEdge, aSecondEdge);
}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByLineAndPlaneIntersection()
+{
+ // Get line.
+ AttributeSelectionPtr aLineSelection= selection(INTERSECTION_LINE());
+ GeomShapePtr aLineShape = aLineSelection->value();
+ if(!aLineShape.get()) {
+ aLineShape = aLineSelection->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aLineShape));
+
+ // Get plane.
+ AttributeSelectionPtr aPlaneSelection= selection(INTERSECTION_PLANE());
+ GeomShapePtr aPlaneShape = aPlaneSelection->value();
+ if(!aPlaneShape.get()) {
+ aPlaneShape = aPlaneSelection->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(aPlaneShape));
+
+ return GeomAlgoAPI_PointBuilder::vertexByIntersection(anEdge, aFace);
+}
return MY_CREATION_METHOD_ID;
}
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()
+ {
+ static const std::string MY_CREATION_METHOD_ID("by_line_and_plane_intersection");
+ return MY_CREATION_METHOD_ID;
+ }
+
/// Attribute name for X coordinate.
inline static const std::string& X()
{
return POINT_ATTR_Z;
}
- /// Attribute name for seleted edge.
+ /// Attribute name for selected edge.
inline static const std::string& EDGE()
{
static const std::string ATTR_ID("edge");
return ATTR_ID;
}
- /// Attribute name for seleted first line.
+ /// Attribute name for selected first line.
inline static const std::string& FIRST_LINE()
{
static const std::string ATTR_ID("first_line");
return ATTR_ID;
}
- /// Attribute name for seleted second line.
+ /// Attribute name for selected second line.
inline static const std::string& SECOND_LINE()
{
static const std::string ATTR_ID("second_line");
return ATTR_ID;
}
+ /// Attribute name for selected intersection line.
+ inline static const std::string& INTERSECTION_LINE()
+ {
+ static const std::string ATTR_ID("intersection_line");
+ return ATTR_ID;
+ }
+
+ /// Attribute name for selected intersection plane.
+ inline static const std::string& INTERSECTION_PLANE()
+ {
+ static const std::string ATTR_ID("intersection_plane");
+ return ATTR_ID;
+ }
+
/// Creates a new part document if needed.
CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
std::shared_ptr<GeomAPI_Vertex> createByXYZ();
std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
std::shared_ptr<GeomAPI_Vertex> createByProjection();
- std::shared_ptr<GeomAPI_Vertex> createByIntersection();
+ std::shared_ptr<GeomAPI_Vertex> createByLinesIntersection();
+ std::shared_ptr<GeomAPI_Vertex> createByLineAndPlaneIntersection();
};
#include "ConstructionPlugin_Validators.h"
#include <GeomAPI_Edge.h>
+#include <GeomAPI_Face.h>
#include <GeomAPI_Lin.h>
+#include <GeomAPI_Pln.h>
#include <ModelAPI_AttributeSelection.h>
#include <Events_InfoMessage.h>
+static std::shared_ptr<GeomAPI_Lin> getLin(const GeomShapePtr theShape);
+static std::shared_ptr<GeomAPI_Pln> getPln(const GeomShapePtr theShape);
+
//==================================================================================================
bool ConstructionPlugin_ValidatorPointLines::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& theArguments,
return true;
}
+
+//==================================================================================================
+bool ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel::isValid(
+ const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
+{
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
+
+ AttributeSelectionPtr anAttribute1 = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ AttributeSelectionPtr anAttribute2 = aFeature->selection(theArguments.front());
+
+ std::shared_ptr<GeomAPI_Lin> aLin;
+ std::shared_ptr<GeomAPI_Pln> aPln;
+
+ GeomShapePtr aShape1 = anAttribute1->value();
+ ResultPtr aContext1 = anAttribute1->context();
+ if(!aContext1.get()) {
+ theError = "One of the attribute not initialized.";
+ return false;
+ }
+ if(!aShape1.get()) {
+ aShape1 = aContext1->shape();
+ }
+
+ GeomShapePtr aShape2 = anAttribute2->value();
+ ResultPtr aContext2 = anAttribute2->context();
+ if(!aContext2.get()) {
+ return true;
+ }
+ if(!aShape2.get()) {
+ aShape2 = aContext2->shape();
+ }
+
+ aLin = getLin(aShape1);
+ aPln = getPln(aShape2);
+ if(!aLin.get() || !aPln.get()) {
+ aLin = getLin(aShape2);
+ aPln = getPln(aShape1);
+ }
+
+ if(!aLin.get() || !aPln.get()) {
+ theError = "Wrong shape types selected.";
+ return false;
+ }
+
+ if(aPln->isParallel(aLin)) {
+ theError = "Plane and line are parallel.";
+ return false;
+ }
+
+ return true;
+}
+
+static std::shared_ptr<GeomAPI_Lin> getLin(const GeomShapePtr theShape)
+{
+ std::shared_ptr<GeomAPI_Lin> aLin;
+
+ if(!theShape->isEdge()) {
+ return aLin;
+ }
+
+ std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(theShape));
+
+ if(!anEdge->isLine()) {
+ return aLin;
+ }
+
+ aLin = anEdge->line();
+
+ return aLin;
+}
+
+static std::shared_ptr<GeomAPI_Pln> getPln(const GeomShapePtr theShape)
+{
+ std::shared_ptr<GeomAPI_Pln> aPln;
+
+ if(!theShape->isFace()) {
+ return aPln;
+ }
+
+ std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face(theShape));
+
+ if(!aFace->isPlanar()) {
+ return aPln;
+ }
+
+ aPln = aFace->getPlane();
+
+ return aPln;
+}
/// \class ConstructionPlugin_ValidatorPointLines
/// \ingroup Validators
-/// \brief A validator for selection lines for point by intersection..
+/// \brief A validator for selection lines for point by intersection.
class ConstructionPlugin_ValidatorPointLines: public ModelAPI_AttributeValidator
{
public:
Events_InfoMessage& theError) const;
};
+/// \class ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel
+/// \ingroup Validators
+/// \brief A validator for selection line and plane for point by intersection..
+class ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel: public ModelAPI_AttributeValidator
+{
+public:
+ //! \return True if the attribute is valid.
+ //! \param[in] theAttribute the checked attribute.
+ //! \param[in] theArguments arguments of the attribute.
+ //! \param[out] theError error message.
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const;
+};
+
#endif
\ No newline at end of file
aSession.finishOperation()
assert (len(aPoint.result()) > 0)
-# Create a sketch with line
+# Create a sketch with lines
aSession.startOperation()
anOrigin = GeomAPI_Pnt(0, 0, 0)
aDirX = GeomAPI_Dir(1, 0, 0)
aNorm = GeomAPI_Dir(0, 0, 1)
aSketch = model.addSketch(aDocument, GeomAPI_Ax3(anOrigin, aDirX, aNorm))
-aSketchLine = aSketch.addLine(25, 25, 100, 25)
+aSketchLine1 = aSketch.addLine(0, 0, 100, 100)
+aSketchLine2 = aSketch.addLine(0, 100, 100, 0)
aSession.finishOperation()
# Create a point on line
aSession.startOperation()
-aPoint = model.addPoint(aDocument, aSketchLine.result()[0], 50, True, False)
+aPoint = model.addPoint(aDocument, aSketchLine1.result()[0], 25, True, False)
aSession.finishOperation()
assert (len(aPoint.result()) > 0)
aPoint = model.addPoint(aDocument, aPoint.result()[0], aPlane.result()[0])
aSession.finishOperation()
assert (len(aPoint.result()) > 0)
+
+# Create a point by lines intersection
+aSession.startOperation()
+aPoint = model.addPoint(aDocument, aSketchLine1.result()[0], aSketchLine2.result()[0])
+aSession.finishOperation()
+assert (len(aPoint.result()) > 0)
+
+# Create a point by line and plane intersection
+aSession.startOperation()
+aPoint = model.addPoint(aDocument, aSketchLine1.result()[0], aPlane.result()[0])
+aSession.finishOperation()
+assert (len(aPoint.result()) > 0)
</shape_selector>
</box>
<box id="by_lines_intersection"
- title="By intersection"
+ title="By two lines intersection"
tooltip="Point by intersection of two coplanar lines."
icon="icons/Construction/point_by_lines_intersection_32x32.png">
<shape_selector id="first_line"
label="First line"
tooltip="First line."
- icon="icons/Construction/point.png"
+ icon="icons/Construction/edge.png"
shape_types="edge">
<validator id="GeomValidators_ShapeType" parameters="line"/>
<validator id="ConstructionPlugin_ValidatorPointLines" parameters="second_line"/>
<shape_selector id="second_line"
label="Second line"
tooltip="Second line."
- icon="icons/Construction/point.png"
+ icon="icons/Construction/edge.png"
shape_types="edge">
<validator id="GeomValidators_ShapeType" parameters="line"/>
<validator id="ConstructionPlugin_ValidatorPointLines" parameters="first_line"/>
</shape_selector>
</box>
+ <box id="by_line_and_plane_intersection"
+ title="By line and plane intersection"
+ tooltip="Point by intersection of line and plane."
+ icon="icons/Construction/point_by_line_and_plane_intersection_32x32.png">
+ <shape_selector id="intersection_line"
+ label="Line"
+ tooltip="Line for intersection."
+ icon="icons/Construction/edge.png"
+ shape_types="edge">
+ <validator id="GeomValidators_ShapeType" parameters="line"/>
+ <validator id="ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel" parameters="intersection_plane"/>
+ </shape_selector>
+ <shape_selector id="intersection_plane"
+ label="Plane"
+ tooltip="Plane for intersection."
+ icon="icons/Construction/face.png"
+ shape_types="face">
+ <validator id="GeomValidators_Face" parameters="plane"/>
+ <validator id="ConstructionPlugin_ValidatorPointLineAndPlaneNotParallel" parameters="intersection_line"/>
+ </shape_selector>
+ </box>
+
</toolbox>
</source>
return (aMyPln.Contains(anOtherPln.Location(), theTolerance) && aMyPln.Axis().IsParallel(anOtherPln.Axis(), theTolerance));
}
+bool GeomAPI_Pln::isParallel(const std::shared_ptr<GeomAPI_Lin> theLine)
+{
+ std::shared_ptr<GeomAPI_XYZ> aLineDir = theLine->direction()->xyz();
+ std::shared_ptr<GeomAPI_XYZ> aLineLoc = theLine->location()->xyz();
+
+ std::shared_ptr<GeomAPI_XYZ> aNormal = direction()->xyz();
+ std::shared_ptr<GeomAPI_XYZ> aLocation = location()->xyz();
+
+ double aDot = aNormal->dot(aLineDir);
+ return Abs(aDot) < Precision::SquareConfusion();
+}
+
std::shared_ptr<GeomAPI_Pnt> GeomAPI_Pln::intersect(const std::shared_ptr<GeomAPI_Lin>& theLine) const
{
std::shared_ptr<GeomAPI_XYZ> aLineDir = theLine->direction()->xyz();
GEOMAPI_EXPORT
bool isCoincident(const std::shared_ptr<GeomAPI_Pln> thePlane, const double theTolerance = 1.e-7);
+ /// Returns true if plane is parallel to theLine.
+ GEOMAPI_EXPORT
+ bool isParallel(const std::shared_ptr<GeomAPI_Lin> theLine);
+
/// Returns intersection point or empty if no intersections
GEOMAPI_EXPORT
std::shared_ptr<GeomAPI_Pnt> intersect(const std::shared_ptr<GeomAPI_Lin>& theLine) const;
{
public:
/// Type of booelan operation
- enum OperationType{
+ enum OperationType {
BOOL_CUT, ///< Cut objects
BOOL_FUSE, ///< Fuse objects
BOOL_COMMON ///< Take common part of objects
return aVertex;
}
- std::shared_ptr<GeomAPI_Pnt> aGeomPnt = theVertex->point();
- gp_Pnt aPnt = aGeomPnt->impl<gp_Pnt>();
+ std::shared_ptr<GeomAPI_Pnt> aProjPnt = theVertex->point();
+ std::shared_ptr<GeomAPI_Pln> aProjPln = thePlane->getPlane();
- std::shared_ptr<GeomAPI_Pln> aGeomPln = thePlane->getPlane();
- gp_Pln aPln = aGeomPln->impl<gp_Pln>();
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aProjPln->project(aProjPnt);
- gp_Dir aPntAxis = aPnt.XYZ() - aPln.Location().XYZ();
- gp_Dir aPlnNorm = aPln.Axis().Direction();
-
- if(aPntAxis * aPlnNorm > 0) {
- aPlnNorm.Reverse();
+ if(!aPnt.get()) {
+ return aVertex;
}
- double aDistance = aPln.Distance(aPnt);
- aPnt.Translate(gp_Vec(aPlnNorm) * aDistance);
-
- aVertex.reset(new GeomAPI_Vertex(aPnt.X(), aPnt.Y(), aPnt.Z()));
+ aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
return aVertex;
}
return aVertex;
}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByIntersection(
+ const std::shared_ptr<GeomAPI_Edge> theEdge,
+ const std::shared_ptr<GeomAPI_Face> theFace)
+{
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+
+ if(!theEdge.get() || !theFace.get() || !theEdge->isLine() || !theFace->isPlanar()) {
+ return aVertex;
+ }
+
+ std::shared_ptr<GeomAPI_Lin> aLin = theEdge->line();
+ std::shared_ptr<GeomAPI_Pln> aPln = theFace->getPlane();
+
+ std::shared_ptr<GeomAPI_Pnt> aPnt = aPln->intersect(aLin);
+
+ if(!aPnt.get()) {
+ return aVertex;
+ }
+
+ aVertex.reset(new GeomAPI_Vertex(aPnt->x(), aPnt->y(), aPnt->z()));
+
+ return aVertex;
+}
static std::shared_ptr<GeomAPI_Vertex> vertexByIntersection(const std::shared_ptr<GeomAPI_Edge> theEdge1,
const std::shared_ptr<GeomAPI_Edge> theEdge2);
+ /// \brief Creates vertex by intersection line and plane.
+ /// \param[in] theEdge linear edge.
+ /// \param[in] theFace planar face.
+ /// \return created vertex.
+ static std::shared_ptr<GeomAPI_Vertex> vertexByIntersection(const std::shared_ptr<GeomAPI_Edge> theEdge,
+ const std::shared_ptr<GeomAPI_Face> theFace);
+
/// Return point by shape vertex
static std::shared_ptr<GeomAPI_Pnt> point(const std::shared_ptr<GeomAPI_Shape> theVertex);
};
END_INIT() \
public:
+//--------------------------------------------------------------------------------------
+#define INTERFACE_14(KIND, \
+ N_0, AN_0, T_0, C_0, \
+ N_1, AN_1, T_1, C_1, \
+ N_2, AN_2, T_2, C_2, \
+ N_3, AN_3, T_3, C_3, \
+ N_4, AN_4, T_4, C_4, \
+ N_5, AN_5, T_5, C_5, \
+ N_6, AN_6, T_6, C_6, \
+ N_7, AN_7, T_7, C_7, \
+ N_8, AN_8, T_8, C_8, \
+ N_9, AN_9, T_9, C_9, \
+ N_10, AN_10, T_10, C_10, \
+ N_11, AN_11, T_11, C_11, \
+ N_12, AN_12, T_12, C_12, \
+ N_13, AN_13, T_13, C_13) \
+ public: \
+ INTERFACE_COMMON(KIND) \
+ DEFINE_ATTRIBUTE(N_0, T_0, C_0) \
+ DEFINE_ATTRIBUTE(N_1, T_1, C_1) \
+ DEFINE_ATTRIBUTE(N_2, T_2, C_2) \
+ DEFINE_ATTRIBUTE(N_3, T_3, C_3) \
+ DEFINE_ATTRIBUTE(N_4, T_4, C_4) \
+ DEFINE_ATTRIBUTE(N_5, T_5, C_5) \
+ DEFINE_ATTRIBUTE(N_6, T_6, C_6) \
+ DEFINE_ATTRIBUTE(N_7, T_7, C_7) \
+ DEFINE_ATTRIBUTE(N_8, T_8, C_8) \
+ DEFINE_ATTRIBUTE(N_9, T_9, C_9) \
+ DEFINE_ATTRIBUTE(N_10, T_10, C_10) \
+ DEFINE_ATTRIBUTE(N_11, T_11, C_11) \
+ DEFINE_ATTRIBUTE(N_12, T_12, C_12) \
+ DEFINE_ATTRIBUTE(N_13, T_13, C_13) \
+ protected: \
+ START_INIT() \
+ SET_ATTRIBUTE(N_0, T_0, AN_0) \
+ SET_ATTRIBUTE(N_1, T_1, AN_1) \
+ SET_ATTRIBUTE(N_2, T_2, AN_2) \
+ SET_ATTRIBUTE(N_3, T_3, AN_3) \
+ SET_ATTRIBUTE(N_4, T_4, AN_4) \
+ SET_ATTRIBUTE(N_5, T_5, AN_5) \
+ SET_ATTRIBUTE(N_6, T_6, AN_6) \
+ SET_ATTRIBUTE(N_7, T_7, AN_7) \
+ SET_ATTRIBUTE(N_8, T_8, AN_8) \
+ SET_ATTRIBUTE(N_9, T_9, AN_9) \
+ SET_ATTRIBUTE(N_10, T_10, AN_10) \
+ SET_ATTRIBUTE(N_11, T_11, AN_11) \
+ SET_ATTRIBUTE(N_12, T_12, AN_12) \
+ SET_ATTRIBUTE(N_13, T_13, AN_13) \
+ END_INIT() \
+ public:
+
//--------------------------------------------------------------------------------------
#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_MACRO_H_ */
return;
}
}
+
+//==================================================================================================
+ModelHighAPI_Selection::VariantType ModelHighAPI_Selection::variantType() const
+{
+ return myVariantType;
+}
+
+//==================================================================================================
+ResultSubShapePair ModelHighAPI_Selection::resultSubShapePair() const
+{
+ return myResultSubShapePair;
+}
+
+//==================================================================================================
+TypeSubShapeNamePair ModelHighAPI_Selection::typeSubShapeNamePair() const
+{
+ return myTypeSubShapeNamePair;
+}
*/
class ModelHighAPI_Selection
{
+public:
+ enum VariantType {
+ VT_ResultSubShapePair,
+ VT_TypeSubShapeNamePair
+ };
+
public:
/// Constructor for result and sub-shape
MODELHIGHAPI_EXPORT
MODELHIGHAPI_EXPORT
virtual void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
+ /// \return variant type.
+ MODELHIGHAPI_EXPORT
+ virtual VariantType variantType() const;
+
+ /// \return pair of result and sub-shape.
+ MODELHIGHAPI_EXPORT
+ virtual ResultSubShapePair resultSubShapePair() const;
+
+ /// \return pair of sub-shape type and name.
+ MODELHIGHAPI_EXPORT
+ virtual TypeSubShapeNamePair typeSubShapeNamePair() const;
+
private:
- enum VariantType { VT_ResultSubShapePair, VT_TypeSubShapeNamePair } myVariantType;
+ VariantType myVariantType;
ResultSubShapePair myResultSubShapePair;
TypeSubShapeNamePair myTypeSubShapeNamePair;
};