+ whitespace improvement

This commit is contained in:
wmayer 2015-05-15 20:07:55 +02:00
parent 0950e1963a
commit 4fe99f2658

View File

@ -1964,7 +1964,7 @@ TopoDS_Shape TopoShape::makeOffsetShape(double offset, double tol, bool intersec
selfInter ? Standard_True : Standard_False, selfInter ? Standard_True : Standard_False,
GeomAbs_JoinType(join)); GeomAbs_JoinType(join));
if (!mkOffset.IsDone()) if (!mkOffset.IsDone())
return TopoDS_Shape(); //maybe throw exception? return TopoDS_Shape(); //maybe throw exception?
const TopoDS_Shape& res = mkOffset.Shape(); const TopoDS_Shape& res = mkOffset.Shape();
if (!fill) if (!fill)
return res; return res;
@ -1975,96 +1975,96 @@ TopoDS_Shape TopoShape::makeOffsetShape(double offset, double tol, bool intersec
freeCheck.Perform(); freeCheck.Perform();
if (freeCheck.NbClosedFreeBounds() < 1) if (freeCheck.NbClosedFreeBounds() < 1)
{ {
std::ostringstream stream; std::ostringstream stream;
stream << "no closed bounds" << std::endl; stream << "no closed bounds" << std::endl;
Base::Console().Message(stream.str().c_str()); Base::Console().Message(stream.str().c_str());
return TopoDS_Shape(); //maybe throw exception? return TopoDS_Shape(); //maybe throw exception?
} }
BRep_Builder builder; BRep_Builder builder;
TopoDS_Compound perimeterCompound; TopoDS_Compound perimeterCompound;
builder.MakeCompound(perimeterCompound); builder.MakeCompound(perimeterCompound);
for (int index = 1; index <= freeCheck.NbClosedFreeBounds(); ++index) for (int index = 1; index <= freeCheck.NbClosedFreeBounds(); ++index)
{ {
TopoDS_Wire originalWire = freeCheck.ClosedFreeBound(index)->FreeBound(); TopoDS_Wire originalWire = freeCheck.ClosedFreeBound(index)->FreeBound();
const BRepAlgo_Image& img = mkOffset.MakeOffset().OffsetEdgesFromShapes(); const BRepAlgo_Image& img = mkOffset.MakeOffset().OffsetEdgesFromShapes();
//build offset wire. //build offset wire.
TopoDS_Wire offsetWire; TopoDS_Wire offsetWire;
builder.MakeWire(offsetWire); builder.MakeWire(offsetWire);
TopExp_Explorer xp; TopExp_Explorer xp;
for (xp.Init(originalWire, TopAbs_EDGE); xp.More(); xp.Next()) for (xp.Init(originalWire, TopAbs_EDGE); xp.More(); xp.Next())
{
if (!img.HasImage(xp.Current()))
{ {
std::ostringstream stream; if (!img.HasImage(xp.Current()))
stream << "no image for shape" << std::endl; {
Base::Console().Message(stream.str().c_str()); std::ostringstream stream;
return TopoDS_Shape(); stream << "no image for shape" << std::endl;
Base::Console().Message(stream.str().c_str());
return TopoDS_Shape();
}
const TopTools_ListOfShape& currentImage = img.Image(xp.Current());
TopTools_ListIteratorOfListOfShape listIt;
int edgeCount(0);
TopoDS_Edge mappedEdge;
for (listIt.Initialize(currentImage); listIt.More(); listIt.Next())
{
if (listIt.Value().ShapeType() != TopAbs_EDGE)
continue;
edgeCount++;
mappedEdge = TopoDS::Edge(listIt.Value());
}
if (edgeCount != 1)
{
std::ostringstream stream;
stream << "wrong edge count: " << edgeCount << std::endl;
Base::Console().Message(stream.str().c_str());
return TopoDS_Shape();
}
builder.Add(offsetWire, mappedEdge);
} }
const TopTools_ListOfShape& currentImage = img.Image(xp.Current());
TopTools_ListIteratorOfListOfShape listIt; //It would be nice if we could get thruSections to build planar faces
int edgeCount(0); //in all areas possible, so we could run through refine. I tried setting
TopoDS_Edge mappedEdge; //ruled to standard_true, but that didn't have the desired affect.
for (listIt.Initialize(currentImage); listIt.More(); listIt.Next()) BRepOffsetAPI_ThruSections aGenerator;
aGenerator.AddWire(originalWire);
aGenerator.AddWire(offsetWire);
aGenerator.Build();
if (!aGenerator.IsDone())
{ {
if (listIt.Value().ShapeType() != TopAbs_EDGE) std::ostringstream stream;
continue; stream << "ThruSections failed" << std::endl;
edgeCount++; Base::Console().Message(stream.str().c_str());
mappedEdge = TopoDS::Edge(listIt.Value()); return TopoDS_Shape();
} }
if (edgeCount != 1) builder.Add(perimeterCompound, aGenerator.Shape());
{
std::ostringstream stream;
stream << "wrong edge count: " << edgeCount << std::endl;
Base::Console().Message(stream.str().c_str());
return TopoDS_Shape();
}
builder.Add(offsetWire, mappedEdge);
}
//It would be nice if we could get thruSections to build planar faces
//in all areas possible, so we could run through refine. I tried setting
//ruled to standard_true, but that didn't have the desired affect.
BRepOffsetAPI_ThruSections aGenerator;
aGenerator.AddWire(originalWire);
aGenerator.AddWire(offsetWire);
aGenerator.Build();
if (!aGenerator.IsDone())
{
std::ostringstream stream;
stream << "ThruSections failed" << std::endl;
Base::Console().Message(stream.str().c_str());
return TopoDS_Shape();
}
builder.Add(perimeterCompound, aGenerator.Shape());
} }
//still had to sew. not using the passed in parameter for sew. //still had to sew. not using the passed in parameter for sew.
//Sew has it's own default tolerance. Opinions? //Sew has it's own default tolerance. Opinions?
BRepBuilderAPI_Sewing sewTool; BRepBuilderAPI_Sewing sewTool;
sewTool.Add(this->_Shape); sewTool.Add(this->_Shape);
sewTool.Add(perimeterCompound); sewTool.Add(perimeterCompound);
sewTool.Add(res); sewTool.Add(res);
sewTool.Perform(); //Perform Sewing sewTool.Perform(); //Perform Sewing
TopoDS_Shape outputShape = sewTool.SewedShape(); TopoDS_Shape outputShape = sewTool.SewedShape();
if ((outputShape.ShapeType() == TopAbs_SHELL) && (outputShape.Closed())) if ((outputShape.ShapeType() == TopAbs_SHELL) && (outputShape.Closed()))
{ {
BRepBuilderAPI_MakeSolid solidMaker(TopoDS::Shell(outputShape)); BRepBuilderAPI_MakeSolid solidMaker(TopoDS::Shell(outputShape));
if (solidMaker.IsDone()) if (solidMaker.IsDone())
{ {
TopoDS_Solid temp = solidMaker.Solid(); TopoDS_Solid temp = solidMaker.Solid();
//contrary to the occ docs the return value OrientCloseSolid doesn't //contrary to the occ docs the return value OrientCloseSolid doesn't
//indicate whether the shell was open or not. It returns true with an //indicate whether the shell was open or not. It returns true with an
//open shell and we end up with an invalid solid. //open shell and we end up with an invalid solid.
if (BRepLib::OrientClosedSolid(temp)) if (BRepLib::OrientClosedSolid(temp))
outputShape = temp; outputShape = temp;
} }
} }
return outputShape; return outputShape;
} }