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());
}
//==================================================================================================
{
GeomShapePtr aShape;
- // to support compatibility with old documents where aCreationMethod did not exist
+ // to support compatibility with old documents where aCreationMethod did not exist
std::string aCreationMethod =
string(CREATION_METHOD()).get() && !string(CREATION_METHOD())->value().empty() ?
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();
}*/ else if(aCreationMethod == CREATION_METHOD_BY_LINE_AND_PLANE_INTERSECTION()) {
- aShape = createByLineAndPlaneIntersection();
+ // 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
+ int anIndex = 0;
+ std::list<std::shared_ptr<GeomAPI_Vertex> >::iterator aPIter = aPoints.begin();
+ for(; aPIter != aPoints.end(); aPIter++, anIndex++) {
+ std::shared_ptr<ModelAPI_ResultConstruction> aConstr =
+ document()->createConstruction(data(), anIndex);
+ aConstr->setShape(*aPIter);
+ setResult(aConstr, anIndex);
+ }
+ removeResults(anIndex);
+ return;
+ }
}
if(!aShape.get()) {
return;
}
+ removeResults(1); // for case the point type was switched from multi-results type
std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
aConstr->setShape(aShape);
setResult(aConstr);
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()
{
*/
//==================================================================================================
-std::shared_ptr<GeomAPI_Vertex> ConstructionPlugin_Point::createByLineAndPlaneIntersection()
+std::list<std::shared_ptr<GeomAPI_Vertex> >
+ ConstructionPlugin_Point::createByLineAndPlaneIntersection()
{
// Get line.
AttributeSelectionPtr aLineSelection = selection(INTERSECTION_LINE());
}
}
- return GeomAlgoAPI_ShapeTools::intersect(anEdge, aFace);
+ return GeomAlgoAPI_ShapeTools::intersect(anEdge, aFace,
+ aPlaneSelection->context()->groupName() == ModelAPI_ResultConstruction::group());
}