Back to index

salome-geom  6.5.0
BlockFix_BlockFixAPI.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 
00022 //  File:    BlockFix_BlockFixAPI.cxx
00023 //  Created: Tue Dec  7 11:59:05 2004
00024 //  Author:  Pavel DURANDIN
00025 
00026 #include <BlockFix_BlockFixAPI.ixx>
00027 
00028 #include <BlockFix.hxx>
00029 #include <BlockFix_UnionFaces.hxx>
00030 #include <BlockFix_UnionEdges.hxx>
00031 
00032 #include <Basics_OCCTVersion.hxx>
00033 
00034 #include <ShapeUpgrade_RemoveLocations.hxx>
00035 
00036 #include <Precision.hxx>
00037 
00038 //=======================================================================
00039 //function : ShapeConvert_CanonicAPI
00040 //purpose  :
00041 //=======================================================================
00042 
00043 BlockFix_BlockFixAPI::BlockFix_BlockFixAPI()
00044 {
00045   myTolerance = Precision::Confusion();
00046   myOptimumNbFaces = 6;
00047 }
00048 
00049 //=======================================================================
00050 //function : Perform
00051 //purpose  :
00052 //=======================================================================
00053 
00054 void BlockFix_BlockFixAPI::Perform()
00055 {
00056   // processing spheres with degenerativities
00057   TopoDS_Shape aShape = Shape();
00058   myShape = BlockFix::RotateSphereSpace(aShape,myTolerance);
00059 
00060   // try to approximate non-canonic surfaces
00061   // with singularities on boundaries by filling
00062   myShape = BlockFix::RefillProblemFaces(myShape);
00063 
00064   // faces unification
00065   BlockFix_UnionFaces aFaceUnifier;
00066   aFaceUnifier.GetTolerance() = myTolerance;
00067   aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces;
00068   TopoDS_Shape aResult = aFaceUnifier.Perform(myShape);
00069 
00070   // avoid problem with degenerated edges appearance
00071   // due to shape quality regress
00072   ShapeUpgrade_RemoveLocations RemLoc;
00073   RemLoc.Remove(aResult);
00074   aResult = RemLoc.GetResult();
00075 
00076   // edges unification
00077   BlockFix_UnionEdges anEdgeUnifier;
00078   myShape = anEdgeUnifier.Perform(aResult,myTolerance);
00079 
00080   TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance);
00081   myShape = aRes;
00082 }