Skip to content

Commit

Permalink
+ properly handle case of degenerated bounding box when creating mesh…
Browse files Browse the repository at this point in the history
… grid
  • Loading branch information
wwmayer committed Nov 14, 2015
1 parent 821cd69 commit 7848d08
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Mod/Mesh/App/Core/Grid.cpp
Expand Up @@ -267,6 +267,31 @@ void MeshGrid::CalculateGridLength (unsigned long ulCtGrid, unsigned long ulMaxG
Base::BoundBox3f clBBMeshEnlarged = _pclMesh->GetBoundBox();
float fVolElem;

// Stelle sicher, dass die Bounding box ein Volumen > 0 besitzt
float fLenX = clBBMeshEnlarged.LengthX();
float fLenY = clBBMeshEnlarged.LengthY();
float fLenZ = clBBMeshEnlarged.LengthZ();
float fMax = 0.005 * std::max<float>(std::max<float>(fLenX, fLenY), fLenZ);
// Falls Bounding box zu einem Punkt degeneriert ist
if (fMax == 0) {
_ulCtGridsX = 1;
_ulCtGridsY = 1;
_ulCtGridsZ = 1;
return;
}
if (fLenX == 0) {
clBBMeshEnlarged.MinX -= fMax;
clBBMeshEnlarged.MaxX += fMax;
}
if (fLenY == 0) {
clBBMeshEnlarged.MinY -= fMax;
clBBMeshEnlarged.MaxY += fMax;
}
if (fLenZ == 0) {
clBBMeshEnlarged.MinZ -= fMax;
clBBMeshEnlarged.MaxZ += fMax;
}

if (_ulCtElements > (ulMaxGrids * ulCtGrid))
fVolElem = (clBBMeshEnlarged.LengthX() * clBBMeshEnlarged.LengthY() * clBBMeshEnlarged.LengthZ()) / float(ulMaxGrids * ulCtGrid);
else
Expand Down

0 comments on commit 7848d08

Please sign in to comment.