if(initialize()) {
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) {
+ setByProjectionOnFace(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) {
+ } */ 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);
}
execute();
}
-/*
//==================================================================================================
-void ConstructionAPI_Point::setByProjection(const ModelHighAPI_Selection& theVertex,
- const ModelHighAPI_Selection& theFace)
+void ConstructionAPI_Point::setByProjectionOnFace(const ModelHighAPI_Selection& theVertex,
+ const ModelHighAPI_Selection& theFace)
{
- fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION(), mycreationMethod);
- fillAttribute(theVertex, mypoint);
- fillAttribute(theFace, myplane);
+ fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION_ON_FACE(),
+ mycreationMethod);
+ fillAttribute(theVertex, mypoinToProjectOnFace);
+ fillAttribute(theFace, myfaceForPointProjection);
execute();
}
+/*
//==================================================================================================
void ConstructionAPI_Point::setByLinesIntersection(const ModelHighAPI_Selection& theEdge1,
const ModelHighAPI_Selection& theEdge2)
if (aMeth == "" || // default is XYZ
aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ()) {
- theDumper << x() << ", " << y() << ", " << z() << ")" << std::endl;
+ theDumper << x() << ", " << y() << ", " << z();
} else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()) {
theDumper << intersectionLine() << ", " <<intersectionPlane() ;
if (!useOffset()->value().empty()) { // call method with defined offset
theDumper << ", " << offset() << ", " << reverseOffset();
}
- theDumper << ")" << std::endl;
- }
- else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_DISTANCE_ON_EDGE()) {
+ } else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_DISTANCE_ON_EDGE()) {
theDumper << edge() << ", ";
if (offsetType()->value() == ConstructionPlugin_Point::OFFSET_TYPE_BY_DISTANCE()) {
theDumper << distance() << ", " << false;
else {
theDumper << ratio() << ", " << true;
}
- theDumper << ", " << reverse()->value() << ")" << std::endl;
+ theDumper << ", " << reverse()->value();
+ } else if (aMeth == ConstructionPlugin_Point::CREATION_METHOD_BY_PROJECTION_ON_FACE()) {
+ theDumper << mypoinToProjectOnFace << ", " << myfaceForPointProjection;
}
+
+ theDumper << ")" << std::endl;
}
//==================================================================================================
CONSTRUCTIONAPI_EXPORT
virtual ~ConstructionAPI_Point();
- INTERFACE_14(ConstructionPlugin_Point::ID(),
+ INTERFACE_16(ConstructionPlugin_Point::ID(),
x, ConstructionPlugin_Point::X(), ModelAPI_AttributeDouble, /** X attribute */,
y, ConstructionPlugin_Point::Y(), ModelAPI_AttributeDouble, /** Y attribute */,
z, ConstructionPlugin_Point::Z(), ModelAPI_AttributeDouble, /** Z attribute */,
ratio, ConstructionPlugin_Point::RATIO(),
ModelAPI_AttributeDouble, /** Ratio */,
reverse, ConstructionPlugin_Point::REVERSE(),
- ModelAPI_AttributeBoolean, /** Reverse */)
+ ModelAPI_AttributeBoolean, /** Reverse */,
+ poinToProjectOnFace, ConstructionPlugin_Point::POINT_TO_PROJECT_ON_FACE(),
+ ModelAPI_AttributeSelection, /** Point to project on face */,
+ faceForPointProjection, ConstructionPlugin_Point::FACE_FOR_POINT_PROJECTION(),
+ ModelAPI_AttributeSelection, /** Face for point projection */)
/// Set point values.
const bool theUseRatio = false,
const bool theReverse = false);
- /*
/// Set point and plane for projection.
CONSTRUCTIONAPI_EXPORT
- void setByProjection(const ModelHighAPI_Selection& theVertex,
- const ModelHighAPI_Selection& theFace);
+ void setByProjectionOnFace(const ModelHighAPI_Selection& theVertex,
+ 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,
TestPoint_XYZ.py
TestPoint_LineAndPlane.py
TestPoint_Edge.py
+ TestPoint_ProjectOnFace.py
TestPointName.py
TestPlane.py)
data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
/*
- data()->addAttribute(POINT(), ModelAPI_AttributeSelection::typeId());
- data()->addAttribute(PLANE(), ModelAPI_AttributeSelection::typeId());
-
data()->addAttribute(FIRST_LINE(), ModelAPI_AttributeSelection::typeId());
data()->addAttribute(SECOND_LINE(), ModelAPI_AttributeSelection::typeId());
*/
data()->addAttribute(DISTANCE(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(RATIO(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(REVERSE(), ModelAPI_AttributeBoolean::typeId());
+
+ data()->addAttribute(POINT_TO_PROJECT_ON_FACE(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(FACE_FOR_POINT_PROJECTION(), 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();
- } else if(aCreationMethod == CREATION_METHOD_BY_LINES_INTERSECTION()) {
+ } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION_ON_FACE()) {
+ aShape = createByProjectionOnFace();
+ } /* else if(aCreationMethod == CREATION_METHOD_BY_LINES_INTERSECTION()) {
aShape = createByLinesIntersection();
- }*/ else if(aCreationMethod == CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()) {
+ } */ else if(aCreationMethod == CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()) {
// this may produce several points
std::list<std::shared_ptr<GeomAPI_Vertex> > aPoints = createByLineAndPlaneIntersection();
if (!aPoints.empty()) { // if no points found produce the standard error later
return GeomAlgoAPI_PointBuilder::vertexOnEdge(anEdge, aValue, anIsPercent, anIsReverse);
}
-/*
+
//==================================================================================================
-std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjection()
+std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjectionOnFace()
{
// Get point.
- AttributeSelectionPtr aPointSelection = selection(POINT());
+ AttributeSelectionPtr aPointSelection = selection(POINT_TO_PROJECT_ON_FACE());
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());
+ AttributeSelectionPtr aPlaneSelection = selection(FACE_FOR_POINT_PROJECTION());
GeomShapePtr aPlaneShape = aPlaneSelection->value();
if(!aPlaneShape.get()) {
aPlaneShape = aPlaneSelection->context()->shape();
return GeomAlgoAPI_PointBuilder::vertexByProjection(aVertex, aFace);
}
+/*
//==================================================================================================
std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByLinesIntersection()
{
return MY_CREATION_METHOD_ID;
}
- /*
/// Attribute name for creation method.
- inline static const std::string& CREATION_METHOD_BY_PROJECTION()
+ inline static const std::string& CREATION_METHOD_BY_PROJECTION_ON_FACE()
{
- static const std::string MY_CREATION_METHOD_ID("by_projection");
+ static const std::string MY_CREATION_METHOD_ID("by_projection_on_face");
return MY_CREATION_METHOD_ID;
}
+ /*
/// Attribute name for creation method.
inline static const std::string& CREATION_METHOD_BY_LINES_INTERSECTION()
{
return ATTR_ID;
}
- /*
- /// Attribute name for point.
- inline static const std::string& POINT()
+ /// Attribute name for point to project on surface.
+ inline static const std::string& POINT_TO_PROJECT_ON_FACE()
{
- static const std::string ATTR_ID("point");
+ static const std::string ATTR_ID("point_to_project_on_face");
return ATTR_ID;
}
- /// Attribute name for plane.
- inline static const std::string& PLANE()
+ /// Attribute name for face for point projection.
+ inline static const std::string& FACE_FOR_POINT_PROJECTION()
{
- static const std::string ATTR_ID("plane");
+ static const std::string ATTR_ID("face_for_point_projection");
return ATTR_ID;
}
+ /*
/// Attribute name for selected first line.
inline static const std::string& FIRST_LINE()
{
private:
std::shared_ptr<GeomAPI_Vertex> createByXYZ();
std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
- /*std::shared_ptr<GeomAPI_Vertex> createByProjection();
- std::shared_ptr<GeomAPI_Vertex> createByLinesIntersection();*/
+ std::shared_ptr<GeomAPI_Vertex> createByProjectionOnFace();
+ /*std::shared_ptr<GeomAPI_Vertex> createByLinesIntersection();*/
std::list<std::shared_ptr<GeomAPI_Vertex> > createByLineAndPlaneIntersection();
};
--- /dev/null
+## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+"""
+Test case for Construction Point feature by projection point on face.
+"""
+
+from salome.shaper import model
+from GeomAPI import *
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchPoint_1 = Sketch_1.addPoint(50, 50)
+model.do()
+Box_1 = model.addBox(Part_1_doc, 10, 100, 100)
+Point_2 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("FACE", "Box_1_1/Front"))
+Point_3 = model.addPoint(Part_1_doc, model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("FACE", "PartSet/XOY"))
+model.do()
+model.end()
+
+assert (len(Point_2.results()) > 0)
+rightPosition = GeomAPI_Vertex(10, 0, 50)
+assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape()))
+
+assert (len(Point_3.results()) > 0)
+rightPosition = GeomAPI_Vertex(50, 0, 0)
+assert(rightPosition.isEqual(Point_3.results()[0].resultSubShapePair()[0].shape()))
+
+assert(model.checkPythonDump())
tooltip="Distance from edge end point."
default="false"/>
</box>
-<!--
- <box id="by_projection"
- title="By projection"
+ <box id="by_projection_on_face"
+ title="By projection on face"
tooltip="Point on face surface by projection selected point."
- icon="icons/Construction/point_by_projection_32x32.png">
- <shape_selector id="point"
+ icon="icons/Construction/point_by_projection_on_face_32x32.png">
+ <shape_selector id="point_to_project_on_face"
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."
+ <shape_selector id="face_for_point_projection"
+ label="face"
+ tooltip="Face for projection."
icon="icons/Construction/face.png"
shape_types="face">
<validator id="GeomValidators_Face" parameters="plane"/>
</shape_selector>
</box>
+<!--
<box id="by_lines_intersection"
title="By two lines intersection"
tooltip="Point by intersection of two coplanar lines."
//==================================================================================================
std::shared_ptr<GeomAPI_Vertex> GeomAlgoAPI_PointBuilder::vertexByProjection(
const std::shared_ptr<GeomAPI_Vertex> theVertex,
- const std::shared_ptr<GeomAPI_Face> thePlane)
+ const std::shared_ptr<GeomAPI_Face> theFace)
{
std::shared_ptr<GeomAPI_Vertex> aVertex;
- if(!theVertex.get() || !thePlane.get() || !thePlane->isPlanar()) {
+ if(!theVertex.get() || !theFace.get() || !theFace->isPlanar()) {
return aVertex;
}
std::shared_ptr<GeomAPI_Pnt> aProjPnt = theVertex->point();
- std::shared_ptr<GeomAPI_Pln> aProjPln = thePlane->getPlane();
+ std::shared_ptr<GeomAPI_Pln> aProjPln = theFace->getPlane();
std::shared_ptr<GeomAPI_Pnt> aPnt = aProjPln->project(aProjPnt);
/// \brief Creates vertex by projection another vertex on plane.
/// \param[in] theVertex vertex to project.
- /// \param[in] thePlane face for projection. Should be planar.
+ /// \param[in] theFace 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);
+ const std::shared_ptr<GeomAPI_Face> theFace);
/// \brief Creates vertex by intersection two coplanar lines.
/// \param[in] theEdge1 first linear edge.
END_INIT() \
public:
+//--------------------------------------------------------------------------------------
+#define INTERFACE_16(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, \
+ N_14, AN_14, T_14, C_14, \
+ N_15, AN_15, T_15, C_15) \
+ 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) \
+ DEFINE_ATTRIBUTE(N_14, T_14, C_14) \
+ DEFINE_ATTRIBUTE(N_15, T_15, C_15) \
+ 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) \
+ SET_ATTRIBUTE(N_14, T_14, AN_14) \
+ SET_ATTRIBUTE(N_15, T_15, AN_15) \
+ END_INIT() \
+ public:
+
//--------------------------------------------------------------------------------------
#define INTERFACE_20(KIND, \
N_0, AN_0, T_0, C_0, \