Skip to content

Commit

Permalink
+ get initial plane fit from B-Spline fit if required
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 5, 2015
1 parent 25fd2ad commit 8645d56
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Mod/ReverseEngineering/App/ApproxSurface.cpp
Expand Up @@ -693,6 +693,22 @@ Base::Vector3d ParameterCorrection::GetGravityPoint() const
return Base::Vector3d(x/ulSize, y/ulSize, z/ulSize);
}

void ParameterCorrection::ProjectControlPointsOnPlane()
{
Base::Vector3d base = GetGravityPoint();
for (unsigned j=0;j<_usUCtrlpoints;j++) {
for (unsigned k=0;k<_usVCtrlpoints;k++) {
gp_Pnt pole = _vCtrlPntsOfSurf(j,k);
Base::Vector3d pnt(pole.X(), pole.Y(), pole.Z());
pnt.ProjToPlane(base, _clW);
pole.SetX(pnt.x);
pole.SetY(pnt.y);
pole.SetZ(pnt.z);
_vCtrlPntsOfSurf(j,k) = pole;
}
}
}

Handle(Geom_BSplineSurface) ParameterCorrection::CreateSurface(const TColgp_Array1OfPnt& points,
int iIter,
bool bParaCor,
Expand All @@ -704,6 +720,7 @@ Handle(Geom_BSplineSurface) ParameterCorrection::CreateSurface(const TColgp_Arra
delete _pvcUVParam;
_pvcUVParam = NULL;
}

_pvcPoints = new TColgp_Array1OfPnt(points.Lower(), points.Upper());
*_pvcPoints = points;
_pvcUVParam = new TColgp_Array1OfPnt2d(points.Lower(), points.Upper());
Expand All @@ -713,6 +730,16 @@ Handle(Geom_BSplineSurface) ParameterCorrection::CreateSurface(const TColgp_Arra
if (!DoInitialParameterCorrection(fSizeFactor))
return NULL;

// Erzeuge die Approximations-Ebene als B-Spline-Flaeche
if (iIter < 0) {
bParaCor = false;
ProjectControlPointsOnPlane();
}
// Keine weiteren Parameterkorrekturen
else if (iIter == 0) {
bParaCor = false;
}

if (bParaCor)
DoParameterCorrection(iIter);

Expand Down
5 changes: 5 additions & 0 deletions src/Mod/ReverseEngineering/App/ApproxSurface.h
Expand Up @@ -274,6 +274,11 @@ class ReenExport ParameterCorrection
*/
virtual void CalcEigenvectors();

/**
* Projiziert die Kontrollpunkte auf die Fit-Ebene
*/
void ProjectControlPointsOnPlane();

/**
* Berechnet eine initiale Flaeche zu Beginn des Algorithmus. Dazu wird die Ausgleichsebene zu der
* Punktwolke berechnet.
Expand Down

0 comments on commit 8645d56

Please sign in to comment.