X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_PatchFaceDriver.cxx;fp=src%2FGEOMImpl%2FGEOMImpl_PatchFaceDriver.cxx;h=4aa496c63a0c463fd8405624c6e60ee8cf008825;hb=de644ac6fe44325aaa8ce9c1aa729dd9189eea6e;hp=0000000000000000000000000000000000000000;hpb=e6d054cfcd53405d16a2466ceb0aee3603057784;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_PatchFaceDriver.cxx b/src/GEOMImpl/GEOMImpl_PatchFaceDriver.cxx new file mode 100644 index 000000000..4aa496c63 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_PatchFaceDriver.cxx @@ -0,0 +1,140 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_PatchFaceDriver::GetID() +{ + static Standard_GUID aPatchFaceDriver("6E0A4C17-9E56-4739-8C67-B37C01C47ED6"); + return aPatchFaceDriver; +} + + +//======================================================================= +//function : GEOMImpl_PatchFaceDriver +//purpose : +//======================================================================= +GEOMImpl_PatchFaceDriver::GEOMImpl_PatchFaceDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_PatchFaceDriver::Execute(Handle(TFunction_Logbook)& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + GEOMImpl_IPatchFace aCI(aFunction); + + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + if (aRefShape.IsNull()) return 0; + + TopoDS_Shape aFaceShape = aRefShape->GetValue(); + + TopoDS_Compound aCompound; + if (aFaceShape.ShapeType() == TopAbs_FACE) + { + if (aFaceShape.Orientation() == TopAbs_Orientation::TopAbs_REVERSED) + aFaceShape.Reverse(); + + // Colect all Wires from face + TopTools_ListOfShape aWires; + TopoDS_Wire anOuterWire = BRepTools::OuterWire(TopoDS::Face(aFaceShape)); + aWires.Append(anOuterWire); + for (TopExp_Explorer anExpW(aFaceShape, TopAbs_WIRE); anExpW.More(); anExpW.Next()) + { + TopoDS_Wire aWire = TopoDS::Wire(anExpW.Current()); + if (anOuterWire.IsSame(aWire)) + continue; + + aWire.Reverse(); + aWires.Append(aWire); + } + + BRep_Builder aBrepBuilder; + TopLoc_Location aLocation; + Handle(Geom_Surface) aSurface = BRep_Tool::Surface(TopoDS::Face(aFaceShape), aLocation); + + // Create result compound from all faces + aBrepBuilder.MakeCompound(aCompound); + TopTools_ListIteratorOfListOfShape anIterWires(aWires); + for (; anIterWires.More(); anIterWires.Next()) + { + // Create face on surface from wire + TopoDS_Face aFace; + aBrepBuilder.MakeFace(aFace, aSurface, aLocation, 1.e-7); + aBrepBuilder.Add(aFace, anIterWires.Value()); + + // Add created face to compound + aBrepBuilder.Add(aCompound, aFace); + } + } + else + { + Standard_ConstructionError::Raise("Wrong arguments: a face must be given"); + } + + if (aCompound.IsNull()) return 0; + + aFunction->SetValue(aCompound); + log->SetTouched(Label()); + + return 1; +} + +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ + //================================================================================ + +bool GEOMImpl_PatchFaceDriver:: +GetCreationInformation(std::string& /*theOperationName*/, + std::vector& /*theParams*/) +{ + return false; +} + +IMPLEMENT_STANDARD_RTTIEXT(GEOMImpl_PatchFaceDriver, GEOM_BaseDriver)