+ patch: improve face union (tanderson69)
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5424 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
1aa7e55e92
commit
281c2620bc
|
@ -1771,17 +1771,24 @@ TopoDS_Shape TopoShape::removeSplitter() const
|
|||
Standard_Failure::Raise("Cannot remove splitter from empty shape");
|
||||
|
||||
if (_Shape.ShapeType() == TopAbs_SOLID) {
|
||||
const TopoDS_Solid& solid = TopoDS::Solid(_Shape);
|
||||
ModelRefine::FaceUniter uniter(solid);
|
||||
if (uniter.process()) {
|
||||
TopoDS_Solid solidMod;
|
||||
if (!uniter.getSolid(solidMod))
|
||||
Standard_Failure::Raise("Getting solid failed");
|
||||
return solidMod;
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("Removing splitter failed");
|
||||
const TopoDS_Solid &solid = TopoDS::Solid(_Shape);
|
||||
BRepTools_ReShape reshape;
|
||||
TopExp_Explorer it;
|
||||
for (it.Init(solid, TopAbs_SHELL); it.More(); it.Next()) {
|
||||
const TopoDS_Shell ¤tShell = TopoDS::Shell(it.Current());
|
||||
ModelRefine::FaceUniter uniter(currentShell);
|
||||
if (uniter.process()) {
|
||||
if (uniter.isModified()) {
|
||||
const TopoDS_Shell &newShell = uniter.getShell();
|
||||
reshape.Replace(currentShell, newShell);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Standard_Failure::Raise("Removing splitter failed");
|
||||
return _Shape;
|
||||
}
|
||||
}
|
||||
return reshape.Apply(solid);
|
||||
}
|
||||
else if (_Shape.ShapeType() == TopAbs_SHELL) {
|
||||
const TopoDS_Shell& shell = TopoDS::Shell(_Shape);
|
||||
|
@ -1801,13 +1808,20 @@ TopoDS_Shape TopoShape::removeSplitter() const
|
|||
TopExp_Explorer xp;
|
||||
// solids
|
||||
for (xp.Init(_Shape, TopAbs_SOLID); xp.More(); xp.Next()) {
|
||||
const TopoDS_Solid& solid = TopoDS::Solid(xp.Current());
|
||||
ModelRefine::FaceUniter uniter(solid);
|
||||
if (uniter.process()) {
|
||||
TopoDS_Solid solidMod;
|
||||
if (uniter.getSolid(solidMod))
|
||||
builder.Add(comp, solidMod);
|
||||
const TopoDS_Solid &solid = TopoDS::Solid(xp.Current());
|
||||
BRepTools_ReShape reshape;
|
||||
TopExp_Explorer it;
|
||||
for (it.Init(solid, TopAbs_SHELL); it.More(); it.Next()) {
|
||||
const TopoDS_Shell ¤tShell = TopoDS::Shell(it.Current());
|
||||
ModelRefine::FaceUniter uniter(currentShell);
|
||||
if (uniter.process()) {
|
||||
if (uniter.isModified()) {
|
||||
const TopoDS_Shell &newShell = uniter.getShell();
|
||||
reshape.Replace(currentShell, newShell);
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.Add(comp, reshape.Apply(solid));
|
||||
}
|
||||
// free shells
|
||||
for (xp.Init(_Shape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next()) {
|
||||
|
|
|
@ -436,19 +436,11 @@ FaceTypedCylinder& ModelRefine::getCylinderObject()
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FaceUniter::FaceUniter(const TopoDS_Shell &shellIn)
|
||||
FaceUniter::FaceUniter(const TopoDS_Shell &shellIn) : modifiedSignal(false)
|
||||
{
|
||||
workShell = shellIn;
|
||||
}
|
||||
|
||||
FaceUniter::FaceUniter(const TopoDS_Solid &solidIn)
|
||||
{
|
||||
//get first shell
|
||||
TopExp_Explorer it;
|
||||
it.Init(solidIn, TopAbs_SHELL);
|
||||
workShell = TopoDS::Shell(it.Current());
|
||||
}
|
||||
|
||||
bool FaceUniter::process()
|
||||
{
|
||||
if (workShell.IsNull())
|
||||
|
@ -495,6 +487,7 @@ bool FaceUniter::process()
|
|||
}
|
||||
if (facesToSew.size() > 0)
|
||||
{
|
||||
modifiedSignal = true;
|
||||
workShell = ModelRefine::removeFaces(workShell, facesToRemove);
|
||||
TopExp_Explorer xp;
|
||||
bool emptyShell = true;
|
||||
|
@ -537,11 +530,3 @@ bool FaceUniter::process()
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FaceUniter::getSolid(TopoDS_Solid &outSolid) const
|
||||
{
|
||||
BRepBuilderAPI_MakeSolid solidMaker;
|
||||
solidMaker.Add(workShell);
|
||||
outSolid = solidMaker.Solid();
|
||||
return solidMaker.IsDone() ? true : false;
|
||||
}
|
||||
|
|
|
@ -151,14 +151,14 @@ namespace ModelRefine
|
|||
FaceUniter(){}
|
||||
public:
|
||||
FaceUniter(const TopoDS_Shell &shellIn);
|
||||
FaceUniter(const TopoDS_Solid &solidIn);//get first shell
|
||||
bool process();
|
||||
const TopoDS_Shell& getShell() const {return workShell;}
|
||||
bool getSolid(TopoDS_Solid &outSolid) const;//tries to make solid from shell.
|
||||
bool isModified(){return modifiedSignal;}
|
||||
|
||||
private:
|
||||
TopoDS_Shell workShell;
|
||||
std::vector<FaceTypedBase *> typeObjects;
|
||||
bool modifiedSignal;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user