Back to index

salome-geom  6.5.0
GEOMAlgo_Gluer2_2.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:      GEOMAlgo_Gluer2_2.cxx
00023 // Created:
00024 // Author:    Peter KURNEV
00025 //            <peter@PREFEX>
00026 //
00027 #include <GEOMAlgo_Gluer2.hxx>
00028 
00029 #include <TopAbs_ShapeEnum.hxx>
00030 
00031 #include <TopoDS_Iterator.hxx>
00032 #include <TopoDS_Shape.hxx>
00033 
00034 #include <GEOMAlgo_BuilderShape.hxx>
00035 #include <GEOMAlgo_Tools3D.hxx>
00036 
00037 //=======================================================================
00038 //function : PrepareHistory
00039 //purpose  :
00040 //=======================================================================
00041 void GEOMAlgo_Gluer2::PrepareHistory()
00042 {
00043   //Standard_Boolean bHasImage, bContainsSD;
00044   //
00045   // 1. Clearing
00046   GEOMAlgo_BuilderShape::PrepareHistory();
00047   //
00048   if(myShape.IsNull()) {
00049     return;
00050   }
00051   //
00052   GEOMAlgo_Gluer2::MapShapes(myShape, myMapShape);
00053   //
00054 }
00055 //=======================================================================
00056 //function : Generated
00057 //purpose  :
00058 //=======================================================================
00059 const TopTools_ListOfShape& GEOMAlgo_Gluer2::Generated(const TopoDS_Shape& )
00060 {
00061   myHistShapes.Clear();
00062   return myHistShapes;
00063 }
00064 //=======================================================================
00065 //function : Modified
00066 //purpose  :
00067 //=======================================================================
00068 const TopTools_ListOfShape& GEOMAlgo_Gluer2::Modified(const TopoDS_Shape& theS)
00069 {
00070   Standard_Boolean bIsDeleted, bHasImage, bToReverse;
00071   TopAbs_ShapeEnum aType;
00072   TopoDS_Shape aSim;
00073   //
00074   myHistShapes.Clear();
00075   //
00076   aType=theS.ShapeType();
00077   if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE ||
00078        aType==TopAbs_FACE || aType==TopAbs_SOLID)) {
00079     return myHistShapes;
00080   }
00081   //
00082   bIsDeleted=IsDeleted(theS);
00083   if (bIsDeleted) {
00084     return myHistShapes;
00085   }
00086   //
00087   bHasImage=myOrigins.IsBound(theS);
00088   if (!bHasImage) {
00089     return myHistShapes;
00090   }
00091   //
00092   aSim=myOrigins.Find(theS);
00093   if (aSim.IsSame(theS)){
00094     return myHistShapes;
00095   }
00096   //
00097   if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) {
00098     aSim.Orientation(theS.Orientation());
00099   }
00100   else {
00101     bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSim, theS, myContext);
00102     if (bToReverse) {
00103       aSim.Reverse();
00104     }
00105   }
00106   //
00107   myHistShapes.Append(aSim);
00108   //
00109   return myHistShapes;
00110 }
00111 //=======================================================================
00112 //function : IsDeleted
00113 //purpose  :
00114 //=======================================================================
00115 Standard_Boolean GEOMAlgo_Gluer2::IsDeleted(const TopoDS_Shape& theS)
00116 {
00117   Standard_Boolean bRet, bContains, bHasImage;
00118   //
00119   bRet=Standard_False;
00120   //
00121   if (theS.IsNull()) {
00122     return !bRet; //true
00123   }
00124   //
00125   bContains=myMapShape.Contains(theS);
00126   if (bContains) {
00127     return bRet; //false
00128   }
00129   //
00130   bHasImage=myOrigins.IsBound(theS);
00131   if (bHasImage) {
00132     const TopoDS_Shape& aSim=myOrigins.Find(theS);
00133     bContains=myMapShape.Contains(aSim);
00134     if (bContains) {
00135       return bRet; //false
00136     }
00137   }
00138   //
00139   return !bRet; //true
00140 }
00141 //=======================================================================
00142 //function : MapShapes
00143 //purpose  :
00144 //=======================================================================
00145 void GEOMAlgo_Gluer2::MapShapes(const TopoDS_Shape& theS,
00146                             TopTools_MapOfShape& theM)
00147 {
00148   TopoDS_Iterator aIt;
00149   //
00150   theM.Add(theS);
00151   aIt.Initialize(theS);
00152   for (; aIt.More(); aIt.Next()) {
00153     const TopoDS_Shape& aSx=aIt.Value();
00154     GEOMAlgo_Gluer2::MapShapes(aSx, theM);
00155   }
00156 }