Implemented with toolbox widgets which should be later replaced by radio buttons.
}
}
-/*//==================================================================================================
+//==================================================================================================
ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Selection& theEdge,
- const ModelHighAPI_Double& theDistanceValue,
- const bool theDistancePercent,
+ const ModelHighAPI_Double& theOffset,
+ const bool theUseRatio,
const bool theReverse)
: ModelHighAPI_Interface(theFeature)
{
if(initialize()) {
- setByDistanceOnEdge(theEdge, theDistanceValue, theDistancePercent, theReverse);
+ setByOffsetOnEdge(theEdge, theOffset, theUseRatio, theReverse);
}
-}*/
+}
//==================================================================================================
ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
execute(false);
}
-/*//==================================================================================================
-void ConstructionAPI_Point::setByDistanceOnEdge(const ModelHighAPI_Selection& theEdge,
- const ModelHighAPI_Double& theDistanceValue,
- const bool theDistancePercent,
- const bool theReverse)
+//==================================================================================================
+void ConstructionAPI_Point::setByOffsetOnEdge(const ModelHighAPI_Selection& theEdge,
+ const ModelHighAPI_Double& theOffset,
+ const bool theUseRatio,
+ const bool theReverse)
{
fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_DISTANCE_ON_EDGE(), mycreationMethod);
fillAttribute(theEdge, myedge);
- fillAttribute(theDistanceValue, mydistanceValue);
- fillAttribute(theDistancePercent, mydistancePercent);
+ if (theUseRatio) {
+ fillAttribute(ConstructionPlugin_Point::OFFSET_TYPE_BY_RATIO(), myoffsetType);
+ fillAttribute(theOffset, myratio);
+ }
+ else {
+ fillAttribute(ConstructionPlugin_Point::OFFSET_TYPE_BY_DISTANCE(), myoffsetType);
+ fillAttribute(theOffset, mydistance);
+ }
fillAttribute(theReverse, myreverse);
execute();
}
+/*
//==================================================================================================
void ConstructionAPI_Point::setByProjection(const ModelHighAPI_Selection& theVertex,
const ModelHighAPI_Selection& theFace)
fillAttribute(theEdge2, mysecondLine);
execute();
-}*/
+}
+*/
//==================================================================================================
void ConstructionAPI_Point::setByLineAndPlaneIntersection(const ModelHighAPI_Selection& theEdge,
}
theDumper << ")" << std::endl;
}
+ 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;
+ }
}
//==================================================================================================
return PointPtr(new ConstructionAPI_Point(aFeature, theX, theY, theZ));
}
-/*//==================================================================================================
+//==================================================================================================
PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
const ModelHighAPI_Selection& theEdge,
- const ModelHighAPI_Double& theDistanceValue,
- const bool theDistancePercent,
+ const ModelHighAPI_Double& theOffset,
+ const bool theUseRatio,
const bool theReverse)
{
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
- return PointPtr(new ConstructionAPI_Point(aFeature, theEdge, theDistanceValue, theDistancePercent, theReverse));
-}*/
+ return PointPtr(new ConstructionAPI_Point(aFeature, theEdge, theOffset, theUseRatio, theReverse));
+}
//==================================================================================================
PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
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 ModelHighAPI_Double& theDistanceValue,
- const bool theDistancePercent = false,
+ const ModelHighAPI_Double& theOffset,
+ const bool theUseRatio = false,
const bool theReverse = false);
- */
+
/// Constructor with values: intersected objects.
CONSTRUCTIONAPI_EXPORT
ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
CONSTRUCTIONAPI_EXPORT
virtual ~ConstructionAPI_Point();
- INTERFACE_9(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 */,
- creationMethod, ConstructionPlugin_Point::CREATION_METHOD(),
- ModelAPI_AttributeString, /** Creation method */,
- intersectionLine, ConstructionPlugin_Point::INTERSECTION_LINE(),
- ModelAPI_AttributeSelection, /** Line for intersection */,
- intersectionPlane, ConstructionPlugin_Point::INTERSECTION_PLANE(),
- ModelAPI_AttributeSelection, /** Plane for intersection */,
- useOffset, ConstructionPlugin_Point::USE_OFFSET(),
- ModelAPI_AttributeString, /** Use offset */,
- offset, ConstructionPlugin_Point::OFFSET(),
- ModelAPI_AttributeDouble, /** Offset */,
- reverseOffset, ConstructionPlugin_Point::REVERSE_OFFSET(),
- ModelAPI_AttributeBoolean, /** Reverse offset */)
+ INTERFACE_14(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 */,
+ creationMethod, ConstructionPlugin_Point::CREATION_METHOD(),
+ ModelAPI_AttributeString, /** Creation method */,
+ intersectionLine, ConstructionPlugin_Point::INTERSECTION_LINE(),
+ ModelAPI_AttributeSelection, /** Line for intersection */,
+ intersectionPlane, ConstructionPlugin_Point::INTERSECTION_PLANE(),
+ ModelAPI_AttributeSelection, /** Plane for intersection */,
+ useOffset, ConstructionPlugin_Point::USE_OFFSET(),
+ ModelAPI_AttributeString, /** Use offset */,
+ offset, ConstructionPlugin_Point::OFFSET(),
+ ModelAPI_AttributeDouble, /** Offset */,
+ reverseOffset, ConstructionPlugin_Point::REVERSE_OFFSET(),
+ ModelAPI_AttributeBoolean, /** Reverse offset */,
+ edge, ConstructionPlugin_Point::EDGE(),
+ ModelAPI_AttributeSelection, /** Edge */,
+ offsetType, ConstructionPlugin_Point::OFFSET_TYPE(),
+ ModelAPI_AttributeString, /** Type of the offset on edge */,
+ distance, ConstructionPlugin_Point::DISTANCE(),
+ ModelAPI_AttributeDouble, /** Distance */,
+ ratio, ConstructionPlugin_Point::RATIO(),
+ ModelAPI_AttributeDouble, /** Ratio */,
+ reverse, ConstructionPlugin_Point::REVERSE(),
+ ModelAPI_AttributeBoolean, /** Reverse */)
/// Set point values.
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);
+ void setByOffsetOnEdge(const ModelHighAPI_Selection& theEdge,
+ const ModelHighAPI_Double& theOffset,
+ const bool theUseRatio = false,
+ const bool theReverse = false);
+ /*
/// Set point and plane for projection.
CONSTRUCTIONAPI_EXPORT
void setByProjection(const ModelHighAPI_Selection& theVertex,
const ModelHighAPI_Double & theY,
const ModelHighAPI_Double & theZ);
-/*/// \ingroup CPPHighAPI
+/// \ingroup CPPHighAPI
/// \brief Create Point feature
CONSTRUCTIONAPI_EXPORT
PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
const ModelHighAPI_Selection& theEdge,
- const ModelHighAPI_Double& theDistanceValue,
- const bool theDistancePercent = false,
+ const ModelHighAPI_Double& theOffset,
+ const bool theUseRatio = false,
const bool theReverse = false);
-*/
+
/// \ingroup CPPHighAPI
/// \brief Create Point feature as an intersection of selected plane (or planar face) and edge
CONSTRUCTIONAPI_EXPORT
UnitTestAxis.py
TestPoint_XYZ.py
TestPoint_LineAndPlane.py
+ TestPoint_Edge.py
TestPointName.py
TestPlane.py)
data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
- /*data()->addAttribute(EDGE(), ModelAPI_AttributeSelection::typeId());
- 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());
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());
data()->addAttribute(USE_OFFSET(), ModelAPI_AttributeString::typeId());
data()->addAttribute(OFFSET(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(REVERSE_OFFSET(), ModelAPI_AttributeBoolean::typeId());
+
+ data()->addAttribute(EDGE(), ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(OFFSET_TYPE(), ModelAPI_AttributeString::typeId());
+ data()->addAttribute(DISTANCE(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(RATIO(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(REVERSE(), ModelAPI_AttributeBoolean::typeId());
}
//==================================================================================================
string(CREATION_METHOD())->value() : CREATION_METHOD_BY_XYZ();
if(aCreationMethod == CREATION_METHOD_BY_XYZ()) {
aShape = createByXYZ();
- }/* else if(aCreationMethod == CREATION_METHOD_BY_DISTANCE_ON_EDGE()) {
+ } else if(aCreationMethod == CREATION_METHOD_BY_DISTANCE_ON_EDGE()) {
aShape = createByDistanceOnEdge();
- } else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION()) {
+ }/* else if(aCreationMethod == CREATION_METHOD_BY_PROJECTION()) {
aShape = createByProjection();
} else if(aCreationMethod == CREATION_METHOD_BY_LINES_INTERSECTION()) {
aShape = createByLinesIntersection();
real(Z())->value());
}
-/*//==================================================================================================
+//==================================================================================================
std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByDistanceOnEdge()
{
// Get edge.
std::shared_ptr<GeomAPI_Edge> anEdge(new GeomAPI_Edge(aShape));
// Get distance value and percent flag.
- double aValue = real(DISTANCE_VALUE())->value();
- bool anIsPercent = boolean(DISTANCE_PERCENT())->value();
+ double aValue;
+ bool anIsPercent = false;
+ if (string(OFFSET_TYPE())->value() == OFFSET_TYPE_BY_DISTANCE()) {
+ aValue = real(DISTANCE())->value();
+ anIsPercent = false;
+ } else {
+ aValue = real(RATIO())->value() * 100.0;
+ anIsPercent = true;
+ }
// Get reverse flag.
bool anIsReverse = boolean(REVERSE())->value();
return GeomAlgoAPI_PointBuilder::vertexOnEdge(anEdge, aValue, anIsPercent, anIsReverse);
}
-
+/*
//==================================================================================================
std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByProjection()
{
static const std::string MY_CREATION_METHOD_ID("by_xyz");
return MY_CREATION_METHOD_ID;
}
- /*
+
/// Attribute name for creation method.
inline static const std::string& CREATION_METHOD_BY_DISTANCE_ON_EDGE()
{
return MY_CREATION_METHOD_ID;
}
+ /*
/// Attribute name for creation method.
inline static const std::string& CREATION_METHOD_BY_PROJECTION()
{
return MY_CREATION_METHOD_ID;
}
*/
+
/// Attribute name for creation method.
inline static const std::string& CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()
{
return POINT_ATTR_Z;
}
- /*/// Attribute name for selected 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 offset type on selected edge.
+ inline static const std::string& OFFSET_TYPE()
+ {
+ static const std::string ATTR_ID("offset_type");
+ return ATTR_ID;
+ }
+
+ /// Attribute name for offset type by distance.
+ inline static const std::string& OFFSET_TYPE_BY_DISTANCE()
+ {
+ static const std::string ATTR_ID("offset_type_by_distance");
+ return ATTR_ID;
+ }
+
+ /// Attribute name for offset type by ratio.
+ inline static const std::string& OFFSET_TYPE_BY_RATIO()
+ {
+ static const std::string ATTR_ID("offset_type_by_ratio");
+ return ATTR_ID;
+ }
+
/// Attribute name for distance.
- inline static const std::string& DISTANCE_VALUE()
+ inline static const std::string& DISTANCE()
{
- static const std::string ATTR_ID("value");
+ static const std::string ATTR_ID("distance");
return ATTR_ID;
}
/// Attribute name for percent flag.
- inline static const std::string& DISTANCE_PERCENT()
+ inline static const std::string& RATIO()
{
- static const std::string ATTR_ID("percent");
+ static const std::string ATTR_ID("ratio");
return ATTR_ID;
}
return ATTR_ID;
}
+ /*
/// Attribute name for point.
inline static const std::string& POINT()
{
private:
std::shared_ptr<GeomAPI_Vertex> createByXYZ();
- /*std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
- std::shared_ptr<GeomAPI_Vertex> createByProjection();
+ std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
+ /*std::shared_ptr<GeomAPI_Vertex> createByProjection();
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 coordinates.
+"""
+
+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("XOY"))
+SketchLine_1 = Sketch_1.addLine(0, 0, 100, 100)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result())
+model.do()
+Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 50, False, False)
+Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 0.4, True, False)
+Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), 0.4, True, True)
+Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 50, 10)
+Point_5 = model.addPoint(Part_1_doc, model.selection("EDGE", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2"), 0.25, True, False)
+Point_6 = model.addPoint(Part_1_doc, model.selection("EDGE", "Cylinder_1_1/Face_1&Cylinder_1_1/Face_2"), 0.25, True, True)
+model.do()
+model.end()
+
+assert (len(Point_2.results()) > 0)
+rightPosition = GeomAPI_Vertex(35.3553390593, 35.3553390593, 0)
+assert(rightPosition.isEqual(Point_2.results()[0].resultSubShapePair()[0].shape()))
+
+assert (len(Point_3.results()) > 0)
+rightPosition = GeomAPI_Vertex(40, 40, 0)
+assert(rightPosition.isEqual(Point_3.results()[0].resultSubShapePair()[0].shape()))
+
+assert (len(Point_4.results()) > 0)
+rightPosition = GeomAPI_Vertex(60, 60, 0)
+assert(rightPosition.isEqual(Point_4.results()[0].resultSubShapePair()[0].shape()))
+
+assert (len(Point_5.results()) > 0)
+rightPosition = GeomAPI_Vertex(0, 50, 10)
+assert(rightPosition.isEqual(Point_5.results()[0].resultSubShapePair()[0].shape()))
+
+assert (len(Point_6.results()) > 0)
+rightPosition = GeomAPI_Vertex(0, -50, 10)
+assert(rightPosition.isEqual(Point_6.results()[0].resultSubShapePair()[0].shape()))
+
+assert(model.checkPythonDump())
icon="icons/Construction/z_size.png"
default="0"/>
</box>
-<!--
<box id="by_distance_on_edge"
title="By distance on edge"
tooltip="Point on an edge, at a given distance of one of its end."
shape_types="edge">
<validator id="GeomValidators_Finite"/>
</shape_selector>
- <groupbox title="Distance">
- <doublevalue id="value"
- label="Value"
- tooltip="Distance value."
- icon="icons/Construction/distance_value.png"
- default="50"/>
- <boolvalue id="percent"
- label="Percent(%)"
- tooltip="Distance in percent from length."
- default="true"/>
- </groupbox>
+ <toolbox id="offset_type">
+ <box id="offset_type_by_distance"
+ title="Distance on edge by value"
+ tooltip="Point on an edge, at a given distance specified by value."
+ icon="icons/Construction/point_by_distance_on_edge_24x24.png">
+ <doublevalue id="distance"
+ label="Distance"
+ tooltip="Distance value."
+ icon="icons/Construction/distance_value.png"
+ min="0.0"
+ default="10">
+ </doublevalue>
+ </box>
+ <box id="offset_type_by_ratio"
+ title="Distance on edge by ratio"
+ tooltip="Point on an edge, at a given distance specified by ratio."
+ icon="icons/Construction/point_by_ratio_on_edge_24x24.png">
+ <doublevalue id="ratio"
+ label="Ratio"
+ tooltip="Ratio value."
+ icon="icons/Construction/distance_value.png"
+ min="0.0"
+ max="1.0"
+ default="0.5">
+ </doublevalue>
+ </box>
+ </toolbox>
<boolvalue id="reverse"
label="Reverse"
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."