Version: 6.3.1

src/GEOMImpl/GEOMImpl_IShapesOperations.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere,
00294                                                            Handle(GEOM_Object) theShapeWhat);
00295 
00302   Standard_EXPORT Handle(GEOM_Object) GetSame(const Handle(GEOM_Object)& theShapeWhere,
00303                                               const Handle(GEOM_Object)& theShapeWhat);
00304 
00313   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00314                               GetShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
00315                                                 const Handle(GEOM_Object)& theShape,
00316                                                 const Standard_Integer theShapeType,
00317                                                 GEOMAlgo_State theState);
00318 
00327   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00328                              GetShapesOnBox(const Handle(GEOM_Object)& theBox,
00329                                             const Handle(GEOM_Object)& theShape,
00330                                             const Standard_Integer theShapeType,
00331                                             GEOMAlgo_State theState);
00332 
00341   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
00342                    GetShapesOnShapeIDs(const Handle(GEOM_Object)& theCheckShape,
00343                                        const Handle(GEOM_Object)& theShape,
00344                                        const Standard_Integer theShapeType,
00345                                        GEOMAlgo_State theState);
00346 
00355   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
00356                       GetShapesOnShape(const Handle(GEOM_Object)& theCheckShape,
00357                                        const Handle(GEOM_Object)& theShape,
00358                                        const Standard_Integer theShapeType,
00359                                        GEOMAlgo_State theState);
00360   Standard_EXPORT Handle(GEOM_Object)
00361             GetShapesOnShapeAsCompound(const Handle(GEOM_Object)& theCheckShape,
00362                                        const Handle(GEOM_Object)& theShape,
00363                                        const Standard_Integer theShapeType,
00364                                        GEOMAlgo_State theState);
00365 
00366  public:
00371   struct CompareShapes : public std::binary_function<TopoDS_Shape, TopoDS_Shape, bool>
00372   {
00373     CompareShapes (bool isOldSorting)
00374       : myIsOldSorting(isOldSorting) {}
00375 
00376     bool operator()(const TopoDS_Shape& lhs, const TopoDS_Shape& rhs);
00377 
00378     typedef NCollection_DataMap<TopoDS_Shape, std::pair<double, double> > NCollection_DataMapOfShapeDouble;
00379     NCollection_DataMapOfShapeDouble myMap;
00380     bool myIsOldSorting;
00381   };
00382 
00383   Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL,
00384                                           const Standard_Boolean isOldSorting = Standard_True);
00385 
00394   Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
00395 
00401   Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
00402 
00408   Standard_EXPORT static TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape);
00409 
00410  private:
00411   Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)>      theShapes,
00412                                  const Standard_Integer         theObjectType,
00413                                  const Standard_Integer         theFunctionType,
00414                                  const TCollection_AsciiString& theMethodName);
00415 
00416 // ----------------------------------------------------
00417 // methods common for all GetShapesOnXXX() functions
00418 // ----------------------------------------------------
00419 
00425   bool checkTypeShapesOn(const Standard_Integer theShapeType);
00426 
00432   Handle(Geom_Surface) makePlane(const TopoDS_Shape& theAx1);
00433 
00440   Handle(Geom_Surface) makeCylinder(const TopoDS_Shape& theAx1,
00441                                     const Standard_Real theRadius);
00442 
00451   Handle(TColStd_HSequenceOfInteger)
00452     getShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
00453                           const TopoDS_Shape&         theShape,
00454                           TopAbs_ShapeEnum            theShapeType,
00455                           GEOMAlgo_State              theState);
00456 
00466   Handle(TColStd_HSequenceOfTransient)
00467     getShapesOnSurface(const Handle(Geom_Surface)& theSurface,
00468                        const Handle(GEOM_Object)&  theShape,
00469                        TopAbs_ShapeEnum            theShapeType,
00470                        GEOMAlgo_State              theState,
00471                        TCollection_AsciiString &   theShapeEntries);
00472 
00484   Handle(TColStd_HSequenceOfInteger)
00485     getShapesOnQuadrangleIDs (const Handle(GEOM_Object)& theShape,
00486                               const Standard_Integer     theShapeType,
00487                               const Handle(GEOM_Object)& theTopLeftPoint,
00488                               const Handle(GEOM_Object)& theTopRigthPoint,
00489                               const Handle(GEOM_Object)& theBottomLeftPoint,
00490                               const Handle(GEOM_Object)& theBottomRigthPoint,
00491                               const GEOMAlgo_State       theState);
00492 
00501   Handle(TColStd_HSequenceOfInteger) getShapesOnBoxIDs(const Handle(GEOM_Object)& theBox,
00502                                                        const Handle(GEOM_Object)& theShape,
00503                                                        const Standard_Integer theShapeType,
00504                                                        GEOMAlgo_State theState);
00505 
00514   Handle(TColStd_HSequenceOfInteger) getShapesOnShapeIDs
00515                                       (const Handle(GEOM_Object)& theCheckShape,
00516                                        const Handle(GEOM_Object)& theShape,
00517                                        const Standard_Integer theShapeType,
00518                                        GEOMAlgo_State theState);
00519 
00527   Handle(TColStd_HSequenceOfTransient)
00528     getObjectsShapesOn(const Handle(GEOM_Object)&                theShape,
00529                        const Handle(TColStd_HSequenceOfInteger)& theShapeIDs,
00530                        TCollection_AsciiString &                 theShapeEntries);
00531 
00538   static Handle(GEOM_Object) getCreatedLast(const Handle(GEOM_Object)& theObj1,
00539                                             const Handle(GEOM_Object)& theObj2);
00540 };
00541 
00542 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS