std::list<FeaturePtr> aChain;
aChain.push_back(aFeature);
if (aStartPoint && anEndPoint) { // not closed edge
- bool isClosed = findWireOneWay(aFeature, aFeature, aStartPoint, anEdgesSet, aChain);
+ bool isClosed = findWireOneWay(aFeature, aFeature, aStartPoint, anEdgesSet, aChain, true);
if (!isClosed)
- findWireOneWay(aFeature, aFeature, anEndPoint, anEdgesSet, aChain);
+ findWireOneWay(aFeature, aFeature, anEndPoint, anEdgesSet, aChain, false);
}
std::set<FeaturePtr>::iterator aPos = anEdgesSet.find(aFeature);
if (aPos != anEdgesSet.end())
const FeaturePtr& theEdge,
const std::shared_ptr<GeomDataAPI_Point2D>& theEndPoint,
std::set<FeaturePtr>& theEdgesSet,
- std::list<FeaturePtr>& theChain)
+ std::list<FeaturePtr>& theChain,
+ const bool isPrepend)
{
// 1. Find a single edge, coincident to theEndPoint by one of its ends
if (!theEndPoint) return false;
AttributePtr aP = (*aPointsIt);
FeaturePtr aCoincFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aP->owner());
+ // Condition 0: not auxiliary
+ if (aCoincFeature->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) continue;
+
// Condition 1: not a point feature
if (aCoincFeature->getKind() != SketchPlugin_Point::ID()) {
// Condition 2: it is not the current edge
return true;
// 3. Add the found edge to the chain
- theChain.push_back(aNextEdgeFeature);
+ if (isPrepend)
+ theChain.push_front(aNextEdgeFeature);
+ else
+ theChain.push_back(aNextEdgeFeature);
// remove from the set, if the set is used
if (theEdgesSet.size()) {
std::set<FeaturePtr>::iterator aPos = theEdgesSet.find(aNextEdgeFeature);
}
// 5. Continue gathering the chain (recursive)
- return findWireOneWay (theFirstEdge, aNextEdgeFeature, aP2, theEdgesSet, theChain);
+ return findWireOneWay (theFirstEdge, aNextEdgeFeature, aP2, theEdgesSet, theChain, isPrepend);
}
void SketchPlugin_Offset::addToSketch(const std::shared_ptr<GeomAPI_Shape>& anOffsetShape)
mkBSpline(aResFeature, aResEdge);
}
else {
+ // convert to b-spline
+ mkBSpline(aResFeature, aResEdge);
}
if (aResFeature.get()) {
void SketchPlugin_Offset::mkBSpline (FeaturePtr& theResult,
const GeomEdgePtr& theEdge)
{
- if (!theEdge->isBSpline())
- return;
-
GeomCurvePtr aCurve (new GeomAPI_Curve (theEdge));
- GeomAPI_BSpline aBSpline (aCurve);
+ // Forced conversion to b-spline, if aCurve is not b-spline
+ GeomAPI_BSpline aBSpline (aCurve, /*isForced*/true);
if (aBSpline.isPeriodic())
theResult = sketch()->addFeature(SketchPlugin_BSplinePeriodic::ID());
std::list<FeaturePtr> aChain;
aChain.push_back(aFeature);
- bool isClosed = findWireOneWay(aFeature, aFeature, aStartPoint, anEdgesSet, aChain);
+ bool isClosed = findWireOneWay(aFeature, aFeature, aStartPoint, anEdgesSet, aChain, true);
if (!isClosed)
- findWireOneWay(aFeature, aFeature, anEndPoint, anEdgesSet, aChain);
+ findWireOneWay(aFeature, aFeature, anEndPoint, anEdgesSet, aChain, false);
std::list<FeaturePtr>::iterator aChainIt = aChain.begin();
for (; aChainIt != aChain.end(); ++aChainIt) {
// \param[in] theEndPoint Point of the Current edge, not belonging to a previous edge
// \param[in/out] theEdgesSet All edges to find among. If empty, all sketch edges assumed.
// \param[in/out] theChain Resulting edges
+ // \param[in] isPrepend if true, push new found edges to theChain front, else to the back
/// \return \c true if the chain is closed
bool findWireOneWay (const FeaturePtr& theFirstEdge,
const FeaturePtr& theEdge,
const std::shared_ptr<GeomDataAPI_Point2D>& theEndPoint,
std::set<FeaturePtr>& theEdgesSet,
- std::list<FeaturePtr>& theChain);
+ std::list<FeaturePtr>& theChain,
+ const bool isPrepend = false);
// tmp
std::set<FeaturePtr> myCreatedFeatures;