From b8030029e00603b927b9e2135df018a0e0e05a4c Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 7 Jun 2011 08:37:17 +0000 Subject: [PATCH] IMP 0021129: EDF 1541 GEOM: Problem with GetInPlace. A new GetInPlace implementation by Peter Kurnev. --- idl/GEOM_Gen.idl | 6 + src/GEOMAlgo/GEOMAlgo.cdl | 33 +- ...aMapIteratorOfDataMapOfShapeMapOfShape.hxx | 99 ++ ...apIteratorOfDataMapOfShapeMapOfShape_0.cxx | 59 + ...lgo_DataMapIteratorOfDataMapOfShapePnt.hxx | 99 ++ ...o_DataMapIteratorOfDataMapOfShapePnt_0.cxx | 59 + ..._DataMapNodeOfDataMapOfShapeMapOfShape.hxx | 121 ++ ...ataMapNodeOfDataMapOfShapeMapOfShape_0.cxx | 105 ++ ...EOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx | 121 ++ ...MAlgo_DataMapNodeOfDataMapOfShapePnt_0.cxx | 105 ++ .../GEOMAlgo_DataMapOfShapeMapOfShape.hxx | 132 ++ .../GEOMAlgo_DataMapOfShapeMapOfShape_0.cxx | 62 + src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt.hxx | 132 ++ src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt_0.cxx | 62 + src/GEOMAlgo/GEOMAlgo_GetInPlace.cxx | 1144 +++++++++++++++++ src/GEOMAlgo/GEOMAlgo_GetInPlace.hxx | 324 +++++ src/GEOMAlgo/GEOMAlgo_GetInPlace_1.cxx | 402 ++++++ src/GEOMAlgo/GEOMAlgo_GetInPlace_2.cxx | 232 ++++ src/GEOMAlgo/GEOMAlgo_GetInPlace_3.cxx | 172 +++ ..._DataMapNodeOfDataMapOfShapeMapOfShape.hxx | 43 + ...EOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx | 43 + src/GEOMAlgo/Makefile.am | 28 +- src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 177 ++- src/GEOMImpl/GEOMImpl_IShapesOperations.hxx | 3 + src/GEOM_I/GEOM_IShapesOperations_i.cc | 30 + src/GEOM_I/GEOM_IShapesOperations_i.hh | 3 + src/GEOM_SWIG/geompyDC.py | 9 +- 27 files changed, 3784 insertions(+), 21 deletions(-) create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_0.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_0.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_0.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_0.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapOfShapeMapOfShape.hxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapOfShapeMapOfShape_0.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt.hxx create mode 100644 src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt_0.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_GetInPlace.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_GetInPlace.hxx create mode 100644 src/GEOMAlgo/GEOMAlgo_GetInPlace_1.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_GetInPlace_2.cxx create mode 100644 src/GEOMAlgo/GEOMAlgo_GetInPlace_3.cxx create mode 100644 src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx create mode 100644 src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index febb9b324..30314c028 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2004,6 +2004,12 @@ module GEOM GEOM_Object GetInPlace (in GEOM_Object theShapeWhere, in GEOM_Object theShapeWhat); + /*! + * Old implementation of GetInPlace functionality, based on shape properties. + */ + GEOM_Object GetInPlaceOld (in GEOM_Object theShapeWhere, + in GEOM_Object theShapeWhat); + /*! * Get sub-shape(s) of \a theShapeWhere, which are * coincident with \a theShapeWhat or could be a part of it. diff --git a/src/GEOMAlgo/GEOMAlgo.cdl b/src/GEOMAlgo/GEOMAlgo.cdl index 7b38a0ef6..94d672db4 100755 --- a/src/GEOMAlgo/GEOMAlgo.cdl +++ b/src/GEOMAlgo/GEOMAlgo.cdl @@ -1,4 +1,7 @@ --- Copyright (C) 2005-2011 CEA/DEN, EDF R&D, OPEN CASCADE +-- Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +-- +-- Copyright (C) 2003-2007 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 @@ -19,7 +22,6 @@ -- File: GEOMAlgo.cdl -- Created: Sat Dec 04 12:36:22 2004 -- Author: Peter KURNEV --- package GEOMAlgo @@ -124,23 +126,23 @@ is class ShapeInfo; class ShapeInfoFiller; -- - -- gluer + -- Gluer / GetInPlace +--modified by NIZNHY-PKV Mon Feb 21 10:07:22 2011f +-- class Gluer1; class Gluer; - class Gluer1; - ---modified by NIZNHY-PKV Mon Feb 21 10:07:22 2011f + imported Gluer2 from GEOMAlgo; imported GlueDetector from GEOMAlgo; - imported GluerAlgo from GEOMAlgo; + imported GluerAlgo from GEOMAlgo; + imported GetInPlace from GEOMAlgo; --modified by NIZNHY-PKV Mon Feb 21 10:07:27 2011t - + class GlueAnalyser; class CoupleOfShapes; class PassKey; class PassKeyMapHasher; class PassKeyShape; - class SurfaceTools; class Tools; -- @@ -245,6 +247,17 @@ is class DataMapOfOrientedShapeShape instantiates DataMap from TCollection (Shape from TopoDS, Shape from TopoDS, - OrientedShapeMapHasher from TopTools); + OrientedShapeMapHasher from TopTools); + + --modified by NIZNHY-PKV Thu Apr 28 08:25:36 2011f + class DataMapOfShapeMapOfShape instantiates + DataMap from TCollection (Shape from TopoDS, + MapOfShape from TopTools, + ShapeMapHasher from TopTools); + class DataMapOfShapePnt instantiates + DataMap from TCollection (Shape from TopoDS, + Pnt from gp, + ShapeMapHasher from TopTools); + --modified by NIZNHY-PKV Thu Apr 28 08:25:39 2011t end GEOMAlgo; diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx b/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx new file mode 100644 index 000000000..60a66da4a --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx @@ -0,0 +1,99 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#ifndef _GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile +#define _GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class TopoDS_Shape; +class TopTools_MapOfShape; +class TopTools_ShapeMapHasher; +class GEOMAlgo_DataMapOfShapeMapOfShape; +class GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape; + + + +class GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape : public TCollection_BasicMapIterator { +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + + Standard_EXPORT GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape(); + + Standard_EXPORT GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape(const GEOMAlgo_DataMapOfShapeMapOfShape& aMap); + + Standard_EXPORT void Initialize(const GEOMAlgo_DataMapOfShapeMapOfShape& aMap) ; + + Standard_EXPORT const TopoDS_Shape& Key() const; + + Standard_EXPORT const TopTools_MapOfShape& Value() const; + + + + + +protected: + + + + + +private: + + + + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_0.cxx b/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_0.cxx new file mode 100644 index 000000000..55efb4bb1 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_0.cxx @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_MapOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile +#include +#endif + + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopTools_MapOfShape +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape +#define TCollection_DataMapNode_Type_() GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_Type_() +#define TCollection_DataMap GEOMAlgo_DataMapOfShapeMapOfShape +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx b/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx new file mode 100644 index 000000000..e86fd05f5 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx @@ -0,0 +1,99 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#ifndef _GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile +#define _GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class TopoDS_Shape; +class gp_Pnt; +class TopTools_ShapeMapHasher; +class GEOMAlgo_DataMapOfShapePnt; +class GEOMAlgo_DataMapNodeOfDataMapOfShapePnt; + + + +class GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt : public TCollection_BasicMapIterator { +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + + Standard_EXPORT GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt(); + + Standard_EXPORT GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt(const GEOMAlgo_DataMapOfShapePnt& aMap); + + Standard_EXPORT void Initialize(const GEOMAlgo_DataMapOfShapePnt& aMap) ; + + Standard_EXPORT const TopoDS_Shape& Key() const; + + Standard_EXPORT const gp_Pnt& Value() const; + + + + + +protected: + + + + + +private: + + + + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_0.cxx b/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_0.cxx new file mode 100644 index 000000000..06c890444 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_0.cxx @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapOfShapePnt_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile +#include +#endif + + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem gp_Pnt +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMAlgo_DataMapNodeOfDataMapOfShapePnt +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt +#define TCollection_DataMapNode_Type_() GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_Type_() +#define TCollection_DataMap GEOMAlgo_DataMapOfShapePnt +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx b/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx new file mode 100644 index 000000000..1f9c5f17a --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx @@ -0,0 +1,121 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#ifndef _GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile +#define _GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_DefineHandle_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_MapOfShape_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class TopoDS_Shape; +class TopTools_MapOfShape; +class TopTools_ShapeMapHasher; +class GEOMAlgo_DataMapOfShapeMapOfShape; +class GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape; + + + +class GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape : public TCollection_MapNode { + +public: + + + GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape(const TopoDS_Shape& K,const TopTools_MapOfShape& I,const TCollection_MapNodePtr& n); + + TopoDS_Shape& Key() const; + + TopTools_MapOfShape& Value() const; + + + + + DEFINE_STANDARD_RTTI(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape) + +protected: + + + + +private: + + +TopoDS_Shape myKey; +TopTools_MapOfShape myValue; + + +}; + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopTools_MapOfShape +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape +#define TCollection_DataMapNode_Type_() GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_Type_() +#define TCollection_DataMap GEOMAlgo_DataMapOfShapeMapOfShape +#define TCollection_DataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_0.cxx b/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_0.cxx new file mode 100644 index 000000000..ffe863b7a --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_0.cxx @@ -0,0 +1,105 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_MapOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile +#include +#endif + + + + +Standard_EXPORT Handle_Standard_Type& GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape", + sizeof(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape) Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape))) { + _anOtherObject = Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape)((Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape::DynamicType() const +{ + return STANDARD_TYPE(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape) ; +} +//Standard_Boolean GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape::IsKind(const Handle(Standard_Type)& AType) const +//{ +// return (STANDARD_TYPE(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape) == AType || TCollection_MapNode::IsKind(AType)); +//} +//Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape::~Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape() {} +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopTools_MapOfShape +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape +#define TCollection_DataMapNode_Type_() GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_Type_() +#define TCollection_DataMap GEOMAlgo_DataMapOfShapeMapOfShape +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx b/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx new file mode 100644 index 000000000..85b4d369d --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx @@ -0,0 +1,121 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#ifndef _GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile +#define _GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_DefineHandle_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class TopoDS_Shape; +class gp_Pnt; +class TopTools_ShapeMapHasher; +class GEOMAlgo_DataMapOfShapePnt; +class GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt; + + + +class GEOMAlgo_DataMapNodeOfDataMapOfShapePnt : public TCollection_MapNode { + +public: + + + GEOMAlgo_DataMapNodeOfDataMapOfShapePnt(const TopoDS_Shape& K,const gp_Pnt& I,const TCollection_MapNodePtr& n); + + TopoDS_Shape& Key() const; + + gp_Pnt& Value() const; + + + + + DEFINE_STANDARD_RTTI(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt) + +protected: + + + + +private: + + +TopoDS_Shape myKey; +gp_Pnt myValue; + + +}; + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem gp_Pnt +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMAlgo_DataMapNodeOfDataMapOfShapePnt +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt +#define TCollection_DataMapNode_Type_() GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_Type_() +#define TCollection_DataMap GEOMAlgo_DataMapOfShapePnt +#define TCollection_DataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_0.cxx b/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_0.cxx new file mode 100644 index 000000000..b389d2469 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_0.cxx @@ -0,0 +1,105 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapOfShapePnt_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile +#include +#endif + + + + +Standard_EXPORT Handle_Standard_Type& GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("GEOMAlgo_DataMapNodeOfDataMapOfShapePnt", + sizeof(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt) Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt))) { + _anOtherObject = Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt)((Handle(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& GEOMAlgo_DataMapNodeOfDataMapOfShapePnt::DynamicType() const +{ + return STANDARD_TYPE(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt) ; +} +//Standard_Boolean GEOMAlgo_DataMapNodeOfDataMapOfShapePnt::IsKind(const Handle(Standard_Type)& AType) const +//{ +// return (STANDARD_TYPE(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt) == AType || TCollection_MapNode::IsKind(AType)); +//} +//Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt::~Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt() {} +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem gp_Pnt +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMAlgo_DataMapNodeOfDataMapOfShapePnt +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt +#define TCollection_DataMapNode_Type_() GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_Type_() +#define TCollection_DataMap GEOMAlgo_DataMapOfShapePnt +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapOfShapeMapOfShape.hxx b/src/GEOMAlgo/GEOMAlgo_DataMapOfShapeMapOfShape.hxx new file mode 100644 index 000000000..f1e56991c --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapOfShapeMapOfShape.hxx @@ -0,0 +1,132 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#ifndef _GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile +#define _GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class TopoDS_Shape; +class TopTools_MapOfShape; +class TopTools_ShapeMapHasher; +class GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape; +class GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape; + + + +class GEOMAlgo_DataMapOfShapeMapOfShape : public TCollection_BasicMap { +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + + Standard_EXPORT GEOMAlgo_DataMapOfShapeMapOfShape(const Standard_Integer NbBuckets = 1); + + Standard_EXPORT GEOMAlgo_DataMapOfShapeMapOfShape& Assign(const GEOMAlgo_DataMapOfShapeMapOfShape& Other) ; + GEOMAlgo_DataMapOfShapeMapOfShape& operator =(const GEOMAlgo_DataMapOfShapeMapOfShape& Other) +{ + return Assign(Other); +} + + Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; + + Standard_EXPORT void Clear() ; +~GEOMAlgo_DataMapOfShapeMapOfShape() +{ + Clear(); +} + + Standard_EXPORT Standard_Boolean Bind(const TopoDS_Shape& K,const TopTools_MapOfShape& I) ; + + Standard_EXPORT Standard_Boolean IsBound(const TopoDS_Shape& K) const; + + Standard_EXPORT Standard_Boolean UnBind(const TopoDS_Shape& K) ; + + Standard_EXPORT const TopTools_MapOfShape& Find(const TopoDS_Shape& K) const; + const TopTools_MapOfShape& operator()(const TopoDS_Shape& K) const +{ + return Find(K); +} + + Standard_EXPORT TopTools_MapOfShape& ChangeFind(const TopoDS_Shape& K) ; + TopTools_MapOfShape& operator()(const TopoDS_Shape& K) +{ + return ChangeFind(K); +} + + + + + +protected: + + + + + +private: + + + Standard_EXPORT GEOMAlgo_DataMapOfShapeMapOfShape(const GEOMAlgo_DataMapOfShapeMapOfShape& Other); + + + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapOfShapeMapOfShape_0.cxx b/src/GEOMAlgo/GEOMAlgo_DataMapOfShapeMapOfShape_0.cxx new file mode 100644 index 000000000..fce49dcbc --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapOfShapeMapOfShape_0.cxx @@ -0,0 +1,62 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopTools_MapOfShape_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile +#include +#endif + + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem TopTools_MapOfShape +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape +#define TCollection_DataMapNode_Type_() GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_Type_() +#define TCollection_DataMap GEOMAlgo_DataMapOfShapeMapOfShape +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt.hxx b/src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt.hxx new file mode 100644 index 000000000..23cb455c6 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt.hxx @@ -0,0 +1,132 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#ifndef _GEOMAlgo_DataMapOfShapePnt_HeaderFile +#define _GEOMAlgo_DataMapOfShapePnt_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class TopoDS_Shape; +class gp_Pnt; +class TopTools_ShapeMapHasher; +class GEOMAlgo_DataMapNodeOfDataMapOfShapePnt; +class GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt; + + + +class GEOMAlgo_DataMapOfShapePnt : public TCollection_BasicMap { +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + + Standard_EXPORT GEOMAlgo_DataMapOfShapePnt(const Standard_Integer NbBuckets = 1); + + Standard_EXPORT GEOMAlgo_DataMapOfShapePnt& Assign(const GEOMAlgo_DataMapOfShapePnt& Other) ; + GEOMAlgo_DataMapOfShapePnt& operator =(const GEOMAlgo_DataMapOfShapePnt& Other) +{ + return Assign(Other); +} + + Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; + + Standard_EXPORT void Clear() ; +~GEOMAlgo_DataMapOfShapePnt() +{ + Clear(); +} + + Standard_EXPORT Standard_Boolean Bind(const TopoDS_Shape& K,const gp_Pnt& I) ; + + Standard_EXPORT Standard_Boolean IsBound(const TopoDS_Shape& K) const; + + Standard_EXPORT Standard_Boolean UnBind(const TopoDS_Shape& K) ; + + Standard_EXPORT const gp_Pnt& Find(const TopoDS_Shape& K) const; + const gp_Pnt& operator()(const TopoDS_Shape& K) const +{ + return Find(K); +} + + Standard_EXPORT gp_Pnt& ChangeFind(const TopoDS_Shape& K) ; + gp_Pnt& operator()(const TopoDS_Shape& K) +{ + return ChangeFind(K); +} + + + + + +protected: + + + + + +private: + + + Standard_EXPORT GEOMAlgo_DataMapOfShapePnt(const GEOMAlgo_DataMapOfShapePnt& Other); + + + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt_0.cxx b/src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt_0.cxx new file mode 100644 index 000000000..30ca13662 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_DataMapOfShapePnt_0.cxx @@ -0,0 +1,62 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _TopTools_ShapeMapHasher_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile +#include +#endif +#ifndef _GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile +#include +#endif + + +#define TheKey TopoDS_Shape +#define TheKey_hxx +#define TheItem gp_Pnt +#define TheItem_hxx +#define Hasher TopTools_ShapeMapHasher +#define Hasher_hxx +#define TCollection_DataMapNode GEOMAlgo_DataMapNodeOfDataMapOfShapePnt +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt +#define TCollection_DataMapNode_Type_() GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_Type_() +#define TCollection_DataMap GEOMAlgo_DataMapOfShapePnt +#define TCollection_DataMap_hxx +#include + diff --git a/src/GEOMAlgo/GEOMAlgo_GetInPlace.cxx b/src/GEOMAlgo/GEOMAlgo_GetInPlace.cxx new file mode 100644 index 000000000..5c8b849d5 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GetInPlace.cxx @@ -0,0 +1,1144 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 +// +// File: GEOMAlgo_GetInPlace.cxx +// Created: +// Author: Peter KURNEV + +#include + +#include +#include + +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + + +#include +#include + + +static + void MapBRepShapes(const TopoDS_Shape& aS, + TopTools_IndexedMapOfShape& aM); + + +//======================================================================= +//function : GEOMAlgo_GetInPlace +//purpose : +//======================================================================= +GEOMAlgo_GetInPlace::GEOMAlgo_GetInPlace() +: + GEOMAlgo_GluerAlgo(), + GEOMAlgo_Algo() +{ + myTolerance=0.0001; + myTolMass=0.0001; + myTolCG=0.0001; + myFound=Standard_False; + myCheckGeometry=Standard_True; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_GetInPlace::~GEOMAlgo_GetInPlace() +{ +} +//======================================================================= +//function : SetTolMass +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::SetTolMass(const Standard_Real theTol) +{ + myTolMass=theTol; +} +//======================================================================= +//function : TolMass +//purpose : +//======================================================================= +Standard_Real GEOMAlgo_GetInPlace::TolMass()const +{ + return myTolMass; +} +//======================================================================= +//function : SetTolCG +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::SetTolCG(const Standard_Real theTol) +{ + myTolCG=theTol; +} +//======================================================================= +//function : TolCG +//purpose : +//======================================================================= +Standard_Real GEOMAlgo_GetInPlace::TolCG()const +{ + return myTolCG; +} +//======================================================================= +//function : IsFound +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_GetInPlace::IsFound()const +{ + return myFound; +} +//======================================================================= +//function : SetShapeWhere +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::SetShapeWhere(const TopoDS_Shape& theShape) +{ + myShapeWhere=theShape; +} +//======================================================================= +//function : ShapeWhere +//purpose : +//======================================================================= +const TopoDS_Shape& GEOMAlgo_GetInPlace::ShapeWhere()const +{ + return myShapeWhere; +} +//======================================================================= +//function : ShapesIn +//purpose : +//======================================================================= +const GEOMAlgo_DataMapOfShapeMapOfShape& GEOMAlgo_GetInPlace::ShapesIn()const +{ + return myShapesIn; +} +//======================================================================= +//function : ShapesOn +//purpose : +//======================================================================= +const GEOMAlgo_DataMapOfShapeMapOfShape& GEOMAlgo_GetInPlace::ShapesOn()const +{ + return myShapesOn; +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::Clear() +{ + myErrorStatus=0; + myWarningStatus=0; + // + GEOMAlgo_GluerAlgo::Clear(); + myIterator.Clear(); + myShapesIn.Clear(); + myShapesOn.Clear(); + myMapShapePnt.Clear(); +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::Perform() +{ + myFound=Standard_False; + myErrorStatus=0; + myWarningStatus=0; + // + Clear(); + if (myErrorStatus) { + return; + } + // + CheckData(); + if (myErrorStatus) { + return; + } + // + Intersect(); + if (myErrorStatus) { + return; + } + // + PerformVV(); + if (myErrorStatus) { + return; + } + // + FillEdgesOn(); + if (myErrorStatus) { + return; + } + // + PerformVE(); + if (myErrorStatus) { + return; + } + // + PerformEE(); + if (myErrorStatus) { + return; + } + // + PerformVF(); + if (myErrorStatus) { + return; + } + // + FillFacesOn(); + if (myErrorStatus) { + return; + } + // + PerformEF(); + if (myErrorStatus) { + return; + } + // + PerformFF(); + if (myErrorStatus) { + return; + } + // + FillSolidsOn(); + if (myErrorStatus) { + return; + } + // + PerformZF(); + if (myErrorStatus) { + return; + } + // + PerformZZ(); + if (myErrorStatus) { + return; + } + // + FillImages(); + if (myErrorStatus) { + return; + } + // + CheckGProps(); + if (myErrorStatus) { + return; + } +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::CheckData() +{ + myErrorStatus=0; + myWarningStatus=0; + // + if (myArgument.IsNull()) { + myErrorStatus=2; + return; + } + // + if (myShapeWhere.IsNull()) { + myErrorStatus=3; + return; + } +} +//======================================================================= +//function : Intersect +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::Intersect() +{ + Standard_Integer i, j, aNbS1, aNbS2, aNbSD; + TColStd_ListIteratorOfListOfInteger aItLI; + TopTools_IndexedMapOfShape aMS1, aMS2; + TopTools_DataMapOfShapeListOfShape aDMSLS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; + TopTools_ListIteratorOfListOfShape aItLS; + NMTTools_CoupleOfShape aCS; + // + NMTDS_BoxBndTreeSelector aSelector; + NMTDS_BoxBndTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + myErrorStatus=0; + myWarningStatus=0; + // + myIterator.Clear(); + // + MapBRepShapes(myArgument, aMS1); + aNbS1=aMS1.Extent(); + for (i=1; i<=aNbS1; ++i) { + Bnd_Box aBox1; + // + const TopoDS_Shape& aS1=aMS1(i); + BRepBndLib::Add(aS1, aBox1); + aBox1.SetGap(myTolerance); + // + aTreeFiller.Add(i, aBox1); + } + // + aTreeFiller.Fill(); + // + MapBRepShapes(myShapeWhere, aMS2); + aNbS2=aMS2.Extent(); + for (j=1; j<=aNbS2; ++j) { + Bnd_Box aBox2; + // + const TopoDS_Shape& aS2=aMS2(j); + BRepBndLib::Add(aS2, aBox2); + aBox2.SetGap(myTolerance); + // + aSelector.Clear(); + aSelector.SetBox(aBox2); + aNbSD=aBBTree.Select(aSelector); + if (!aNbSD) { + continue; // it should not be + } + // + const TColStd_ListOfInteger& aLI=aSelector.Indices(); + aItLI.Initialize(aLI); + for (; aItLI.More(); aItLI.Next()) { + i=aItLI.Value(); + const TopoDS_Shape& aS1=aMS1(i); + // + if (aDMSLS.IsBound(aS1)) { + TopTools_ListOfShape& aLS=aDMSLS.ChangeFind(aS1); + aLS.Append(aS2); + } + else { + TopTools_ListOfShape aLS; + // + aLS.Append(aS2); + aDMSLS.Bind(aS1, aLS); + } + } + }// for (j=1; j<=aNbS2; ++j) { + // + aItDMSLS.Initialize(aDMSLS); + for (; aItDMSLS.More(); aItDMSLS.Next()) { + const TopoDS_Shape& aS1=aItDMSLS.Key(); + const TopTools_ListOfShape& aLS2=aItDMSLS.Value(); + aCS.SetShape1(aS1); + aItLS.Initialize(aLS2); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aS2=aItLS.Value(); + aCS.SetShape2(aS2); + myIterator.AppendPair(aCS); + } + } +} +//======================================================================= +//function : PerformVV +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::PerformVV() +{ + myErrorStatus=0; + myWarningStatus=0; + // + myIterator.Initialize(TopAbs_VERTEX, TopAbs_VERTEX); + for (; myIterator.More(); myIterator.Next()) { + const NMTTools_CoupleOfShape& aCS=myIterator.Value(); + const TopoDS_Shape& aV1=aCS.Shape1(); + const TopoDS_Shape& aV2=aCS.Shape2(); + // + FillShapesOn(aV1, aV2); + } +} +//======================================================================= +//function : FillEdgesOn +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::FillEdgesOn() +{ + Standard_Integer i, aNbE, aNbSOn; + TopoDS_Iterator aIt; + TopTools_IndexedMapOfShape aME; + TopTools_MapIteratorOfMapOfShape aItMS; + // + TopExp::MapShapes(myArgument, TopAbs_EDGE, aME); + aNbE=aME.Extent(); + for (i=1; i<=aNbE; ++i) { + const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i)); + if (BRep_Tool::Degenerated(aE1)) { + continue; + } + // + aIt.Initialize(aE1); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aV1=aIt.Value(); + if (myShapesOn.IsBound(aV1)) { + const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aV1); + aNbSOn=aMSOn.Extent(); + aItMS.Initialize(aMSOn); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aV2=aItMS.Key(); + FillShapesOn(aE1, aV2); + } + } + } + } +} +//======================================================================= +//function : PerformVE +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::PerformVE() +{ + Standard_Boolean bFound; + // + myErrorStatus=0; + myWarningStatus=0; + // + // 2. Fill Shapes In + myIterator.Initialize(TopAbs_EDGE, TopAbs_VERTEX); + for (; myIterator.More(); myIterator.Next()) { + const NMTTools_CoupleOfShape& aCS=myIterator.Value(); + const TopoDS_Shape& aE1=aCS.Shape1(); + const TopoDS_Shape& aV2=aCS.Shape2(); + // + if (myShapesOn.IsBound(aE1)) { + const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1); + if (aMSOn.Contains(aV2)) { + continue; + } + } + // + bFound=CheckCoincidence(aE1, aV2); + if (myErrorStatus) { + return; + } + if (bFound) { + FillShapesIn(aE1, aV2); + } + } +} +//======================================================================= +//function : PerformEE +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::PerformEE() +{ + Standard_Boolean bHasOn, bHasIn, bFound; + TopoDS_Iterator aIt; + TopTools_MapOfShape aMSX; + // + myErrorStatus=0; + myWarningStatus=0; + // + myIterator.Initialize(TopAbs_EDGE, TopAbs_EDGE); + for (; myIterator.More(); myIterator.Next()) { + const NMTTools_CoupleOfShape& aCS=myIterator.Value(); + const TopoDS_Shape& aE1=aCS.Shape1(); + const TopoDS_Shape& aE2=aCS.Shape2(); + // + bHasOn=myShapesOn.IsBound(aE1); + bHasIn=myShapesIn.IsBound(aE1); + const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX; + const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX; + // + bFound=Standard_True; + aIt.Initialize(aE2); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aV2=aIt.Value(); + if (!(aMSOn.Contains(aV2) || aMSIn.Contains(aV2))) { + bFound=!bFound; + break; + } + } + if (!bFound) { + continue; + } + // + bFound=CheckCoincidence(aE1, aE2); + if (myErrorStatus) { + return; + } + if (bFound) { + FillShapesIn(aE1, aE2); + } + } +} +//======================================================================= +//function : PerformVF +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::PerformVF() +{ + Standard_Boolean bHasOn, bHasIn, bFound; + Standard_Integer i, aNbE; + TopTools_MapOfShape aMSX; + TopTools_IndexedMapOfShape aME; + // + myErrorStatus=0; + myWarningStatus=0; + // + myIterator.Initialize(TopAbs_FACE, TopAbs_VERTEX); + for (; myIterator.More(); myIterator.Next()) { + const NMTTools_CoupleOfShape& aCS=myIterator.Value(); + const TopoDS_Shape& aF1=aCS.Shape1(); + const TopoDS_Shape& aV2=aCS.Shape2(); + // + aME.Clear(); + TopExp::MapShapes(aF1, TopAbs_EDGE, aME); + // + bFound=Standard_False; + aNbE=aME.Extent(); + for (i=1; i<=aNbE; ++i) { + const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(i)); + if (BRep_Tool::Degenerated(aE1)) { + continue; + } + // + bHasOn=myShapesOn.IsBound(aE1); + bHasIn=myShapesIn.IsBound(aE1); + const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aE1) : aMSX; + const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aE1) : aMSX; + bFound= (aMSOn.Contains(aV2) || aMSIn.Contains(aV2)); + if (bFound) { + break; + } + } + // + if (bFound) { + continue; + } + // + bFound=CheckCoincidence(aF1, aV2); + if (myErrorStatus) { + return; + } + if (bFound) { + FillShapesIn(aF1, aV2); + } + } +} +//======================================================================= +//function : FillFacesOn +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::FillFacesOn() +{ + Standard_Integer i, j, aNbF, aNbE, aNbSOn; + TopoDS_Iterator aIt; + TopTools_IndexedMapOfShape aMF, aME; + TopTools_MapIteratorOfMapOfShape aItMS; + // + TopExp::MapShapes(myArgument, TopAbs_FACE, aMF); + aNbF=aMF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Face& aF1=*((TopoDS_Face*)&aMF(i)); + // + aME.Clear(); + TopExp::MapShapes(aF1, TopAbs_EDGE, aME); + aNbE=aME.Extent(); + for (j=1; j<=aNbE; ++j) { + const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aME(j)); + if (BRep_Tool::Degenerated(aE1)) { + continue; + } + // + if (myShapesOn.IsBound(aE1)) { + const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aE1); + aItMS.Initialize(aMSOn); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aS2=aItMS.Key(); + FillShapesOn(aF1, aS2); + } + } + // + if (myShapesIn.IsBound(aE1)) { + const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aE1); + aItMS.Initialize(aMSIn); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aS2=aItMS.Key(); + FillShapesOn(aF1, aS2); + } + } + }//for (j=1; j<=aNbE; ++j) { + }//for (i=1; i<=aNbF; ++i) { +} +//======================================================================= +//function : PerformEF +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::PerformEF() +{ + Standard_Boolean bFound, bHasOnF, bHasInF; + Standard_Integer i, aNbE; + TopoDS_Iterator aIt; + TopTools_MapOfShape aMSX; + // + myErrorStatus=0; + myWarningStatus=0; + // + myIterator.Initialize(TopAbs_FACE, TopAbs_EDGE); + for (; myIterator.More(); myIterator.Next()) { + const NMTTools_CoupleOfShape& aCS=myIterator.Value(); + const TopoDS_Shape& aF1=aCS.Shape1(); + const TopoDS_Shape& aE2=aCS.Shape2(); + // + // 1. + bHasOnF=myShapesOn.IsBound(aF1); + const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX; + bFound=aMSOnF.Contains(aE2); + if (bFound) { + continue; + } + // + // 2. + bHasInF=myShapesIn.IsBound(aF1); + const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX; + // + aIt.Initialize(aE2); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aV2=aIt.Value(); + bFound=(aMSOnF.Contains(aV2) || aMSInF.Contains(aV2)); + if (!bFound) { + break; + } + } + if (!bFound) { + continue; + } + //------------------------------ + bFound=CheckCoincidence(aF1, aE2); + if (myErrorStatus) { + return; + } + if (bFound) { + FillShapesIn(aF1, aE2); + } + } +} +//======================================================================= +//function : PerformFF +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::PerformFF() +{ + Standard_Boolean bFound, bHasOnF, bHasInF; + Standard_Integer i, aNbS2; + TopTools_MapOfShape aMSX; + TopTools_IndexedMapOfShape aMS2; + // + myErrorStatus=0; + myWarningStatus=0; + // + myIterator.Initialize(TopAbs_FACE, TopAbs_FACE); + for (; myIterator.More(); myIterator.Next()) { + const NMTTools_CoupleOfShape& aCS=myIterator.Value(); + const TopoDS_Shape& aF1=aCS.Shape1(); + const TopoDS_Shape& aF2=aCS.Shape2(); + // + bHasOnF=myShapesOn.IsBound(aF1); + const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aF1) : aMSX; + // + bHasInF=myShapesIn.IsBound(aF1); + const TopTools_MapOfShape& aMSInF=(bHasInF) ? myShapesIn.Find(aF1) : aMSX; + // + aMS2.Clear(); + MapBRepShapes(aF2, aMS2); + // + bFound=Standard_False; + aNbS2=aMS2.Extent(); + for (i=1; i<=aNbS2; ++i) { + const TopoDS_Shape& aS2=aMS2(i); + if (aS2.IsSame(aF2)) { + continue; + } + bFound=(aMSOnF.Contains(aS2) || aMSInF.Contains(aS2)); + if (!bFound) { + break; + } + } + if (!bFound) { + continue; + } + // + bFound=CheckCoincidence(aF1, aF2); + if (myErrorStatus) { + return; + } + if (bFound) { + FillShapesIn(aF1, aF2); + } + } +} +//======================================================================= +//function : FillSolidsOn +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::FillSolidsOn() +{ + Standard_Integer i, j, aNbS, aNbF, aNbSOn; + TopTools_IndexedMapOfShape aMS, aMF; + TopTools_MapIteratorOfMapOfShape aItMS; + // + TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS); + // + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aSD1=aMS(i); + // + aMF.Clear(); + TopExp::MapShapes(aSD1, TopAbs_FACE, aMF); + aNbF=aMF.Extent(); + for (j=1; j<=aNbF; ++j) { + const TopoDS_Shape& aF1=aMF(j); + // + if (myShapesOn.IsBound(aF1)) { + const TopTools_MapOfShape& aMSOn=myShapesOn.Find(aF1); + aItMS.Initialize(aMSOn); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aS2=aItMS.Key(); + FillShapesOn(aSD1, aS2); + } + } + // + if (myShapesIn.IsBound(aF1)) { + const TopTools_MapOfShape& aMSIn=myShapesIn.Find(aF1); + aItMS.Initialize(aMSIn); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aS2=aItMS.Key(); + FillShapesOn(aSD1, aS2); + } + } + }//for (j=1; j<=aNbF; ++j) { + }//for (i=1; i<=aNbS; ++i) { +} +//======================================================================= +//function : PerformZF +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::PerformZF() +{ + Standard_Boolean bFound, bHasOnF, bHasInF; + Standard_Integer i, aNbE; + TopTools_MapOfShape aMSX; + // + myErrorStatus=0; + myWarningStatus=0; + // + myIterator.Initialize(TopAbs_SOLID, TopAbs_FACE); + for (; myIterator.More(); myIterator.Next()) { + const NMTTools_CoupleOfShape& aCS=myIterator.Value(); + const TopoDS_Shape& aSo1=aCS.Shape1(); + const TopoDS_Shape& aF2=aCS.Shape2(); + // + bHasOnF=myShapesOn.IsBound(aSo1); + const TopTools_MapOfShape& aMSOnF=(bHasOnF) ? myShapesOn.Find(aSo1) : aMSX; + bFound=aMSOnF.Contains(aF2); + if (bFound) { + continue; + } + //------------------------------ + bFound=CheckCoincidence(aSo1, aF2); + if (myErrorStatus) { + return; + } + if (bFound) { + FillShapesIn(aSo1, aF2); + } + } +} +//======================================================================= +//function : PerformZZ +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::PerformZZ() +{ + Standard_Boolean bFound, bHasOn, bHasIn; + Standard_Integer i, aNbS2, iCntOn, iCntIn, iCntOut; + TopTools_MapOfShape aMSX; + TopTools_IndexedMapOfShape aMS2; + // + myErrorStatus=0; + myWarningStatus=0; + // + myIterator.Initialize(TopAbs_SOLID, TopAbs_SOLID); + for (; myIterator.More(); myIterator.Next()) { + const NMTTools_CoupleOfShape& aCS=myIterator.Value(); + const TopoDS_Shape& aSo1=aCS.Shape1(); + const TopoDS_Shape& aSo2=aCS.Shape2(); + // + bHasOn=myShapesOn.IsBound(aSo1); + const TopTools_MapOfShape& aMSOn=(bHasOn) ? myShapesOn.Find(aSo1) : aMSX; + // + bHasIn=myShapesIn.IsBound(aSo1); + const TopTools_MapOfShape& aMSIn=(bHasIn) ? myShapesIn.Find(aSo1) : aMSX; + // + aMS2.Clear(); + TopExp::MapShapes(aSo2, TopAbs_FACE, aMS2); + // + iCntIn=0; + iCntOn=0; + iCntOut=0; + bFound=Standard_False; + aNbS2=aMS2.Extent(); + for (i=1; i<=aNbS2; ++i) { + const TopoDS_Shape& aF2=aMS2(i); + // + if (aMSIn.Contains(aF2)) { + ++iCntIn; + bFound=Standard_True; + break; + } + else if (!aMSOn.Contains(aF2)) { + ++iCntOut; + bFound=Standard_False;// out + break; + } + else { + ++iCntOn; //on + } + } + // + if (!bFound && iCntOut) { + continue; + } + // + if (!iCntIn) { + bFound=CheckCoincidence(aSo1, aSo2); + if (myErrorStatus) { + return; + } + } + if (bFound) { + FillShapesIn(aSo1, aSo2); + } + }// for (; myIterator.More(); myIterator.Next()) { +} +//======================================================================= +//function : FillImages +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::FillImages() +{ + Standard_Integer i, aNbS, aNbSx, aNbSi; + TopAbs_ShapeEnum aType; + TopoDS_Iterator aIt; + TopTools_ListOfShape aLSx; + TopTools_ListIteratorOfListOfShape aItLS; + TopTools_IndexedMapOfShape aMS; + TopTools_MapIteratorOfMapOfShape aItMS; + // + myErrorStatus=0; + myWarningStatus=0; + // + myImages.Clear(); + // + // 1. Vertices + aMS.Clear(); + TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMS); + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aV=aMS(i); + if (myShapesOn.IsBound(aV)) { + const TopTools_MapOfShape& aMSx=myShapesOn.Find(aV); + aNbSx=aMSx.Extent(); + // + aLSx.Clear(); + aItMS.Initialize(aMSx); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aVx=aItMS.Key(); + aLSx.Append(aVx); + } + // + myImages.Bind(aV, aLSx); + } + } + // + // 2. Edges + aMS.Clear(); + TopExp::MapShapes(myArgument, TopAbs_EDGE, aMS); + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aE=aMS(i); + if (myShapesIn.IsBound(aE)) { + const TopTools_MapOfShape& aMSx=myShapesIn.Find(aE); + aNbSx=aMSx.Extent(); + // + aLSx.Clear(); + aItMS.Initialize(aMSx); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aEx=aItMS.Key(); + aType=aEx.ShapeType(); + if (aType==TopAbs_EDGE){ + aLSx.Append(aEx); + } + } + // + myImages.Bind(aE, aLSx); + } + } + // + // 3. Wires + aMS.Clear(); + TopExp::MapShapes(myArgument, TopAbs_WIRE, aMS); + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aW=aMS(i); + aLSx.Clear(); + aIt.Initialize(aW); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (myImages.IsBound(aE)) { + const TopTools_ListOfShape& aLSi=myImages.Find(aE); + aNbSi=aLSi.Extent(); + // + aItLS.Initialize(aLSi); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aEi=aItLS.Value(); + aLSx.Append(aEi); + } + } + } + myImages.Bind(aW, aLSx); + } + // + // 4. Faces + aMS.Clear(); + TopExp::MapShapes(myArgument, TopAbs_FACE, aMS); + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aF=aMS(i); + if (myShapesIn.IsBound(aF)) { + const TopTools_MapOfShape& aMSx=myShapesIn.Find(aF); + aNbSx=aMSx.Extent(); + // + aLSx.Clear(); + aItMS.Initialize(aMSx); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aFx=aItMS.Key(); + aType=aFx.ShapeType(); + if (aType==TopAbs_FACE){ + aLSx.Append(aFx); + } + } + // + myImages.Bind(aF, aLSx); + } + } + // + // 5. Shells + aMS.Clear(); + TopExp::MapShapes(myArgument, TopAbs_SHELL, aMS); + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aSh=aMS(i); + aLSx.Clear(); + aIt.Initialize(aSh); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (myImages.IsBound(aF)) { + const TopTools_ListOfShape& aLSi=myImages.Find(aF); + aNbSi=aLSi.Extent(); + // + aItLS.Initialize(aLSi); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aFi=aItLS.Value(); + aLSx.Append(aFi); + } + } + } + myImages.Bind(aSh, aLSx); + } + // + // 6. Solids + aMS.Clear(); + TopExp::MapShapes(myArgument, TopAbs_SOLID, aMS); + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aZ=aMS(i); + if (myShapesIn.IsBound(aZ)) { + const TopTools_MapOfShape& aMSx=myShapesIn.Find(aZ); + aNbSx=aMSx.Extent(); + // + aLSx.Clear(); + aItMS.Initialize(aMSx); + for (; aItMS.More(); aItMS.Next()) { + const TopoDS_Shape& aZx=aItMS.Key(); + aType=aZx.ShapeType(); + if (aType==TopAbs_SOLID){ + aLSx.Append(aZx); + } + } + // + myImages.Bind(aZ, aLSx); + } + } + // + // 7. CompSolids + aMS.Clear(); + TopExp::MapShapes(myArgument, TopAbs_COMPSOLID, aMS); + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aCs=aMS(i); + aLSx.Clear(); + aIt.Initialize(aCs); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aZ=aIt.Value(); + if (myImages.IsBound(aZ)) { + const TopTools_ListOfShape& aLSi=myImages.Find(aZ); + aNbSi=aLSi.Extent(); + // + aItLS.Initialize(aLSi); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aZi=aItLS.Value(); + aLSx.Append(aZi); + } + } + } + myImages.Bind(aCs, aLSx); + } + // + // 8. Compounds + aType=myArgument.ShapeType(); + if (aType==TopAbs_COMPOUND) { + FillImagesCompound(myArgument); + } +} +//======================================================================= +//function : FillImagesCompound +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::FillImagesCompound(const TopoDS_Shape& aS) +{ + TopAbs_ShapeEnum aType; + TopoDS_Iterator aIt; + TopTools_ListOfShape aLSx; + TopTools_ListIteratorOfListOfShape aItLS; + // + aIt.Initialize(aS); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + aType=aSx.ShapeType(); + // + if (aType==TopAbs_COMPOUND) { + FillImagesCompound(aSx); + } + // + if (myImages.IsBound(aSx)) { + const TopTools_ListOfShape& aLSi=myImages.Find(aSx); + aItLS.Initialize(aLSi); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aSi=aItLS.Value(); + aLSx.Append(aSi); + } + } + } + myImages.Bind(aS, aLSx); +} + +//======================================================================= +//function : FillShapesIn +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::FillShapesIn(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) +{ + if (myShapesIn.IsBound(aS1)) { + TopTools_MapOfShape& aMS=myShapesIn.ChangeFind(aS1); + aMS.Add(aS2); + } + else { + TopTools_MapOfShape aMS; + // + aMS.Add(aS2); + myShapesIn.Bind(aS1, aMS); + } +} +//======================================================================= +//function : FillShapesOn +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::FillShapesOn(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) +{ + if (myShapesOn.IsBound(aS1)) { + TopTools_MapOfShape& aMS=myShapesOn.ChangeFind(aS1); + aMS.Add(aS2); + } + else { + TopTools_MapOfShape aMS; + // + aMS.Add(aS2); + myShapesOn.Bind(aS1, aMS); + } +} +//======================================================================= +//function : MapBRepShapes +//purpose : +//======================================================================= +void MapBRepShapes(const TopoDS_Shape& aS, + TopTools_IndexedMapOfShape& aM) +{ + Standard_Boolean bHasBRep, bDegenerated; + TopAbs_ShapeEnum aType; + TopoDS_Iterator aIt; + // + aType=aS.ShapeType(); + if (aType==TopAbs_VERTEX || aType==TopAbs_EDGE || + aType==TopAbs_FACE || aType==TopAbs_SOLID) { + bDegenerated=Standard_False; + if (aType==TopAbs_EDGE) { + TopoDS_Edge *pE=(TopoDS_Edge*)&aS; + bDegenerated=BRep_Tool::Degenerated(*pE); + } + if (!bDegenerated) { + aM.Add(aS); + } + } + // + aIt.Initialize(aS); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + aType=aSx.ShapeType(); + MapBRepShapes(aSx, aM); + } +} diff --git a/src/GEOMAlgo/GEOMAlgo_GetInPlace.hxx b/src/GEOMAlgo/GEOMAlgo_GetInPlace.hxx new file mode 100644 index 000000000..cf3c61f0b --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GetInPlace.hxx @@ -0,0 +1,324 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 +// +// File: GEOMAlgo_GetInPlace.hxx +// Created: +// Author: Peter KURNEV + +#ifndef _GEOMAlgo_GetInPlace_HeaderFile +#define _GEOMAlgo_GetInPlace_HeaderFile + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + + +//======================================================================= +/** + * The implementation of iterator of intersected shapes + * for Get In Place Algorithm. + * The intersection is in terms of 3D bounding boxes. + */ +//======================================================================= +//class : GEOMAlgo_GetInPlaceIterator +//purpose : +//======================================================================= +class GEOMAlgo_GetInPlaceIterator { + public: + /** + * Constructor. + */ + //Standard_EXPORT + GEOMAlgo_GetInPlaceIterator(); + + /** + * Destructor. + */ + //Standard_EXPORT + virtual ~GEOMAlgo_GetInPlaceIterator(); + + /** + * Clear the internal content. + */ + //Standard_EXPORT + void Clear() ; + + /** + * Append the pair of intersected shapes. + * @param theCS + * The pair of intersected shapes. + */ + //Standard_EXPORT + void AppendPair(const NMTTools_CoupleOfShape& theCS) ; + + /** + * Initialize the iterator. + * @param theT1 + * The type of (sub)shape What. + * @param theT2 + * The type of (sub)shape Where. + */ + //Standard_EXPORT + void Initialize(const TopAbs_ShapeEnum theT1, + const TopAbs_ShapeEnum theT2) ; + /** + * Check the existence of pairs to iterare. + * @return + * Standard_True if there are pairs to iterare. + */ + //Standard_EXPORT + Standard_Boolean More() const; + + /** + * Shift to the next pair. + */ + //Standard_EXPORT + void Next() ; + + /** + * Returns the pair of intersected shapes. + * @return + * The pair of intersected shapes. + */ + //Standard_EXPORT + const NMTTools_CoupleOfShape& Value() const; + +protected: + Standard_Integer myDim; + NMTTools_ListOfCoupleOfShape myLists[10]; + NMTTools_ListOfCoupleOfShape myEmptyList; + NMTTools_ListIteratorOfListOfCoupleOfShape myIterator; + +private: +}; + + +//======================================================================= +/** + * The implementation of Get In Place Algorithm. + * The algorithm provides the search the argument [What] + * in the shape [Where]. + */ +//======================================================================= +//class : GEOMAlgo_GetInPlace +//purpose : +//======================================================================= +class GEOMAlgo_GetInPlace : public GEOMAlgo_GluerAlgo, + public GEOMAlgo_Algo +{ + public: + /** + * Constructor. + */ + Standard_EXPORT + GEOMAlgo_GetInPlace(); + /** + * Destructor. + */ + Standard_EXPORT + virtual ~GEOMAlgo_GetInPlace(); + /** + * Modifier. Sets the shape where the search is intended. + * @param theShape + * The shape where the search is intended. + */ + Standard_EXPORT + virtual void SetShapeWhere(const TopoDS_Shape& theShape) ; + + /** + * Selector. Returns the shape where the search is intended. + * @return + * The shape where the search is intended. + */ + Standard_EXPORT + const TopoDS_Shape& ShapeWhere() const; + + /** + * Modifier. Sets the tolerance of mass. + * @param theTol + * The value tolerance of mass. + */ + Standard_EXPORT + void SetTolMass(const Standard_Real theTol) ; + + /** + * Selector. Returns the value tolerance of mass. + * @return + * The value tolerance of mass. + */ + Standard_EXPORT + Standard_Real TolMass() const; + + /** + * Modifier. Sets the tolerance of center of gravily. + * @param theTol + * The value tolerance of center of gravily. + */ + Standard_EXPORT + void SetTolCG(const Standard_Real theTol) ; + + /** + * Selector. Returns the tolerance of center of gravily. + * @return + * The value tolerance of center of gravily. + */ + Standard_EXPORT + Standard_Real TolCG() const; + + /** + * Perform the algorithm. + */ + Standard_EXPORT + virtual void Perform() ; + + /** + * Returns state of the search. + * @return + * Standard_True if the argument is found. + */ + Standard_EXPORT + Standard_Boolean IsFound() const; + + /** + * Checks data + */ + Standard_EXPORT + virtual void CheckData() ; + + /** + * Clear the internal content. + */ + Standard_EXPORT + virtual void Clear() ; + + /** + * Returns the map of shapes IN. + * @return + ** Returns the map of shapes IN. + * The Key - the (sub)shape of the argument [What]. + * The Item- the (sub)shapes of the shape [Where] that have + * the state IN in respect of [What]. + */ + Standard_EXPORT + const GEOMAlgo_DataMapOfShapeMapOfShape& ShapesIn() const; + + /** + * Returns the map of shapes ON. + * @return + * Returns the map of shapes ON. + * The Key - the (sub)shape of the argument [What]. + * The Item- the (sub)shapes of the shape [Where] that have + * the state ON in respect of [What]. + */ + Standard_EXPORT + const GEOMAlgo_DataMapOfShapeMapOfShape& ShapesOn() const; + +protected: + Standard_EXPORT + void Intersect() ; + + Standard_EXPORT + void PerformVV() ; + + Standard_EXPORT + void PerformVE() ; + + Standard_EXPORT + void PerformEE() ; + + Standard_EXPORT + void PerformVF() ; + + Standard_EXPORT + void PerformEF() ; + + Standard_EXPORT + void PerformFF() ; + + Standard_EXPORT + void FillEdgesOn() ; + + Standard_EXPORT + void FillFacesOn() ; + + Standard_EXPORT + void FillSolidsOn() ; + + Standard_EXPORT + void PerformZF() ; + + Standard_EXPORT + void PerformZZ() ; + + Standard_EXPORT + void FillImages() ; + + Standard_EXPORT + void FillImagesCompound(const TopoDS_Shape& theS) ; + + Standard_EXPORT + void CheckGProps() ; + + Standard_EXPORT + void CheckGProps(const TopoDS_Shape& theS) ; + + Standard_EXPORT + void FillShapesIn(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2) ; + + Standard_EXPORT + void FillShapesOn(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2) ; + + Standard_EXPORT + Standard_Boolean CheckCoincidence(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2); + + + TopoDS_Shape myShapeWhere; + GEOMAlgo_GetInPlaceIterator myIterator; + GEOMAlgo_DataMapOfShapeMapOfShape myShapesIn; + GEOMAlgo_DataMapOfShapeMapOfShape myShapesOn; + Standard_Real myTolMass; + Standard_Real myTolCG; + Standard_Boolean myFound; + GEOMAlgo_DataMapOfShapePnt myMapShapePnt; + +private: +}; + + + +#endif diff --git a/src/GEOMAlgo/GEOMAlgo_GetInPlace_1.cxx b/src/GEOMAlgo/GEOMAlgo_GetInPlace_1.cxx new file mode 100644 index 000000000..9220a21b3 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GetInPlace_1.cxx @@ -0,0 +1,402 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 +// +// File: GEOMAlgo_GetInPlace_1.cxx +// Created: +// Author: Peter KURNEV + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include +#include + + + +static + Standard_Integer PntInEdge(const TopoDS_Edge& aF, + gp_Pnt& aP); +static + Standard_Integer PntInEdge(const TopoDS_Edge& aF, + gp_Pnt& aP, + Standard_Real& aT); +static + Standard_Integer PntInFace(const TopoDS_Face& aF, + gp_Pnt& aP); +static + Standard_Integer PntInFace(const TopoDS_Face& aF, + gp_Pnt& aP, + gp_Pnt2d& theP2D); +static + Standard_Integer PntInSolid(const TopoDS_Solid& aZ, + const Standard_Real aTol, + gp_Pnt& aP); + + +//======================================================================= +//function : CheckCoincidence +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_GetInPlace::CheckCoincidence(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) +{ + Standard_Boolean bOk, bIsDone; + Standard_Integer iErr; + Standard_Real aTol2, aD2; + TopAbs_ShapeEnum aType1, aType2; + TopAbs_State aState; + gp_Pnt aP1, aP2; + // + myErrorStatus=0; + // + iErr=0; + bOk=Standard_False; + aTol2=myTolerance*myTolerance; + aType1=aS1.ShapeType(); + aType2=aS2.ShapeType(); + // + // 1. A point on shape #2 -> aP2 + if (myMapShapePnt.IsBound(aS2)) { + aP2=myMapShapePnt.Find(aS2); + } + else {//else 1 + if (aType2==TopAbs_VERTEX) { + const TopoDS_Vertex& aV2=*((TopoDS_Vertex*)&aS2); + aP2=BRep_Tool::Pnt(aV2); + } + // + else if (aType2==TopAbs_EDGE) { + const TopoDS_Edge& aE2=*((TopoDS_Edge*)&aS2); + iErr=PntInEdge(aE2, aP2); + } + // + else if (aType2==TopAbs_FACE) { + const TopoDS_Face& aF2=*((TopoDS_Face*)&aS2); + iErr=PntInFace(aF2, aP2); + } + // + else if (aType2==TopAbs_SOLID) { + const TopoDS_Solid& aZ2=*((TopoDS_Solid*)&aS2); + iErr=PntInSolid(aZ2, myTolerance, aP2); + } + // + else { + iErr=1; + } + // + if (iErr) { + myErrorStatus=50; + return bOk; + } + // + myMapShapePnt.Bind(aS2, aP2); + } //else 1 + // + // 2. Project the point aP2 on shape #1 and check + if (aType1==TopAbs_EDGE) { + Standard_Integer aNbPoints; + Standard_Real aDmin, aT, aT1, aT2, dT; + // + const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aS1); + // + GeomAPI_ProjectPointOnCurve& aPPC=myContext.ProjPC(aE1); + aPPC.Perform(aP2); + aNbPoints=aPPC.NbPoints(); + if (aNbPoints) { + aDmin=aPPC.LowerDistance(); + aT=aPPC.LowerDistanceParameter(); + if (aDmin < myTolerance) { + dT=1.e-12; + BRep_Tool::Curve(aE1, aT1, aT2); + if(aT > (aT1-dT) && aT < (aT2+dT)) { + bOk=Standard_True; + } + } + } + //else { + // iErr=2; + //} + }//if (aType1==TopAbs_EDGE) { + // + else if (aType1==TopAbs_FACE) { + const TopoDS_Face& aF1=*((TopoDS_Face*)&aS1); + // + bOk=myContext.IsValidPointForFace(aP2, aF1, myTolerance); + } + // + else if (aType1==TopAbs_SOLID) { + const TopoDS_Solid& aZ1=*((TopoDS_Solid*)&aS1); + // + BRepClass3d_SolidClassifier& aSC=myContext.SolidClassifier(aZ1); + aSC.Perform(aP2, myTolerance); + aState=aSC.State(); + bOk=(aState==TopAbs_IN); + } + // + if (iErr) { + myErrorStatus=50; + } + // + return bOk; +} +//======================================================================= +// +//======================================================================= +//function : PntInEdge +//purpose : +//======================================================================= +Standard_Integer PntInEdge(const TopoDS_Edge& aE, + gp_Pnt& aP) + +{ + Standard_Integer iErr; + Standard_Real aT; + // + iErr=PntInEdge(aE, aP, aT); + // + return iErr; +} +//======================================================================= +//function : PntInEdge +//purpose : +//======================================================================= +Standard_Integer PntInEdge(const TopoDS_Edge& aE, + gp_Pnt& aP, + Standard_Real& aT) +{ + Standard_Integer iErr; + Standard_Real aT1, aT2; + Handle(Geom_Curve) aC3D; + // + iErr=0; + // + aC3D=BRep_Tool::Curve(aE, aT1, aT2); + aT=IntTools_Tools::IntermediatePoint(aT1, aT2); + aC3D->D0(aT, aP); + // + return iErr; +} +//======================================================================= +//function : PntInSolid +//purpose : +//======================================================================= +Standard_Integer PntInSolid(const TopoDS_Solid& aZ, + const Standard_Real aTol, + gp_Pnt& aP) +{ + Standard_Integer iErr; + Standard_Real aUx, aVx, aCoef; + gp_Pnt aPx; + gp_Pnt2d aP2Dx; + gp_Vec aDNx; + + TopoDS_Face aF; + TopExp_Explorer aExp; + // + iErr=0; + aCoef=10.; + // + aExp.Init (aZ, TopAbs_FACE); + for (; aExp.More() ; aExp.Next()) { + aF=*((TopoDS_Face*)&aExp.Current()); + break; + } + // + iErr=PntInFace(aF, aPx, aP2Dx); + if (iErr) { + return iErr; + } + // + aP2Dx.Coord(aUx, aVx); + BOPTools_Tools2D::FaceNormal(aF, aUx, aVx, aDNx); + aDNx.Reverse(); + // + aP.SetXYZ(aPx.XYZ()+aCoef*aTol*aDNx.XYZ()); + // + return iErr; +} +//======================================================================= +//function : PntInFace +//purpose : +//======================================================================= +Standard_Integer PntInFace(const TopoDS_Face& aF, + gp_Pnt& aP) +{ + Standard_Integer iErr; + // + gp_Pnt2d aP2Dx; + // + iErr=PntInFace(aF, aP, aP2Dx); + // + return iErr; +} +//======================================================================= +//function : PntInFace +//purpose : +//======================================================================= +Standard_Integer PntInFace(const TopoDS_Face& aF, + gp_Pnt& theP, + gp_Pnt2d& theP2D) +{ + Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint; + Standard_Integer iErr, aIx, aNbDomains, i; + Standard_Real aUMin, aUMax, aVMin, aVMax; + Standard_Real aVx, aUx, aV1, aV2, aU1, aU2, aEpsT; + Standard_Real aTotArcIntr, aTolTangfIntr, aTolHatch2D, aTolHatch3D; + gp_Dir2d aD2D (0., 1.); + gp_Pnt2d aP2D; + gp_Pnt aPx; + Handle(Geom2d_Curve) aC2D; + Handle(Geom2d_TrimmedCurve) aCT2D; + Handle(Geom2d_Line) aL2D; + Handle(Geom_Surface) aS; + TopAbs_Orientation aOrE; + TopoDS_Face aFF; + TopExp_Explorer aExp; + // + aTolHatch2D=1.e-8; + aTolHatch3D=1.e-8; + aTotArcIntr=1.e-10; + aTolTangfIntr=1.e-10; + // + Geom2dHatch_Intersector aIntr(aTotArcIntr, aTolTangfIntr); + Geom2dHatch_Hatcher aHatcher(aIntr, + aTolHatch2D, aTolHatch3D, + Standard_True, Standard_False); + // + iErr=0; + aEpsT=1.e-12; + // + aFF=aF; + aFF.Orientation (TopAbs_FORWARD); + // + aS=BRep_Tool::Surface(aFF); + BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax); + // + // 1 + aExp.Init (aFF, TopAbs_EDGE); + for (; aExp.More() ; aExp.Next()) { + const TopoDS_Edge& aE=*((TopoDS_Edge*)&aExp.Current()); + aOrE=aE.Orientation(); + // + aC2D=BRep_Tool::CurveOnSurface (aE, aFF, aU1, aU2); + if (aC2D.IsNull() ) { + iErr=1; + return iErr; + } + if (fabs(aU1-aU2) < aEpsT) { + iErr=2; + return iErr; + } + // + aCT2D=new Geom2d_TrimmedCurve(aC2D, aU1, aU2); + aHatcher.AddElement(aCT2D, aOrE); + }// for (; aExp.More() ; aExp.Next()) { + // + // 2 + aUx=IntTools_Tools::IntermediatePoint(aUMin, aUMax); + aP2D.SetCoord(aUx, 0.); + aL2D=new Geom2d_Line (aP2D, aD2D); + Geom2dAdaptor_Curve aHCur(aL2D); + // + aIx=aHatcher.AddHatching(aHCur) ; + // + // 3. + aHatcher.Trim(); + bIsDone=aHatcher.TrimDone(aIx); + if (!bIsDone) { + iErr=3; + return iErr; + } + // + aHatcher.ComputeDomains(aIx); + bIsDone=aHatcher.IsDone(aIx); + if (!bIsDone) { + iErr=4; + return iErr; + } + // + // 4. + aNbDomains=aHatcher.NbDomains(aIx); + for (i=1; i<=aNbDomains; ++i) { + const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ; + bHasFirstPoint=aDomain.HasFirstPoint(); + if (!bHasFirstPoint) { + iErr=5; + return iErr; + } + // + aV1=aDomain.FirstPoint().Parameter(); + // + bHasSecondPoint=aDomain.HasSecondPoint(); + if (!bHasSecondPoint) { + iErr=6; + return iErr; + } + // + aV2=aDomain.SecondPoint().Parameter(); + // + aVx=IntTools_Tools::IntermediatePoint(aV1, aV2); + // + break; + } + // + aS->D0(aUx, aVx, aPx); + // + theP2D.SetCoord(aUx, aVx); + theP=aPx; + // + return iErr; +} + diff --git a/src/GEOMAlgo/GEOMAlgo_GetInPlace_2.cxx b/src/GEOMAlgo/GEOMAlgo_GetInPlace_2.cxx new file mode 100644 index 000000000..7378e0e51 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GetInPlace_2.cxx @@ -0,0 +1,232 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 +// +// File: GEOMAlgo_GetInPlace_2.cxx +// Created: +// Author: Peter KURNEV + +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include + + +static + Standard_Integer Dimension(const TopAbs_ShapeEnum aType); +static + void PointProperties(const TopoDS_Shape& aS, + GProp_GProps& aGProps); + +//======================================================================= +//function : CheckGProps +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::CheckGProps() +{ + myFound=Standard_False; + CheckGProps(myArgument); +} +//======================================================================= +//function : CheckGProps +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlace::CheckGProps(const TopoDS_Shape& aS1) +{ + Standard_Boolean bOnlyClosed; + Standard_Integer iDim, aNbS2; + Standard_Real aMass1, aMass2, aD2, aTolCG2, dM; + TopAbs_ShapeEnum aType1; + gp_Pnt aCG1, aCG2; + TopoDS_Iterator aIt; + TopoDS_Compound aC2; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aItLS; + // + myErrorStatus=0; + // + aType1=aS1.ShapeType(); + if (aType1==TopAbs_COMPOUND) { + aIt.Initialize(aS1); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS1x=aIt.Value(); + CheckGProps(aS1x); + if (!myFound) { + return; + } + } + } + // + iDim=Dimension(aType1); + // + if (!myImages.IsBound(aS1)) { + // it should not be. + return; + } + const TopTools_ListOfShape& aLS2=myImages.Find(aS1); + aNbS2=aLS2.Extent(); + if (!aNbS2) { + // it should not be. + return; + } + // + aBB.MakeCompound(aC2); + aItLS.Initialize(aLS2); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aS2x=aItLS.Value(); + aBB.Add(aC2, aS2x); + } + //------------------------- + GProp_GProps aG1, aG2; + // + aTolCG2=myTolCG*myTolCG; + bOnlyClosed=Standard_False; + // + if (iDim==0) { + PointProperties(aS1, aG1); + PointProperties(aC2, aG2); + } + else if (iDim==1) { + BRepGProp::LinearProperties(aS1, aG1); + BRepGProp::LinearProperties(aC2, aG2); + } + else if (iDim==2) { + BRepGProp::SurfaceProperties(aS1, aG1); + BRepGProp::SurfaceProperties(aC2, aG2); + } + else if (iDim==3) { + BRepGProp::VolumeProperties(aS1, aG1, bOnlyClosed); + BRepGProp::VolumeProperties(aC2, aG2, bOnlyClosed); + } + // + aMass1=aG1.Mass(); + aMass2=aG2.Mass(); + aCG1=aG1.CentreOfMass(); + aCG2=aG2.CentreOfMass(); + // + dM=fabs(aMass1-aMass2); + if (aMass1 > myTolMass) { + dM=dM/aMass1; + } + // + aD2=aCG1.SquareDistance(aCG2); + // + if ((dM > myTolMass) || (aD2 > aTolCG2)) { + myFound=Standard_False; + return; + } + myFound=Standard_True; +} +//======================================================================= +//function : Dimension +//purpose : +//======================================================================= +Standard_Integer Dimension(const TopAbs_ShapeEnum aType) +{ + Standard_Integer iDim; + // + iDim=-1; + switch (aType) { + case TopAbs_VERTEX: + iDim=0; + break; + case TopAbs_EDGE: + case TopAbs_WIRE: + iDim=1; + break; + case TopAbs_FACE: + case TopAbs_SHELL: + iDim=2; + break; + case TopAbs_SOLID: + case TopAbs_COMPSOLID: + iDim=3; + break; + default: + break; + } + return iDim; +} +//======================================================================= +//class : GEOMAlgo_GProps +//purpose : +//======================================================================= +class GEOMAlgo_GProps : public GProp_GProps { + public: + GEOMAlgo_GProps() : GProp_GProps() { + }; + // + GEOMAlgo_GProps(const gp_Pnt& aPLoc) : GProp_GProps(aPLoc) { + }; + // + ~GEOMAlgo_GProps() { + }; + // + void SetMass(const Standard_Real aMass) { + dim=aMass; + } + // + void SetCG(const gp_Pnt& aPCG) { + g=aPCG; + } +}; +//======================================================================= +//function : PointProperties +//purpose : +//======================================================================= +void PointProperties(const TopoDS_Shape& aS, GProp_GProps& aGProps) +{ + Standard_Integer i, aNbS; + Standard_Real aDensity; + gp_Pnt aPX; + TopTools_IndexedMapOfShape aMS; + // + aDensity=1.; + // + TopExp::MapShapes(aS, TopAbs_VERTEX, aMS); + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + GEOMAlgo_GProps aGPropsX; + // + const TopoDS_Vertex& aVX=*((TopoDS_Vertex*)&aMS(i)); + aPX=BRep_Tool::Pnt(aVX); + aGPropsX.SetMass(1.); + aGPropsX.SetCG(aPX); + aGProps.Add(aGPropsX, aDensity); + } +} diff --git a/src/GEOMAlgo/GEOMAlgo_GetInPlace_3.cxx b/src/GEOMAlgo/GEOMAlgo_GetInPlace_3.cxx new file mode 100644 index 000000000..6f86b5442 --- /dev/null +++ b/src/GEOMAlgo/GEOMAlgo_GetInPlace_3.cxx @@ -0,0 +1,172 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 +// +// File: GEOMAlgo_GetInPlaceIterator.cxx +// Created: +// Author: Peter KURNEV + +#include + +#include + +static + Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2); + +//======================================================================= +//function : +//purpose : +//======================================================================= +GEOMAlgo_GetInPlaceIterator::GEOMAlgo_GetInPlaceIterator() +{ + myDim=10; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_GetInPlaceIterator::~GEOMAlgo_GetInPlaceIterator() +{ +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlaceIterator::Clear() +{ + Standard_Integer i; + // + for (i=0; i=0) { + myLists[iX].Append(theCS); + } +} +//======================================================================= +//function : ShapeWhere +//purpose : +//======================================================================= +void GEOMAlgo_GetInPlaceIterator::Initialize(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + Standard_Integer iX; + // + iX=TypeToInteger(aType1, aType2); + if (iX>=0) { + myIterator.Initialize(myLists[iX]); + } + else { + myIterator.Initialize(myEmptyList); + } +} +//======================================================================= +// function: More +// purpose: +//======================================================================= +Standard_Boolean GEOMAlgo_GetInPlaceIterator::More()const +{ + return myIterator.More(); +} +//======================================================================= +// function: Next +// purpose: +//======================================================================= +void GEOMAlgo_GetInPlaceIterator::Next() +{ + myIterator.Next(); +} +//======================================================================= +// function: Value +// purpose: +//======================================================================= +const NMTTools_CoupleOfShape& GEOMAlgo_GetInPlaceIterator::Value()const +{ + return myIterator.Value(); +} +//======================================================================= +//function : TypeToInteger +//purpose : +//======================================================================= +Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + Standard_Integer iRet, iT1, iT2, iX; + // + iRet=-1; + // + if (aType1==TopAbs_VERTEX) { + if (aType2==TopAbs_VERTEX) { + iRet=0; + } + } + else if (aType1==TopAbs_EDGE) { + if (aType2==TopAbs_VERTEX) { + iRet=1; + } + else if (aType2==TopAbs_EDGE) { + iRet=2; + } + } + else if (aType1==TopAbs_FACE) { + if (aType2==TopAbs_VERTEX) { + iRet=3; + } + else if (aType2==TopAbs_EDGE) { + iRet=4; + } + else if (aType2==TopAbs_FACE) { + iRet=5; + } + } + // So_1,*_2 + else if (aType1==TopAbs_SOLID) { + if (aType2==TopAbs_VERTEX) { + iRet=6; + } + else if (aType2==TopAbs_EDGE) { + iRet=7; + } + else if (aType2==TopAbs_FACE) { + iRet=8; + } + else if (aType2==TopAbs_SOLID) { + iRet=9; + } + } + return iRet; +} diff --git a/src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx b/src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx new file mode 100644 index 000000000..f14d3720c --- /dev/null +++ b/src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#ifndef _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile +#define _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_DefineHandle_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle(Standard_Type); +class Handle(TCollection_MapNode); +class GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape; + +DEFINE_STANDARD_HANDLE(GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape,TCollection_MapNode) + +#endif diff --git a/src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx b/src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx new file mode 100644 index 000000000..66eaa6179 --- /dev/null +++ b/src/GEOMAlgo/Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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. +// +// 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 + +#ifndef _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile +#define _Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_DefineHandle_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle(Standard_Type); +class Handle(TCollection_MapNode); +class GEOMAlgo_DataMapNodeOfDataMapOfShapePnt; + +DEFINE_STANDARD_HANDLE(GEOMAlgo_DataMapNodeOfDataMapOfShapePnt,TCollection_MapNode) + +#endif diff --git a/src/GEOMAlgo/Makefile.am b/src/GEOMAlgo/Makefile.am index b16c5a123..4eaff7daa 100644 --- a/src/GEOMAlgo/Makefile.am +++ b/src/GEOMAlgo/Makefile.am @@ -16,11 +16,10 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # - -# GEOM GEOMAlgo : tools for Glue Faces algorithm -# File : Makefile.in -# Author : Julia DOROVSKIKH -# Module : GEOM +# GEOM GEOMAlgo : tools for Glue Faces algorithm +# File : Makefile.am +# Author : Julia DOROVSKIKH +# Module : GEOM include $(top_srcdir)/adm_local/unix/make_common_starter.am @@ -56,24 +55,34 @@ dist_libGEOMAlgo_la_SOURCES = \ GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger_0.cxx \ GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape_0.cxx \ GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape_0.cxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_0.cxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_0.cxx \ GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal_0.cxx \ GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet_0.cxx \ GEOMAlgo_DataMapNodeOfDataMapOfOrientedShapeShape_0.cxx \ GEOMAlgo_DataMapNodeOfDataMapOfPassKeyInteger_0.cxx \ GEOMAlgo_DataMapNodeOfDataMapOfPassKeyShapeShape_0.cxx \ GEOMAlgo_DataMapNodeOfDataMapOfRealListOfShape_0.cxx \ + GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape_0.cxx \ + GEOMAlgo_DataMapNodeOfDataMapOfShapePnt_0.cxx \ GEOMAlgo_DataMapNodeOfDataMapOfShapeReal_0.cxx \ GEOMAlgo_DataMapNodeOfDataMapOfShapeShapeSet_0.cxx \ GEOMAlgo_DataMapOfOrientedShapeShape_0.cxx \ GEOMAlgo_DataMapOfPassKeyInteger_0.cxx \ GEOMAlgo_DataMapOfPassKeyShapeShape_0.cxx \ GEOMAlgo_DataMapOfRealListOfShape_0.cxx \ + GEOMAlgo_DataMapOfShapeMapOfShape_0.cxx \ + GEOMAlgo_DataMapOfShapePnt_0.cxx \ GEOMAlgo_DataMapOfShapeReal_0.cxx \ GEOMAlgo_DataMapOfShapeShapeSet_0.cxx \ GEOMAlgo_FinderShapeOn1.cxx \ GEOMAlgo_FinderShapeOn2.cxx \ GEOMAlgo_FinderShapeOn.cxx \ GEOMAlgo_FinderShapeOnQuad.cxx \ + GEOMAlgo_GetInPlace.cxx \ + GEOMAlgo_GetInPlace_1.cxx \ + GEOMAlgo_GetInPlace_2.cxx \ + GEOMAlgo_GetInPlace_3.cxx \ GEOMAlgo_GlueAnalyser.cxx \ GEOMAlgo_Gluer.cxx \ GEOMAlgo_GlueDetector.cxx \ @@ -193,18 +202,24 @@ salomeinclude_HEADERS = \ GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx \ GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx \ GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx \ GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx \ GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx \ GEOMAlgo_DataMapNodeOfDataMapOfOrientedShapeShape.hxx \ GEOMAlgo_DataMapNodeOfDataMapOfPassKeyInteger.hxx \ GEOMAlgo_DataMapNodeOfDataMapOfPassKeyShapeShape.hxx \ GEOMAlgo_DataMapNodeOfDataMapOfRealListOfShape.hxx \ + GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx \ + GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx \ GEOMAlgo_DataMapNodeOfDataMapOfShapeReal.hxx \ GEOMAlgo_DataMapNodeOfDataMapOfShapeShapeSet.hxx \ GEOMAlgo_DataMapOfOrientedShapeShape.hxx \ GEOMAlgo_DataMapOfPassKeyInteger.hxx \ GEOMAlgo_DataMapOfPassKeyShapeShape.hxx \ GEOMAlgo_DataMapOfRealListOfShape.hxx \ + GEOMAlgo_DataMapOfShapeMapOfShape.hxx \ + GEOMAlgo_DataMapOfShapePnt.hxx \ GEOMAlgo_DataMapOfShapeReal.hxx \ GEOMAlgo_DataMapOfShapeShapeSet.hxx \ GEOMAlgo_FinderShapeOn1.ixx \ @@ -217,6 +232,7 @@ salomeinclude_HEADERS = \ GEOMAlgo_FinderShapeOn.ixx \ GEOMAlgo_FinderShapeOn.jxx \ GEOMAlgo_FinderShapeOnQuad.hxx \ + GEOMAlgo_GetInPlace.hxx \ GEOMAlgo_GlueAnalyser.hxx \ GEOMAlgo_GlueAnalyser.ixx \ GEOMAlgo_GlueAnalyser.jxx \ @@ -329,6 +345,8 @@ salomeinclude_HEADERS = \ Handle_GEOMAlgo_DataMapNodeOfDataMapOfRealListOfShape.hxx \ Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeReal.hxx \ Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeShapeSet.hxx \ + Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapeMapOfShape.hxx \ + Handle_GEOMAlgo_DataMapNodeOfDataMapOfShapePnt.hxx \ Handle_GEOMAlgo_HAlgo.hxx \ Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfIntegerShape.hxx \ Handle_GEOMAlgo_IndexedDataMapNodeOfIndexedDataMapOfPassKeyListOfShape.hxx \ diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index fabc92f02..6efa75034 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -46,14 +46,15 @@ #include "GEOM_ISubShape.hxx" #include "GEOM_PythonDump.hxx" +#include "GEOMAlgo_ClsfBox.hxx" +#include "GEOMAlgo_ClsfSolid.hxx" +#include "GEOMAlgo_CoupleOfShapes.hxx" #include "GEOMAlgo_FinderShapeOn1.hxx" #include "GEOMAlgo_FinderShapeOnQuad.hxx" #include "GEOMAlgo_FinderShapeOn2.hxx" -#include "GEOMAlgo_ClsfBox.hxx" -#include "GEOMAlgo_ClsfSolid.hxx" +#include "GEOMAlgo_GetInPlace.hxx" #include "GEOMAlgo_GlueDetector.hxx" #include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx" -#include "GEOMAlgo_CoupleOfShapes.hxx" #include "GEOMAlgo_ListOfCoupleOfShapes.hxx" #include "utilities.h" @@ -3782,6 +3783,174 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) TopTools_IndexedMapOfShape aWhereIndices; TopExp::MapShapes(aWhere, aWhereIndices); + TopAbs_ShapeEnum iType = TopAbs_SOLID; + Standard_Real dl_l = 1e-3; + Standard_Real min_l, Tol_0D, Tol_1D, Tol_2D, Tol_3D, Tol_Mass; + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; + Bnd_Box BoundingBox; + gp_Pnt aPnt, aPnt_aWhat, tab_Pnt[2]; + GProp_GProps aProps; + + // Find the iType of the aWhat shape + iType = GetTypeOfSimplePart(aWhat); + if (iType == TopAbs_SHAPE) { + SetErrorCode("Error: An attempt to extract a shape of not supported type."); + return NULL; + } + + TopExp_Explorer Exp_aWhat ( aWhat, iType ); + TopExp_Explorer Exp_aWhere ( aWhere, iType ); + TopExp_Explorer Exp_Edge ( aWhere, TopAbs_EDGE ); + + // Find the shortest edge in theShapeWhere shape + BRepBndLib::Add(aWhere, BoundingBox); + BoundingBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + min_l = fabs(aXmax - aXmin); + if( min_l < fabs(aYmax - aYmin) ) min_l = fabs(aYmax - aYmin); + if( min_l < fabs(aZmax - aZmin) ) min_l = fabs(aZmax - aZmin); + min_l /= dl_l; + // Mantis issue 0020908 BEGIN + if (!Exp_Edge.More()) { + min_l = Precision::Confusion(); + } + // Mantis issue 0020908 END + for ( Standard_Integer nbEdge = 0; Exp_Edge.More(); Exp_Edge.Next(), nbEdge++ ) { + TopExp_Explorer Exp_Vertex( Exp_Edge.Current(), TopAbs_VERTEX); + for ( Standard_Integer nbVertex = 0; Exp_Vertex.More(); Exp_Vertex.Next(), nbVertex++ ) { + aPnt = BRep_Tool::Pnt( TopoDS::Vertex( Exp_Vertex.Current() ) ); + tab_Pnt[nbVertex] = aPnt; + } + if ( ! tab_Pnt[0].IsEqual(tab_Pnt[1], dl_l) ) { + BRepGProp::LinearProperties(Exp_Edge.Current(), aProps); + if ( aProps.Mass() < min_l ) min_l = aProps.Mass(); + } + } + + // Compute tolerances + Tol_0D = dl_l; + Tol_1D = dl_l * min_l; + Tol_2D = dl_l * ( min_l * min_l) * ( 2. + dl_l); + Tol_3D = dl_l * ( min_l * min_l * min_l ) * ( 3. + (3 * dl_l) + (dl_l * dl_l) ); + + if (Tol_0D < Precision::Confusion()) Tol_0D = Precision::Confusion(); + if (Tol_1D < Precision::Confusion()) Tol_1D = Precision::Confusion(); + if (Tol_2D < Precision::Confusion()) Tol_2D = Precision::Confusion(); + if (Tol_3D < Precision::Confusion()) Tol_3D = Precision::Confusion(); + + Tol_Mass = Tol_3D; + if ( iType == TopAbs_VERTEX ) Tol_Mass = Tol_0D; + else if ( iType == TopAbs_EDGE ) Tol_Mass = Tol_1D; + else if ( iType == TopAbs_FACE ) Tol_Mass = Tol_2D; + + // Searching for the sub-shapes inside the ShapeWhere shape + GEOMAlgo_GetInPlace aGIP; + aGIP.SetTolerance(Tol_1D); + aGIP.SetTolMass(Tol_Mass); + aGIP.SetTolCG(Tol_1D); + + aGIP.SetArgument(aWhat); + aGIP.SetShapeWhere(aWhere); + + aGIP.Perform(); + int iErr = aGIP.ErrorStatus(); + if (iErr) { + SetErrorCode("Error in GEOMAlgo_GetInPlace"); + return NULL; + } + + if (!aGIP.IsFound()) { + SetErrorCode(NOT_FOUND_ANY); + return NULL; + } + + const TopTools_DataMapOfShapeListOfShape& aDMSLS = aGIP.Images(); + if (!aDMSLS.IsBound(aWhat)) { + SetErrorCode(NOT_FOUND_ANY); + return NULL; + } + + // the list of shapes aLSA contains the shapes + // of the Shape For Search that corresponds + // to the Argument aWhat + const TopTools_ListOfShape& aLSA = aDMSLS.Find(aWhat); + if (aLSA.Extent() == 0) { + SetErrorCode(NOT_FOUND_ANY); // Not found any Results + return NULL; + } + + Handle(TColStd_HArray1OfInteger) aModifiedArray = new TColStd_HArray1OfInteger (1, aLSA.Extent()); + TopTools_ListIteratorOfListOfShape anIterModif (aLSA); + for (Standard_Integer imod = 1; anIterModif.More(); anIterModif.Next(), imod++) { + if (aWhereIndices.Contains(anIterModif.Value())) { + aModifiedArray->SetValue(imod, aWhereIndices.FindIndex(anIterModif.Value())); + } + else { + SetErrorCode("Error: wrong sub shape returned"); + return NULL; + } + } + + //Add a new object + Handle(GEOM_Object) aResult = GetEngine()->AddSubShape(theShapeWhere, aModifiedArray); + if (aResult.IsNull()) { + SetErrorCode("Error in algorithm: result found, but cannot be returned."); + return NULL; + } + + if (aModifiedArray->Length() > 1) { + //Set a GROUP type + aResult->SetType(GEOM_GROUP); + + //Set a sub shape type + TopoDS_Shape aFirstFound = aLSA.First(); + TopAbs_ShapeEnum aShapeType = aFirstFound.ShapeType(); + + TDF_Label aFreeLabel = aResult->GetFreeLabel(); + TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)aShapeType); + } + + //Make a Python command + Handle(GEOM_Function) aFunction = aResult->GetFunction(1); + + GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetInPlace(" + << theShapeWhere << ", " << theShapeWhat << ", True)"; + + SetErrorCode(OK); + return aResult; +} + +//============================================================================= +/*! + * case GetInPlaceOld: + * default: + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlaceOld (Handle(GEOM_Object) theShapeWhere, + Handle(GEOM_Object) theShapeWhat) +{ + SetErrorCode(KO); + + if (theShapeWhere.IsNull() || theShapeWhat.IsNull()) return NULL; + + TopoDS_Shape aWhere = theShapeWhere->GetValue(); + TopoDS_Shape aWhat = theShapeWhat->GetValue(); + TopoDS_Shape aPntShape; + TopoDS_Vertex aVertex; + + if (aWhere.IsNull() || aWhat.IsNull()) { + SetErrorCode("Error: aWhere and aWhat TopoDS_Shape are Null."); + return NULL; + } + + Handle(GEOM_Function) aWhereFunction = theShapeWhere->GetLastFunction(); + if (aWhereFunction.IsNull()) { + SetErrorCode("Error: aWhereFunction is Null."); + return NULL; + } + + TopTools_IndexedMapOfShape aWhereIndices; + TopExp::MapShapes(aWhere, aWhereIndices); + TColStd_ListOfInteger aModifiedList; Standard_Integer aWhereIndex; Handle(TColStd_HArray1OfInteger) aModifiedArray; @@ -3972,7 +4141,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) Handle(GEOM_Function) aFunction = aResult->GetFunction(1); GEOM::TPythonDump(aFunction) << aResult << " = geompy.GetInPlace(" - << theShapeWhere << ", " << theShapeWhat << ")"; + << theShapeWhere << ", " << theShapeWhat << ", False)"; SetErrorCode(OK); return aResult; diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index c60cae38f..c30ae1868 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -290,6 +290,9 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere, Handle(GEOM_Object) theShapeWhat); + Standard_EXPORT Handle(GEOM_Object) GetInPlaceOld (Handle(GEOM_Object) theShapeWhere, + Handle(GEOM_Object) theShapeWhat); + Standard_EXPORT Handle(GEOM_Object) GetInPlaceByHistory (Handle(GEOM_Object) theShapeWhere, Handle(GEOM_Object) theShapeWhat); diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index 11328f5d1..e29a6e763 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -1739,6 +1739,36 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace return GetObject(anObject); } +//============================================================================= +/*! + * GetInPlaceOld + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld + (GEOM::GEOM_Object_ptr theShapeWhere, + GEOM::GEOM_Object_ptr theShapeWhat) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference objects + Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere); + Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat); + + if (aShapeWhere.IsNull() || + aShapeWhat.IsNull()) return aGEOMObject._retn(); + + //Get Shapes in place of aShapeWhat + Handle(GEOM_Object) anObject = + GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * GetInPlaceByHistory diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index 17d8b97fa..4b5ad0318 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -255,6 +255,9 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i : GEOM::GEOM_Object_ptr GetInPlace (GEOM::GEOM_Object_ptr theShapeWhere, GEOM::GEOM_Object_ptr theShapeWhat); + GEOM::GEOM_Object_ptr GetInPlaceOld (GEOM::GEOM_Object_ptr theShapeWhere, + GEOM::GEOM_Object_ptr theShapeWhat); + GEOM::GEOM_Object_ptr GetInPlaceByHistory (GEOM::GEOM_Object_ptr theShapeWhere, GEOM::GEOM_Object_ptr theShapeWhat); diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 21922a58f..4712290f1 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -2154,9 +2154,14 @@ class geompyDC(GEOM._objref_GEOM_Gen): # @image html get_in_place_lost_part.png # # @ref swig_GetInPlace "Example" - def GetInPlace(self, theShapeWhere, theShapeWhat): + def GetInPlace(self, theShapeWhere, theShapeWhat, isNewImplementation = False): # Example: see GEOM_TestOthers.py - anObj = self.ShapesOp.GetInPlace(theShapeWhere, theShapeWhat) + anObj = None + if isNewImplementation: + anObj = self.ShapesOp.GetInPlace(theShapeWhere, theShapeWhat) + else: + anObj = self.ShapesOp.GetInPlaceOld(theShapeWhere, theShapeWhat) + pass RaiseIfFailed("GetInPlace", self.ShapesOp) return anObj -- 2.39.2