aSecondShape = aSecondelection->value();
if (!aSecondShape && aSecondelection->context())
aSecondShape = aSecondelection->context()->shape();
-
}
- // Loft for two edges
- if(aFirstShape->isEdge()) {
-
- std::shared_ptr<GeomAlgoAPI_Filling> aFilling(
- new GeomAlgoAPI_Filling(2.0, 5.0, 0, 0.0001, 0.0001 ));
-
- // collect base shapes
- GeomEdgePtr aFirstEdge = toEdge(aFirstShape);
- if (!aFirstEdge) {
- myLastEdgeStartPoint = GeomPointPtr();
- myLastEdgeEndPoint = GeomPointPtr();
- return;
- }
- aFilling->add(aFirstEdge);
-
- GeomEdgePtr aSecondEdge = toEdge(aSecondShape);
- if (!aSecondEdge) {
- myLastEdgeStartPoint = GeomPointPtr();
- myLastEdgeEndPoint = GeomPointPtr();
- return;
- }
- aFilling->add(aSecondEdge);
- myLastEdgeStartPoint = GeomPointPtr();
- myLastEdgeEndPoint = GeomPointPtr();
-
- // build result
- aFilling->build();
- std::string anError;
- if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilling, getKind(), anError)) {
- setError(anError);
- removeResults(0);
- return;
- }
-
- /// store result
- GeomShapePtr aCreatedFace = aFilling->shape();
- ResultBodyPtr aResultBody = document()->createBody(data());
- aResultBody->store(aCreatedFace);
- // store edges
- for(GeomAPI_ShapeExplorer anExp(aCreatedFace, GeomAPI_Shape::EDGE);
- anExp.more(); anExp.next()) {
- GeomShapePtr anEdge = anExp.current();
- aResultBody->generated(anEdge, "Loft_Edge");
- }
- setResult(aResultBody, 0);
- } else {
+ std::string anError;
+ std::shared_ptr<GeomAlgoAPI_Loft> aLoftAlgo(new GeomAlgoAPI_Loft(aFirstShape, aSecondShape));
- std::shared_ptr<GeomAlgoAPI_Loft> aLoftAlgo(new GeomAlgoAPI_Loft(aFirstShape, aSecondShape));
-
- std::string anError;
-
- if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aLoftAlgo, getKind(), anError)) {
- setError(anError);
- return;
- }
- ListOfShape theBoundaryShapes;
- theBoundaryShapes.push_back(aFirstShape);
- theBoundaryShapes.push_back(aSecondShape);
-
- // Create result body.
- ResultBodyPtr aResultBody = document()->createBody(data());
-
- aResultBody->store(aLoftAlgo->shape());
- // store Faces
- for(GeomAPI_ShapeExplorer anExp(aLoftAlgo->shape(), GeomAPI_Shape::FACE);
- anExp.more(); anExp.next()) {
- GeomShapePtr anEdge = anExp.current();
- aResultBody->generated(anEdge, "Loft_Face");
- }
- setResult(aResultBody, 0);
+ if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aLoftAlgo, getKind(), anError)) {
+ setError(anError);
+ return;
}
- }
-}
-
-//=================================================================================================
-GeomEdgePtr FeaturesPlugin_Loft::toEdge(const GeomShapePtr& theShape)
-{
- GeomEdgePtr anEdge = GeomEdgePtr(new GeomAPI_Edge(GeomAlgoAPI_Copy(theShape).shape()));
-
- if (!anEdge || anEdge->empty()) {
- static const std::string aFeatureError =
- "Error: incorrect type of input feature (edges are supported only).";
- setError(aFeatureError);
- return anEdge;
- }
-
- // correct edge orientation according to filling method
- // check the distance to previous edge boundaries, reverse edge if necessary
- GeomPointPtr aStartPnt = anEdge->firstPoint();
- GeomPointPtr aEndPnt = anEdge->lastPoint();
- if (anEdge->orientation() == GeomAPI_Shape::REVERSED) {
- aStartPnt = anEdge->lastPoint();
- aEndPnt = anEdge->firstPoint();
- }
- bool isReverse = false;
- if (myLastEdgeStartPoint) {
- double d1 = myLastEdgeStartPoint->distance(aStartPnt)
- + myLastEdgeEndPoint->distance(aEndPnt);
- double d2 = myLastEdgeStartPoint->distance(aEndPnt)
- + myLastEdgeEndPoint->distance(aStartPnt);
- if (fabs(d1 - d2) < 1.e-7) {
- // undefined case => check distance to start point only
- d1 = myLastEdgeStartPoint->distance(aStartPnt);
- d2 = myLastEdgeStartPoint->distance(aEndPnt);
+ ListOfShape theBoundaryShapes;
+ theBoundaryShapes.push_back(aFirstShape);
+ theBoundaryShapes.push_back(aSecondShape);
+
+ // Create result body.
+ ResultBodyPtr aResultBody = document()->createBody(data());
+
+ aResultBody->store(aLoftAlgo->shape());
+ // store Faces
+ for(GeomAPI_ShapeExplorer anExp(aLoftAlgo->shape(), GeomAPI_Shape::FACE);
+ anExp.more(); anExp.next()) {
+ GeomShapePtr anEdge = anExp.current();
+ aResultBody->generated(anEdge, "Loft_Face");
}
- isReverse = d2 < d1;
+ setResult(aResultBody, 0);
}
-
- if (isReverse) {
- anEdge->reverse();
- myLastEdgeStartPoint = aEndPnt;
- myLastEdgeEndPoint = aStartPnt;
- } else {
- myLastEdgeStartPoint = aStartPnt;
- myLastEdgeEndPoint = aEndPnt;
- }
-
- return anEdge;
}
#include "GeomAlgoAPI_DFLoader.h"
#include "GeomAlgoAPI_Loft.h"
+#include "GeomAlgoAPI_WireBuilder.h"
#include <BRepOffsetAPI_ThruSections.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
//==================================================================================================
-GeomAlgoAPI_Loft::GeomAlgoAPI_Loft(const GeomShapePtr theFirstShape,
- const GeomShapePtr theSecondShape)
+GeomAlgoAPI_Loft::GeomAlgoAPI_Loft(const GeomShapePtr theFirstShape, const GeomShapePtr theSecondShape)
{
build(theFirstShape, theSecondShape);
}
return;
}
- bool anIsSolid = true;
+ bool anIsSolid = false;
TopoDS_Shape aFirstShapeOut;
TopoDS_Shape aSecondShapeOut;
aFirstShapeOut = anExp.Current();
TopExp_Explorer anExp2(aSecondShape, TopAbs_WIRE);
aSecondShapeOut = anExp2.Current();
+ anIsSolid = true;
}
if (aFirstShape.ShapeType() == TopAbs_WIRE) {
aFirstShapeOut = aFirstShape;
aSecondShapeOut = aSecondShape;
- anIsSolid = false;
+ }
+
+ if (aFirstShape.ShapeType() == TopAbs_EDGE)
+ {
+ GeomShapePtr aFirstWire, aSecondWire;
+ ListOfShape aFirstEdge, aSecondEdge;
+
+ // Convert first edge to wire
+ aFirstEdge.push_back(theFirstShape);
+ aFirstWire = GeomAlgoAPI_WireBuilder::wire(aFirstEdge);
+ TopoDS_Shape aFirstShape = aFirstWire->impl<TopoDS_Shape>();
+
+ // Convert first edge to wire
+ aSecondEdge.push_back(theSecondShape);
+ aSecondWire = GeomAlgoAPI_WireBuilder::wire(aSecondEdge);
+ TopoDS_Shape aSecondShape = aSecondWire->impl<TopoDS_Shape>();
+
+ aFirstShapeOut = aFirstShape;
+ aSecondShapeOut = aSecondShape;
}
// Initialize and build