X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_HealingDriver.cxx;h=09441ab23dd683491d274f440846ee1e0f7c035e;hb=73747ffeb558151f48c52ef25e58900b4e31278c;hp=7771033fbdbd65e82042a28c6ab3c5fed4d613e9;hpb=73555c78ebf12a1fdb85157b8e7934ad566ae90a;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx index 7771033fb..09441ab23 100644 --- a/src/GEOMImpl/GEOMImpl_HealingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_HealingDriver.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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. +// 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 @@ -18,6 +18,7 @@ // 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 @@ -29,6 +30,9 @@ #include #include +#include +#include + #include #include #include @@ -132,7 +136,13 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const RemoveHoles(&HI, anOriginalShape, aShape); break; case SEWING: - Sew(&HI, anOriginalShape, aShape); + Sew(&HI, anOriginalShape, aShape, false); + break; + case SEWING_NON_MANIFOLD: + Sew(&HI, anOriginalShape, aShape, true); + break; + case REMOVE_INTERNAL_FACES: + RemoveInternalFaces(anOriginalShape, aShape); break; case DIVIDE_EDGE: AddPointOnEdge(&HI, anOriginalShape, aShape); @@ -417,12 +427,16 @@ Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI, //======================================================================= Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI, const TopoDS_Shape& theOriginalShape, - TopoDS_Shape& theOutShape) const + TopoDS_Shape& theOutShape, + Standard_Boolean isAllowNonManifold) const { Standard_Real aTol = theHI->GetTolerance(); ShHealOper_Sewing aHealer (theOriginalShape, aTol); + // Set non-manifold mode. + aHealer.SetNonManifoldMode(isAllowNonManifold); + Standard_Boolean aResult = aHealer.Perform(); if (aResult) @@ -433,6 +447,36 @@ Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI, return aResult; } +//======================================================================= +//function : RemoveInternalFaces +//purpose : +//======================================================================= +Standard_Boolean GEOMImpl_HealingDriver::RemoveInternalFaces (const TopoDS_Shape& theOriginalShape, + TopoDS_Shape& theOutShape) const +{ + GEOMAlgo_RemoverWebs aTool; + aTool.SetShape(theOriginalShape); + aTool.Perform(); + + if (aTool.ErrorStatus() == 0) { // OK + theOutShape = aTool.Result(); + + // as GEOMAlgo_RemoverWebs always produces compound, lets simplify it + // for the case, if it contains only one sub-shape + TopTools_ListOfShape listShapeRes; + GEOMUtils::AddSimpleShapes(theOutShape, listShapeRes); + if (listShapeRes.Extent() == 1) { + theOutShape = listShapeRes.First(); + } + } + else if (aTool.ErrorStatus() == 11) // invalid argument (contains non-solids), do nothing + theOutShape = theOriginalShape; + else // error + StdFail_NotDone::Raise("GEOMAlgo_RemoverWebs failed!"); + + return Standard_True; +} + //======================================================================= //function : AddPointOnEdge //purpose : @@ -771,45 +815,109 @@ Standard_Boolean GEOMImpl_HealingDriver::AreEdgesC1 (const TopoDS_Edge& E1, cons return Standard_False; } -//======================================================================= -//function : GEOMImpl_HealingDriver_Type_ -//purpose : -//======================================================================= -Standard_EXPORT Handle_Standard_Type& GEOMImpl_HealingDriver_Type_() -{ - - static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); - static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); - - - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; - static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_HealingDriver", - sizeof(GEOMImpl_HealingDriver), - 1, - (Standard_Address)_Ancestors, - (Standard_Address)NULL); - - return _aType; -} +//================================================================================ +/*! + * \brief Returns a name of creation operation and names and values of creation parameters + */ +//================================================================================ -//======================================================================= -//function : DownCast -//purpose : -//======================================================================= - -const Handle(GEOMImpl_HealingDriver) Handle(GEOMImpl_HealingDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +bool GEOMImpl_HealingDriver:: +GetCreationInformation(std::string& theOperationName, + std::vector& theParams) { - Handle(GEOMImpl_HealingDriver) _anOtherObject; + if (Label().IsNull()) return 0; + Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label()); - if (!AnObject.IsNull()) { - if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_HealingDriver))) { - _anOtherObject = Handle(GEOMImpl_HealingDriver)((Handle(GEOMImpl_HealingDriver)&)AnObject); - } - } + GEOMImpl_IHealing aCI( function ); + Standard_Integer aType = function->GetType(); - return _anOtherObject; + switch ( aType ) { + case SHAPE_PROCESS: + { + theOperationName = "SHAPE_PROCESS"; + AddParam( theParams, "Object", aCI.GetOriginal() ); + Handle(TColStd_HArray1OfExtendedString) anOperators = aCI.GetOperators(); + Handle(TColStd_HArray1OfExtendedString) aParams = aCI.GetParameters(); + Handle(TColStd_HArray1OfExtendedString) aValues = aCI.GetValues(); + for ( int i = anOperators->Lower(), nb = anOperators->Upper(); i <= nb; ++i ) + { + const TCollection_ExtendedString& op = anOperators->Value(i); + AddParam( theParams, "Operation", op ); + for ( int iP = aParams->Lower(), nbP = aParams->Upper(); iP <= nbP; ++iP ) + { + const TCollection_ExtendedString& par = aParams->Value(i); + TCollection_AsciiString parAscii( par ); + if ( par.Search( op ) == 1 && parAscii.Value( op.Length() + 1 ) == '.' ) + { + GEOM_Param& p = AddParam( theParams, parAscii.ToCString() ); + if ( iP <= aValues->Upper() ) + p << aValues->Value( iP ); + } + } + } + break; + } + case SUPPRESS_FACES: + theOperationName = "SUPPRESS_FACES"; + AddParam( theParams, "Selected Shape", aCI.GetOriginal() ); + AddParam( theParams, "Faces to remove", aCI.GetFaces() ); + break; + case CLOSE_CONTOUR: + theOperationName = "CLOSE_CONTOUR"; + AddParam( theParams, "Selected Shape", aCI.GetOriginal() ); + AddParam( theParams, "Contour to close", aCI.GetWires() ); + AddParam( theParams, "Close by common vertex", aCI.GetIsCommonVertex() ); + break; + case REMOVE_INT_WIRES: + theOperationName = "SUPPRESS_INT_WIRES"; + AddParam( theParams, "Selected face", aCI.GetOriginal() ); + AddParam( theParams, "Wires to remove", aCI.GetWires(), "all" ); + break; + case FILL_HOLES: + theOperationName = "SUPPERSS_HOLES"; + AddParam( theParams, "Selected shape", aCI.GetOriginal() ); + AddParam( theParams, "Wires to remove", aCI.GetWires(), "all" ); + break; + case SEWING: + case SEWING_NON_MANIFOLD: + theOperationName = "SEWING"; + AddParam( theParams, "Selected shape", aCI.GetOriginal() ); + AddParam( theParams, "Allow Non Manifold", ( aType == SEWING_NON_MANIFOLD )); + AddParam( theParams, "Tolerance", aCI.GetTolerance() ); + break; + case DIVIDE_EDGE: + theOperationName = "POINT_ON_EDGE"; + if ( aCI.GetIndex() > 0 ) + AddParam( theParams, "Edge", "#" ) << aCI.GetIndex() << " of " << aCI.GetOriginal(); + else + AddParam( theParams, "Edge", aCI.GetOriginal() ); + AddParam( theParams, "By parameter", aCI.GetIsByParameter() ); + AddParam( theParams, "Value", aCI.GetDevideEdgeValue() ); + break; + case CHANGE_ORIENTATION: + theOperationName = "CHANGE_ORIENTATION"; + AddParam( theParams, "Selected shape", aCI.GetOriginal() ); + break; + case LIMIT_TOLERANCE: + theOperationName = "LIMIT_TOLERANCE"; + AddParam( theParams, "Selected shape", aCI.GetOriginal() ); + AddParam( theParams, "Tolerance", aCI.GetTolerance() ); + break; + case FUSE_COLLINEAR_EDGES: + theOperationName = "FUSE_EDGES"; + AddParam( theParams, "Wire", aCI.GetOriginal() ); + AddParam( theParams, "Vertexes", aCI.GetShapes() ); + break; + case REMOVE_INTERNAL_FACES: + theOperationName = "REMOVE_WEBS"; + AddParam( theParams, "Selected shape", aCI.GetOriginal() ); + break; + default: + return false; + } + + return true; } +IMPLEMENT_STANDARD_HANDLE (GEOMImpl_HealingDriver,GEOM_BaseDriver); + +IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_HealingDriver,GEOM_BaseDriver);