Back to index

salome-geom  6.5.0
GEOMImpl_IShapesOperations.hxx
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 
00023 //=============================================================================
00024 // File      : GEOMImpl_IShapesOperations.hxx
00025 // Created   :
00026 // Author    : modified by Lioka RAZAFINDRAZAKA (CEA) 22/06/2007
00027 // Project   : SALOME
00028 //=============================================================================
00029 
00030 #ifndef _GEOMImpl_IShapesOperations_HXX_
00031 #define _GEOMImpl_IShapesOperations_HXX_
00032 
00033 #include "GEOM_IOperations.hxx"
00034 
00035 #include "GEOMAlgo_State.hxx"
00036 
00037 #include <TopoDS_Shape.hxx>
00038 #include <TopTools_ListOfShape.hxx>
00039 #include <NCollection_DataMap.hxx>
00040 #include <TColStd_HSequenceOfTransient.hxx>
00041 #include <TColStd_HSequenceOfInteger.hxx>
00042 
00043 #include <Handle_Geom_Surface.hxx>
00044 
00045 #include <gp_Pnt.hxx>
00046 
00047 #include <list>
00048 #include <functional>
00049 
00050 class GEOM_Engine;
00051 class Handle(GEOM_Object);
00052 class Handle(TColStd_HArray1OfInteger);
00053 
00054 inline Standard_Boolean IsEqual (const TopoDS_Shape& S1, const TopoDS_Shape& S2)
00055 {
00056   return S1.IsSame(S2);
00057 }
00058 
00059 class GEOMImpl_IShapesOperations : public GEOM_IOperations
00060 {
00061  public:
00062   Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
00063   Standard_EXPORT ~GEOMImpl_IShapesOperations();
00064 
00065   Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
00066                                                 Handle(GEOM_Object) thePoint2);
00067 
00068   Standard_EXPORT Handle(GEOM_Object) MakeEdgeOnCurveByLength (Handle(GEOM_Object) theCurve,
00069                                                                const Standard_Real theLength,
00070                                                                Handle(GEOM_Object) theStartPoint);
00071 
00072   Standard_EXPORT Handle(GEOM_Object) MakeEdgeWire (Handle(GEOM_Object) theWire,
00073                                                     const Standard_Real theLinearTolerance,
00074                                                     const Standard_Real theAngularTolerance);
00075 
00076   Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
00077                                                 const Standard_Real            theTolerance);
00078 
00079   Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
00080 
00081   Standard_EXPORT Handle(GEOM_Object) MakeFaceWires (std::list<Handle(GEOM_Object)> theWires,
00082                                                      const bool isPlanarWanted);
00083 
00084   Standard_EXPORT Handle(GEOM_Object) MakeShell (std::list<Handle(GEOM_Object)> theShapes);
00085 
00086   Standard_EXPORT Handle(GEOM_Object) MakeSolidShells (std::list<Handle(GEOM_Object)> theShells);
00087 
00088   Standard_EXPORT Handle(GEOM_Object) MakeCompound (std::list<Handle(GEOM_Object)> theShapes);
00089 
00090   Standard_EXPORT Handle(GEOM_Object) MakeGlueFaces (Handle(GEOM_Object) theShape,
00091                                                      const Standard_Real theTolerance,
00092                                                      const Standard_Boolean doKeepNonSolids);
00093 
00094   //Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueFaces (Handle(GEOM_Object) theShape,
00095   //                                                                   const Standard_Real theTolerance);
00096 
00097   Standard_EXPORT Handle(GEOM_Object) MakeGlueFacesByList (Handle(GEOM_Object) theShape,
00098                                                            const Standard_Real theTolerance,
00099                                                            std::list<Handle(GEOM_Object)> theFaces,
00100                                                            const Standard_Boolean doKeepNonSolids,
00101                                                            const Standard_Boolean doGlueAllEdges);
00102 
00103   Standard_EXPORT Handle(GEOM_Object) MakeGlueEdges (Handle(GEOM_Object) theShape,
00104                                                      const Standard_Real theTolerance);
00105 
00106   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetGlueShapes (Handle(GEOM_Object) theShape,
00107                                                                       const Standard_Real theTolerance,
00108                                                                       const TopAbs_ShapeEnum theType);
00109 
00110   Standard_EXPORT Handle(GEOM_Object) MakeGlueEdgesByList (Handle(GEOM_Object) theShape,
00111                                                            const Standard_Real theTolerance,
00112                                                            std::list<Handle(GEOM_Object)> theEdges);
00113 
00114   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetExistingSubObjects
00115     (Handle(GEOM_Object)    theShape,
00116      const Standard_Boolean theGroupsOnly);
00117 
00118   enum ExplodeType {
00119     EXPLODE_OLD_INCLUDE_MAIN,
00120     EXPLODE_NEW_INCLUDE_MAIN,
00121     EXPLODE_NEW_EXCLUDE_MAIN
00122   };
00123 
00124   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeExplode
00125     (Handle(GEOM_Object)    theShape,
00126      const Standard_Integer theShapeType,
00127      const Standard_Boolean isSorted,
00128      const ExplodeType      theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
00129 
00130   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) SubShapeAllIDs
00131     (Handle(GEOM_Object)    theShape,
00132      const Standard_Integer theShapeType,
00133      const Standard_Boolean isSorted,
00134      const ExplodeType      theExplodeType = EXPLODE_NEW_INCLUDE_MAIN);
00135 
00136   Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object)    theMainShape,
00137                                                    const Standard_Integer theID);
00138 
00139   Standard_EXPORT Handle(TColStd_HSequenceOfTransient) MakeSubShapes
00140     (Handle(GEOM_Object)              theMainShape,
00141      Handle(TColStd_HArray1OfInteger) theIndices);
00142 
00143   Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
00144                                                      Handle(GEOM_Object) theSubShape);
00145 
00146   Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape,
00147                                                      Handle(GEOM_Object) theSubShape);
00148 
00149   Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
00150 
00151   Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object)    theShape,
00152                                                       const Standard_Integer theShapeType);
00153 
00154   Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
00155 
00156   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetFreeFacesIDs (Handle(GEOM_Object) theShape);
00157 
00158   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00159     GetSharedShapes (Handle(GEOM_Object)    theShape1,
00160                      Handle(GEOM_Object)    theShape2,
00161                      const Standard_Integer theShapeType);
00162 
00163   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00164     GetSharedShapes (std::list<Handle(GEOM_Object)> theShapes,
00165                      const Standard_Integer         theShapeType);
00166 
00167   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00168     GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
00169                       const Standard_Integer     theShapeType,
00170                       const Handle(GEOM_Object)& theAx1,
00171                       const GEOMAlgo_State       theState);
00172 
00173   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00174     GetShapesOnPlaneWithLocation (const Handle(GEOM_Object)& theShape,
00175                                   const Standard_Integer     theShapeType,
00176                                   const Handle(GEOM_Object)& theAx1,
00177                                   const Handle(GEOM_Object)& thePnt,
00178                                   const GEOMAlgo_State       theState);
00179 
00180 
00181   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00182     GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
00183                          const Standard_Integer     theShapeType,
00184                          const Handle(GEOM_Object)& theAxis,
00185                          const Standard_Real        theRadius,
00186                          const GEOMAlgo_State       theState);
00187 
00188   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00189     GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
00190                                      const Standard_Integer     theShapeType,
00191                                      const Handle(GEOM_Object)& theAxis,
00192                                      const Handle(GEOM_Object)& thePnt,
00193                                      const Standard_Real        theRadius,
00194                                      const GEOMAlgo_State       theState);
00195 
00196   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00197     GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
00198                        const Standard_Integer     theShapeType,
00199                        const Handle(GEOM_Object)& theCenter,
00200                        const Standard_Real        theRadius,
00201                        const GEOMAlgo_State       theState);
00202 
00203   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00204     GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
00205                          const Standard_Integer     theShapeType,
00206                          const Handle(GEOM_Object)& theAx1,
00207                          const GEOMAlgo_State       theState);
00208 
00209   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00210     GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
00211                                      const Standard_Integer     theShapeType,
00212                                      const Handle(GEOM_Object)& theAx1,
00213                                      const Handle(GEOM_Object)& thePnt,
00214                                      const GEOMAlgo_State       theState);
00215 
00216   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00217     GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
00218                             const Standard_Integer     theShapeType,
00219                             const Handle(GEOM_Object)& theAxis,
00220                             const Standard_Real        theRadius,
00221                             const GEOMAlgo_State       theState);
00222 
00223   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00224     GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
00225                                         const Standard_Integer     theShapeType,
00226                                         const Handle(GEOM_Object)& theAxis,
00227                                         const Handle(GEOM_Object)& thePnt,
00228                                         const Standard_Real        theRadius,
00229                                         const GEOMAlgo_State       theState);
00230 
00231   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00232     GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
00233                           const Standard_Integer     theShapeType,
00234                           const Handle(GEOM_Object)& theCenter,
00235                           const Standard_Real        theRadius,
00236                           const GEOMAlgo_State       theState);
00237 
00249   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00250     GetShapesOnQuadrangle (const Handle(GEOM_Object)& theShape,
00251                            const Standard_Integer     theShapeType,
00252                            const Handle(GEOM_Object)& theTopLeftPoint,
00253                            const Handle(GEOM_Object)& theTopRigthPoint,
00254                            const Handle(GEOM_Object)& theBottomLeftPoint,
00255                            const Handle(GEOM_Object)& theBottomRigthPoint,
00256                            const GEOMAlgo_State       theState);
00257 
00269   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00270     GetShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
00271                               const Standard_Integer     theShapeType,
00272                               const Handle(GEOM_Object)& theTopLeftPoint,
00273                               const Handle(GEOM_Object)& theTopRigthPoint,
00274                               const Handle(GEOM_Object)& theBottomLeftPoint,
00275                               const Handle(GEOM_Object)& theBottomRigthPoint,
00276                               const GEOMAlgo_State       theState);
00277 
00278   Standard_EXPORT Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object)    theShape,
00279                                                               const Standard_Integer theShapeType,
00280                                                               Handle(GEOM_Object)    theAxis,
00281                                                               const Standard_Real    theRadius);
00282 
00283   Standard_EXPORT Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object)    theShape,
00284                                                             const Standard_Integer theShapeType,
00285                                                             Handle(GEOM_Object)    theCenter,
00286                                                             const Standard_Real    theRadius);
00287 
00288   void GetShapeProperties(const TopoDS_Shape aShape, Standard_Real propertiesArray[], gp_Pnt & aPnt);
00289 
00290   Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
00291                                                   Handle(GEOM_Object) theShapeWhat);
00292 
00293   Standard_EXPORT Handle(GEOM_Object) GetInPlaceOld (Handle(GEOM_Object) theShapeWhere,
00294                                                      Handle(GEOM_Object) theShapeWhat);
00295 
00296   Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
00297                                                            Handle(GEOM_Object) theShapeWhat);
00298 
00305   Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
00306                                               const Handle(GEOM_Object)& theShapeWhat);
00307 
00314   Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetSameIDs(const Handle(GEOM_Object)& theShapeWhere,
00315                                                                  const Handle(GEOM_Object)& theShapeWhat);
00316 
00325   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00326                               GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
00327                                                 const Handle(GEOM_Object)& theShape,
00328                                                 const Standard_Integer theShapeType,
00329                                                 GEOMAlgo_State theState);
00330 
00339   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00340                              GetShapesOnBox(const Handle(GEOM_Object)& theBox,
00341                                             const Handle(GEOM_Object)& theShape,
00342                                             const Standard_Integer theShapeType,
00343                                             GEOMAlgo_State theState);
00344 
00353   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00354                    GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
00355                                        const Handle(GEOM_Object)& theShape,
00356                                        const Standard_Integer theShapeType,
00357                                        GEOMAlgo_State theState);
00358 
00367   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00368                       GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
00369                                        const Handle(GEOM_Object)& theShape,
00370                                        const Standard_Integer theShapeType,
00371                                        GEOMAlgo_State theState);
00372   Standard_EXPORT Handle(GEOM_Object)
00373             GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
00374                                        const Handle(GEOM_Object)& theShape,
00375                                        const Standard_Integer theShapeType,
00376                                        GEOMAlgo_State theState);
00377 
00378  public:
00383   struct CompareShapes : public std::binary_function<TopoDS_Shape, TopoDS_Shape, bool>
00384   {
00385     CompareShapes (bool isOldSorting)
00386       : myIsOldSorting(isOldSorting) {}
00387 
00388     bool operator()(const TopoDS_Shape& lhs, const TopoDS_Shape& rhs);
00389 
00390     typedef NCollection_DataMap<TopoDS_Shape, std::pair<double, double> > NCollection_DataMapOfShapeDouble;
00391     NCollection_DataMapOfShapeDouble myMap;
00392     bool myIsOldSorting;
00393   };
00394 
00395   Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL,
00396                                           const Standard_Boolean isOldSorting = Standard_True);
00397 
00406   Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
00407 
00413   Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
00414 
00420   Standard_EXPORT static TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape);
00421 
00422  private:
00423   Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)>      theShapes,
00424                                  const Standard_Integer         theObjectType,
00425                                  const Standard_Integer         theFunctionType,
00426                                  const TCollection_AsciiString& theMethodName);
00427 
00428 // ----------------------------------------------------
00429 // methods common for all GetShapesOnXXX() functions
00430 // ----------------------------------------------------
00431 
00437   bool checkTypeShapesOn(const Standard_Integer theShapeType);
00438 
00444   Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
00445 
00452   Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
00453                                     const Standard_Real theRadius);
00454 
00463   Handle(TColStd_HSequenceOfInteger)
00464     getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
00465                           const TopoDS_Shape&         theShape,
00466                           TopAbs_ShapeEnum            theShapeType,
00467                           GEOMAlgo_State              theState);
00468 
00478   Handle(TColStd_HSequenceOfTransient)
00479     getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
00480                        const Handle(GEOM_Object)&  theShape,
00481                        TopAbs_ShapeEnum            theShapeType,
00482                        GEOMAlgo_State              theState,
00483                        TCollection_AsciiString &   theShapeEntries);
00484 
00496   Handle(TColStd_HSequenceOfInteger)
00497     getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
00498                               const Standard_Integer     theShapeType,
00499                               const Handle(GEOM_Object)& theTopLeftPoint,
00500                               const Handle(GEOM_Object)& theTopRigthPoint,
00501                               const Handle(GEOM_Object)& theBottomLeftPoint,
00502                               const Handle(GEOM_Object)& theBottomRigthPoint,
00503                               const GEOMAlgo_State       theState);
00504 
00513   Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
00514                                                        const Handle(GEOM_Object)& theShape,
00515                                                        const Standard_Integer theShapeType,
00516                                                        GEOMAlgo_State theState);
00517 
00526   Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
00527                                       (const Handle(GEOM_Object)& theCheckShape,
00528                                        const Handle(GEOM_Object)& theShape,
00529                                        const Standard_Integer theShapeType,
00530                                        GEOMAlgo_State theState);
00531 
00539   Handle(TColStd_HSequenceOfTransient)
00540     getObjectsShapesOn(const Handle(GEOM_Object)&                theShape,
00541                        const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
00542                        TCollection_AsciiString &                 theShapeEntries);
00543 
00550   static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
00551                                             const Handle(GEOM_Object)& theObj2);
00552 };
00553 
00554 #endif