Skip to content

Commit

Permalink
+ fix bug in B-Spline approximation
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 23, 2015
1 parent 1c90c37 commit 67d8469
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/Mod/ReverseEngineering/App/ApproxSurface.cpp
Expand Up @@ -682,7 +682,7 @@ bool ParameterCorrection::GetUVParameters(double fSizeFactor)
(*_pvcPoints)(ii).Y(),
(*_pvcPoints)(ii).Z()));
vcProjPts.push_back(Base::Vector2D(clProjPnt.X(), clProjPnt.Y()));
clBBox.Add(Base::Vector2D(clProjPnt.X(), clProjPnt.Y()));
clBBox.Add(Base::Vector2D(clProjPnt.X(), clProjPnt.Y()));
}

if ((clBBox.fMaxX == clBBox.fMinX) || (clBBox.fMaxY == clBBox.fMinY))
Expand Down Expand Up @@ -825,15 +825,15 @@ void BSplineParameterCorrection::Init()
// u-Richtung
for (int i=0;i<=usUMax; i++)
{
_vUKnots(i) = i / usUMax;
_vUKnots(i) = static_cast<double>(i) / static_cast<double>(usUMax);
_vUMults(i) = 1;
}
_vUMults(0) = _usUOrder;
_vUMults(usUMax) = _usUOrder;
// v-Richtung
for (int i=0; i<=usVMax; i++)
{
_vVKnots(i) = i / usVMax;
_vVKnots(i) = static_cast<double>(i) / static_cast<double>(usVMax);
_vVMults(i) = 1;
}
_vVMults(0) = _usVOrder;
Expand Down Expand Up @@ -885,7 +885,7 @@ void BSplineParameterCorrection::SetVKnots(const std::vector<double>& afKnots)
void BSplineParameterCorrection::DoParameterCorrection(unsigned short usIter)
{
int i=0;
float fMaxDiff=0.0f, fMaxScalar=1.0f;
double fMaxDiff=0.0, fMaxScalar=1.0;
double fWeight = _fSmoothInfluence;

Base::SequencerLauncher seq("Calc surface...", usIter*_pvcPoints->Length());
Expand Down Expand Up @@ -924,7 +924,7 @@ void BSplineParameterCorrection::DoParameterCorrection(unsigned short usIter)
{
ErrorVec.Normalize();
if(fabs(clNormal*ErrorVec) < fMaxScalar)
fMaxScalar = (float)fabs(clNormal*ErrorVec);
fMaxScalar = fabs(clNormal*ErrorVec);
}

fDeltaU = ( (P-X) * Xu ) / ( (P-X)*Xuu - Xu*Xu );
Expand All @@ -942,8 +942,8 @@ void BSplineParameterCorrection::DoParameterCorrection(unsigned short usIter)
{
(*_pvcUVParam)(ii).SetX(fU);
(*_pvcUVParam)(ii).SetY(fV);
fMaxDiff = std::max<float>(float(fabs(fDeltaU)), fMaxDiff);
fMaxDiff = std::max<float>(float(fabs(fDeltaV)), fMaxDiff);
fMaxDiff = std::max<double>(fabs(fDeltaU), fMaxDiff);
fMaxDiff = std::max<double>(fabs(fDeltaV), fMaxDiff);
}

seq.next();
Expand Down Expand Up @@ -1214,7 +1214,7 @@ void BSplineParameterCorrection::CalcThirdSmoothMatrix(Base::SequencerLauncher&

void BSplineParameterCorrection::EnableSmoothing(bool bSmooth, double fSmoothInfl)
{
EnableSmoothing(bSmooth, fSmoothInfl, 1.0f, 0.0f, 0.0f);
EnableSmoothing(bSmooth, fSmoothInfl, 1.0, 0.0, 0.0);
}

void BSplineParameterCorrection::EnableSmoothing(bool bSmooth, double fSmoothInfl,
Expand Down
14 changes: 7 additions & 7 deletions src/Mod/ReverseEngineering/App/ApproxSurface.h
Expand Up @@ -319,13 +319,13 @@ class ReenExport ParameterCorrection
bool _bGetUVDir; //! Stellt fest, ob u/v-Richtung vorgegeben wird
bool _bSmoothing; //! Glättung verwenden
double _fSmoothInfluence; //! Einfluß der Glättung
unsigned short _usUOrder; //! Ordnung in u-Richtung
unsigned short _usVOrder; //! Ordnung in v-Richtung
unsigned short _usUCtrlpoints; //! Anzahl der Kontrollpunkte in u-Richtung
unsigned short _usVCtrlpoints; //! Anzahl der Kontrollpunkte in v-Richtung
Base::Vector3d _clU; //! u-Richtung
Base::Vector3d _clV; //! v-Richtung
Base::Vector3d _clW; //! w-Richtung (senkrecht zu u-und w-Richtung)
unsigned short _usUOrder; //! Ordnung in u-Richtung
unsigned short _usVOrder; //! Ordnung in v-Richtung
unsigned short _usUCtrlpoints; //! Anzahl der Kontrollpunkte in u-Richtung
unsigned short _usVCtrlpoints; //! Anzahl der Kontrollpunkte in v-Richtung
Base::Vector3d _clU; //! u-Richtung
Base::Vector3d _clV; //! v-Richtung
Base::Vector3d _clW; //! w-Richtung (senkrecht zu u-und w-Richtung)
TColgp_Array1OfPnt* _pvcPoints; //! Punktliste der Rohdaten
TColgp_Array1OfPnt2d* _pvcUVParam; //! Parameterwerte zu den Punkten aus der Liste
TColgp_Array2OfPnt _vCtrlPntsOfSurf; //! Array von Kontrollpunkten
Expand Down

0 comments on commit 67d8469

Please sign in to comment.