Part: ModelRefine: adding basis surface to cylinder.

This commit is contained in:
blobfish 2015-08-21 13:17:09 -04:00 committed by wmayer
parent 2ccf588392
commit 973dda6f88

View File

@ -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 bool FaceTypedCylinder::isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &faceTwo) const
{ {
//check if these handles are valid? Handle(Geom_CylindricalSurface) surfaceOne = getGeomCylinder(faceOne);
Handle(Geom_CylindricalSurface) surfaceOne = Handle(Geom_CylindricalSurface)::DownCast(BRep_Tool::Surface(faceOne)); Handle(Geom_CylindricalSurface) surfaceTwo = getGeomCylinder(faceTwo);
Handle(Geom_CylindricalSurface) surfaceTwo = Handle(Geom_CylindricalSurface)::DownCast(BRep_Tool::Surface(faceTwo));
if (surfaceOne.IsNull() || surfaceTwo.IsNull()) if (surfaceOne.IsNull() || surfaceTwo.IsNull())
return false;//probably need an error return false;//probably need an error
gp_Cylinder cylinderOne = surfaceOne->Cylinder(); gp_Cylinder cylinderOne = surfaceOne->Cylinder();
@ -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 // 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 // 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> innerWires, encirclingWires;
std::vector<TopoDS_Wire>::iterator wireIt; std::vector<TopoDS_Wire>::iterator wireIt;
for (wireIt = allWires.begin(); wireIt != allWires.end(); ++wireIt) { for (wireIt = allWires.begin(); wireIt != allWires.end(); ++wireIt) {