X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_IBlocksOperations.cxx;h=a3f53ce5bb076eaa5429ec8ca1e8d8a0fb9303b5;hb=04e48a49077a1dbdffb320370fd97927e935950b;hp=aac760183168f6de90fc0915a8a13170ac574ff9;hpb=9499b99fe2dcb53e1ea364f97986f8f432b04600;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index aac760183..a3f53ce5b 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -1,22 +1,24 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// 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. +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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 +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// 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. // +// 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 + #ifdef WNT #pragma warning( disable:4786 ) #endif @@ -94,6 +96,7 @@ #include +#include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC //============================================================================= @@ -161,6 +164,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad //Compute the Face value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a face"); return NULL; @@ -216,6 +222,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad2Edges //Compute the Face value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a face"); return NULL; @@ -278,6 +287,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeQuad4Vertices //Compute the Face value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a face"); return NULL; @@ -347,6 +359,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa //Compute the Block value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a block"); return NULL; @@ -403,6 +418,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeHexa2Faces //Compute the Block value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a block"); return NULL; @@ -456,6 +474,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeBlockCompound //Compute the Blocks Compound value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to compute a blocks compound"); return NULL; @@ -585,6 +606,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdge //Compute the Edge value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopTools_IndexedDataMapOfShapeListOfShape MVE; GEOMImpl_Block6Explorer::MapShapesAndAncestors (aBlockOrComp, TopAbs_VERTEX, TopAbs_EDGE, MVE); @@ -688,6 +712,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetEdgeNearPoint //Compute the Edge value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopoDS_Shape aShape; TopoDS_Vertex aVert = TopoDS::Vertex(anArg); @@ -817,6 +844,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByPoints //Compute the Face value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopoDS_Shape aShape; TopTools_IndexedDataMapOfShapeListOfShape MVF; @@ -934,12 +964,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByEdges SetErrorCode("Block or compound is null"); return NULL; } - if (aBlockOrComp.ShapeType() != TopAbs_SOLID && - aBlockOrComp.ShapeType() != TopAbs_COMPOUND && - aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { - SetErrorCode("Shape is neither a block, nor a compound of blocks"); - return NULL; - } TopoDS_Shape anArg1 = theEdge1->GetValue(); TopoDS_Shape anArg2 = theEdge2->GetValue(); @@ -955,6 +979,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByEdges //Compute the Face value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopoDS_Shape aShape; TopTools_IndexedDataMapOfShapeListOfShape MEF; @@ -1077,6 +1104,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetOppositeFace //Compute the Face value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopoDS_Shape aShape; GEOMImpl_Block6Explorer aBlockTool; @@ -1127,12 +1157,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint SetErrorCode("Block or compound is null"); return NULL; } - if (aBlockOrComp.ShapeType() != TopAbs_SOLID && - aBlockOrComp.ShapeType() != TopAbs_COMPOUND && - aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { - SetErrorCode("Shape is neither a block, nor a compound of blocks"); - return NULL; - } TopoDS_Shape anArg = thePoint->GetValue(); if (anArg.IsNull()) { @@ -1146,6 +1170,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceNearPoint //Compute the Face value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopoDS_Shape aShape; TopoDS_Vertex aVert = TopoDS::Vertex(anArg); @@ -1322,12 +1349,6 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByNormale SetErrorCode("Block or compound is null"); return NULL; } - if (aBlockOrComp.ShapeType() != TopAbs_SOLID && - aBlockOrComp.ShapeType() != TopAbs_COMPOUND && - aBlockOrComp.ShapeType() != TopAbs_COMPSOLID) { - SetErrorCode("Shape is neither a block, nor a compound of blocks"); - return NULL; - } TopoDS_Shape anArg = theVector->GetValue(); if (anArg.IsNull()) { @@ -1341,6 +1362,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByNormale //Compute the Face value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopoDS_Shape aShape; TopoDS_Edge anEdge = TopoDS::Edge(anArg); @@ -1454,6 +1478,9 @@ Standard_Boolean GEOMImpl_IBlocksOperations::IsCompoundOfBlocks //Check isCompOfBlocks = Standard_True; try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopTools_MapOfShape mapShape; TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); for (; exp.More(); exp.Next()) { @@ -1898,7 +1925,7 @@ Standard_Boolean HasAnyConnection (const Standard_Integer theBlockIndex, //============================================================================= Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocksOld (Handle(GEOM_Object) theCompound, - list& theErrors) + std::list& theErrors) { SetErrorCode(KO); @@ -2050,11 +2077,11 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocksOld //============================================================================= TCollection_AsciiString GEOMImpl_IBlocksOperations::PrintBCErrors (Handle(GEOM_Object) theCompound, - const list& theErrors) + const std::list& theErrors) { TCollection_AsciiString aDescr; - list::const_iterator errIt = theErrors.begin(); + std::list::const_iterator errIt = theErrors.begin(); int i = 0; for (; errIt != theErrors.end(); i++, errIt++) { BCError errStruct = *errIt; @@ -2079,8 +2106,8 @@ TCollection_AsciiString GEOMImpl_IBlocksOperations::PrintBCErrors break; } - list sshList = errStruct.incriminated; - list::iterator sshIt = sshList.begin(); + std::list sshList = errStruct.incriminated; + std::list::iterator sshIt = sshList.begin(); int jj = 0; for (; sshIt != sshList.end(); jj++, sshIt++) { if (jj > 0) @@ -2099,7 +2126,7 @@ TCollection_AsciiString GEOMImpl_IBlocksOperations::PrintBCErrors //============================================================================= Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound, - list& theErrors) + std::list& theErrors) { SetErrorCode(KO); @@ -2195,7 +2222,7 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks } // 3. Find not glued blocks - GEOMAlgo_GlueAnalyser aGD; + GEOMAlgo_GlueAnalyser aGD; aGD.SetShape(aComp); aGD.SetTolerance(Precision::Confusion()); @@ -2282,7 +2309,8 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks */ //============================================================================= Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges - (Handle(GEOM_Object) theObject) + (Handle(GEOM_Object) theObject, + const Standard_Integer theOptimumNbFaces) { SetErrorCode(KO); @@ -2303,9 +2331,13 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges GEOMImpl_IBlockTrsf aTI (aFunction); aTI.SetOriginal(aLastFunction); + aTI.SetOptimumNbFaces(theOptimumNbFaces); //Compute the fixed shape try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to remove extra edges of the given shape"); return NULL; @@ -2318,8 +2350,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges } //Make a Python command - GEOM::TPythonDump(aFunction) << aCopy - << " = geompy.RemoveExtraEdges(" << theObject << ")"; + std::string doUnionFaces = (theOptimumNbFaces < 0) ? "False" : "True"; + GEOM::TPythonDump(aFunction) << aCopy << " = geompy.RemoveExtraEdges(" + << theObject << ", " << doUnionFaces.data() << ")"; SetErrorCode(OK); return aCopy; @@ -2353,8 +2386,15 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::CheckAndImprove GEOMImpl_IBlockTrsf aTI (aFunction); aTI.SetOriginal(aLastFunction); + // -1 means do not unite faces on common surface (?except case of seam edge between them?) + //aTI.SetOptimumNbFaces(-1); + aTI.SetOptimumNbFaces(6); + //Compute the fixed shape try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to improve the given blocks compound"); return NULL; @@ -2404,6 +2444,9 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::ExplodeCompound // Explode try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); for (; exp.More(); exp.Next()) { if (mapShape.Add(exp.Current())) { @@ -2496,6 +2539,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockNearPoint //Compute the Block value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopoDS_Shape aShape; TopoDS_Vertex aVert = TopoDS::Vertex(anArg); @@ -2672,6 +2718,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetBlockByParts //Compute the Block value try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif // 1. Explode compound on solids TopTools_MapOfShape mapShape; Standard_Integer nbSolids = 0; @@ -2788,6 +2837,9 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IBlocksOperations::GetBlocksByPart //Get the Blocks try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif TopTools_MapOfShape mapShape; Standard_Integer nbSolids = 0; TopExp_Explorer exp (aBlockOrComp, TopAbs_SOLID); @@ -2908,6 +2960,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation1D //Compute the transformation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to make multi-transformation"); return NULL; @@ -2969,6 +3024,9 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::MakeMultiTransformation2D //Compute the transformation try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Block driver failed to make multi-transformation"); return NULL;