const ModelHighAPI_Selection & theFace,
const ModelHighAPI_Double & theDistance)
{
+ fillAttribute("PlaneByFaceAndDistance", mycreationMethod);
fillAttribute(theFace, myface);
fillAttribute(theDistance, mydistance);
const ModelHighAPI_Double & theC,
const ModelHighAPI_Double & theD)
{
+ fillAttribute("PlaneByGeneralEquation", mycreationMethod);
fillAttribute(theA, myA);
fillAttribute(theB, myB);
fillAttribute(theC, myC);
}
}
+//==================================================================================================
+ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theObject1,
+ const ModelHighAPI_Selection& theObject2)
+: ModelHighAPI_Interface(theFeature)
+{
+ if(initialize()) {
+ /// If first object is vertex and second object is face then set by projection.
+ /// TODO: check
+ setByProjection(theObject1, theObject2);
+ }
+}
+
//==================================================================================================
ConstructionAPI_Point::~ConstructionAPI_Point()
{
execute();
}
+//==================================================================================================
+void ConstructionAPI_Point::setByProjection(const ModelHighAPI_Selection& theVertex,
+ const ModelHighAPI_Selection& thePlane)
+{
+ fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION(), mycreationMethod);
+ fillAttribute(theVertex, mypoint);
+ fillAttribute(thePlane, myplane);
+
+ execute();
+}
+
//==================================================================================================
PointPtr addPoint(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Double& theX,
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
return PointPtr(new ConstructionAPI_Point(aFeature, theEdge, theDistanceValue, theDistancePercent, theReverse));
}
+
+//==================================================================================================
+PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const ModelHighAPI_Selection& theObject1,
+ const ModelHighAPI_Selection& theObject2)
+{
+ // TODO(spo): check that thePart is not empty
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
+ return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2));
+}
/// \class ConstructionAPI_Point
/// \ingroup CPPHighAPI
-/// \brief Interface for Point feature
+/// \brief Interface for Point feature.
class ConstructionAPI_Point: public ModelHighAPI_Interface
{
public:
- /// Constructor without values
+ /// Constructor without values.
CONSTRUCTIONAPI_EXPORT
explicit ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature);
- /// Constructor with values
+ /// Constructor with values.
CONSTRUCTIONAPI_EXPORT
ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Double& theX,
const ModelHighAPI_Double& theY,
const ModelHighAPI_Double& theZ);
- /// Constructor with values
+ /// Constructor with values.
CONSTRUCTIONAPI_EXPORT
ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Selection& theEdge,
const bool theDistancePercent = false,
const bool theReverse = false);
- /// Destructor
+ /// Constructor with values.
+ CONSTRUCTIONAPI_EXPORT
+ ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theObject1,
+ const ModelHighAPI_Selection& theObject2);
+
+ /// Destructor.
CONSTRUCTIONAPI_EXPORT
virtual ~ConstructionAPI_Point();
- INTERFACE_8(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 */,
- z, ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble, /** Z attribute */,
- edge, ConstructionPlugin_Point::EDGE(), ModelAPI_AttributeSelection, /** Edge attribute */,
- distanceValue, ConstructionPlugin_Point::DISTANCE_VALUE(), ModelAPI_AttributeDouble, /** Distance value attribute */,
- distancePercent, ConstructionPlugin_Point::DISTANCE_PERCENT(), ModelAPI_AttributeBoolean, /** Distance percent attribute */,
- reverse, ConstructionPlugin_Point::REVERSE(), ModelAPI_AttributeBoolean, /** Reverse attribute */
+ INTERFACE_10(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 */,
+ z, ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble, /** Z attribute */,
+ edge, ConstructionPlugin_Point::EDGE(), ModelAPI_AttributeSelection, /** Edge attribute */,
+ distanceValue, ConstructionPlugin_Point::DISTANCE_VALUE(), ModelAPI_AttributeDouble, /** Distance value 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 */
)
- /// Set point values
+ /// Set point values.
CONSTRUCTIONAPI_EXPORT
void setByXYZ(const ModelHighAPI_Double & theX,
const ModelHighAPI_Double & theY,
const ModelHighAPI_Double & theZ);
- /// Set edge and distance on it for point
+ /// Set edge and distance on it for point.
CONSTRUCTIONAPI_EXPORT
void setByDistanceOnEdge(const ModelHighAPI_Selection& theEdge,
const ModelHighAPI_Double& theDistanceValue,
const bool theDistancePercent = false,
const bool theReverse = false);
+
+ /// Set point and plane for projection.
+ CONSTRUCTIONAPI_EXPORT
+ void setByProjection(const ModelHighAPI_Selection& theVertex,
+ const ModelHighAPI_Selection& thePlane);
};
-/// Pointer on Point object
+/// Pointer on Point object.
typedef std::shared_ptr<ConstructionAPI_Point> PointPtr;
/// \ingroup CPPHighAPI
const bool theDistancePercent = false,
const bool theReverse = false);
+/// \ingroup CPPHighAPI
+/// \brief Create Point feature
+CONSTRUCTIONAPI_EXPORT
+PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const ModelHighAPI_Selection& theObject1,
+ const ModelHighAPI_Selection& theObject2);
+
#endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_POINT_H_ */
ADD_UNIT_TESTS(TestAxisCreation.py
- TestPointName.py)
+ TestPointName.py
+ TestPoint.py)
#include <ModelAPI_ResultConstruction.h>
#include <GeomAlgoAPI_PointBuilder.h>
-#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Vertex.h>
//==================================================================================================
ConstructionPlugin_Point::ConstructionPlugin_Point()
data()->addAttribute(DISTANCE_VALUE(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(DISTANCE_PERCENT(), ModelAPI_AttributeBoolean::typeId());
data()->addAttribute(REVERSE(), ModelAPI_AttributeBoolean::typeId());
+
+ data()->addAttribute(POINT(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(PLANE(), ModelAPI_AttributeSelection::typeId());
}
//==================================================================================================
aShape = createByXYZ();
} else if(aCreationMethod == CREATION_METHOD_BY_DISTANCE_ON_EDGE()) {
aShape = createByDistanceOnEdge();
+ } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION()) {
+ aShape = createByProjection();
}
if(aShape.get()) {
}
//==================================================================================================
-GeomShapePtr ConstructionPlugin_Point::createByXYZ()
+std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByXYZ()
{
- return GeomAlgoAPI_PointBuilder::point(real(X())->value(),
- real(Y())->value(),
- real(Z())->value());
+ return GeomAlgoAPI_PointBuilder::vertex(real(X())->value(),
+ real(Y())->value(),
+ real(Z())->value());
}
//==================================================================================================
-GeomShapePtr ConstructionPlugin_Point::createByDistanceOnEdge()
+std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByDistanceOnEdge()
{
// Get edge.
AttributeSelectionPtr anEdgeSelection = selection(EDGE());
// Get reverse flag.
bool anIsReverse = boolean(REVERSE())->value();
- return GeomAlgoAPI_ShapeTools::findVertexOnEdge(anEdge, aValue, anIsPercent, anIsReverse);
+ return GeomAlgoAPI_PointBuilder::vertexOnEdge(anEdge, aValue, anIsPercent, anIsReverse);
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjection()
+{
+ // Get point.
+ AttributeSelectionPtr aPointSelection = selection(POINT());
+ GeomShapePtr aPointShape = aPointSelection->value();
+ if(!aPointShape.get()) {
+ aPointShape = aPointSelection->context()->shape();
+ }
+ std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aPointShape));
+
+ // Get plane.
+ AttributeSelectionPtr aPlaneSelection = selection(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::vertexByProjection(aVertex, aFace);
}
#include <ModelAPI_Feature.h>
#include <ModelAPI_Result.h>
+class GeomAPI_Vertex;
+
/// \class ConstructionPlugin_Point
/// \ingroup Plugins
/// \brief Feature for creation of the new part in PartSet.
return MY_CREATION_METHOD_ID;
}
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_PROJECTION()
+ {
+ static const std::string MY_CREATION_METHOD_ID("by_projection");
+ return MY_CREATION_METHOD_ID;
+ }
+
/// Attribute name for X coordinate.
inline static const std::string& X()
{
return ATTR_ID;
}
+ /// Attribute name for point.
+ inline static const std::string& POINT()
+ {
+ static const std::string ATTR_ID("point");
+ return ATTR_ID;
+ }
+
+ /// Attribute name for plane.
+ inline static const std::string& PLANE()
+ {
+ static const std::string ATTR_ID("plane");
+ return ATTR_ID;
+ }
+
/// Creates a new part document if needed.
CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
private:
- std::shared_ptr<GeomAPI_Shape> createByXYZ();
- std::shared_ptr<GeomAPI_Shape> createByDistanceOnEdge();
+ std::shared_ptr<GeomAPI_Vertex> createByXYZ();
+ std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
+ std::shared_ptr<GeomAPI_Vertex> createByProjection();
};
--- /dev/null
+"""
+Test case for Construction Point feature. Written on High API.
+"""
+from ModelAPI import *
+from GeomAPI import *
+
+import model
+
+# Get session
+aSession = ModelAPI_Session.get()
+
+# Create a part
+aDocument = aSession.activeDocument()
+aSession.startOperation()
+model.addPart(aDocument)
+aDocument = aSession.activeDocument()
+aSession.finishOperation()
+
+# Create a point by coordinates
+aSession.startOperation()
+aPoint = model.addPoint(aDocument, 50, 50, 50)
+aSession.finishOperation()
+assert (len(aPoint.result()) > 0)
+
+# Create a sketch with line
+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)
+aSession.finishOperation()
+
+# Create a point on line
+aSession.startOperation()
+aPoint = model.addPoint(aDocument, aSketchLine.result()[0], 50, True, False)
+aSession.finishOperation()
+assert (len(aPoint.result()) > 0)
+
+# Create plane
+aSession.startOperation()
+aPlane = model.addPlane(aDocument, 1, 1, 1, 1)
+aSession.finishOperation()
+
+# Create a point by projection
+aSession.startOperation()
+aPoint = model.addPoint(aDocument, aPoint.result()[0], aPlane.result()[0])
+aSession.finishOperation()
+assert (len(aPoint.result()) > 0)
tooltip="Distance from edge end point."
default="false"/>
</box>
+ <box id="by_projection"
+ title="By projection"
+ tooltip="Point on face surface by projection selected point."
+ icon="icons/Construction/point_by_projection_32x32.png">
+ <shape_selector id="point"
+ label="Point"
+ tooltip="Point for projection."
+ icon="icons/Construction/point.png"
+ shape_types="vertex">
+ </shape_selector>
+ <shape_selector id="plane"
+ label="Plane"
+ tooltip="Plane for projection."
+ icon="icons/Construction/face.png"
+ shape_types="face">
+ <validator id="GeomValidators_Face" parameters="plane"/>
+ </shape_selector>
+ </box>
</toolbox>
</source>
class GeomAPI_Pnt;
-/**\class GeomAPI_Vertex
-* \ingroup DataModel
- * \brief Interface to the vertex object
- */
-
-class GeomAPI_Vertex : public GeomAPI_Shape
+/// \class GeomAPI_Vertex
+/// \ingroup DataModel
+/// \brief Interface to the vertex object.
+class GeomAPI_Vertex: public GeomAPI_Shape
{
public:
- /// Creation of empty (null) shape
- GEOMAPI_EXPORT
- GeomAPI_Vertex();
+ /// Creation of empty (null) shape.
+ GEOMAPI_EXPORT
+ GeomAPI_Vertex();
- /// Creation of vertex by the vertex-shape
- GEOMAPI_EXPORT
- GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Shape>& theShape);
+ /// Creation of vertex by the vertex-shape.
+ GEOMAPI_EXPORT
+ GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Shape>& theShape);
- /// Creation of vertex by 3d coordinates
- GEOMAPI_EXPORT
- GeomAPI_Vertex(double theX, double theY, double theZ);
+ /// Creation of vertex by 3d coordinates.
+ GEOMAPI_EXPORT
+ GeomAPI_Vertex(double theX, double theY, double theZ);
- /// Returns the first vertex coordinates of the edge
- GEOMAPI_EXPORT
+ /// Returns the first vertex coordinates of the edge.
+ GEOMAPI_EXPORT
std::shared_ptr<GeomAPI_Pnt> point();
- /// Returns true if the current edge is geometrically equal to the given edge
- GEOMAPI_EXPORT
+ /// Returns true if the current edge is geometrically equal to the given edge.
+ GEOMAPI_EXPORT
bool isEqual(const std::shared_ptr<GeomAPI_Shape> theVert) const;
};
// Created: 02 Jun 2014
// Author: Mikhail PONIKAROV
-#include <GeomAlgoAPI_PointBuilder.h>
+#include "GeomAlgoAPI_PointBuilder.h"
+
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Face.h>
+#include <GeomAPI_Pln.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_Vertex.h>
-#include <BRepBuilderAPI_MakeVertex.hxx>
+
#include <BRep_Tool.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <gp_Pln.hxx>
#include <gp_Pnt.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
- std::shared_ptr<GeomAPI_Pnt> thePoint)
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertex(const std::shared_ptr<GeomAPI_Pnt> thePoint)
{
const gp_Pnt& aPnt = thePoint->impl<gp_Pnt>();
BRepBuilderAPI_MakeVertex aMaker(aPnt);
return aRes;
}
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
- const double theX, const double theY, const double theZ)
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertex(const double theX,
+ const double theY,
+ const double theZ)
{
const gp_Pnt aPnt(theX, theY, theZ);
BRepBuilderAPI_MakeVertex aMaker(aPnt);
return aRes;
}
-std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_PointBuilder::point(std::shared_ptr<GeomAPI_Shape> theVertex)
+//==================================================================================================
+std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_PointBuilder::point(const std::shared_ptr<GeomAPI_Shape> theVertex)
{
TopoDS_Shape aShape = theVertex->impl<TopoDS_Shape>();
if ((!aShape.IsNull()) && (aShape.ShapeType() == TopAbs_VERTEX)) {
}
return std::shared_ptr<GeomAPI_Pnt>();
}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexOnEdge(const std::shared_ptr<GeomAPI_Edge> theEdge,
+ const double theValue,
+ const bool theIsPercent,
+ const bool theIsReverse)
+{
+ if(!theEdge.get()) {
+ return NULL;
+ }
+
+ double aValue = theValue;
+ if(theIsPercent) {
+ aValue = theEdge->length() / 100.0 * aValue;
+ }
+
+ const TopoDS_Edge& anEdge = TopoDS::Edge(theEdge->impl<TopoDS_Shape>());
+ Standard_Real aUFirst, aULast;
+ Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(anEdge, aUFirst, aULast);
+
+ std::shared_ptr<GeomAPI_Vertex> aVertex;
+ if(!anEdgeCurve.IsNull() ) {
+ Handle(Geom_Curve) aReOrientedCurve = anEdgeCurve;
+
+ if(theIsReverse) {
+ aReOrientedCurve = anEdgeCurve->Reversed();
+ aUFirst = anEdgeCurve->ReversedParameter(aULast);
+ }
+
+ // Get the point by length
+ GeomAdaptor_Curve anAdapCurve = GeomAdaptor_Curve(aReOrientedCurve);
+ GCPnts_AbscissaPoint anAbsPnt(anAdapCurve, aValue, aUFirst);
+ Standard_Real aParam = anAbsPnt.Parameter();
+ gp_Pnt aPnt = anAdapCurve.Value(aParam);
+ BRepBuilderAPI_MakeVertex aMkVertex(aPnt);
+ const TopoDS_Vertex& aShape = aMkVertex.Vertex();
+ aVertex.reset(new GeomAPI_Vertex());
+ aVertex->setImpl(new TopoDS_Vertex(aShape));
+ }
+
+ return aVertex;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByProjection(
+ const std::shared_ptr<GeomAPI_Vertex> theVertex,
+ const std::shared_ptr<GeomAPI_Face> thePlane)
+{
+ if(!theVertex.get() || !thePlane.get() || !thePlane->isPlanar()) {
+ return NULL;
+ }
+
+ std::shared_ptr<GeomAPI_Pnt> aGeomPnt = theVertex->point();
+ gp_Pnt aPnt = aGeomPnt->impl<gp_Pnt>();
+
+ std::shared_ptr<GeomAPI_Pln> aGeomPln = thePlane->getPlane();
+ gp_Pln aPln = aGeomPln->impl<gp_Pln>();
+
+ gp_Dir aPntAxis = aPnt.XYZ() - aPln.Location().XYZ();
+ gp_Dir aPlnNorm = aPln.Axis().Direction();
+
+ if(aPntAxis * aPlnNorm > 0) {
+ aPlnNorm.Reverse();
+ }
+
+ double aDistance = aPln.Distance(aPnt);
+ aPnt.Translate(gp_Vec(aPlnNorm) * aDistance);
+
+ return std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(aPnt.X(), aPnt.Y(), aPnt.Z()));
+}
#include <GeomAlgoAPI.h>
#include <memory>
-class GeomAPI_Shape;
+class GeomAPI_Edge;
+class GeomAPI_Face;
class GeomAPI_Pnt;
+class GeomAPI_Shape;
+class GeomAPI_Vertex;
-/**\class GeomAlgoAPI_PointBuilder
- * \ingroup DataAlgo
- * \brief Allows to create face-shapes by different parameters
- */
-
+/// \class GeomAlgoAPI_PointBuilder
+/// \ingroup DataAlgo
+/// \brief Allows to create vertex-shapes by different parameters
class GEOMALGOAPI_EXPORT GeomAlgoAPI_PointBuilder
{
- public:
- /// Creates a shape by point
- static std::shared_ptr<GeomAPI_Shape> point(std::shared_ptr<GeomAPI_Pnt> thePoint);
-
- /// Creates a shape by point coordinates
- static std::shared_ptr<GeomAPI_Shape> point(
- const double theX, const double theY, const double theZ);
+public:
+ /// Creates a vertex by point
+ static std::shared_ptr<GeomAPI_Vertex> vertex(const std::shared_ptr<GeomAPI_Pnt> thePoint);
+
+ /// Creates a vertex by point coordinates
+ static std::shared_ptr<GeomAPI_Vertex> vertex(const double theX,
+ const double theY,
+ const double theZ);
+
+ /// \brief Creates vertex by edge and distance on it.
+ /// \param[in] theEdge edge.
+ /// \param[in] theValue distance value.
+ /// \param[in] theIsPercent if true theValue will be treated as a percentage of theEdge total length.
+ /// \param[in] theIsReverse if true the distance will be measured from the edge end point.
+ /// \return created vertex.
+ static std::shared_ptr<GeomAPI_Vertex> vertexOnEdge(const std::shared_ptr<GeomAPI_Edge> theEdge,
+ const double theValue,
+ const bool theIsPercent = false,
+ const bool theIsReverse = false);
+
+ /// \brief Creates vertex by projection another vertex on plane.
+ /// \param[in] theVertex vertex to project.
+ /// \param[in] thePlane face for projection. Should be planar.
+ /// \return created vertex.
+ static std::shared_ptr<GeomAPI_Vertex> vertexByProjection(const std::shared_ptr<GeomAPI_Vertex> theVertex,
+ const std::shared_ptr<GeomAPI_Face> thePlane);
/// Return point by shape vertex
- static std::shared_ptr<GeomAPI_Pnt> point(std::shared_ptr<GeomAPI_Shape> theVertex);
+ static std::shared_ptr<GeomAPI_Pnt> point(const std::shared_ptr<GeomAPI_Shape> theVertex);
};
#endif
#include "GeomAlgoAPI_SketchBuilder.h"
+#include <GeomAPI_Edge.h>
#include <GeomAPI_Dir.h>
#include <GeomAPI_Face.h>
-#include <GeomAPI_PlanarEdges.h>
#include <GeomAPI_Pln.h>
#include <GeomAPI_Pnt.h>
#include <BRepAlgo_FaceRestrictor.hxx>
#include <BRepBndLib.hxx>
#include <BRepBuilderAPI_FindPlane.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRepGProp.hxx>
#include <BRepTools.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
-#include <GCPnts_AbscissaPoint.hxx>
-#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
+#include <Handle_Geom2d_Curve.hxx>
#include <BRepLib_CheckCurveOnSurface.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Plane.hxx>
#include <GeomLib_IsPlanarSurface.hxx>
#include <GeomLib_Tool.hxx>
-#include <GeomProjLib.hxx>
#include <gp_Pln.hxx>
#include <GProp_GProps.hxx>
#include <IntAna_IntConicQuad.hxx>
BRepExtrema_ExtCF anExt(anEdge, aFace);
return anExt.IsParallel() == Standard_True;
}
-
-//==================================================================================================
-std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_ShapeTools::findVertexOnEdge(const std::shared_ptr<GeomAPI_Edge> theEdge,
- const double theValue,
- const bool theIsPercent,
- const bool theIsReverse)
-{
- std::shared_ptr<GeomAPI_Vertex> aVertex;
-
- if(!theEdge.get()) {
- return aVertex;
- }
-
- double aValue = theValue;
- if(theIsPercent) {
- aValue = theEdge->length() / 100.0 * aValue;
- }
-
- const TopoDS_Edge& anEdge = TopoDS::Edge(theEdge->impl<TopoDS_Shape>());
- Standard_Real aUFirst, aULast;
- Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(anEdge, aUFirst, aULast);
-
- if(!anEdgeCurve.IsNull() ) {
- Handle(Geom_Curve) aReOrientedCurve = anEdgeCurve;
-
- if(theIsReverse) {
- aReOrientedCurve = anEdgeCurve->Reversed();
- aUFirst = anEdgeCurve->ReversedParameter(aULast);
- }
-
- // Get the point by length
- GeomAdaptor_Curve anAdapCurve = GeomAdaptor_Curve(aReOrientedCurve);
- GCPnts_AbscissaPoint anAbsPnt(anAdapCurve, aValue, aUFirst);
- Standard_Real aParam = anAbsPnt.Parameter();
- gp_Pnt aPnt = anAdapCurve.Value(aParam);
- BRepBuilderAPI_MakeVertex aMkVertex(aPnt);
- const TopoDS_Vertex& aShape = aMkVertex.Vertex();
- aVertex.reset(new GeomAPI_Vertex());
- aVertex->setImpl(new TopoDS_Vertex(aShape));
- }
-
- return aVertex;
-}
/// \return true if edge is parallel to face.
GEOMALGOAPI_EXPORT static bool isParallel(const std::shared_ptr<GeomAPI_Edge> theEdge,
const std::shared_ptr<GeomAPI_Face> theFace);
-
- /// \brief Creates vertex by edge and distance on it.
- /// \param[in] theEdge edge.
- /// \param[in] theValue distance value.
- /// \param[in] theIsPercent if true theValue will be treated as a percentage of theEdge total length.
- /// \param[in] theIsReverse if true the distance will be measured from the edge end point.
- /// \ return created vertex.
- GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Vertex> findVertexOnEdge(const std::shared_ptr<GeomAPI_Edge> theEdge,
- const double theValue,
- const bool theIsPercent = false,
- const bool theIsReverse = false);
-
};
#endif
#include <GeomAPI_Lin2d.h>
#include <GeomAPI_Lin.h>
#include <GeomAPI_Pnt2d.h>
+#include <GeomAPI_Vertex.h>
#include <GeomAPI_XY.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Dir.h>
std::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
// make a visible point
- std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
+ std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter);
std::shared_ptr<ModelAPI_ResultConstruction> aConstr1 = document()->createConstruction(
data(), 0);
aConstr1->setShape(aCenterPointShape);
}
}
// make a visible point
- std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
+ std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter);
aShapes.push_back(aCenterPointShape);
}
if (!aShapes.empty()) {
#include <GeomAPI_Pnt2d.h>
#include <GeomAPI_Circ.h>
#include <GeomAPI_Circ2d.h>
+#include <GeomAPI_Vertex.h>
#include <GeomAPI_XY.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomDataAPI_Dir.h>
if (aCircleShape && aRadius != 0) {
std::list<std::shared_ptr<GeomAPI_Shape> > aShapes;
// make a visible point
- std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
+ std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter);
aShapes.push_back(aCenterPointShape);
aShapes.push_back(aCircleShape);
data()->attribute(SketchPlugin_Point::COORD_ID()));
std::shared_ptr<GeomAPI_Pnt> aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y()));
// make a visible point
- std::shared_ptr<GeomAPI_Shape> aPointShape = GeomAlgoAPI_PointBuilder::point(aPoint3D);
+ std::shared_ptr<GeomAPI_Shape> aPointShape = GeomAlgoAPI_PointBuilder::vertex(aPoint3D);
std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
aConstr->setShape(aPointShape);
aConstr->setIsInHistory(false);
#include <GeomAPI_Dir.h>
#include <GeomAPI_PlanarEdges.h>
+#include <GeomAPI_Vertex.h>
#include <GeomDataAPI_Point2D.h>
#include <GeomAlgoAPI_PointBuilder.h>
std::shared_ptr<GeomAPI_Pnt> aCenter(theSketch->to3D(aPoint->x(), aPoint->y()));
//std::cout<<"Execute circle "<<aCenter->x()<<" "<<aCenter->y()<<" "<<aCenter->z()<<std::endl;
// make a visible point
- std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
+ std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter);
std::shared_ptr<ModelAPI_ResultConstruction> aResult = theFeature->document()->createConstruction(
theFeature->data(), theIndex);
aResult->setShape(aCenterPointShape);