-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022 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
gp_Vec aVec;
std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(theShape);
if (aShape->isEdge()) {
+ std::shared_ptr<GeomAPI_Edge> anEdge = aShape->edge();
std::shared_ptr<GeomAPI_Curve> aCurve =
std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
- if (aCurve->isCircle() || aCurve->isEllipse()) {
+ if (anEdge->isClosed()) {
+ double aPeriod = aCurve->endParam() - aCurve->startParam();
Handle(Geom_Curve) aCurv = aCurve->impl<Handle_Geom_Curve>();
GeomAPI_ProjectPointOnCurve anExtr(theP, aCurv);
double aParam = anExtr.LowerDistanceParameter();
// if parameter is near the LastParam, make the vector go inside (reverse)
double aDelta = aLastParam - aParam;
while (aDelta < -Precision::Confusion())
- aDelta += 2. * M_PI;
- while (aDelta > 2. * M_PI - Precision::Confusion())
- aDelta -= 2. * M_PI;
+ aDelta += aPeriod;
+ while (aDelta > aPeriod + Precision::Confusion())
+ aDelta -= aPeriod;
if (fabs(aDelta) < Precision::Confusion())
aVec.Reverse();
}
// Compute shifting vector for a one symbol
gp_Vec aShift = aVec1.Crossed(thePrs->plane()->normal()->impl<gp_Dir>());
- aShift.Normalize();
+ if (aShift.SquareMagnitude() > Precision::SquareConfusion())
+ aShift.Normalize();
aShift.Multiply(theStep * 0.8);
// Shift the position coordinate according to position index
gp_Vec aVecPos;
// If number of angle less then number of symbols then each symbol can be placed
// directly inside of the angle
- if (aAngles.size() >= aPos[1] && !aVectors.empty()) {
+ if ((int)aAngles.size() >= aPos[1] && !aVectors.empty()) {
int aId = aPos[0];
aVecPos = *(std::next(aVectors.begin(), aId));
double aAng;
std::list<double>::const_iterator aItAng;
- double aAngPos;
bool aHasPlace = false;
- //int aIntId = 0; // a position inside a one sector
while (aPosCount < aPos[1]) {
for (aItAng = aAngles.cbegin(), aItVec = aVectors.cbegin();
aItAng != aAngles.cend(); ++aItAng, ++aItVec) {
if ((!aHasPlace) && (aPosCount >= (aPos[0] + 1))) {
aHasPlace = true;
- aAngPos = (*aItAng);
aVecPos = (*aItVec);
- //aIntId = aPos[0] - (aPosCount - Nb);
}
}
if (aPosCount < aPos[1]) {
aToDel.push_back(aIt->first);
else {
// Reindex objects positions in order to avoid spaces
- PositionsMap::iterator aIt;
+ PositionsMap::iterator aPMIt;
int i = 0;
- for (aIt = aPosMap.begin(); aIt != aPosMap.end(); aIt++, i++)
- aIt->second = i;
+ for (aPMIt = aPosMap.begin(); aPMIt != aPosMap.end(); aPMIt++, i++)
+ aPMIt->second = i;
}
}
}