Skip to content

Commit

Permalink
Part: ModelRefine: adding basis surface to cylinder.
Browse files Browse the repository at this point in the history
  • Loading branch information
blobfish authored and wwmayer committed May 7, 2016
1 parent 2ccf588 commit 973dda6
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/Mod/Part/App/modelRefine.cpp
Expand Up @@ -435,11 +435,28 @@ FaceTypedCylinder::FaceTypedCylinder() : FaceTypedBase(GeomAbs_Cylinder)
{
}

static Handle(Geom_CylindricalSurface) getGeomCylinder(const TopoDS_Face &faceIn)
{
Handle_Geom_CylindricalSurface cylinderSurfaceOut;
Handle_Geom_Surface surface = BRep_Tool::Surface(faceIn);
if (!surface.IsNull())
{
cylinderSurfaceOut = Handle(Geom_CylindricalSurface)::DownCast(surface);
if (cylinderSurfaceOut.IsNull())
{
Handle_Geom_RectangularTrimmedSurface trimmedSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(surface);
if (!trimmedSurface.IsNull())
cylinderSurfaceOut = Handle(Geom_CylindricalSurface)::DownCast(trimmedSurface->BasisSurface());
}
}

return cylinderSurfaceOut;
}

bool FaceTypedCylinder::isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &faceTwo) const
{
//check if these handles are valid?
Handle(Geom_CylindricalSurface) surfaceOne = Handle(Geom_CylindricalSurface)::DownCast(BRep_Tool::Surface(faceOne));
Handle(Geom_CylindricalSurface) surfaceTwo = Handle(Geom_CylindricalSurface)::DownCast(BRep_Tool::Surface(faceTwo));
Handle(Geom_CylindricalSurface) surfaceOne = getGeomCylinder(faceOne);
Handle(Geom_CylindricalSurface) surfaceTwo = getGeomCylinder(faceTwo);
if (surfaceOne.IsNull() || surfaceTwo.IsNull())
return false;//probably need an error
gp_Cylinder cylinderOne = surfaceOne->Cylinder();
Expand Down Expand Up @@ -623,7 +640,9 @@ TopoDS_Face FaceTypedCylinder::buildFace(const FaceVectorType &faces) const

// Find outer boundary wires that cut the cylinder into segments. This will be the case f we
// have removed the seam edges of a complete (360 degrees) cylindrical face
Handle(Geom_CylindricalSurface) surface = Handle(Geom_CylindricalSurface)::DownCast(BRep_Tool::Surface(faces.at(0)));
Handle(Geom_CylindricalSurface) surface = getGeomCylinder(faces.at(0));
if (surface.IsNull())
return dummy;
std::vector<TopoDS_Wire> innerWires, encirclingWires;
std::vector<TopoDS_Wire>::iterator wireIt;
for (wireIt = allWires.begin(); wireIt != allWires.end(); ++wireIt) {
Expand Down

0 comments on commit 973dda6

Please sign in to comment.