From 9ea269be1c99f4b2fed58d2a6ec7b82867677843 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 12 Apr 2012 19:06:38 +0200 Subject: [PATCH 1/2] 0000649: Creating a ruled surface fails --- src/Mod/Part/App/PartFeatures.cpp | 52 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/Mod/Part/App/PartFeatures.cpp b/src/Mod/Part/App/PartFeatures.cpp index 7029066b0..3bc5c0683 100644 --- a/src/Mod/Part/App/PartFeatures.cpp +++ b/src/Mod/Part/App/PartFeatures.cpp @@ -59,28 +59,38 @@ void RuledSurface::onChanged(const App::Property* prop) App::DocumentObjectExecReturn *RuledSurface::execute(void) { - App::DocumentObject* c1 = Curve1.getValue(); - if (!(c1 && c1->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))) - return new App::DocumentObjectExecReturn("No shape linked."); - const std::vector& element1 = Curve1.getSubValues(); - if (element1.size() != 1) - return new App::DocumentObjectExecReturn("Not exactly one sub-shape linked."); - App::DocumentObject* c2 = Curve2.getValue(); - if (!(c2 && c2->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))) - return new App::DocumentObjectExecReturn("No shape linked."); - const std::vector& element2 = Curve2.getSubValues(); - if (element2.size() != 1) - return new App::DocumentObjectExecReturn("Not exactly one sub-shape linked."); - - const Part::TopoShape& shape1 = static_cast(c1)->Shape.getValue(); - TopoDS_Shape curve1 = shape1.getSubShape(element1[0].c_str()); - if (curve1.IsNull()) curve1 = shape1._Shape; - - const Part::TopoShape& shape2 = static_cast(c2)->Shape.getValue(); - TopoDS_Shape curve2 = shape2.getSubShape(element2[0].c_str()); - if (curve2.IsNull()) curve2 = shape2._Shape; - try { + App::DocumentObject* c1 = Curve1.getValue(); + if (!(c1 && c1->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))) + return new App::DocumentObjectExecReturn("No shape linked."); + const std::vector& element1 = Curve1.getSubValues(); + if (element1.size() != 1) + return new App::DocumentObjectExecReturn("Not exactly one sub-shape linked."); + App::DocumentObject* c2 = Curve2.getValue(); + if (!(c2 && c2->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))) + return new App::DocumentObjectExecReturn("No shape linked."); + const std::vector& element2 = Curve2.getSubValues(); + if (element2.size() != 1) + return new App::DocumentObjectExecReturn("Not exactly one sub-shape linked."); + + TopoDS_Shape curve1; + const Part::TopoShape& shape1 = static_cast(c1)->Shape.getValue(); + if (!shape1._Shape.IsNull()) { + if (shape1._Shape.ShapeType() == TopAbs_EDGE) + curve1 = shape1._Shape; + else + curve1 = shape1.getSubShape(element1[0].c_str()); + } + + TopoDS_Shape curve2; + const Part::TopoShape& shape2 = static_cast(c2)->Shape.getValue(); + if (!shape2._Shape.IsNull()) { + if (shape2._Shape.ShapeType() == TopAbs_EDGE) + curve2 = shape2._Shape; + else + curve2 = shape2.getSubShape(element2[0].c_str()); + } + if (curve1.IsNull() || curve2.IsNull()) return new App::DocumentObjectExecReturn("Linked shapes are empty."); if (curve1.ShapeType() == TopAbs_EDGE && curve2.ShapeType() == TopAbs_EDGE) { From c11cf35f2ad91530b04bf8cfca6d62e9f2add1d5 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 12 Apr 2012 19:11:09 +0200 Subject: [PATCH 2/2] 0000649: Creating a ruled surface fails --- src/Mod/Part/App/PartFeatures.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Mod/Part/App/PartFeatures.cpp b/src/Mod/Part/App/PartFeatures.cpp index 3bc5c0683..9f1512b26 100644 --- a/src/Mod/Part/App/PartFeatures.cpp +++ b/src/Mod/Part/App/PartFeatures.cpp @@ -78,6 +78,8 @@ App::DocumentObjectExecReturn *RuledSurface::execute(void) if (!shape1._Shape.IsNull()) { if (shape1._Shape.ShapeType() == TopAbs_EDGE) curve1 = shape1._Shape; + else if (shape1._Shape.ShapeType() == TopAbs_WIRE) + curve1 = shape1._Shape; else curve1 = shape1.getSubShape(element1[0].c_str()); } @@ -87,6 +89,8 @@ App::DocumentObjectExecReturn *RuledSurface::execute(void) if (!shape2._Shape.IsNull()) { if (shape2._Shape.ShapeType() == TopAbs_EDGE) curve2 = shape2._Shape; + else if (shape2._Shape.ShapeType() == TopAbs_WIRE) + curve2 = shape2._Shape; else curve2 = shape2.getSubShape(element2[0].c_str()); }