From: jfa Date: Wed, 14 Mar 2012 10:26:55 +0000 (+0000) Subject: Internal issue 0022865: Restructurization of Partition packages. X-Git-Tag: V6_5_0a1~28 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=35bb93a206728fca2a4053e19711b494393204df;p=modules%2Fgeom.git Internal issue 0022865: Restructurization of Partition packages. --- diff --git a/configure.ac b/configure.ac index 8e0abd9f0..929a9190b 100644 --- a/configure.ac +++ b/configure.ac @@ -316,6 +316,19 @@ echo CHECK_CAS +echo "OCC_VERSION_DEVELOPMENT = ${OCC_VERSION_DEVELOPMENT}" +NMTDS_VAR=NMTDS +NMTTools_VAR=NMTTools +GEOMAlgo_VAR=GEOMAlgo +if test "${OCC_VERSION_DEVELOPMENT}" == "1"; then + NMTDS_VAR=NMTDS_NEW + NMTTools_VAR=NMTTools_NEW + GEOMAlgo_VAR=GEOMAlgo_NEW +fi +AC_SUBST(NMTDS_VAR) +AC_SUBST(NMTTools_VAR) +AC_SUBST(GEOMAlgo_VAR) + echo echo --------------------------------------------- echo Testing html generators @@ -445,6 +458,7 @@ AC_OUTPUT([ \ src/EntityGUI/Makefile \ src/GEOM/Makefile \ src/GEOMAlgo/Makefile \ + src/GEOMAlgo_NEW/Makefile \ src/GEOMBase/Makefile \ src/GEOMClient/Makefile \ src/GEOMFiltersSelection/Makefile \ @@ -464,7 +478,9 @@ AC_OUTPUT([ \ src/IGESImport/Makefile \ src/MeasureGUI/Makefile \ src/NMTDS/Makefile \ + src/NMTDS_NEW/Makefile \ src/NMTTools/Makefile \ + src/NMTTools_NEW/Makefile \ src/OBJECT/Makefile \ src/OCC2VTK/Makefile \ src/OperationGUI/Makefile \ diff --git a/src/GEOMAlgo_NEW/BlockFix.cdl b/src/GEOMAlgo_NEW/BlockFix.cdl new file mode 100644 index 000000000..478685c9c --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix.cdl @@ -0,0 +1,67 @@ +-- 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: BlockFix.cdl +-- Created: Tue Dec 7 11:59:05 2004 +-- Author: Pavel Durandin +-- +package BlockFix + +uses + + TColStd, + gp, + Geom, + Geom2d, + GeomAbs, + TopLoc, + TopoDS, + BRepTools, + TopTools, + ShapeBuild + +is + + class SphereSpaceModifier; + + class UnionFaces; + + class UnionEdges; + + class BlockFixAPI; + ---Purpose: API class to perform the fixing of the + -- block + + class PeriodicSurfaceModifier; + + class CheckTool; + + RotateSphereSpace (S: Shape from TopoDS; Tol: Real) + returns Shape from TopoDS; + + FixRanges (S: Shape from TopoDS; Tol: Real) + returns Shape from TopoDS; + ---Purpose: checking and fixing cases where parametric + -- boundaries of face based on periodic surface are not + -- contained in the range of this surface. + +end BlockFix; diff --git a/src/GEOMAlgo_NEW/BlockFix.cxx b/src/GEOMAlgo_NEW/BlockFix.cxx new file mode 100644 index 000000000..ef9ca5578 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix.cxx @@ -0,0 +1,216 @@ +// 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: BlockFix.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN +// +#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 +#include +#include + +#include +#include +#include +#include + +#include + + +//======================================================================= +//function : FixResult +//purpose : auxilary +//======================================================================= +static void FixResult(const TopoDS_Shape& result, + Handle(ShapeBuild_ReShape)& Context, + const Standard_Real Tol) +{ + for (TopExp_Explorer ex_f(result,TopAbs_FACE); ex_f.More(); ex_f.Next()) { + TopoDS_Shape aShape = Context->Apply(ex_f.Current().Oriented(TopAbs_FORWARD)); + // face coud not be dropped or splitted on this step + TopoDS_Face aFace = TopoDS::Face(aShape); + TopLoc_Location L; + Handle(Geom_Surface) Surf = BRep_Tool::Surface(aFace,L); + + if( Surf->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || + Surf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) ) { + + Standard_Integer nbWires = 0; + for (TopExp_Explorer ex_w(aFace,TopAbs_WIRE); ex_w.More(); ex_w.Next()) { + nbWires++; + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(ex_w.Current()), + aFace, + Precision::Confusion()); + sfw->FixReorder(); + if(sfw->StatusReorder ( ShapeExtend_FAIL )) + continue; + + sfw->SetPrecision(2.*Tol); + sfw->FixShifted(); + + Standard_Boolean isDone = sfw->LastFixStatus ( ShapeExtend_DONE ); + isDone |= sfw->FixDegenerated(); + + // remove degenerated edges from not degenerated points + ShapeAnalysis_Edge sae; + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + Standard_Integer i; + for( i = 1; i<=sewd->NbEdges();i++) { + TopoDS_Edge E = sewd->Edge(i); + if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aFace)) { + sewd->Remove(i); + isDone = Standard_True; + i--; + } + } + + //isDone |= sfw->FixLacking(); // commented by skl 22.03.2005 (PAL8395) + + // remove neighbour seam edges + if(isDone) { + for( i = 1; iNbEdges();i++) { + if(sewd->IsSeam(i) && sewd->IsSeam(i+1)) { + isDone = Standard_True; + sewd->Remove(i); + sewd->Remove(i); + i--; + } + } + if(sewd->IsSeam(1) && sewd->IsSeam(sewd->NbEdges())) { + sewd->Remove(1); + sewd->Remove(sewd->NbEdges()); + } + } + + + if(isDone) { + TopoDS_Wire ResWire = sfw->Wire(); + Context->Replace(ex_w.Current(), ResWire); + }; + } + // Implement fix orientation in case of several wires + if(nbWires > 1) { + TopoDS_Face aFixedFace = TopoDS::Face(Context->Apply(aFace)); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFixedFace); + if(sff->FixOrientation()) + Context->Replace(aFixedFace,sff->Face()); + } + + } + } +} + + + + + +//======================================================================= +//function : ConvertToAnalytical +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix::RotateSphereSpace (const TopoDS_Shape& S, + const Standard_Real Tol) +{ + + // Create a modification description + Handle(BlockFix_SphereSpaceModifier) SR = new BlockFix_SphereSpaceModifier; + SR->SetTolerance(Tol); + + TopTools_DataMapOfShapeShape context; + BRepTools_Modifier MD; + TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); + + Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; + FixResult(result,RS,Tol); + result = RS->Apply(result); + + ShapeFix_Edge sfe; + for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + } + + ShapeFix::SameParameter(result,Standard_False); + return result; +} + + +//======================================================================= +//function : FixRanges +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix::FixRanges (const TopoDS_Shape& S, + const Standard_Real Tol) +{ + // Create a modification description + Handle(BlockFix_PeriodicSurfaceModifier) SR = new BlockFix_PeriodicSurfaceModifier; + SR->SetTolerance(Tol); + + TopTools_DataMapOfShapeShape context; + BRepTools_Modifier MD; + TopoDS_Shape result = ShapeCustom::ApplyModifier ( S, SR, context,MD ); + + Handle(ShapeBuild_ReShape) RS = new ShapeBuild_ReShape; + FixResult(result,RS,Tol); + result = RS->Apply(result); + + ShapeFix_Edge sfe; + for(TopExp_Explorer exp(result,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + } + + ShapeFix::SameParameter(result,Standard_False); + + return result; +} diff --git a/src/GEOMAlgo_NEW/BlockFix.hxx b/src/GEOMAlgo_NEW/BlockFix.hxx new file mode 100644 index 000000000..3bd612070 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix.hxx @@ -0,0 +1,106 @@ +// 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 _BlockFix_HeaderFile +#define _BlockFix_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#endif +class TopoDS_Shape; +class BlockFix_SphereSpaceModifier; +class BlockFix_UnionFaces; +class BlockFix_UnionEdges; +class BlockFix_BlockFixAPI; +class BlockFix_PeriodicSurfaceModifier; +class BlockFix_CheckTool; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class BlockFix { + +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); + } + // Methods PUBLIC + // +Standard_EXPORT static TopoDS_Shape RotateSphereSpace(const TopoDS_Shape& S,const Standard_Real Tol) ; +Standard_EXPORT static TopoDS_Shape FixRanges(const TopoDS_Shape& S,const Standard_Real Tol) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + +friend class BlockFix_SphereSpaceModifier; +friend class BlockFix_UnionFaces; +friend class BlockFix_UnionEdges; +friend class BlockFix_BlockFixAPI; +friend class BlockFix_PeriodicSurfaceModifier; +friend class BlockFix_CheckTool; + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix.ixx b/src/GEOMAlgo_NEW/BlockFix.ixx new file mode 100644 index 000000000..05477e7e1 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix.ixx @@ -0,0 +1,27 @@ +// 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 + + + + diff --git a/src/GEOMAlgo_NEW/BlockFix.jxx b/src/GEOMAlgo_NEW/BlockFix.jxx new file mode 100644 index 000000000..1cc0d609d --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix.jxx @@ -0,0 +1,28 @@ +// 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 _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cdl b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cdl new file mode 100644 index 000000000..85dd360e2 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cdl @@ -0,0 +1,68 @@ +-- 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: BlockFix_BlockFixAPI.cdl +-- Created: Tue Dec 7 17:56:09 2004 +-- Author: Pavel Durandin +-- +class BlockFixAPI from BlockFix inherits TShared from MMgt + + ---Purpose: + +uses + + Shape from TopoDS, + ReShape from ShapeBuild + +is + Create returns BlockFixAPI from BlockFix; + ---Purpose: Empty constructor + + SetShape(me: mutable; Shape: Shape from TopoDS); + ---Purpose: Sets the shape to be operated on + ---C++: inline + + Perform(me: mutable); + ---Purpose: + + Shape(me) returns Shape from TopoDS; + ---Purpose: Returns resulting shape. + ---C++: inline + + Context(me:mutable) returns ReShape from ShapeBuild; + ---Purpose: Returns modifiable context for storing the + -- mofifications + ---C++: inline + ---C++: return & + + Tolerance (me:mutable) returns Real; + ---Purpose: Returns modifiable tolerance of recognition + ---C++: inline + ---C++: return & + +fields + + myContext : ReShape from ShapeBuild; + myShape : Shape from TopoDS; + myTolerance : Real from Standard; + +end BlockFixAPI from BlockFix; diff --git a/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cxx b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cxx new file mode 100644 index 000000000..21281eefd --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.cxx @@ -0,0 +1,66 @@ +// 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: BlockFix_BlockFixAPI.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN +// +#include +#include +#include +#include +#include + +//======================================================================= +//function : ShapeConvert_CanonicAPI +//purpose : +//======================================================================= + +BlockFix_BlockFixAPI::BlockFix_BlockFixAPI() +{ + myTolerance = Precision::Confusion(); + myOptimumNbFaces = 6; +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +void BlockFix_BlockFixAPI::Perform() +{ + // processing spheres with degenerativities + TopoDS_Shape aShape = Shape(); + myShape = BlockFix::RotateSphereSpace(aShape,myTolerance); + + // faces unification + BlockFix_UnionFaces aFaceUnifier; + aFaceUnifier.GetTolerance() = myTolerance; + aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces; + TopoDS_Shape aResult = aFaceUnifier.Perform(myShape); + + BlockFix_UnionEdges anEdgeUnifier; + myShape = anEdgeUnifier.Perform(aResult,myTolerance); + + TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); + myShape = aRes; +} diff --git a/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.hxx new file mode 100644 index 000000000..9100b6dac --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.hxx @@ -0,0 +1,94 @@ +// 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 _BlockFix_BlockFixAPI_HeaderFile +#define _BlockFix_BlockFixAPI_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile +#include +#endif + +#ifndef _Handle_ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _MMgt_TShared_HeaderFile +#include +#endif + +class ShapeBuild_ReShape; +class TopoDS_Shape; + + +class BlockFix_BlockFixAPI : public MMgt_TShared +{ +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); + } + + // Methods PUBLIC + // + Standard_EXPORT BlockFix_BlockFixAPI(); + void SetShape(const TopoDS_Shape& Shape); + Standard_EXPORT void Perform(); + TopoDS_Shape Shape() const; + Handle_ShapeBuild_ReShape& Context(); + Standard_Real& Tolerance(); + Standard_Integer& OptimumNbFaces(); + Standard_EXPORT ~BlockFix_BlockFixAPI(); + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& BlockFix_BlockFixAPI_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +private: + // Fields PRIVATE + // + Handle_ShapeBuild_ReShape myContext; + TopoDS_Shape myShape; + Standard_Real myTolerance; + Standard_Integer myOptimumNbFaces; +}; + +#include + +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.ixx b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.ixx new file mode 100644 index 000000000..55c205dc1 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.ixx @@ -0,0 +1,77 @@ +// 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 + +BlockFix_BlockFixAPI::~BlockFix_BlockFixAPI() {} + + + +Standard_EXPORT Handle_Standard_Type& BlockFix_BlockFixAPI_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("BlockFix_BlockFixAPI", + sizeof(BlockFix_BlockFixAPI), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(BlockFix_BlockFixAPI) Handle(BlockFix_BlockFixAPI)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(BlockFix_BlockFixAPI) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(BlockFix_BlockFixAPI))) { + _anOtherObject = Handle(BlockFix_BlockFixAPI)((Handle(BlockFix_BlockFixAPI)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& BlockFix_BlockFixAPI::DynamicType() const +{ + return STANDARD_TYPE(BlockFix_BlockFixAPI) ; +} +Standard_Boolean BlockFix_BlockFixAPI::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(BlockFix_BlockFixAPI) == AType || MMgt_TShared::IsKind(AType)); +} +Handle_BlockFix_BlockFixAPI::~Handle_BlockFix_BlockFixAPI() {} + diff --git a/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.jxx b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.jxx new file mode 100644 index 000000000..81f42ef35 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.jxx @@ -0,0 +1,31 @@ +// 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 _ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_BlockFixAPI_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.lxx b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.lxx new file mode 100644 index 000000000..6184d5aca --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_BlockFixAPI.lxx @@ -0,0 +1,73 @@ +// 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 + +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= + +inline void BlockFix_BlockFixAPI::SetShape(const TopoDS_Shape& Shape) +{ + myShape = Shape; +} + +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + +inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const +{ + return myShape; +} + +//======================================================================= +//function : Context +//purpose : +//======================================================================= + +inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context() +{ + return myContext; +} + +//======================================================================= +//function : Tolerance +//purpose : +//======================================================================= + +inline Standard_Real& BlockFix_BlockFixAPI::Tolerance() +{ + return myTolerance; +} + +//======================================================================= +//function : OptimumNbFaces +//purpose : +//======================================================================= + +inline Standard_Integer& BlockFix_BlockFixAPI::OptimumNbFaces() +{ + return myOptimumNbFaces; +} diff --git a/src/GEOMAlgo_NEW/BlockFix_CheckTool.cdl b/src/GEOMAlgo_NEW/BlockFix_CheckTool.cdl new file mode 100644 index 000000000..dce838ad3 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_CheckTool.cdl @@ -0,0 +1,67 @@ +-- 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: BlockFix_CheckTool.cdl +-- Created: Fri Dec 17 10:36:58 2004 +-- Author: Sergey KUUL +-- +class CheckTool from BlockFix + + ---Purpose: + +uses + + Shape from TopoDS, + SequenceOfShape from TopTools + +is + + Create returns CheckTool from BlockFix; + ---Purpose: Empty constructor + + SetShape(me: in out; aShape: Shape from TopoDS); + + Perform(me: in out); + ---Purpose: + + NbPossibleBlocks(me) returns Integer; + + PossibleBlock(me; num: Integer) returns Shape from TopoDS; + + DumpCheckResult(me; S : in out OStream); + ---Purpose: Dumps results of checking + + +fields + + myShape : Shape from TopoDS; + myHasCheck : Boolean; + myNbSolids : Integer; + myNbBlocks : Integer; + myPossibleBlocks : SequenceOfShape from TopTools; + myNbDegen : Integer; + myNbUF : Integer; + myNbUE : Integer; + myNbUFUE : Integer; + myBadRanges : Integer; + +end CheckTool; diff --git a/src/GEOMAlgo_NEW/BlockFix_CheckTool.cxx b/src/GEOMAlgo_NEW/BlockFix_CheckTool.cxx new file mode 100644 index 000000000..b936d9d4a --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_CheckTool.cxx @@ -0,0 +1,279 @@ +// 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: BlockFix_CheckTool.cxx +// Created: 17.12.04 11:15:25 +// Author: Sergey KUUL +// +#include + +//#include +//#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : BlockFix_CheckTool() +//purpose : Constructor +//======================================================================= + +BlockFix_CheckTool::BlockFix_CheckTool( ) +{ + myHasCheck = Standard_False; + myPossibleBlocks.Clear(); +} + + +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= + +void BlockFix_CheckTool::SetShape(const TopoDS_Shape& aShape) +{ + myHasCheck = Standard_False; + myShape = aShape; + myPossibleBlocks.Clear(); +} + + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +void BlockFix_CheckTool::Perform() +{ + myNbSolids=0; + myNbBlocks=0; + myNbDegen=0; + myNbUF=0; + myNbUE=0; + myNbUFUE=0; + + TopExp_Explorer exps (myShape, TopAbs_SOLID); + TopTools_MapOfShape mapS; + for (; exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + if (!mapS.Add(aSolid)) continue; + myNbSolids++; + Standard_Boolean IsBlock=Standard_True; + Standard_Boolean MayBeUF=Standard_False; + Standard_Boolean MayBeUE=Standard_False; + Standard_Integer nf=0; + TopExp_Explorer expf (aSolid, TopAbs_FACE); + TopTools_MapOfShape mapF; + for (; expf.More(); expf.Next()) { + if (mapF.Add(expf.Current())) + nf++; + } + + if (nf < 6) { + IsBlock = Standard_False; + } + else if (nf > 6) { + IsBlock = Standard_False; + // check faces unification + TopTools_SequenceOfShape faces; + mapF.Clear(); + for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + if (mapF.Add(expf.Current())) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + faces.Append(aFace); + } + } + Standard_Boolean HasFacesForUnification = Standard_False; + for (Standard_Integer i=1; i 0) { + IsBlock = Standard_False; + myNbDegen++; + myPossibleBlocks.Append(aSolid); + continue; + } + if (nbe < 12) + IsBlock = Standard_False; + if (nbe > 12) { + IsBlock = Standard_False; + // check edges unification + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + mapF.Clear(); + for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) { + TopoDS_Face aFace = TopoDS::Face(expf.Current()); + if (!mapF.Add(aFace)) continue; + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + + TopTools_MapOfShape mapEe; + for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge edge = TopoDS::Edge(expe.Current()); + if (!mapEe.Add(edge)) continue; + if (!aMapEdgeFaces.Contains(edge)) continue; + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter (aList); + for (; anIter.More(); anIter.Next()) { + TopoDS_Face face = TopoDS::Face(anIter.Value()); + if (face.IsSame(aFace)) continue; + if (aMapFacesEdges.Contains(face)) { + aMapFacesEdges.ChangeFromKey(face).Append(edge); + } + else { + TopTools_ListOfShape ListEdges; + ListEdges.Append(edge); + aMapFacesEdges.Add(face,ListEdges); + } + } + } + Standard_Integer i = 1; + for (; i <= aMapFacesEdges.Extent(); i++) { + const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); + if (ListEdges.Extent() > 1) break; + } + if (i <= aMapFacesEdges.Extent()) { + MayBeUE = Standard_True; + break; + } + } + } + + if (IsBlock) + myNbBlocks++; + else { + if (MayBeUF) { + myPossibleBlocks.Append(aSolid); + if (MayBeUE) + myNbUFUE++; + else + myNbUF++; + } + else if (MayBeUE) { + myNbUE++; + myPossibleBlocks.Append(aSolid); + } + } + } + + myHasCheck = Standard_True; +} + + +//======================================================================= +//function : NbPossibleBlocks +//purpose : +//======================================================================= + +Standard_Integer BlockFix_CheckTool::NbPossibleBlocks() const +{ + return myPossibleBlocks.Length(); +} + + +//======================================================================= +//function : PossibleBlock +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix_CheckTool::PossibleBlock(const Standard_Integer num) const +{ + TopoDS_Shape res; + if( num>0 && num<=myPossibleBlocks.Length() ) + res = myPossibleBlocks.Value(num); + return res; +} + + +//======================================================================= +//function : DumpCheckResult +//purpose : +//======================================================================= + +void BlockFix_CheckTool::DumpCheckResult(Standard_OStream& S) const +{ + if(!myHasCheck) + S<<"Check not performed!"< + + + + diff --git a/src/GEOMAlgo_NEW/BlockFix_CheckTool.jxx b/src/GEOMAlgo_NEW/BlockFix_CheckTool.jxx new file mode 100644 index 000000000..ba5c9672d --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_CheckTool.jxx @@ -0,0 +1,28 @@ +// 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 _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_CheckTool_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cdl b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cdl new file mode 100644 index 000000000..b654d6182 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cdl @@ -0,0 +1,135 @@ +-- 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: BlockFix_PeriodicSurfaceModifier.cdl +-- Created: Wed Dec 15 10:03:50 2004 +-- Author: Sergey KUUL +-- +class PeriodicSurfaceModifier from BlockFix inherits Modification from BRepTools + + ---Purpose: + +uses + Vertex from TopoDS, + Edge from TopoDS, + Face from TopoDS, + Location from TopLoc, + Shape from GeomAbs, + Pnt from gp, + Curve from Geom, + Curve from Geom2d, + Surface from Geom, + IndexedMapOfTransient from TColStd, + DataMapOfShapeInteger from TopTools + +is + + Create returns mutable PeriodicSurfaceModifier from BlockFix; + + SetTolerance(me: mutable; Toler: Real); + ---Purpose: Sets the tolerance for recognition of geometry + + NewSurface(me: mutable; F : Face from TopoDS; + S : out Surface from Geom; + L : out Location from TopLoc; + Tol: out Real from Standard; + RevWires : out Boolean from Standard; + RevFace : out Boolean from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the face has been + -- modified. In this case, is the new geometric + -- support of the face, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , are not + -- significant. + + NewCurve(me: mutable; E : Edge from TopoDS; + C : out Curve from Geom; + L : out Location from TopLoc; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the edge has been + -- modified. In this case, is the new geometric + -- support of the edge, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , are not + -- significant. + + NewPoint(me: mutable; V : Vertex from TopoDS; + P : out Pnt from gp; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the vertex has been + -- modified. In this case,

is the new geometric + -- support of the vertex, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- are not significant. + + NewCurve2d(me: mutable; E : Edge from TopoDS; + F : Face from TopoDS; + NewE : Edge from TopoDS; + NewF : Face from TopoDS; + C : out Curve from Geom2d; + Tol : out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the edge has a new + -- curve on surface on the face .In this case, + -- is the new geometric support of the edge, the + -- new location, the new tolerance. + -- + -- Otherwise, returns Standard_False, and , , + -- are not significant. + -- + -- is the new edge created from . + -- is the new face created from . They may be usefull. + + NewParameter(me: mutable; V : Vertex from TopoDS; + E : Edge from TopoDS; + P : out Real from Standard; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the Vertex has a new + -- parameter on the edge . In this case,

is + -- the parameter, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- are not significant. + + Continuity(me: mutable; E : Edge from TopoDS; + F1,F2 : Face from TopoDS; + NewE : Edge from TopoDS; + NewF1,NewF2: Face from TopoDS) + returns Shape from GeomAbs; + ---Purpose: Returns the continuity of between + -- and . + -- + -- is the new edge created from . + -- (resp. ) is the new face created from + -- (resp. ). + + +fields + + myTolerance : Real; + myMapOfFaces : DataMapOfShapeInteger from TopTools; + myMapOfSurfaces: IndexedMapOfTransient from TColStd; + +end PeriodicSurfaceModifier; diff --git a/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cxx b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cxx new file mode 100644 index 000000000..2d001d179 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.cxx @@ -0,0 +1,250 @@ +// 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: BlockFix_PeriodicSurfaceModifier.cxx +// Created: 15.12.04 10:08:50 +// Author: Sergey KUUL + +#include + +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : BlockFix_PeriodicSurfaceModifier() +//purpose : Constructor +//======================================================================= + +BlockFix_PeriodicSurfaceModifier::BlockFix_PeriodicSurfaceModifier ( ) +{ + myMapOfFaces.Clear(); + myMapOfSurfaces.Clear(); +} + + +//======================================================================= +//function : SetTolerance +//purpose : +//======================================================================= + +void BlockFix_PeriodicSurfaceModifier::SetTolerance(const Standard_Real Tol) +{ + myTolerance = Tol; +} + + +//======================================================================= +//function : ModifySurface +//purpose : auxilary +//======================================================================= + +static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, + const Handle(Geom_Surface)& aSurface, + Handle(Geom_Surface)& aNewSurface) +{ + Handle(Geom_Surface) S = aSurface; + + if(S->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { + Handle(Geom_CylindricalSurface) aCyl = + Handle(Geom_CylindricalSurface)::DownCast(S); + Standard_Real Umin, Umax, Vmin, Vmax; + BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); + if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) { + gp_Ax3 ax3 = aCyl->Position(); + gp_Ax1 NDir = ax3.Axis(); + gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); + Handle(Geom_CylindricalSurface) aNewCyl = + new Geom_CylindricalSurface(newax3,aCyl->Radius()); + aNewSurface = aNewCyl; + return Standard_True; + } + } + + if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { + Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); + Standard_Real Umin, Umax, Vmin, Vmax; + BRepTools::UVBounds(aFace, Umin, Umax, Vmin, Vmax); + if (Umin < -Precision::PConfusion() || Umax > 2*M_PI + Precision::PConfusion()) { + gp_Ax3 ax3 = aSphere->Position(); + gp_Ax1 NDir = ax3.Axis(); + gp_Ax3 newax3 = ax3.Rotated(NDir,Umin-Precision::PConfusion()); + Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(newax3,aSphere->Radius()); + aNewSurface = aNewSphere; + return Standard_True; + } + } + + return Standard_False; +} + + +//======================================================================= +//function : NewSurface +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewSurface(const TopoDS_Face& F, + Handle(Geom_Surface)& S, + TopLoc_Location& L,Standard_Real& Tol, + Standard_Boolean& RevWires, + Standard_Boolean& RevFace) +{ + TopLoc_Location LS; + Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS); + + if(ModifySurface(F, SIni, S)) { + + RevWires = Standard_False; + RevFace = Standard_False; + + L = LS; + Tol = BRep_Tool::Tolerance(F); + + Standard_Integer anIndex = myMapOfSurfaces.Add(S); + myMapOfFaces.Bind(F,anIndex); + return Standard_True; + } + + return Standard_False; +} + + +//======================================================================= +//function : NewCurve +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve(const TopoDS_Edge& /*E*/, + Handle(Geom_Curve)& /*C*/, + TopLoc_Location& /*L*/, + Standard_Real& /*Tol*/) +{ + return Standard_False; +} + + +//======================================================================= +//function : NewPoint +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewPoint(const TopoDS_Vertex& /*V*/, + gp_Pnt& /*P*/, + Standard_Real& /*Tol*/) +{ + return Standard_False; +} + + +//======================================================================= +//function : NewCurve2d +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewCurve2d(const TopoDS_Edge& E, + const TopoDS_Face& F, + const TopoDS_Edge& /*NewE*/, + const TopoDS_Face& /*NewF*/, + Handle(Geom2d_Curve)& C, + Standard_Real& Tol) +{ + //check if undelying surface of the face was modified + if(myMapOfFaces.IsBound(F)) { + Standard_Integer anIndex = myMapOfFaces.Find(F); + + Handle(Geom_Surface) aNewSurf = Handle(Geom_Surface)::DownCast(myMapOfSurfaces.FindKey(anIndex)); + + Standard_Real f,l; + TopLoc_Location LC, LS; + Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l ); + Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS); + + //taking into accound the orientation of the seam + C = BRep_Tool::CurveOnSurface(E,F,f,l); + Tol = BRep_Tool::Tolerance(E); + + BRep_Builder B; + TopoDS_Edge TempE; + B.MakeEdge(TempE); + B.Add(TempE, TopExp::FirstVertex(E)); + B.Add(TempE, TopExp::LastVertex(E)); + + if(!C3d.IsNull()) + B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion()); + B.Range(TempE, f, l); + + Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; + Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSurf->Transformed(LS.Transformation())); + TopLoc_Location LTemp; + LTemp.Identity(); + + Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F); + Standard_Real aWorkTol = 2*myTolerance+Tol; + sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol)); + sfe->FixSameParameter(TempE); + + //keep the orientation of original edge + TempE.Orientation(E.Orientation()); + C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l); + + //surface was modified + return Standard_True; + } + + return Standard_False; +} + + +//======================================================================= +//function : NewParameter +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_PeriodicSurfaceModifier::NewParameter(const TopoDS_Vertex& /*V*/, + const TopoDS_Edge& /*E*/, + Standard_Real& /*P*/, + Standard_Real& /*Tol*/) +{ + return Standard_False; +} + + +//======================================================================= +//function : Continuity +//purpose : +//======================================================================= + +GeomAbs_Shape BlockFix_PeriodicSurfaceModifier::Continuity(const TopoDS_Edge& E, + const TopoDS_Face& F1, + const TopoDS_Face& F2, + const TopoDS_Edge& /*NewE*/, + const TopoDS_Face& /*NewF1*/, + const TopoDS_Face& /*NewF2*/) +{ + return BRep_Tool::Continuity(E,F1,F2); +} + diff --git a/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.hxx new file mode 100644 index 000000000..78973d0f3 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.hxx @@ -0,0 +1,140 @@ +// 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 _BlockFix_PeriodicSurfaceModifier_HeaderFile +#define _BlockFix_PeriodicSurfaceModifier_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile +#include +#endif + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_IndexedMapOfTransient_HeaderFile +#include +#endif +#ifndef _BRepTools_Modification_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Curve_HeaderFile +#include +#endif +#ifndef _Handle_Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _GeomAbs_Shape_HeaderFile +#include +#endif +class TopoDS_Face; +class Geom_Surface; +class TopLoc_Location; +class TopoDS_Edge; +class Geom_Curve; +class TopoDS_Vertex; +class gp_Pnt; +class Geom2d_Curve; + + +class BlockFix_PeriodicSurfaceModifier : public BRepTools_Modification { + +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); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_PeriodicSurfaceModifier(); +Standard_EXPORT void SetTolerance(const Standard_Real Toler) ; +Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ; +Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ; +Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ; +Standard_EXPORT ~BlockFix_PeriodicSurfaceModifier(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myTolerance; +TopTools_DataMapOfShapeInteger myMapOfFaces; +TColStd_IndexedMapOfTransient myMapOfSurfaces; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.ixx b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.ixx new file mode 100644 index 000000000..8625b1650 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.ixx @@ -0,0 +1,79 @@ +// 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 + +BlockFix_PeriodicSurfaceModifier::~BlockFix_PeriodicSurfaceModifier() {} + + + +Standard_EXPORT Handle_Standard_Type& BlockFix_PeriodicSurfaceModifier_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("BlockFix_PeriodicSurfaceModifier", + sizeof(BlockFix_PeriodicSurfaceModifier), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(BlockFix_PeriodicSurfaceModifier) Handle(BlockFix_PeriodicSurfaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(BlockFix_PeriodicSurfaceModifier) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier))) { + _anOtherObject = Handle(BlockFix_PeriodicSurfaceModifier)((Handle(BlockFix_PeriodicSurfaceModifier)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& BlockFix_PeriodicSurfaceModifier::DynamicType() const +{ + return STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) ; +} +Standard_Boolean BlockFix_PeriodicSurfaceModifier::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier) == AType || BRepTools_Modification::IsKind(AType)); +} +Handle_BlockFix_PeriodicSurfaceModifier::~Handle_BlockFix_PeriodicSurfaceModifier() {} + diff --git a/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.jxx b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.jxx new file mode 100644 index 000000000..3ceaab7d2 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_PeriodicSurfaceModifier.jxx @@ -0,0 +1,49 @@ +// 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 _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopLoc_Location_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _Geom_Curve_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cdl b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cdl new file mode 100644 index 000000000..69e4cd9ec --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cdl @@ -0,0 +1,139 @@ +-- 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: BlockFix_SphereSpaceModifier.cdl +-- Created: Tue Dec 7 12:01:49 2004 +-- Author: Pavel Durandin +-- +class SphereSpaceModifier from BlockFix inherits Modification from BRepTools + + ---Purpose: Rotation of the parametric space of the sphere in order + -- to avoid the seam and degenerared edge within it + +uses + Vertex from TopoDS, + Edge from TopoDS, + Face from TopoDS, + Location from TopLoc, + Shape from GeomAbs, + Pnt from gp, + Curve from Geom, + Curve from Geom2d, + Surface from Geom, + IndexedMapOfTransient from TColStd, + DataMapOfShapeInteger from TopTools + +is + + Create returns mutable SphereSpaceModifier from BlockFix; + + SetTolerance(me: mutable; Toler: Real); + ---Purpose: Sets the tolerance for recognition of geometry + + NewSurface(me: mutable; F : Face from TopoDS; + S : out Surface from Geom; + L : out Location from TopLoc; + Tol: out Real from Standard; + RevWires : out Boolean from Standard; + RevFace : out Boolean from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the face has been + -- modified. In this case, is the new geometric + -- support of the face, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , are not + -- significant. + + NewCurve(me: mutable; E : Edge from TopoDS; + C : out Curve from Geom; + L : out Location from TopLoc; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the edge has been + -- modified. In this case, is the new geometric + -- support of the edge, the new location, + -- the new tolerance. Otherwise, returns + -- Standard_False, and , , are not + -- significant. + + NewPoint(me: mutable; V : Vertex from TopoDS; + P : out Pnt from gp; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the vertex has been + -- modified. In this case,

is the new geometric + -- support of the vertex, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- are not significant. + + NewCurve2d(me: mutable; E : Edge from TopoDS; + F : Face from TopoDS; + NewE : Edge from TopoDS; + NewF : Face from TopoDS; + C : out Curve from Geom2d; + Tol : out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the edge has a new + -- curve on surface on the face .In this case, + -- is the new geometric support of the edge, the + -- new location, the new tolerance. + -- + -- Otherwise, returns Standard_False, and , , + -- are not significant. + -- + -- is the new edge created from . + -- is the new face created from . They may be usefull. + + NewParameter(me: mutable; V : Vertex from TopoDS; + E : Edge from TopoDS; + P : out Real from Standard; + Tol: out Real from Standard) + returns Boolean from Standard; + ---Purpose: Returns Standard_True if the Vertex has a new + -- parameter on the edge . In this case,

is + -- the parameter, the new tolerance. + -- Otherwise, returns Standard_False, and

, + -- are not significant. + + Continuity(me: mutable; E : Edge from TopoDS; + F1,F2 : Face from TopoDS; + NewE : Edge from TopoDS; + NewF1,NewF2: Face from TopoDS) + returns Shape from GeomAbs; + ---Purpose: Returns the continuity of between + -- and . + -- + -- is the new edge created from . + -- (resp. ) is the new face created from + -- (resp. ). + + ForRotation(me: mutable; F: Face from TopoDS) returns Boolean; + +fields + + myTolerance : Real; + myMapOfFaces : DataMapOfShapeInteger from TopTools; + myMapOfSpheres: IndexedMapOfTransient from TColStd; + --myMapOfGeom: MapOfShapeTransient from TColStd; + +end SphereSpaceModifier; + diff --git a/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cxx b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cxx new file mode 100644 index 000000000..570e3921f --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.cxx @@ -0,0 +1,262 @@ +// 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: BlockFix.cxx +// Created: Tue Dec 7 11:59:05 2004 +// Author: Pavel DURANDIN + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : BlockFix_SphereSpaceModifier +//purpose : +//======================================================================= + +BlockFix_SphereSpaceModifier::BlockFix_SphereSpaceModifier() +{ + myMapOfFaces.Clear(); + myMapOfSpheres.Clear(); +} + +//======================================================================= +//function : SetTolerance +//purpose : +//======================================================================= + +void BlockFix_SphereSpaceModifier::SetTolerance(const Standard_Real Tol) +{ + myTolerance = Tol; +} + + +//======================================================================= +//function : NewSurface +//purpose : +//======================================================================= + + +static Standard_Boolean ModifySurface(const TopoDS_Face& aFace, + const Handle(Geom_Surface)& aSurface, + Handle(Geom_Surface)& aNewSurface) +{ + Handle(Geom_Surface) S = aSurface; + if(S->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) RTS = + Handle(Geom_RectangularTrimmedSurface)::DownCast(S); + S = RTS->BasisSurface(); + } + + if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { + Standard_Real Umin, Umax, Vmin, Vmax; + ShapeAnalysis::GetFaceUVBounds(aFace,Umin, Umax, Vmin, Vmax); + Standard_Real PI2 = M_PI/2.; + if(Vmax > PI2 - Precision::PConfusion() || Vmin < -PI2+::Precision::PConfusion()) { + Handle(Geom_SphericalSurface) aSphere = Handle(Geom_SphericalSurface)::DownCast(S); + gp_Sphere sp = aSphere->Sphere(); + gp_Ax3 ax3 = sp.Position(); + if(Abs(Vmax-Vmin) < PI2) { + gp_Ax3 axnew3(ax3.Axis().Location(), ax3.Direction()^ax3.XDirection(),ax3.XDirection()); + sp.SetPosition(axnew3); + Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp); + aNewSurface = aNewSphere; + return Standard_True; + } + else { + gp_Pnt PC = ax3.Location(); + Standard_Real Vpar; + if(fabs(PI2-Vmax)>fabs(-PI2-Vmin)) + Vpar = (PI2+Vmax)/2.; + else + Vpar = (-PI2+Vmin)/2.; + Standard_Real Upar = (Umin+Umax)/2.;; + gp_Pnt PN,PX; + S->D0(Upar,Vpar,PN); + S->D0(Upar+PI2,0.,PX); + gp_Dir newNorm(gp_Vec(PC,PN)); + gp_Dir newDirX(gp_Vec(PC,PX)); + gp_Ax3 axnew3(ax3.Axis().Location(), newNorm, newDirX); + sp.SetPosition(axnew3); + Handle(Geom_SphericalSurface) aNewSphere = new Geom_SphericalSurface(sp); + aNewSurface = aNewSphere; + return Standard_True; + } + } + } + return Standard_False; +} + + +Standard_Boolean BlockFix_SphereSpaceModifier::NewSurface(const TopoDS_Face& F, + Handle(Geom_Surface)& S, + TopLoc_Location& L,Standard_Real& Tol, + Standard_Boolean& RevWires, + Standard_Boolean& RevFace) +{ + TopLoc_Location LS; + Handle(Geom_Surface) SIni = BRep_Tool::Surface(F, LS); + + //check if pole of the sphere in the parametric space + if(ModifySurface(F, SIni, S)) { + + RevWires = Standard_False; + RevFace = Standard_False; + + L = LS; + Tol = BRep_Tool::Tolerance(F); + + Standard_Integer anIndex = myMapOfSpheres.Add(S); + myMapOfFaces.Bind(F,anIndex); + return Standard_True; + } + + return Standard_False; +} + +//======================================================================= +//function : NewCurve +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve(const TopoDS_Edge& /*E*/,Handle(Geom_Curve)& /*C*/, + TopLoc_Location& /*L*/,Standard_Real& /*Tol*/) +{ + return Standard_False; +} + +//======================================================================= +//function : NewPoint +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_SphereSpaceModifier::NewPoint(const TopoDS_Vertex& /*V*/, + gp_Pnt& /*P*/, + Standard_Real& /*Tol*/) +{ + return Standard_False; +} + +//======================================================================= +//function : NewCurve2d +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_SphereSpaceModifier::NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F, + const TopoDS_Edge& /*NewE*/,const TopoDS_Face& /*NewF*/, + Handle(Geom2d_Curve)& C,Standard_Real& Tol) +{ + //check if undelying surface of the face was modified + if(myMapOfFaces.IsBound(F)) { + Standard_Integer anIndex = myMapOfFaces.Find(F); + + Handle(Geom_Surface) aNewSphere = Handle(Geom_Surface)::DownCast(myMapOfSpheres.FindKey(anIndex)); + + Standard_Real f,l; + TopLoc_Location LC, LS; + Handle(Geom_Curve) C3d = BRep_Tool::Curve ( E, LC, f, l ); + Handle(Geom_Surface) S = BRep_Tool::Surface(F, LS); + + //taking into accound the orientation of the seam + C = BRep_Tool::CurveOnSurface(E,F,f,l); + Tol = BRep_Tool::Tolerance(E); + + BRep_Builder B; + TopoDS_Edge TempE; + B.MakeEdge(TempE); + B.Add(TempE, TopExp::FirstVertex(E)); + B.Add(TempE, TopExp::LastVertex(E)); + + if(!C3d.IsNull()) + B.UpdateEdge(TempE, Handle(Geom_Curve)::DownCast(C3d->Transformed(LC.Transformation())), Precision::Confusion()); + B.Range(TempE, f, l); + + Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge; + Handle(Geom_Surface) STemp = Handle(Geom_Surface)::DownCast(aNewSphere->Transformed(LS.Transformation())); + TopLoc_Location LTemp; + LTemp.Identity(); + + Standard_Boolean isClosed = BRep_Tool::IsClosed (E, F); + Standard_Real aWorkTol = 2*myTolerance+Tol; + sfe->FixAddPCurve(TempE, STemp, LTemp, isClosed, Max(Precision::Confusion(), aWorkTol)); + sfe->FixSameParameter(TempE); + + //keep the orientation of original edge + TempE.Orientation(E.Orientation()); + C = BRep_Tool::CurveOnSurface(TempE, STemp, LTemp, f, l); + + // shifting seam of sphere + if(isClosed && !C.IsNull()) { + Standard_Real f2,l2; + Handle(Geom2d_Curve) c22 = + BRep_Tool::CurveOnSurface(TopoDS::Edge(TempE.Reversed()),STemp, LTemp,f2,l2); + Standard_Real dPreci = Precision::PConfusion()*Precision::PConfusion(); + if((C->Value(f).SquareDistance(c22->Value(f2)) < dPreci) + ||(C->Value(l).SquareDistance(c22->Value(l2)) < dPreci)) { + gp_Vec2d shift(S->UPeriod(),0.); + C->Translate(shift); + } + } + //sphere was modified + return Standard_True; + } + + return Standard_False; +} + + +//======================================================================= +//function : NewParameter +//purpose : +//======================================================================= + +Standard_Boolean BlockFix_SphereSpaceModifier::NewParameter(const TopoDS_Vertex& /*V*/,const TopoDS_Edge& /*E*/, + Standard_Real& /*P*/,Standard_Real& /*Tol*/) +{ + return Standard_False; +} + + +//======================================================================= +//function : Continuity +//purpose : +//======================================================================= + +GeomAbs_Shape BlockFix_SphereSpaceModifier::Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1, + const TopoDS_Face& F2,const TopoDS_Edge& /*NewE*/, + const TopoDS_Face& /*NewF1*/,const TopoDS_Face& /*NewF2*/) +{ + return BRep_Tool::Continuity(E,F1,F2); +} diff --git a/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.hxx new file mode 100644 index 000000000..bd9871e0a --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.hxx @@ -0,0 +1,141 @@ +// 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 _BlockFix_SphereSpaceModifier_HeaderFile +#define _BlockFix_SphereSpaceModifier_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile +#include +#endif + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile +#include +#endif +#ifndef _TColStd_IndexedMapOfTransient_HeaderFile +#include +#endif +#ifndef _BRepTools_Modification_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Surface_HeaderFile +#include +#endif +#ifndef _Handle_Geom_Curve_HeaderFile +#include +#endif +#ifndef _Handle_Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _GeomAbs_Shape_HeaderFile +#include +#endif +class TopoDS_Face; +class Geom_Surface; +class TopLoc_Location; +class TopoDS_Edge; +class Geom_Curve; +class TopoDS_Vertex; +class gp_Pnt; +class Geom2d_Curve; + + +class BlockFix_SphereSpaceModifier : public BRepTools_Modification { + +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); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_SphereSpaceModifier(); +Standard_EXPORT void SetTolerance(const Standard_Real Toler) ; +Standard_EXPORT Standard_Boolean NewSurface(const TopoDS_Face& F,Handle(Geom_Surface)& S,TopLoc_Location& L,Standard_Real& Tol,Standard_Boolean& RevWires,Standard_Boolean& RevFace) ; +Standard_EXPORT Standard_Boolean NewCurve(const TopoDS_Edge& E,Handle(Geom_Curve)& C,TopLoc_Location& L,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewPoint(const TopoDS_Vertex& V,gp_Pnt& P,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewCurve2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& NewE,const TopoDS_Face& NewF,Handle(Geom2d_Curve)& C,Standard_Real& Tol) ; +Standard_EXPORT Standard_Boolean NewParameter(const TopoDS_Vertex& V,const TopoDS_Edge& E,Standard_Real& P,Standard_Real& Tol) ; +Standard_EXPORT GeomAbs_Shape Continuity(const TopoDS_Edge& E,const TopoDS_Face& F1,const TopoDS_Face& F2,const TopoDS_Edge& NewE,const TopoDS_Face& NewF1,const TopoDS_Face& NewF2) ; +Standard_EXPORT Standard_Boolean ForRotation(const TopoDS_Face& F) ; +Standard_EXPORT ~BlockFix_SphereSpaceModifier(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myTolerance; +TopTools_DataMapOfShapeInteger myMapOfFaces; +TColStd_IndexedMapOfTransient myMapOfSpheres; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.ixx b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.ixx new file mode 100644 index 000000000..f756d7280 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.ixx @@ -0,0 +1,79 @@ +// 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 + +BlockFix_SphereSpaceModifier::~BlockFix_SphereSpaceModifier() {} + + + +Standard_EXPORT Handle_Standard_Type& BlockFix_SphereSpaceModifier_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(BRepTools_Modification); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(BRepTools_Modification); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("BlockFix_SphereSpaceModifier", + sizeof(BlockFix_SphereSpaceModifier), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(BlockFix_SphereSpaceModifier) Handle(BlockFix_SphereSpaceModifier)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(BlockFix_SphereSpaceModifier) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(BlockFix_SphereSpaceModifier))) { + _anOtherObject = Handle(BlockFix_SphereSpaceModifier)((Handle(BlockFix_SphereSpaceModifier)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& BlockFix_SphereSpaceModifier::DynamicType() const +{ + return STANDARD_TYPE(BlockFix_SphereSpaceModifier) ; +} +Standard_Boolean BlockFix_SphereSpaceModifier::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(BlockFix_SphereSpaceModifier) == AType || BRepTools_Modification::IsKind(AType)); +} +Handle_BlockFix_SphereSpaceModifier::~Handle_BlockFix_SphereSpaceModifier() {} + diff --git a/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.jxx b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.jxx new file mode 100644 index 000000000..413af0805 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_SphereSpaceModifier.jxx @@ -0,0 +1,49 @@ +// 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 _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _Geom_Surface_HeaderFile +#include +#endif +#ifndef _TopLoc_Location_HeaderFile +#include +#endif +#ifndef _TopoDS_Edge_HeaderFile +#include +#endif +#ifndef _Geom_Curve_HeaderFile +#include +#endif +#ifndef _TopoDS_Vertex_HeaderFile +#include +#endif +#ifndef _gp_Pnt_HeaderFile +#include +#endif +#ifndef _Geom2d_Curve_HeaderFile +#include +#endif +#ifndef _BlockFix_SphereSpaceModifier_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionEdges.cdl b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.cdl new file mode 100644 index 000000000..6e9d3bcc1 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.cdl @@ -0,0 +1,49 @@ +-- 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: BlockFix_UnionEdges.cdl +-- Created: Tue Dec 7 15:24:51 2004 +-- Author: Sergey KUUL +-- +class UnionEdges from BlockFix + + ---Purpose: + +uses + + Shape from TopoDS, + ReShape from ShapeBuild + +is + + Create returns UnionEdges from BlockFix; + + Perform(me: in out; Shape: Shape from TopoDS; + Tol : Real) + returns Shape from TopoDS; + +fields + + myTolerance : Real; + myContext : ReShape from ShapeBuild; + +end UnionEdges; diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionEdges.cxx b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.cxx new file mode 100644 index 000000000..68bc3a92a --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.cxx @@ -0,0 +1,398 @@ +// 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: BlockFix_UnionEdges.cxx +// Created: 07.12.04 15:27:30 +// Author: Sergey KUUL + +#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 +#include +#include +#include + +#include "utilities.h" + +//======================================================================= +//function : BlockFix_UnionEdges() +//purpose : Constructor +//======================================================================= + +BlockFix_UnionEdges::BlockFix_UnionEdges ( ) +{ +} + + +//======================================================================= +//function : MergeEdges +//purpose : auxilary +//======================================================================= +static Standard_Boolean MergeEdges(const TopTools_SequenceOfShape& SeqEdges, + const TopoDS_Face& aFace, + const Standard_Real Tol, + TopoDS_Edge& anEdge) +{ + // make chain for union + BRep_Builder B; + ShapeAnalysis_Edge sae; + TopoDS_Edge FirstE = TopoDS::Edge(SeqEdges.Value(1)); + TopoDS_Edge LastE = FirstE; + TopoDS_Vertex VF = sae.FirstVertex(FirstE); + TopoDS_Vertex VL = sae.LastVertex(LastE); + TopTools_SequenceOfShape aChain; + aChain.Append(FirstE); + TColStd_MapOfInteger IndUsedEdges; + IndUsedEdges.Add(1); + Standard_Integer j; + for(j=2; j<=SeqEdges.Length(); j++) { + for(Standard_Integer k=2; k<=SeqEdges.Length(); k++) { + if(IndUsedEdges.Contains(k)) continue; + TopoDS_Edge edge = TopoDS::Edge(SeqEdges.Value(k)); + TopoDS_Vertex VF2 = sae.FirstVertex(edge); + TopoDS_Vertex VL2 = sae.LastVertex(edge); + if(sae.FirstVertex(edge).IsSame(VL)) { + aChain.Append(edge); + LastE = edge; + VL = sae.LastVertex(LastE); + IndUsedEdges.Add(k); + } + else if(sae.LastVertex(edge).IsSame(VF)) { + aChain.Prepend(edge); + FirstE = edge; + VF = sae.FirstVertex(FirstE); + IndUsedEdges.Add(k); + } + } + } + if(aChain.Length()IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d1); + c3d1 = tc->BasisCurve(); + } + TopoDS_Edge edge2 = TopoDS::Edge(aChain.Value(j+1)); + Handle(Geom_Curve) c3d2 = BRep_Tool::Curve(edge2,Loc,fp2,lp2); + if(c3d2.IsNull()) break; + while(c3d2->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d2); + c3d2 = tc->BasisCurve(); + } + if( c3d1->IsKind(STANDARD_TYPE(Geom_Line)) && c3d2->IsKind(STANDARD_TYPE(Geom_Line)) ) { + // union lines + Handle(Geom_Line) L1 = Handle(Geom_Line)::DownCast(c3d1); + Handle(Geom_Line) L2 = Handle(Geom_Line)::DownCast(c3d2); + gp_Dir Dir1 = L1->Position().Direction(); + gp_Dir Dir2 = L2->Position().Direction(); + //if(!Dir1.IsEqual(Dir2,Precision::Angular())) { + //if(!Dir1.IsParallel(Dir2,Precision::Angular())) { + if(!Dir1.IsParallel(Dir2,Tol)) { + continue; + } + // can union lines => create new edge + TopoDS_Vertex V1 = sae.FirstVertex(edge1); + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + TopoDS_Vertex V2 = sae.LastVertex(edge2); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + gp_Vec Vec(PV1,PV2); + Handle(Geom_Line) L = new Geom_Line(gp_Ax1(PV1,Vec)); + Standard_Real dist = PV1.Distance(PV2); + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(L,0.0,dist); + TopoDS_Edge E; + B.MakeEdge (E,tc,Precision::Confusion()); + B.Add (E,V1); B.Add (E,V2); + B.UpdateVertex(V1, 0., E, 0.); + B.UpdateVertex(V2, dist, E, 0.); + //ShapeFix_Edge sfe; + //sfe.FixAddPCurve(E,aFace,Standard_False); + //sfe.FixSameParameter(E); + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + if( c3d1->IsKind(STANDARD_TYPE(Geom_Circle)) && c3d2->IsKind(STANDARD_TYPE(Geom_Circle)) ) { + // union circles + Handle(Geom_Circle) C1 = Handle(Geom_Circle)::DownCast(c3d1); + Handle(Geom_Circle) C2 = Handle(Geom_Circle)::DownCast(c3d2); + gp_Pnt P01 = C1->Location(); + gp_Pnt P02 = C2->Location(); + if (P01.Distance(P02) > Precision::Confusion()) continue; + // can union circles => create new edge + TopoDS_Vertex V1 = sae.FirstVertex(edge1); + gp_Pnt PV1 = BRep_Tool::Pnt(V1); + TopoDS_Vertex V2 = sae.LastVertex(edge2); + gp_Pnt PV2 = BRep_Tool::Pnt(V2); + TopoDS_Vertex VM = sae.LastVertex(edge1); + gp_Pnt PVM = BRep_Tool::Pnt(VM); + GC_MakeCircle MC (PV1,PVM,PV2); + Handle(Geom_Circle) C = MC.Value(); + TopoDS_Edge E; + if (!MC.IsDone() || C.IsNull()) { + // jfa for Mantis issue 0020228 + if (PV1.Distance(PV2) > Precision::Confusion()) continue; + // closed chain + C = C1; + B.MakeEdge (E,C,Precision::Confusion()); + B.Add(E,V1); + B.Add(E,V2); + } + else { + gp_Pnt P0 = C->Location(); + gp_Dir D1(gp_Vec(P0,PV1)); + gp_Dir D2(gp_Vec(P0,PV2)); + Standard_Real fpar = C->XAxis().Direction().Angle(D1); + if(fabs(fpar)>Precision::Confusion()) { + // check orientation + gp_Dir ND = C->XAxis().Direction().Crossed(D1); + if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { + fpar = -fpar; + } + } + Standard_Real lpar = C->XAxis().Direction().Angle(D2); + if(fabs(lpar)>Precision::Confusion()) { + // check orientation + gp_Dir ND = C->XAxis().Direction().Crossed(D2); + if(ND.IsOpposite(C->Axis().Direction(),Precision::Confusion())) { + lpar = -lpar; + } + } + if (lpar < fpar) lpar += 2*M_PI; + Handle(Geom_TrimmedCurve) tc = new Geom_TrimmedCurve(C,fpar,lpar); + B.MakeEdge (E,tc,Precision::Confusion()); + B.Add(E,V1); + B.Add(E,V2); + B.UpdateVertex(V1, fpar, E, 0.); + B.UpdateVertex(V2, lpar, E, 0.); + } + aChain.Remove(j); + aChain.SetValue(j,E); + j--; + } + } + if (j < aChain.Length()) { + MESSAGE ("null curve3d in edge..."); + return Standard_False; + } + if (aChain.Length() > 1) { + // second step: union edges with various curves + // skl for bug 0020052 from Mantis: perform such unions + // only if curves are bspline or bezier + bool NeedUnion = true; + for(j=1; j<=aChain.Length(); j++) { + TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); + Handle(Geom_Curve) c3d = BRep_Tool::Curve(edge,Loc,fp1,lp1); + if(c3d.IsNull()) continue; + while(c3d->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) { + Handle(Geom_TrimmedCurve) tc = + Handle(Geom_TrimmedCurve)::DownCast(c3d); + c3d = tc->BasisCurve(); + } + if( ( c3d->IsKind(STANDARD_TYPE(Geom_BSplineCurve)) || + c3d->IsKind(STANDARD_TYPE(Geom_BezierCurve)) ) ) continue; + NeedUnion = false; + break; + } + if(NeedUnion) { + MESSAGE ("can not make analitical union => make approximation"); + TopoDS_Wire W; + B.MakeWire(W); + for(j=1; j<=aChain.Length(); j++) { + TopoDS_Edge edge = TopoDS::Edge(aChain.Value(j)); + B.Add(W,edge); + } + Handle(BRepAdaptor_HCompCurve) Adapt = new BRepAdaptor_HCompCurve(W); + Approx_Curve3d Conv(Adapt,Tol,GeomAbs_C1,9,1000); + Handle(Geom_BSplineCurve) bc = Conv.Curve(); + TopoDS_Edge E; + B.MakeEdge (E,bc,Precision::Confusion()); + B.Add (E,VF); + B.Add (E,VL); + aChain.SetValue(1,E); + } + else { + MESSAGE ("can not make approximation for such types of curves"); + return Standard_False; + } + } + + anEdge = TopoDS::Edge(aChain.Value(1)); + return Standard_True; +} + + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix_UnionEdges::Perform(const TopoDS_Shape& Shape, + const Standard_Real Tol) +{ + myContext = new ShapeBuild_ReShape; + myTolerance = Tol; + TopoDS_Shape aResult = myContext->Apply(Shape); + + // processing each solid + TopAbs_ShapeEnum aType = TopAbs_SOLID; + TopExp_Explorer exps (Shape, aType); + if (!exps.More()) { + aType = TopAbs_SHELL; + exps.Init(Shape, aType); + } + for (; exps.More(); exps.Next()) { + //TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + TopoDS_Shape aSolid = exps.Current(); + + TopTools_IndexedMapOfShape ChangedFaces; + + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + TopoDS_Shape aRes = aSolid; + aRes = aContext->Apply(aSolid); + + // processing each face + TopExp_Explorer exp; + for (exp.Init(aRes, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = + TopoDS::Face(aContext->Apply(exp.Current().Oriented(TopAbs_FORWARD))); + TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges; + + for (TopExp_Explorer expe(aFace,TopAbs_EDGE); expe.More(); expe.Next()) { + TopoDS_Edge edge = TopoDS::Edge(expe.Current()); + if (!aMapEdgeFaces.Contains(edge)) continue; + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for ( ; anIter.More(); anIter.Next()) { + TopoDS_Face face = TopoDS::Face(anIter.Value()); + TopoDS_Face face1 = TopoDS::Face(aContext->Apply(anIter.Value())); + if (face1.IsSame(aFace)) continue; + if (aMapFacesEdges.Contains(face)) { + aMapFacesEdges.ChangeFromKey(face).Append(edge); + } + else { + TopTools_ListOfShape ListEdges; + ListEdges.Append(edge); + aMapFacesEdges.Add(face,ListEdges); + } + } + } + + for (Standard_Integer i=1; i<=aMapFacesEdges.Extent(); i++) { + const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i); + TopTools_SequenceOfShape SeqEdges; + TopTools_ListIteratorOfListOfShape anIter(ListEdges); + for ( ; anIter.More(); anIter.Next()) { + SeqEdges.Append(anIter.Value()); + } + if (SeqEdges.Length()==1) continue; + TopoDS_Edge E; + if ( MergeEdges(SeqEdges,aFace,Tol,E) ) { + // now we have only one edge - aChain.Value(1) + // we have to replace old ListEdges with this new edge + aContext->Replace(SeqEdges(1),E); + for (Standard_Integer j=2; j<=SeqEdges.Length(); j++) { + aContext->Remove(SeqEdges(j)); + } + TopoDS_Face tmpF = TopoDS::Face(exp.Current()); + if ( !ChangedFaces.Contains(tmpF) ) + ChangedFaces.Add(tmpF); + tmpF = TopoDS::Face(aMapFacesEdges.FindKey(i)); + if ( !ChangedFaces.Contains(tmpF) ) + ChangedFaces.Add(tmpF); + } + } + + } // end processing each face + + // fix changed faces and replace them in the local context + for (Standard_Integer i=1; i<=ChangedFaces.Extent(); i++) { + TopoDS_Face aFace = TopoDS::Face(aContext->Apply(ChangedFaces.FindKey(i))); + Handle(ShapeFix_Face) sff = new ShapeFix_Face(aFace); + sff->SetContext(myContext); + sff->SetPrecision(myTolerance); + sff->SetMinTolerance(myTolerance); + sff->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sff->Perform(); + aContext->Replace(aFace,sff->Face()); + } + + if (ChangedFaces.Extent() > 0) { + // fix changed shell and replace it in the local context + TopoDS_Shape aRes1 = aContext->Apply(aRes); + TopExp_Explorer expsh; + for (expsh.Init(aRes1, TopAbs_SHELL); expsh.More(); expsh.Next()) { + TopoDS_Shell aShell = TopoDS::Shell(expsh.Current()); + Handle(ShapeFix_Shell) sfsh = new ShapeFix_Shell; + sfsh->FixFaceOrientation(aShell); + aContext->Replace(aShell,sfsh->Shell()); + } + TopoDS_Shape aRes2 = aContext->Apply(aRes1); + // put new solid into global context + myContext->Replace(aSolid,aRes2); + } + + } // end processing each solid + + aResult = myContext->Apply(Shape); + return aResult; +} diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionEdges.hxx b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.hxx new file mode 100644 index 000000000..07909ce7c --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.hxx @@ -0,0 +1,100 @@ +// 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 _BlockFix_UnionEdges_HeaderFile +#define _BlockFix_UnionEdges_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Handle_ShapeBuild_ReShape_HeaderFile +#include +#endif +class ShapeBuild_ReShape; +class TopoDS_Shape; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class BlockFix_UnionEdges { + +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); + } + // Methods PUBLIC + // +Standard_EXPORT BlockFix_UnionEdges(); +Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape,const Standard_Real Tol) ; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myTolerance; +Handle_ShapeBuild_ReShape myContext; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionEdges.ixx b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.ixx new file mode 100644 index 000000000..63a34541d --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.ixx @@ -0,0 +1,27 @@ +// 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 + + + + diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionEdges.jxx b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.jxx new file mode 100644 index 000000000..c6cf527cb --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionEdges.jxx @@ -0,0 +1,31 @@ +// 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 _ShapeBuild_ReShape_HeaderFile +#include +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _BlockFix_UnionEdges_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionFaces.cdl b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.cdl new file mode 100644 index 000000000..b566b8228 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.cdl @@ -0,0 +1,65 @@ +-- 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: BlockFix_UnionFaces.cdl +-- Created: Tue Dec 7 17:15:42 2004 +-- Author: Pavel Durandin +-- +class UnionFaces from BlockFix + +uses + + Face from TopoDS, + Shape from TopoDS + +is + + Create returns UnionFaces from BlockFix; + ---Purpose: Empty constructor + + GetTolerance(me: in out) returns Real; + ---Purpose: Returns modifiable tolerance + ---C++: return& + + Perform (me: in out; Shape: Shape from TopoDS) returns Shape from TopoDS; + ---Purpose: Performs the unification of the fsces + -- whith the same geometry + + IsSameDomain(me; aFace : Face from TopoDS; + aChekedFace: Face from TopoDS) + returns Boolean is virtual; + ---Purpose: Returns true is surfaces have same geometrically domain + -- with given tolerance + + MovePCurves(me; aTarget: in out Face from TopoDS; + aSource: Face from TopoDS) + is virtual; + ---Purpose: Creates pcurves on aTarget face for each edge from + -- aSource one. + +fields + + myTolerance: Real; + +end; + + diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionFaces.cxx b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.cxx new file mode 100644 index 000000000..e2f9f32fd --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.cxx @@ -0,0 +1,721 @@ +// 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: BlockFix_UnionFaces.cxx +// Created: Tue Dec 7 17:15:42 2004 +// Author: Pavel DURANDIN + +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 +#include +#else +#include +#endif + +#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 +#include +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC + +//======================================================================= +//function : BlockFix_UnionFaces +//purpose : +//======================================================================= + +BlockFix_UnionFaces::BlockFix_UnionFaces() + : myTolerance(Precision::Confusion()), + myOptimumNbFaces(6) +{ +} + + +//======================================================================= +//function : GetTolerance +//purpose : +//======================================================================= + +Standard_Real& BlockFix_UnionFaces::GetTolerance() +{ + return myTolerance; +} + + +//======================================================================= +//function : GetOptimumNbFaces +//purpose : +//======================================================================= + +Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces() +{ + return myOptimumNbFaces; +} + + +//======================================================================= +//function : AddOrdinaryEdges +//purpose : auxilary +//======================================================================= +// adds edges from the shape to the sequence +// seams and equal edges are dropped +// Returns true if one of original edges dropped +static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges, + const TopoDS_Shape aShape, + Standard_Integer& anIndex) +{ + //map of edges + TopTools_MapOfShape aNewEdges; + //add edges without seams + for(TopExp_Explorer exp(aShape,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Shape edge = exp.Current(); + if(aNewEdges.Contains(edge)) + aNewEdges.Remove(edge); + else + aNewEdges.Add(edge); + } + + Standard_Boolean isDropped = Standard_False; + //merge edges and drop seams + for(Standard_Integer i = 1; i <= edges.Length(); i++) { + TopoDS_Shape current = edges(i); + if(aNewEdges.Contains(current)) { + + aNewEdges.Remove(current); + edges.Remove(i); + i--; + + if(!isDropped) { + isDropped = Standard_True; + anIndex = i; + } + } + } + + //add edges to the sequemce + for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next()) + edges.Append(anIter.Key()); + + return isDropped; +} + + +//======================================================================= +//function : ClearRts +//purpose : auxilary +//======================================================================= +static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface) +{ + if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { + Handle(Geom_RectangularTrimmedSurface) rts = + Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); + return rts->BasisSurface(); + } + return aSurface; +} + + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) +{ + Handle(ShapeBuild_ReShape) myContext = new ShapeBuild_ReShape; + TopoDS_Shape aResShape = myContext->Apply(Shape); + + // processing each solid + TopExp_Explorer exps; + for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) { + TopoDS_Solid aSolid = TopoDS::Solid(exps.Current()); + + // creating map of edge faces + TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces; + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces); + + // map of processed shapes + TopTools_MapOfShape aProcessed; + + Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape; + + Standard_Integer NbModif = 0; + Standard_Boolean hasFailed = Standard_False; + Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1); + + // count faces + int nbf = 0; + TopExp_Explorer exp; + TopTools_MapOfShape mapF; + for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + if (mapF.Add(exp.Current())) + nbf++; + } + + bool doUnion = ((myOptimumNbFaces == 0) || + ((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces))); + + // processing each face + mapF.Clear(); + for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + + if (aProcessed.Contains(aFace)) + continue; + + Standard_Integer dummy; + TopTools_SequenceOfShape edges; + AddOrdinaryEdges(edges,aFace,dummy); + + TopTools_SequenceOfShape faces; + faces.Append(aFace); + + //surface and location to construct result + TopLoc_Location aBaseLocation; + Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation); + aBaseSurface = ClearRts(aBaseSurface); + + // find adjacent faces to union + Standard_Integer i; + for (i = 1; i <= edges.Length(); i++) { + TopoDS_Edge edge = TopoDS::Edge(edges(i)); + if (BRep_Tool::Degenerated(edge)) + continue; + + const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); + TopTools_ListIteratorOfListOfShape anIter(aList); + for (; anIter.More(); anIter.Next()) { + TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD)); + if (anCheckedFace.IsSame(aFace)) + continue; + + if (aProcessed.Contains(anCheckedFace)) + continue; + + if (IsSameDomain(aFace,anCheckedFace)) { + + if (aList.Extent() != 2) { + // non mainfold case is not processed + continue; + } + + // replacing pcurves + TopoDS_Face aMockUpFace; + BRep_Builder B; + B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.); + MovePCurves(aMockUpFace,anCheckedFace); + + if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) { + // sequence edges is modified + i = dummy; + } + + faces.Append(anCheckedFace); + aProcessed.Add(anCheckedFace); + break; + } + } + } + + // all faces collected in the sequence. Perform union of faces + if (faces.Length() > 1) { + NbModif++; + TopoDS_Face aResult; + BRep_Builder B; + B.MakeFace(aResult,aBaseSurface,aBaseLocation,0); + Standard_Integer nbWires = 0; + + // connecting wires + while (edges.Length()>0) { + + Standard_Boolean isEdge3d = Standard_False; + nbWires++; + TopTools_MapOfShape aVertices; + TopoDS_Wire aWire; + B.MakeWire(aWire); + + TopoDS_Edge anEdge = TopoDS::Edge(edges(1)); + edges.Remove(1); + + isEdge3d |= !BRep_Tool::Degenerated(anEdge); + B.Add(aWire,anEdge); + TopoDS_Vertex V1,V2; + TopExp::Vertices(anEdge,V1,V2); + aVertices.Add(V1); + aVertices.Add(V2); + + Standard_Boolean isNewFound = Standard_False; + do { + isNewFound = Standard_False; + for(Standard_Integer j = 1; j <= edges.Length(); j++) { + anEdge = TopoDS::Edge(edges(j)); + TopExp::Vertices(anEdge,V1,V2); + if(aVertices.Contains(V1) || aVertices.Contains(V2)) { + isEdge3d |= !BRep_Tool::Degenerated(anEdge); + aVertices.Add(V1); + aVertices.Add(V2); + B.Add(aWire,anEdge); + edges.Remove(j); + j--; + isNewFound = Standard_True; + } + } + } while (isNewFound); + + // sorting any type of edges + aWire = TopoDS::Wire(aContext->Apply(aWire)); + + TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); + sfw->FixReorder(); + Standard_Boolean isDegRemoved = Standard_False; + if(!sfw->StatusReorder ( ShapeExtend_FAIL )) { + // clear degenerated edges if at least one with 3d curve exist + if(isEdge3d) { + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + for(Standard_Integer j = 1; j<=sewd->NbEdges();j++) { + TopoDS_Edge E = sewd->Edge(j); + if(BRep_Tool::Degenerated(E)) { + sewd->Remove(j); + isDegRemoved = Standard_True; + j--; + } + } + } + sfw->FixShifted(); + if(isDegRemoved) + sfw->FixDegenerated(); + } + TopoDS_Wire aWireFixed = sfw->Wire(); + aContext->Replace(aWire,aWireFixed); + // add resulting wire + if(isEdge3d) { + B.Add(aResult,aWireFixed); + } + else { + // sorting edges + Handle(ShapeExtend_WireData) sbwd = sfw->WireData(); + Standard_Integer nbEdges = sbwd->NbEdges(); + // sort degenerated edges and create one edge instead of several ones + ShapeAnalysis_WireOrder sawo(Standard_False, 0); + ShapeAnalysis_Edge sae; + Standard_Integer aLastEdge = nbEdges; + for(Standard_Integer j = 1; j <= nbEdges; j++) { + Standard_Real f,l; + //smh protection on NULL pcurve + Handle(Geom2d_Curve) c2d; + if(!sae.PCurve(sbwd->Edge(j),tmpF,c2d,f,l)) { + aLastEdge--; + continue; + } + sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY()); + } + sawo.Perform(); + + // constructind one degenerative edge + gp_XY aStart, anEnd, tmp; + Standard_Integer nbFirst = sawo.Ordered(1); + TopoDS_Edge anOrigE = TopoDS::Edge(sbwd->Edge(nbFirst).Oriented(TopAbs_FORWARD)); + ShapeBuild_Edge sbe; + TopoDS_Vertex aDummyV; + TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV); + sawo.XY(nbFirst,aStart,tmp); + sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd); + + gp_XY aVec = anEnd-aStart; + Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart)); + + B.UpdateEdge(E,aLine,tmpF,0.); + B.Range(E,tmpF,0.,aVec.Modulus()); + Handle(Geom_Curve) C3d; + B.UpdateEdge(E,C3d,0.); + B.Degenerated(E,Standard_True); + TopoDS_Wire aW; + B.MakeWire(aW); + B.Add(aW,E); + B.Add(aResult,aW); + } + } + + // perform substitution of face + aContext->Replace(aContext->Apply(aFace),aResult); + + ShapeFix_Face sff (aResult); + //Intializing by tolerances + sff.SetPrecision(myTolerance); + sff.SetMinTolerance(tol); + sff.SetMaxTolerance(Max(1.,myTolerance*1000.)); + //Setting modes + sff.FixOrientationMode() = 0; + //sff.FixWireMode() = 0; + sff.SetContext(aContext); + // Applying the fixes + sff.Perform(); + if(sff.Status(ShapeExtend_FAIL)) + hasFailed = Standard_True; + + // breaking down to several faces + TopoDS_Shape theResult = aContext->Apply(aResult); + for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) { + TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD)); + Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 ); + grid->SetValue ( 1, 1, aBaseSurface ); + Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid ); + ShapeFix_ComposeShell CompShell; + CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision + CompShell.SetContext( aContext ); + + TopTools_SequenceOfShape parts; + ShapeFix_SequenceOfWireSegment wires; + for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) { + Handle(ShapeExtend_WireData) sbwd = + new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() )); + ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); + wires.Append(seg); + } + + CompShell.DispatchWires ( parts,wires ); + for (Standard_Integer j=1; j <= parts.Length(); j++ ) { + ShapeFix_Face aFixOrient(TopoDS::Face(parts(j))); + aFixOrient.SetContext(aContext); + aFixOrient.FixOrientation(); + } + + TopoDS_Shape CompRes; + if ( faces.Length() !=1 ) { + TopoDS_Shell S; + B.MakeShell ( S ); + for ( i=1; i <= parts.Length(); i++ ) + B.Add ( S, parts(i) ); + CompRes = S; + } + else CompRes = parts(1); + + aContext->Replace(aCurrent,CompRes); + } + + // remove the remaining faces + for(i = 2; i <= faces.Length(); i++) + aContext->Remove(faces(i)); + } + } // end processing each face + + //TopoDS_Shape aResult = Shape; + if (NbModif > 0 && !hasFailed) { + TopoDS_Shape aResult = aContext->Apply(aSolid); + + ShapeFix_Edge sfe; + for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + sfe.FixVertexTolerance (E); + // ptv add fix same parameter + sfe.FixSameParameter(E, myTolerance); + } + + myContext->Replace(aSolid, aResult); + } + //else + { + for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire; + sfw->SetContext(myContext); + sfw->SetPrecision(myTolerance); + sfw->SetMinTolerance(myTolerance); + sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); + sfw->SetFace(aFace); + for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) { + TopoDS_Wire wire = TopoDS::Wire(iter.Value()); + sfw->Load(wire); + sfw->FixReorder(); + sfw->FixShifted(); + } + } + } + } // end processing each solid + + aResShape = myContext->Apply(Shape); + return aResShape; +} + + +//======================================================================= +//function : IsSameDomain +//purpose : +//======================================================================= + +bool getCylinder (Handle(Geom_Surface)& theInSurface, gp_Cylinder& theOutCylinder) +{ + bool isCylinder = false; + + if (theInSurface->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) { + Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(theInSurface); + + theOutCylinder = aGC->Cylinder(); + isCylinder = true; + } + else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfRevolution))) { + Handle(Geom_SurfaceOfRevolution) aRS = + Handle(Geom_SurfaceOfRevolution)::DownCast(theInSurface); + Handle(Geom_Curve) aBasis = aRS->BasisCurve(); + if (aBasis->IsKind(STANDARD_TYPE(Geom_Line))) { + Handle(Geom_Line) aBasisLine = Handle(Geom_Line)::DownCast(aBasis); + gp_Dir aDir = aRS->Direction(); + gp_Dir aBasisDir = aBasisLine->Position().Direction(); + if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { + // basis line is parallel to the revolution axis: it is a cylinder + gp_Pnt aLoc = aRS->Location(); + Standard_Real aR = aBasisLine->Lin().Distance(aLoc); + gp_Ax3 aCylAx (aLoc, aDir); + + theOutCylinder = gp_Cylinder(aCylAx, aR); + isCylinder = true; + } + } + } + else if (theInSurface->IsKind(STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion))) { + Handle(Geom_SurfaceOfLinearExtrusion) aLES = + Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(theInSurface); + Handle(Geom_Curve) aBasis = aLES->BasisCurve(); + if (aBasis->IsKind(STANDARD_TYPE(Geom_Circle))) { + Handle(Geom_Circle) aBasisCircle = Handle(Geom_Circle)::DownCast(aBasis); + gp_Dir aDir = aLES->Direction(); + gp_Dir aBasisDir = aBasisCircle->Position().Direction(); + if (aBasisDir.IsParallel(aDir, Precision::Confusion())) { + // basis circle is normal to the extrusion axis: it is a cylinder + gp_Pnt aLoc = aBasisCircle->Location(); + Standard_Real aR = aBasisCircle->Radius(); + gp_Ax3 aCylAx (aLoc, aDir); + + theOutCylinder = gp_Cylinder(aCylAx, aR); + isCylinder = true; + } + } + } + else { + } + + return isCylinder; +} + +Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, + const TopoDS_Face& aCheckedFace) const +{ + //checking the same handles + TopLoc_Location L1, L2; + Handle(Geom_Surface) S1, S2; + + S1 = BRep_Tool::Surface(aFace,L1); + S2 = BRep_Tool::Surface(aCheckedFace,L2); + + if (S1 == S2 && L1 == L2) + return true; + + // planar and cylindrical cases (IMP 20052) + Standard_Real aPrec = Precision::Confusion(); + + S1 = BRep_Tool::Surface(aFace); + S2 = BRep_Tool::Surface(aCheckedFace); + + S1 = ClearRts(S1); + S2 = ClearRts(S2); + + //Handle(Geom_OffsetSurface) aGOFS1, aGOFS2; + //aGOFS1 = Handle(Geom_OffsetSurface)::DownCast(S1); + //aGOFS2 = Handle(Geom_OffsetSurface)::DownCast(S2); + //if (!aGOFS1.IsNull()) S1 = aGOFS1->BasisSurface(); + //if (!aGOFS2.IsNull()) S2 = aGOFS2->BasisSurface(); + + // case of two elementary surfaces: use OCCT tool + // elementary surfaces: ConicalSurface, CylindricalSurface, + // Plane, SphericalSurface and ToroidalSurface + if (S1->IsKind(STANDARD_TYPE(Geom_ElementarySurface)) && + S2->IsKind(STANDARD_TYPE(Geom_ElementarySurface))) + { + Handle(GeomAdaptor_HSurface) aGA1 = new GeomAdaptor_HSurface(S1); + Handle(GeomAdaptor_HSurface) aGA2 = new GeomAdaptor_HSurface(S2); + + Handle(BRepTopAdaptor_TopolTool) aTT1 = new BRepTopAdaptor_TopolTool(); + Handle(BRepTopAdaptor_TopolTool) aTT2 = new BRepTopAdaptor_TopolTool(); + + try { +#if OCC_VERSION_LARGE > 0x06010000 + OCC_CATCH_SIGNALS; +#endif + +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 + IntPatch_ImpImpIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); +#else + IntPatch_TheIIIntOfIntersection anIIInt (aGA1, aTT1, aGA2, aTT2, aPrec, aPrec); +#endif + if (!anIIInt.IsDone() || anIIInt.IsEmpty()) + return false; + + return anIIInt.TangentFaces(); + } + catch (Standard_Failure) { + return false; + } + } + + // case of two planar surfaces: + // all kinds of surfaces checked, including b-spline and bezier + GeomLib_IsPlanarSurface aPlanarityChecker1 (S1, aPrec); + if (aPlanarityChecker1.IsPlanar()) { + GeomLib_IsPlanarSurface aPlanarityChecker2 (S2, aPrec); + if (aPlanarityChecker2.IsPlanar()) { + gp_Pln aPln1 = aPlanarityChecker1.Plan(); + gp_Pln aPln2 = aPlanarityChecker2.Plan(); + + if (aPln1.Position().Direction().IsParallel(aPln2.Position().Direction(), aPrec) && + aPln1.Distance(aPln2) < aPrec) { + return true; + } + } + } + + // case of two cylindrical surfaces, at least one of which is a swept surface + // swept surfaces: SurfaceOfLinearExtrusion, SurfaceOfRevolution + if ((S1->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || + S1->IsKind(STANDARD_TYPE(Geom_SweptSurface))) && + (S2->IsKind(STANDARD_TYPE(Geom_CylindricalSurface)) || + S2->IsKind(STANDARD_TYPE(Geom_SweptSurface)))) + { + gp_Cylinder aCyl1, aCyl2; + if (getCylinder(S1, aCyl1) && getCylinder(S2, aCyl2)) { + if (fabs(aCyl1.Radius() - aCyl2.Radius()) < aPrec) { + gp_Dir aDir1 = aCyl1.Position().Direction(); + gp_Dir aDir2 = aCyl2.Position().Direction(); + if (aDir1.IsParallel(aDir2, aPrec)) { + gp_Pnt aLoc1 = aCyl1.Location(); + gp_Pnt aLoc2 = aCyl2.Location(); + gp_Vec aVec12 (aLoc1, aLoc2); + if (aVec12.SquareMagnitude() < aPrec*aPrec || + aVec12.IsParallel(aDir1, aPrec)) { + return true; + } + } + } + } + } + + return false; +} + + +//======================================================================= +//function : MovePCurves +//purpose : +//======================================================================= + +void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget, + const TopoDS_Face& aSource) const +{ + BRep_Builder B; + for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) { + Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()), + aTarget, Precision::Confusion()); + sfw->FixReorder(); + Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL ); + sfw->FixEdgeCurves(); + if(isReoredFailed) + continue; + + sfw->FixShifted(); + sfw->FixDegenerated(); + + // remove degenerated edges from not degenerated points + ShapeAnalysis_Edge sae; + Handle(ShapeExtend_WireData) sewd = sfw->WireData(); + for(Standard_Integer i = 1; i<=sewd->NbEdges();i++) { + TopoDS_Edge E = sewd->Edge(i); + if(BRep_Tool::Degenerated(E)&&!sae.HasPCurve(E,aTarget)) { + sewd->Remove(i); + i--; + } + } + + TopoDS_Wire ResWire = sfw->Wire(); + B.Add(aTarget,ResWire); + } +} diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionFaces.hxx b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.hxx new file mode 100644 index 000000000..62c50504b --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.hxx @@ -0,0 +1,90 @@ +// 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 _BlockFix_UnionFaces_HeaderFile +#define _BlockFix_UnionFaces_HeaderFile + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class TopoDS_Shape; +class TopoDS_Face; + +class BlockFix_UnionFaces +{ +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); + } + + // Methods PUBLIC + // + Standard_EXPORT BlockFix_UnionFaces(); + + Standard_EXPORT Standard_Real& GetTolerance(); + + /* \brief To get/set the OptimumNbFaces parameter + * + * If a being processed solid has less than OptimumNbFaces + * faces, no union will be performed. + * By default this parameter is set to 6 (to correctly + * process blocks - hexahedral solids) + * Special values: 0 - do all possible unions, regardless the faces quantity, + * negative - do not perform any unions, regardless the faces quantity. + * + */ + Standard_EXPORT Standard_Integer& GetOptimumNbFaces(); + + Standard_EXPORT TopoDS_Shape Perform(const TopoDS_Shape& Shape); + + Standard_EXPORT virtual Standard_Boolean IsSameDomain(const TopoDS_Face& aFace, + const TopoDS_Face& aChekedFace) const; + Standard_EXPORT virtual void MovePCurves(TopoDS_Face& aTarget, + const TopoDS_Face& aSource) const; + +private: + // Fields PRIVATE + // + Standard_Real myTolerance; + Standard_Integer myOptimumNbFaces; +}; + +#endif diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionFaces.ixx b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.ixx new file mode 100644 index 000000000..471f45326 --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.ixx @@ -0,0 +1,27 @@ +// 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 + + + + diff --git a/src/GEOMAlgo_NEW/BlockFix_UnionFaces.jxx b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.jxx new file mode 100644 index 000000000..ee5ff52ca --- /dev/null +++ b/src/GEOMAlgo_NEW/BlockFix_UnionFaces.jxx @@ -0,0 +1,31 @@ +// 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 _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _TopoDS_Face_HeaderFile +#include +#endif +#ifndef _BlockFix_UnionFaces_HeaderFile +#include +#endif diff --git a/src/GEOMAlgo_NEW/FILES b/src/GEOMAlgo_NEW/FILES new file mode 100644 index 000000000..44aeb0c17 --- /dev/null +++ b/src/GEOMAlgo_NEW/FILES @@ -0,0 +1,169 @@ +GEOMAlgo_Builder_0.cxx +GEOMAlgo_Builder_1.cxx +GEOMAlgo_Builder_2.cxx +GEOMAlgo_Builder_3.cxx +GEOMAlgo_Builder_4.cxx +GEOMAlgo_ShapeInfoFiller_1.cxx +GEOMAlgo_Tools_1.cxx + +GEOMAlgo_Gluer2.hxx +GEOMAlgo_Gluer2.cxx +GEOMAlgo_Gluer2_1.cxx +GEOMAlgo_Gluer2_2.cxx +GEOMAlgo_Gluer2_3.cxx + +GEOMAlgo_GluerAlgo.hxx +GEOMAlgo_GluerAlgo.cxx + +GEOMAlgo_GlueDetector.hxx +GEOMAlgo_GlueDetector.cxx + +GEOMAlgo_GetInPlace.hxx +GEOMAlgo_GetInPlace.cxx +GEOMAlgo_GetInPlace_1.cxx +GEOMAlgo_GetInPlace_2.cxx +GEOMAlgo_GetInPlace_3.cxx + +GEOMAlgo_FinderShapeOnQuad.hxx +GEOMAlgo_FinderShapeOnQuad.cxx + +GEOMAlgo_WireSplitter.hxx +GEOMAlgo_WireSplitter.cxx +GEOMAlgo_WESScaler.hxx +GEOMAlgo_WESScaler.cxx +GEOMAlgo_WESCorrector.hxx +GEOMAlgo_WESCorrector.cxx +GEOMAlgo_WireEdgeSet.hxx +GEOMAlgo_WireEdgeSet.cxx +GEOMAlgo_GlueAnalyser.hxx +GEOMAlgo_GlueAnalyser.cxx +GEOMAlgo_Gluer.hxx +GEOMAlgo_Gluer.cxx +GEOMAlgo_FinderShapeOn2.hxx +GEOMAlgo_FinderShapeOn2.cxx +GEOMAlgo_FinderShapeOn1.hxx +GEOMAlgo_FinderShapeOn1.cxx +GEOMAlgo_FinderShapeOn.hxx +GEOMAlgo_FinderShapeOn.cxx +GEOMAlgo_ShapeAlgo.hxx +GEOMAlgo_ShapeAlgo.cxx +GEOMAlgo_SolidSolid.hxx +GEOMAlgo_SolidSolid.cxx +GEOMAlgo_ShellSolid.hxx +GEOMAlgo_ShellSolid.cxx +GEOMAlgo_VertexSolid.hxx +GEOMAlgo_VertexSolid.cxx +GEOMAlgo_WireSolid.hxx +GEOMAlgo_WireSolid.cxx +GEOMAlgo_ShapeSolid.hxx +GEOMAlgo_ShapeSolid.cxx +GEOMAlgo_Splitter.hxx +GEOMAlgo_Splitter.cxx +GEOMAlgo_Builder.hxx +GEOMAlgo_Builder.cxx +GEOMAlgo_BuilderShape.hxx +GEOMAlgo_BuilderShape.cxx +GEOMAlgo_BuilderArea.hxx +GEOMAlgo_BuilderArea.cxx +GEOMAlgo_BuilderFace.hxx +GEOMAlgo_BuilderFace.cxx +GEOMAlgo_BuilderSolid.hxx +GEOMAlgo_BuilderSolid.cxx +GEOMAlgo_ShapeInfoFiller.hxx +GEOMAlgo_ShapeInfoFiller.cxx +GEOMAlgo_Algo.hxx +GEOMAlgo_Algo.cxx +GEOMAlgo_ShapeSet.hxx +GEOMAlgo_ShapeSet.cxx +GEOMAlgo_SurfaceTools.hxx +GEOMAlgo_SurfaceTools.cxx +GEOMAlgo_State.hxx +GEOMAlgo_KindOfBounds.hxx +GEOMAlgo_KindOfClosed.hxx +GEOMAlgo_KindOfName.hxx +GEOMAlgo_KindOfShape.hxx +GEOMAlgo_ShapeInfo.hxx +GEOMAlgo_ShapeInfo.cxx +GEOMAlgo_CoupleOfShapes.hxx +GEOMAlgo_CoupleOfShapes.cxx +GEOMAlgo_BuilderTools.hxx +GEOMAlgo_BuilderTools.cxx +GEOMAlgo_Tools3D.hxx +GEOMAlgo_Tools3D.cxx +GEOMAlgo_Tools.hxx +GEOMAlgo_Tools.cxx +GEOMAlgo_PWireEdgeSet.hxx +GEOMAlgo_StateCollector.cxx +GEOMAlgo_StateCollector.hxx +GEOMAlgo_PassKey.hxx +GEOMAlgo_PassKey.cxx +GEOMAlgo_PassKeyMapHasher.hxx +GEOMAlgo_PassKeyMapHasher.cxx +GEOMAlgo_PassKeyShape.hxx +GEOMAlgo_PassKeyShape.cxx +GEOMAlgo_PassKeyShapeMapHasher.hxx +GEOMAlgo_PassKeyShapeMapHasher.cxx +GEOMAlgo_ClsfBox.hxx +GEOMAlgo_ClsfBox.cxx +GEOMAlgo_ClsfSolid.hxx +GEOMAlgo_ClsfSolid.cxx +GEOMAlgo_ClsfSurf.hxx +GEOMAlgo_ClsfSurf.cxx +GEOMAlgo_Clsf.hxx +GEOMAlgo_Clsf.cxx +GEOMAlgo_HAlgo.hxx +GEOMAlgo_HAlgo.cxx + +GEOMAlgo_ListOfCoupleOfShapes.hxx +GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx +GEOMAlgo_ListOfPnt.hxx +GEOMAlgo_ListIteratorOfListOfPnt.hxx +GEOMAlgo_DataMapOfShapeShapeSet.hxx +GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx +GEOMAlgo_DataMapOfShapeReal.hxx +GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx +GEOMAlgo_DataMapOfRealListOfShape.hxx +GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx +GEOMAlgo_DataMapOfPassKeyInteger.hxx +GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx +GEOMAlgo_DataMapOfPassKeyShapeShape.hxx +GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx +GEOMAlgo_DataMapOfOrientedShapeShape.hxx +GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx +GEOMAlgo_DataMapOfShapeMapOfShape.hxx +GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx +GEOMAlgo_DataMapOfShapePnt.hxx +GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx +GEOMAlgo_IndexedDataMapOfShapeBox.hxx + +GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx +GEOMAlgo_IndexedDataMapOfShapeState.hxx +GEOMAlgo_IndexedDataMapOfIntegerShape.hxx +GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/GEOMAlgo_NEW/GEOMAlgo.cdl b/src/GEOMAlgo_NEW/GEOMAlgo.cdl new file mode 100644 index 000000000..da00ffaee --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo.cdl @@ -0,0 +1,342 @@ +-- 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.cdl +-- Created: Sat Dec 04 12:36:22 2004 +-- Author: Peter KURNEV + +package GEOMAlgo + + ---Purpose: + +uses + TCollection, + + TColgp, + Geom, + Bnd, + gp, + GeomAdaptor, + TopAbs, + TopoDS, + TopTools, + IntTools, + BOPTools, + BOP, + + TColStd, + BOPTColStd, + BRepAlgo, + NMTDS, + NMTTools + +is + -- Enumerations + imported State from GEOMAlgo; + imported KindOfShape from GEOMAlgo; + imported KindOfName from GEOMAlgo; + imported KindOfBounds from GEOMAlgo; + imported KindOfClosed from GEOMAlgo; + -- + -- Gluer / GetInPlace + imported Gluer2 from GEOMAlgo; + imported GlueDetector from GEOMAlgo; + imported GluerAlgo from GEOMAlgo; + imported GetInPlace from GEOMAlgo; + -- Algos + imported WireSplitter from GEOMAlgo; + imported WESScaler from GEOMAlgo; + imported WESCorrector from GEOMAlgo; + imported WireEdgeSet from GEOMAlgo; + imported GlueAnalyser from GEOMAlgo; + imported Gluer from GEOMAlgo; + imported FinderShapeOn2 from GEOMAlgo; + imported FinderShapeOn1 from GEOMAlgo; + imported FinderShapeOn from GEOMAlgo; + imported ShapeAlgo from GEOMAlgo; + imported SolidSolid from GEOMAlgo; + imported ShellSolid from GEOMAlgo; + imported VertexSolid from GEOMAlgo; + imported WireSolid from GEOMAlgo; + imported ShapeSolid from GEOMAlgo; + imported Splitter from GEOMAlgo; + imported Builder from GEOMAlgo; + imported BuilderShape from GEOMAlgo; + imported BuilderSolid from GEOMAlgo; + imported BuilderFace from GEOMAlgo; + imported BuilderArea from GEOMAlgo; + imported ShapeInfoFiller from GEOMAlgo; + imported Algo from GEOMAlgo; + -- Data / Tools + imported ShapeSet from GEOMAlgo; + imported SurfaceTools from GEOMAlgo; + imported ShapeInfo from GEOMAlgo; + imported CoupleOfShapes from GEOMAlgo; + imported BuilderTools from GEOMAlgo; + imported Tools3D from GEOMAlgo; + imported Tools from GEOMAlgo; + imported PWireEdgeSet from GEOMAlgo; + imported StateCollector from GEOMAlgo; + imported PassKey from GEOMAlgo; + imported PassKeyMapHasher from GEOMAlgo; + imported PassKeyShape from GEOMAlgo; + imported PassKeyShapeMapHasher from GEOMAlgo; + imported ClsfBox from GEOMAlgo; + imported ClsfSurf from GEOMAlgo; + imported ClsfSolid from GEOMAlgo; + imported Clsf from GEOMAlgo; + imported HAlgo from GEOMAlgo; + + imported ListOfCoupleOfShapes from GEOMAlgo; + imported ListIteratorOfListOfCoupleOfShapes from GEOMAlgo; + imported ListOfPnt from GEOMAlgo; + imported ListIteratorOfListOfPnt from GEOMAlgo; + imported DataMapOfShapeShapeSet from GEOMAlgo; + imported DataMapIteratorOfDataMapOfShapeShapeSet from GEOMAlgo; + imported DataMapOfShapeReal from GEOMAlgo; + imported DataMapIteratorOfDataMapOfShapeReal from GEOMAlgo; + imported DataMapOfRealListOfShape from GEOMAlgo; + imported DataMapIteratorOfDataMapOfRealListOfShape from GEOMAlgo; + imported DataMapOfPassKeyInteger from GEOMAlgo; + imported DataMapIteratorOfDataMapOfPassKeyInteger from GEOMAlgo; + imported DataMapOfPassKeyShapeShape from GEOMAlgo; + imported DataMapIteratorOfDataMapOfPassKeyShapeShape from GEOMAlgo; + imported DataMapOfOrientedShapeShape from GEOMAlgo; + imported DataMapIteratorOfDataMapOfOrientedShapeShape from GEOMAlgo; + imported DataMapOfShapeMapOfShape from GEOMAlgo; + imported DataMapIteratorOfDataMapOfShapeMapOfShape from GEOMAlgo; + imported DataMapOfShapePnt from GEOMAlgo; + imported DataMapIteratorOfDataMapOfShapePnt from GEOMAlgo; + imported IndexedDataMapOfShapeBox from GEOMAlgo; + imported IndexedDataMapOfShapeShapeInfo from GEOMAlgo; + imported IndexedDataMapOfShapeState from GEOMAlgo; + imported IndexedDataMapOfIntegerShape from GEOMAlgo; + imported IndexedDataMapOfPassKeyShapeListOfShape from GEOMAlgo; + + + -- Instantiations + + --class ListOfCoupleOfShapes + -- instantiates List from TCollection (CoupleOfShapes from GEOMAlgo); + + --class ListOfPnt + -- instantiates List from TCollection (Pnt from gp); + -- + + --class DataMapOfShapeShapeSet instantiates + -- DataMap from TCollection(Shape from TopoDS, + -- ShapeSet from GEOMAlgo, + -- ShapeMapHasher from TopTools); + + --class DataMapOfShapeReal instantiates + -- DataMap from TCollection(Shape from TopoDS, + -- Real from Standard, + -- ShapeMapHasher from TopTools); + + + --class DataMapOfRealListOfShape instantiates + -- DataMap from TCollection(Real from Standard, + -- ListOfShape from TopTools, + -- MapRealHasher from TColStd); + + + --class DataMapOfPassKeyInteger + -- instantiates DataMap from TCollection (PassKey from GEOMAlgo, + -- Integer from Standard, + -- PassKeyMapHasher from GEOMAlgo); + + --class DataMapOfPassKeyShapeShape + -- instantiates DataMap from TCollection (PassKeyShape from GEOMAlgo, + -- Shape from TopoDS, + -- PassKeyShapeMapHasher from GEOMAlgo); + + --class DataMapOfOrientedShapeShape instantiates + -- DataMap from TCollection (Shape from TopoDS, + -- Shape from TopoDS, + -- OrientedShapeMapHasher from TopTools); + + + --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); + + -- + --class IndexedDataMapOfShapeBox + -- instantiates IndexedDataMap from TCollection (Shape from TopoDS, +-- Box from Bnd, +-- ShapeMapHasher from TopTools); + +-- class IndexedDataMapOfShapeShapeInfo +-- instantiates IndexedDataMap from TCollection (Shape from TopoDS, +-- ShapeInfo from GEOMAlgo, +-- ShapeMapHasher from TopTools); +-- class IndexedDataMapOfShapeState +-- instantiates IndexedDataMap from TCollection (Shape from TopoDS, +-- State from TopAbs, +-- ShapeMapHasher from TopTools); + + +-- +-- class IndexedDataMapOfIntegerShape +-- instantiates IndexedDataMap from TCollection (Integer from Standard, +-- Shape from TopoDS, +-- MapIntegerHasher from TColStd); + + +-- class IndexedDataMapOfPassKeyShapeListOfShape +-- instantiates IndexedDataMap from TCollection (PassKeyShape from GEOMAlgo, +-- ListOfShape from TopTools, +-- PassKeyShapeMapHasher from GEOMAlgo); + + + + + + +end GEOMAlgo; + -- + -- enumerations + -- + --enumeration State is + -- ST_UNKNOWN, +-- ST_IN, +-- ST_OUT, +-- ST_ON, +-- ST_ONIN, +-- ST_ONOUT, +-- ST_INOUT +-- end State; + -- +-- enumeration KindOfShape is +-- KS_UNKNOWN, +-- KS_SPHERE, +-- KS_CYLINDER, +-- KS_BOX, +-- KS_TORUS, +-- KS_CONE, +-- KS_ELLIPSE, +-- KS_PLANE, +-- KS_CIRCLE, +-- KS_LINE, +-- KS_DEGENERATED +-- end KindOfShape; + -- +-- enumeration KindOfName is +-- KN_UNKNOWN, +-- KN_SPHERE, +-- KN_CYLINDER, +-- KN_TORUS, +-- KN_CONE, +-- KN_ELLIPSE, +-- KN_CIRCLE, +-- KN_PLANE, +-- KN_LINE, +-- KN_BOX, +-- KN_SEGMENT, +-- KN_ARCCIRCLE, +-- KN_POLYGON, +-- KN_POLYHEDRON, +-- KN_DISKCIRCLE, +-- KN_DISKELLIPSE, +-- KN_RECTANGLE, +-- KN_TRIANGLE, +-- KN_QUADRANGLE, +-- KN_ARCELLIPSE +-- end KindOfName; + -- + -- enumeration KindOfBounds is + -- KB_UNKNOWN, +-- KB_TRIMMED, + -- KB_INFINITE +-- end KindOfBounds; + -- +-- enumeration KindOfClosed is +-- KC_UNKNOWN, +-- KC_CLOSED, +-- KC_NOTCLOSED +-- end KindOfClosed; + -- + + --deferred class HAlgo; + --deferred class Clsf; + --class ClsfSurf; + --class ClsfBox; + --class ClsfSolid; + + -- + -- classes + -- + --deferred class Algo; + --deferred class ShapeAlgo; + -- + --class ShapeInfo; + --class ShapeInfoFiller; + --class CoupleOfShapes; + --class SurfaceTools; + --class Tools; + --class PassKey; + --class PassKeyMapHasher; + --class PassKeyShape; + --class PassKeyShapeMapHasher; + -- + -- finder on + --deferred class ShapeSolid; + --class WireSolid; + --class ShellSolid; + --class VertexSolid; + --class SolidSolid; + --class StateCollector; + + -- + --class Gluer; + --class GlueAnalyser; + --class FinderShapeOn; + --class FinderShapeOn1; + --class FinderShapeOn2; + -- + -- Builder/Splitter + --deferred class BuilderShape; + --class Builder; + --class Splitter; + --class Tools3D; + --class BuilderTools; + --class ShapeSet; + + --deferred class BuilderArea; + --class BuilderFace; + --class BuilderSolid; + + --class WireSplitter; + --class WireEdgeSet; + --class WESCorrector; + --class WESScaler; + -- + -- Pointers + -- + --pointer PWireEdgeSet to WireEdgeSet from GEOMAlgo; + -- + -- diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Algo.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Algo.cxx new file mode 100644 index 000000000..a33b3c50c --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Algo.cxx @@ -0,0 +1,90 @@ +// 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_Algo.cxx +// Created: Sat Dec 04 12:39:47 2004 +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +// function: +// purpose: +//======================================================================= + GEOMAlgo_Algo::GEOMAlgo_Algo() +: + myErrorStatus(1), + myWarningStatus(0), + myComputeInternalShapes(Standard_True) +{} +//======================================================================= +// function: ~ +// purpose: +//======================================================================= + GEOMAlgo_Algo::~GEOMAlgo_Algo() +{ +} +//======================================================================= +// function: CheckData +// purpose: +//======================================================================= + void GEOMAlgo_Algo::CheckData() +{ + myErrorStatus=0; +} +//======================================================================= +// function: CheckResult +// purpose: +//======================================================================= + void GEOMAlgo_Algo::CheckResult() +{ + myErrorStatus=0; +} +//======================================================================= +// function: ErrorStatus +// purpose: +//======================================================================= + Standard_Integer GEOMAlgo_Algo::ErrorStatus()const +{ + return myErrorStatus; +} +//======================================================================= +// function: WarningStatus +// purpose: +//======================================================================= + Standard_Integer GEOMAlgo_Algo::WarningStatus()const +{ + return myWarningStatus; +} +// myErrorStatus +// +// 1 - object is just initialized + +//======================================================================= +//function : ComputeInternalShapes +//purpose : +//======================================================================= + void GEOMAlgo_Algo::ComputeInternalShapes(const Standard_Boolean theFlag) +{ + myComputeInternalShapes = theFlag; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Algo.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_Algo.hxx new file mode 100644 index 000000000..13f3e162e --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Algo.hxx @@ -0,0 +1,75 @@ +// 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_Algo.hxx +// Created: Sat Dec 04 12:39:47 2004 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_Algo_HeaderFile +#define _GEOMAlgo_Algo_HeaderFile + +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_Algo +//purpose : +//======================================================================= +class GEOMAlgo_Algo +{ + public: + Standard_EXPORT + virtual void Perform() = 0; + + Standard_EXPORT + Standard_Integer ErrorStatus() const; + + Standard_EXPORT + Standard_Integer WarningStatus() const; + + //! Allows to omit of creation of internal shapes (manifold topology).
+ //! Needed for the SALOME/TRIPOLI module.
+ Standard_EXPORT + void ComputeInternalShapes(const Standard_Boolean theFlag) ; + +protected: + Standard_EXPORT + GEOMAlgo_Algo(); + + Standard_EXPORT + virtual ~GEOMAlgo_Algo(); + + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + virtual void CheckResult() ; + + + Standard_Integer myErrorStatus; + Standard_Integer myWarningStatus; + Standard_Boolean myComputeInternalShapes; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Builder.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Builder.cxx new file mode 100644 index 000000000..5429d32c3 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Builder.cxx @@ -0,0 +1,416 @@ +// 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_Builder.cxx +// Created: +// Author: Peter KURNEV +// +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_Builder::GEOMAlgo_Builder() +: + GEOMAlgo_BuilderShape() +{ + myNbTypes=9; + myPaveFiller=NULL; + myEntryPoint=0; // Entry point through PerformWithFiller () +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_Builder::~GEOMAlgo_Builder() +{ + if (myEntryPoint==1) { + if (myPaveFiller) { + delete myPaveFiller; + myPaveFiller=NULL; + } + } +} +//======================================================================= +//function : AddCompound +//purpose : +//======================================================================= + void GEOMAlgo_Builder::AddCompound(const TopoDS_Shape& theShape) +{ + TopoDS_Iterator aIt; + // + aIt.Initialize(theShape); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + AddShape(aS); + } +} +//======================================================================= +//function : AddShape +//purpose : +//======================================================================= + void GEOMAlgo_Builder::AddShape(const TopoDS_Shape& theShape) +{ + if (myMapFence.Add(theShape)) { + myShapes.Append(theShape); + } +} +//======================================================================= +//function : Shapes +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_Builder::Shapes()const +{ + return myShapes; +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void GEOMAlgo_Builder::Clear() +{ + myShapes.Clear(); + ClearInternals(); +} +//======================================================================= +//function : ClearInternals +//purpose : +//======================================================================= + void GEOMAlgo_Builder::ClearInternals() +{ + Standard_Integer i; + // + for (i=0; iSetCompositeShape(aCS); + pPF->Perform(); + // + myEntryPoint=1; + PerformInternal(*pPF); +} +//======================================================================= +//function : PerformWithFiller +//purpose : +//======================================================================= + void GEOMAlgo_Builder::PerformWithFiller(const NMTTools_PaveFiller& theDSF) +{ + myEntryPoint=0; + // + PerformInternal(theDSF); +} +//======================================================================= +//function : PerformInternal +//purpose : +//======================================================================= + void GEOMAlgo_Builder::PerformInternal(const NMTTools_PaveFiller& pPF) +{ + myErrorStatus=0; + // + Standard_Boolean bIsDone; + // + // 0. myPaveFiller + myPaveFiller=(NMTTools_PaveFiller *)&pPF; + // + bIsDone=myPaveFiller->IsDone(); + if (!bIsDone) { + myErrorStatus=2; // PaveFiller is failed + return; + } + // + // 1. Clear Internal fields + ClearInternals(); + // + // 2. Prepare + Prepare(); + if (myErrorStatus) { + return; + } + // + // 3. Fill Images + // + // 3.1 Vertices + FillImagesVertices(); + if (myErrorStatus) { + return; + } + // + BuildResult(TopAbs_VERTEX); + if (myErrorStatus) { + return; + } + // 3.2 Edges + FillImagesEdges(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_EDGE); + if (myErrorStatus) { + return; + } + // 3.3 Wires + FillImagesContainers(TopAbs_WIRE); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_WIRE); + if (myErrorStatus) { + return; + } + + // 3.4 Faces + FillImagesFaces(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_FACE); + if (myErrorStatus) { + return; + } + // 3.5 Shells + + FillImagesContainers(TopAbs_SHELL); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_SHELL); + if (myErrorStatus) { + return; + } + // 3.6 Solids + FillImagesSolids(); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_SOLID); + if (myErrorStatus) { + return; + } + // 3.7 CompSolids + FillImagesContainers(TopAbs_COMPSOLID); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_COMPSOLID); + if (myErrorStatus) { + return; + } + // 3.8 Compounds + FillImagesContainers(TopAbs_COMPOUND); + if (myErrorStatus) { + return; + } + + BuildResult(TopAbs_COMPOUND); + if (myErrorStatus) { + return; + } + // + // 4.History + PrepareHistory(); + // + // 5 Post-treatment + PostTreat(); +} +// +// static +// void CorrectWires(const TopoDS_Shape& aS); +// +//======================================================================= +//function : PostTreat +//purpose : +//======================================================================= + void GEOMAlgo_Builder::PostTreat() +{ + Standard_Integer aNbS; + TopoDS_Iterator aIt; + TopTools_ListOfShape aLS; + // + aIt.Initialize(myShape); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aLS.Append(aS); + } + aNbS=aLS.Extent(); + if (aNbS==1) { + myShape=aLS.First(); + } + + BRepLib::SameParameter(myShape, 1.e-7, Standard_True); + // + GEOMAlgo_Tools::CorrectWires(myShape); +} +// +// myErrorStatus +// +// 0 - Ok +// 1 - The object is just initialized +// 2 - PaveFiller is failed +// 10 - No shapes to process +// 30 - SolidBuilder failed + diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Builder.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_Builder.hxx new file mode 100644 index 000000000..529ae81b2 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Builder.hxx @@ -0,0 +1,224 @@ +// 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_Builder.cxx +// Created: +// Author: Peter KURNEV +// +#ifndef _GEOMAlgo_Builder_HeaderFile +#define _GEOMAlgo_Builder_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_Builder +//purpose : +//======================================================================= +class GEOMAlgo_Builder : public GEOMAlgo_BuilderShape +{ + public: + //! Empty constructor
+ Standard_EXPORT + GEOMAlgo_Builder(); + + Standard_EXPORT + virtual ~GEOMAlgo_Builder(); + + //! Performs calculations
+ Standard_EXPORT + virtual void Perform() ; + + //! Performs calculations using prepared PaveFiller
+ //! object theDSF
+ Standard_EXPORT + virtual void PerformWithFiller(const NMTTools_PaveFiller& theDSF) ; + + //! Adds argument theShape of the operation
+ Standard_EXPORT + virtual void AddShape(const TopoDS_Shape& theShape) ; + + //! Clears internal fields and arguments
+ Standard_EXPORT + virtual void Clear() ; + + //! Returns the arguments of the operation
+ Standard_EXPORT + const TopTools_ListOfShape& Shapes() const; + + //! Returns the list of shapes generated from the
+ //! shape theS.
+ Standard_EXPORT + virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ; + + //! Returns the list of shapes modified from the shape
+ //! theS.
+ Standard_EXPORT + virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ; + + //! Returns true if the shape theS has been deleted.
+ Standard_EXPORT + virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ; + + //! Adds arguments of the operation as
+ //! shapes of upper level of container shape theShape
+ Standard_EXPORT + void AddCompound(const TopoDS_Shape& theShape) ; + + //! Returns list of arguments of type theType
+ Standard_EXPORT + const TopTools_ListOfShape& Shapes1(const Standard_Integer theType) const; + + //! Returns image shapes
+ Standard_EXPORT + const BRepAlgo_Image& Images() const; + + //! Returns split-parts of shapes that have
+ //! state IN for the domain of shape theShape
+ Standard_EXPORT + const TopTools_ListOfShape& InParts(const TopoDS_Shape& theShape) const; + +protected: + //! Performs calculations using prepared DSFiller
+ //! object theDSF
+ Standard_EXPORT + virtual void PerformInternal(const NMTTools_PaveFiller& theDSF) ; + + //! Prepare information for history support
+ Standard_EXPORT + virtual void PrepareHistory() ; + + //! Clears internal fields
+ Standard_EXPORT + virtual void ClearInternals() ; + + //! Provides preparing actions
+ Standard_EXPORT + virtual void Prepare() ; + + //! Provides post-tratment actions
+ Standard_EXPORT + virtual void PostTreat() ; + + //! Append the argument theShape to
+ //! typified lists of arguments myShapes1
+ Standard_EXPORT + void AddShape1(const TopoDS_Shape& theShape) ; + + //! Build the resulting shapes of type theType
+ Standard_EXPORT + virtual void BuildResult(const TopAbs_ShapeEnum theType) ; + + //! Fill Images for vertices
+ Standard_EXPORT + void FillImagesVertices() ; + + //! Fill Images for edges
+ Standard_EXPORT + void FillImagesEdges() ; + + //! Fill Images for faces
+ Standard_EXPORT + void FillImagesFaces() ; + + //! For each interferred face find split edges
+ //! that are in 2-D domain of the face
+ Standard_EXPORT + void FillIn2DParts() ; + + //! Build draft faces
+ Standard_EXPORT + void BuildSplitFaces() ; + + //! Among draft faces find same domain faces
+ Standard_EXPORT + void FillSameDomainFaces() ; + + //! Fill Images for faces
+ //! taking into account same domain faces
+ Standard_EXPORT + void FillImagesFaces1() ; + + //! Update Images for faces by
+ //! internal vertices
+ Standard_EXPORT + void FillInternalVertices() ; + + //! Fill Images for Wires, Shells, Compsolids, Compounds
+ Standard_EXPORT + void FillImagesContainers(const TopAbs_ShapeEnum theType) ; + + //! Fill Images for solids
+ Standard_EXPORT + void FillImagesSolids() ; + + //! For each interferred solid find split faces
+ //! that are in 3-D domain of the solid
+ Standard_EXPORT + void FillIn3DParts() ; + + //! Build draft solids
+ Standard_EXPORT + void BuildSplitSolids() ; + + //! Update draft solids by
+ //! internal shells, edges, vertices
+ Standard_EXPORT + void FillInternalShapes() ; + + //! Build solid theDraftSolid that consists of
+ //! non-internal split faces of the solid
+ //! theSolid.
+ //! All splits of internal faces of
+ //! theSolid are in the list: theInternalFaces
+ Standard_EXPORT + void BuildDraftSolid(const TopoDS_Shape& theSolid, + TopoDS_Shape& theDraftSolid, + TopTools_ListOfShape& theInternalFaces) ; + + + NMTTools_PPaveFiller myPaveFiller; + TopTools_ListOfShape myShapes; + Standard_Integer myNbTypes; + TopTools_MapOfShape myMapFence; + TopTools_ListOfShape myShapes1[9]; + BRepAlgo_Image myImages; + TopTools_IndexedDataMapOfShapeListOfShape myInParts; + BRepAlgo_Image mySplitFaces; + TopTools_IndexedDataMapOfShapeShape mySameDomainShapes; + TopTools_IndexedDataMapOfShapeShape myDraftSolids; + Standard_Integer myEntryPoint; + +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.cxx new file mode 100644 index 000000000..0cd264068 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.cxx @@ -0,0 +1,142 @@ +// 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_BuilderArea.cxx +// Created: +// Author: Peter KURNEV +// +#include + +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= +GEOMAlgo_BuilderArea::GEOMAlgo_BuilderArea() +: + GEOMAlgo_Algo() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_BuilderArea::~GEOMAlgo_BuilderArea() +{ +} +//======================================================================= +//function : SetContext +//purpose : +//======================================================================= +void GEOMAlgo_BuilderArea::SetContext(const Handle(IntTools_Context)& theContext) +{ + myContext=theContext; +} +//======================================================================= +//function : Context +//purpose : +//======================================================================= +const Handle(IntTools_Context)& GEOMAlgo_BuilderArea::Context()const +{ + return myContext; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_BuilderArea::Perform() +{ + if (myContext.IsNull()) { + myContext=new IntTools_Context; + } +} +//======================================================================= +//function : SetShapes +//purpose : +//======================================================================= +void GEOMAlgo_BuilderArea::SetShapes(const TopTools_ListOfShape& theLF) +{ + TopTools_ListIteratorOfListOfShape aIt; + // + myShapes.Clear(); + aIt.Initialize(theLF); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + myShapes.Append(aF); + } +} +//======================================================================= +//function : Shapes +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_BuilderArea::Shapes()const +{ + return myShapes; +} +//======================================================================= +//function : Loops +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_BuilderArea::Loops()const +{ + return myLoops; +} +//======================================================================= +//function : Areas +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_BuilderArea::Areas()const +{ + return myAreas; +} +//======================================================================= +//function :PerformShapesToAvoid +//purpose : +//======================================================================= +void GEOMAlgo_BuilderArea::PerformShapesToAvoid() +{ +} +//======================================================================= +//function : PerformLoops +//purpose : +//======================================================================= +void GEOMAlgo_BuilderArea::PerformLoops() +{ +} +//======================================================================= +//function : PerformAreas +//purpose : +//======================================================================= +void GEOMAlgo_BuilderArea::PerformAreas() +{ +} +//======================================================================= +//function : PerformInternalShapes +//purpose : +//======================================================================= +void GEOMAlgo_BuilderArea::PerformInternalShapes() +{ +} + diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.hxx new file mode 100644 index 000000000..a6d5d8aba --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderArea.hxx @@ -0,0 +1,112 @@ +// 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_BuilderArea.hxx +// Created: +// Author: Peter KURNEV +// + +#ifndef _GEOMAlgo_BuilderArea_HeaderFile +#define _GEOMAlgo_BuilderArea_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + +//! The root class for algorithms to build
+//! faces/solids from set of edges/faces
+//======================================================================= +//class : GEOMAlgo_BuilderArea +//purpose : +//======================================================================= +class GEOMAlgo_BuilderArea : public GEOMAlgo_Algo +{ + public: + //! Sets cashed geometrical tools
+ Standard_EXPORT + void SetContext(const Handle(IntTools_Context)& theContext) ; + + //! Returns cashed geometrical tools
+ Standard_EXPORT + const Handle_IntTools_Context& Context() const; + + //! Sets edges/faces to process
+ Standard_EXPORT + void SetShapes(const TopTools_ListOfShape& theLS) ; + + //! Returns edges/faces to process
+ Standard_EXPORT + const TopTools_ListOfShape& Shapes() const; + + //! Returns wires/shells that have been built
+ Standard_EXPORT + const TopTools_ListOfShape& Loops() const; + + //! Returns faces/solids that have been built
+ Standard_EXPORT + const TopTools_ListOfShape& Areas() const; + + Standard_EXPORT + virtual void Perform() ; + + protected: + //! Empty constructor
+ Standard_EXPORT + GEOMAlgo_BuilderArea(); + + Standard_EXPORT + virtual ~GEOMAlgo_BuilderArea(); + //! Collect the edges/faces that
+ //! a) are internal
+ //! b) are the same and have different orientation
+ + Standard_EXPORT + virtual void PerformShapesToAvoid() ; + + //! Build draft faces/shells
+ //! a)myLoops - draft faces/shells that consist of
+ //! boundary edges/faces
+ //! b)myLoopsInternal - draft faces/shells that contains
+ //! inner edges/faces
+ Standard_EXPORT + virtual void PerformLoops() ; + //! Build draft faces/solids that contains boundary faces
+ + Standard_EXPORT + virtual void PerformAreas() ; + + //! Build finalized faces/solids with internal wires/shells
+ Standard_EXPORT + virtual void PerformInternalShapes() ; + + TopTools_ListOfShape myShapes; + TopTools_ListOfShape myLoops; + TopTools_ListOfShape myLoopsInternal; + TopTools_MapOfOrientedShape myShapesToAvoid; + TopTools_ListOfShape myAreas; + Handle_IntTools_Context myContext; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.cxx new file mode 100644 index 000000000..ce238b31f --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.cxx @@ -0,0 +1,711 @@ +// 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_BuilderFace.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 +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +// +static + Standard_Boolean IsGrowthWire(const TopoDS_Shape& , + + const TopTools_IndexedMapOfShape& ); + +static + Standard_Boolean IsInside(const TopoDS_Shape& , + const TopoDS_Shape& , + const Handle(IntTools_Context)& ); +static + void MakeInternalWires(const TopTools_MapOfShape& , + TopTools_ListOfShape& ); + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_BuilderFace::GEOMAlgo_BuilderFace() +: + GEOMAlgo_BuilderArea() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_BuilderFace::~GEOMAlgo_BuilderFace() +{ +} +//======================================================================= +//function : SetFace +//purpose : +//======================================================================= + void GEOMAlgo_BuilderFace::SetFace(const TopoDS_Face& theFace) +{ + myFace=theFace; +} +//======================================================================= +//function : Face +//purpose : +//======================================================================= + const TopoDS_Face& GEOMAlgo_BuilderFace::Face()const +{ + return myFace; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void GEOMAlgo_BuilderFace::Perform() +{ + myErrorStatus=0; + // + if (myFace.IsNull()) { + myErrorStatus=12;// Null face generix + return; + } + // Initialize the context + GEOMAlgo_BuilderArea::Perform(); + // + PerformShapesToAvoid(); + if (myErrorStatus) { + return; + } + // + PerformLoops(); + if (myErrorStatus) { + return; + } + // + PerformAreas(); + if (myErrorStatus) { + return; + } + // + PerformInternalShapes(); + if (myErrorStatus) { + return; + } +} +//======================================================================= +//function :PerformShapesToAvoid +//purpose : +//======================================================================= + void GEOMAlgo_BuilderFace::PerformShapesToAvoid() +{ + Standard_Boolean bFound; + Standard_Integer i, iCnt, aNbV, aNbE; + TopTools_IndexedDataMapOfShapeListOfShape aMVE; + TopTools_ListIteratorOfListOfShape aIt; + // + myShapesToAvoid.Clear(); + // + iCnt=0; + while (1) { + ++iCnt; + bFound=Standard_False; + // + // 1. MEF + aMVE.Clear(); + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (!myShapesToAvoid.Contains(aE)) { + TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + } +// else { +// int a=0; +// } + } + aNbV=aMVE.Extent(); + // + // 2. myEdgesToAvoid + for (i=1; i<=aNbV; ++i) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aMVE.FindKey(i)); + // + TopTools_ListOfShape& aLE=aMVE.ChangeFromKey(aV); + aNbE=aLE.Extent(); + if (!aNbE) { + continue; + } + // + const TopoDS_Edge& aE1=TopoDS::Edge(aLE.First()); + if (aNbE==1) { + if (BRep_Tool::Degenerated(aE1)) { + continue; + } + if (aV.Orientation()==TopAbs_INTERNAL) { + continue; + } + bFound=Standard_True; + myShapesToAvoid.Add(aE1); + } + else if (aNbE==2) { + const TopoDS_Edge& aE2=TopoDS::Edge(aLE.Last()); + if (aE2.IsSame(aE1)) { + TopoDS_Vertex aV1x, aV2x; + // + TopExp::Vertices(aE1, aV1x, aV2x); + if (aV1x.IsSame(aV2x)) { + continue; + } + bFound=Standard_True; + myShapesToAvoid.Add(aE1); + myShapesToAvoid.Add(aE2); + } + } + }// for (i=1; i<=aNbE; ++i) { + // + if (!bFound) { + break; + } + // + }//while (1) + //printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt); +} +//======================================================================= +//function : PerformLoops +//purpose : +//======================================================================= + void GEOMAlgo_BuilderFace::PerformLoops() +{ + myErrorStatus=0; + // + Standard_Boolean bFlag; + Standard_Integer aNbEA; + TopTools_ListIteratorOfListOfShape aIt; + TopTools_MapIteratorOfMapOfOrientedShape aItM; + TopTools_IndexedDataMapOfShapeListOfShape aVEMap; + TopTools_MapOfOrientedShape aMAdded; + TopoDS_Iterator aItW; + BRep_Builder aBB; + GEOMAlgo_WireEdgeSet aWES; + GEOMAlgo_WESCorrector aWESCor; + // + // 1. Usual Wires + myLoops.Clear(); + aWES.SetFace(myFace); + // + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (!myShapesToAvoid.Contains(aE)) { + aWES.AddStartElement(aE); + } + } + // + aWESCor.SetWES(aWES); + aWESCor.Perform(); + // + GEOMAlgo_WireEdgeSet& aWESN=aWESCor.NewWES(); + const TopTools_ListOfShape& aLW=aWESN.Shapes(); + // + aIt.Initialize (aLW); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aW=aIt.Value(); + myLoops.Append(aW); + } + //modified by NIZNHY-PKV Tue Aug 5 15:09:29 2008f + // Post Treatment + TopTools_MapOfOrientedShape aMEP; + // + // a. collect all edges that are in loops + aIt.Initialize (myLoops); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aW=aIt.Value(); + aItW.Initialize(aW); + for (; aItW.More(); aItW.Next()) { + const TopoDS_Shape& aE=aItW.Value(); + aMEP.Add(aE); + } + } + // + // b. collect all edges that are to avoid + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aE=aItM.Key(); + aMEP.Add(aE); + } + // + // c. add all edges that are not processed to myShapesToAvoid + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (!aMEP.Contains(aE)) { + myShapesToAvoid.Add(aE); + } + } + //modified by NIZNHY-PKV Tue Aug 5 15:09:35 2008t + // + // 2. Internal Wires + myLoopsInternal.Clear(); + // + aNbEA=myShapesToAvoid.Extent(); + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aEE=aItM.Key(); + TopExp::MapShapesAndAncestors(aEE, TopAbs_VERTEX, TopAbs_EDGE, aVEMap); + } + // + bFlag=Standard_True; + aItM.Initialize(myShapesToAvoid); + for (; aItM.More()&&bFlag; aItM.Next()) { + const TopoDS_Shape& aEE=aItM.Key(); + if (!aMAdded.Add(aEE)) { + continue; + } + // + // make new wire + TopoDS_Wire aW; + aBB.MakeWire(aW); + aBB.Add(aW, aEE); + // + aItW.Initialize(aW); + for (; aItW.More()&&bFlag; aItW.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aItW.Value()); + // + TopoDS_Iterator aItE(aE); + for (; aItE.More()&&bFlag; aItE.Next()) { + const TopoDS_Vertex& aV = TopoDS::Vertex(aItE.Value()); + const TopTools_ListOfShape& aLE=aVEMap.FindFromKey(aV); + aIt.Initialize(aLE); + for (; aIt.More()&&bFlag; aIt.Next()) { + const TopoDS_Shape& aEx=aIt.Value(); + if (aMAdded.Add(aEx)) { + aBB.Add(aW, aEx); + if(aMAdded.Extent()==aNbEA) { + bFlag=!bFlag; + } + } + }//for (; aIt.More(); aIt.Next()) { + }//for (; aItE.More(); aItE.Next()) { + }//for (; aItW.More(); aItW.Next()) { + myLoopsInternal.Append(aW); + }//for (; aItM.More(); aItM.Next()) { +} +//======================================================================= +//function : PerformAreas +//purpose : +//======================================================================= + void GEOMAlgo_BuilderFace::PerformAreas() +{ + myErrorStatus=0; + // + Standard_Boolean bIsGrowth, bIsHole; + Standard_Real aTol; + TopTools_ListOfShape aNewFaces, aHoleWires; + TopoDS_Shape anInfinitePointShape; + TopTools_DataMapOfShapeShape aInOutMap; + TopTools_DataMapOfShapeListOfShape aMSH; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH; + TopTools_ListIteratorOfListOfShape aIt1, aIt2; + TopTools_IndexedMapOfShape aMHE; + BRep_Builder aBB; + Handle(Geom_Surface) aS; + TopLoc_Location aLoc; + // + aTol=BRep_Tool::Tolerance(myFace); + aS=BRep_Tool::Surface(myFace, aLoc); + // + myAreas.Clear(); + // + // Draft faces [aNewFaces] + aIt1.Initialize(myLoops); + for ( ; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aWire=aIt1.Value(); + // + bIsGrowth=IsGrowthWire(aWire, aMHE); + if (bIsGrowth) { + // make a growth face from a wire + TopoDS_Face aFace; + aBB.MakeFace(aFace, aS, aLoc, aTol); + aBB.Add (aFace, aWire); + // + aNewFaces.Append (aFace); + } + else{ + // check if a wire is a hole + //XX + //bIsHole=IsHole(aWire, myFace, myContext); + bIsHole=GEOMAlgo_BuilderTools::IsHole(aWire, myFace); + //XX + if (bIsHole) { + aHoleWires.Append(aWire); + TopExp::MapShapes(aWire, TopAbs_EDGE, aMHE); + } + else { + // make a growth face from a wire + TopoDS_Face aFace; + aBB.MakeFace(aFace, aS, aLoc, aTol); + aBB.Add (aFace, aWire); + // + aNewFaces.Append (aFace); + } + } + } + // + // 2. Find outer growth shell that is most close to each hole shell + aIt2.Initialize(aHoleWires); + for (; aIt2.More(); aIt2.Next()) { + const TopoDS_Shape& aHole = aIt2.Value(); + // + aIt1.Initialize(aNewFaces); + for ( ; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aF=aIt1.Value(); + // + if (!IsInside(aHole, aF, myContext)){ + continue; + } + // + if ( aInOutMap.IsBound (aHole)){ + const TopoDS_Shape& aF2=aInOutMap(aHole); + if (IsInside(aF, aF2, myContext)) { + aInOutMap.UnBind(aHole); + aInOutMap.Bind (aHole, aF); + } + } + else{ + aInOutMap.Bind (aHole, aF); + } + } + // + // Add aHole to a map Face/ListOfHoles [aMSH] + if (aInOutMap.IsBound(aHole)){ + const TopoDS_Shape& aF=aInOutMap(aHole); + if (aMSH.IsBound(aF)) { + TopTools_ListOfShape& aLH=aMSH.ChangeFind(aF); + aLH.Append(aHole); + } + else { + TopTools_ListOfShape aLH; + aLH.Append(aHole); + aMSH.Bind(aF, aLH); + } + } + }// for (; aIt2.More(); aIt2.Next()) + // + // 3. Add aHoles to Faces + aItMSH.Initialize(aMSH); + for (; aItMSH.More(); aItMSH.Next()) { + TopoDS_Face aF=TopoDS::Face(aItMSH.Key()); + // + const TopTools_ListOfShape& aLH=aItMSH.Value(); + aIt2.Initialize(aLH); + for (; aIt2.More(); aIt2.Next()) { + const TopoDS_Shape& aHole = aIt2.Value(); + aBB.Add (aF, aHole); + } + // + // update classifier + aTol=BRep_Tool::Tolerance(aF); + IntTools_FClass2d& aClsf=myContext->FClass2d(aF); + aClsf.Init(aF, aTol); + } + // + // These aNewFaces are draft faces that + // do not contain any internal shapes + // + myAreas.Append(aNewFaces); +} +//======================================================================= +//function : PerformInternalShapes +//purpose : +//======================================================================= + void GEOMAlgo_BuilderFace::PerformInternalShapes() +{ + myErrorStatus=0; + // + Standard_Integer aNbWI=myLoopsInternal.Extent(); + if (!aNbWI) {// nothing to do + return; + } + // + //Standard_Real aTol; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aIt1, aIt2; + TopoDS_Iterator aIt; + TopTools_MapOfShape aME, aMEP; + TopTools_MapIteratorOfMapOfShape aItME; + TopTools_IndexedDataMapOfShapeListOfShape aMVE; + TopTools_ListOfShape aLSI; + // + // 1. All internal edges + aIt1.Initialize(myLoopsInternal); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aWire=aIt1.Value(); + aIt.Initialize(aWire); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + aME.Add(aE); + } + } + aNbWI=aME.Extent(); + // + // 2 Process faces + aIt2.Initialize(myAreas); + for ( ; aIt2.More(); aIt2.Next()) { + TopoDS_Face& aF=TopoDS::Face(aIt2.Value()); + // + aMVE.Clear(); + TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + // + // 2.1 Separate faces to process aMEP + aMEP.Clear(); + aItME.Initialize(aME); + for (; aItME.More(); aItME.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aItME.Key()); + if (IsInside(aE, aF, myContext)) { + aMEP.Add(aE); + } + } + // + // 2.2 Make Internal Wires + aLSI.Clear(); + MakeInternalWires(aMEP, aLSI); + // + // 2.3 Add them to aF + aIt1.Initialize(aLSI); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aSI=aIt1.Value(); + aBB.Add (aF, aSI); + } + // + // 2.4 Remove faces aMFP from aMF + aItME.Initialize(aMEP); + for (; aItME.More(); aItME.Next()) { + const TopoDS_Shape& aE=aItME.Key(); + aME.Remove(aE); + } + // + aNbWI=aME.Extent(); + if (!aNbWI) { + break; + } + } //for ( ; aIt2.More(); aIt2.Next()) { +} +//======================================================================= +//function : MakeInternalWires +//purpose : +//======================================================================= +void MakeInternalWires(const TopTools_MapOfShape& theME, + TopTools_ListOfShape& theWires) +{ + TopTools_MapIteratorOfMapOfShape aItM; + TopTools_MapOfShape aAddedMap; + TopTools_ListIteratorOfListOfShape aItE; + TopTools_IndexedDataMapOfShapeListOfShape aMVE; + BRep_Builder aBB; + // + aItM.Initialize(theME); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aE=aItM.Key(); + TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + } + // + aItM.Initialize(theME); + for (; aItM.More(); aItM.Next()) { + TopoDS_Shape aEE=aItM.Key(); + if (!aAddedMap.Add(aEE)) { + continue; + } + // + // make a new shell + TopoDS_Wire aW; + aBB.MakeWire(aW); + aEE.Orientation(TopAbs_INTERNAL); + aBB.Add(aW, aEE); + // + TopoDS_Iterator aItAdded (aW); + for (; aItAdded.More(); aItAdded.Next()) { + const TopoDS_Shape& aE =aItAdded.Value(); + // + TopExp_Explorer aExp(aE, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aV =aExp.Current(); + const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV); + aItE.Initialize(aLE); + for (; aItE.More(); aItE.Next()) { + TopoDS_Shape aEL=aItE.Value(); + if (aAddedMap.Add(aEL)){ + aEL.Orientation(TopAbs_INTERNAL); + aBB.Add(aW, aEL); + } + } + } + } + theWires.Append(aW); + } +} +//======================================================================= +//function : IsInside +//purpose : +//======================================================================= +Standard_Boolean IsInside(const TopoDS_Shape& theHole, + const TopoDS_Shape& theF2, + const Handle(IntTools_Context)& theContext) +{ + Standard_Boolean bRet; + Standard_Real aT, aU, aV; + + TopAbs_State aState; + TopExp_Explorer aExp; + TopTools_IndexedMapOfShape aME2; + gp_Pnt2d aP2D; + // + bRet=Standard_False; + aState=TopAbs_UNKNOWN; + const TopoDS_Face& aF2=TopoDS::Face(theF2); + // + TopExp::MapShapes(aF2, TopAbs_EDGE, aME2); + // + aExp.Init(theHole, TopAbs_EDGE); + if (aExp.More()) { + const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current()); + if (aME2.Contains(aE)) { + return bRet; + } + // + aT=BOPTools_Tools2D::IntermediatePoint(aE); + BOPTools_Tools2D::PointOnSurface(aE, aF2, aT, aU, aV); + aP2D.SetCoord(aU, aV); + // + IntTools_FClass2d& aClsf=theContext->FClass2d(aF2); + aState=aClsf.Perform(aP2D); + bRet=(aState==TopAbs_IN); + } + // + return bRet; +} + +//======================================================================= +//function : IsGrowthWire +//purpose : +//======================================================================= +Standard_Boolean IsGrowthWire(const TopoDS_Shape& theWire, + const TopTools_IndexedMapOfShape& theMHE) +{ + Standard_Boolean bRet; + TopoDS_Iterator aIt; + // + bRet=Standard_False; + if (theMHE.Extent()) { + aIt.Initialize(theWire); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (theMHE.Contains(aE)) { + return !bRet; + } + } + } + return bRet; +} + +//BRepTools::Write(aFF, "ff"); +// +// ErrorStatus : +// 11 - Null Context +// 12 - Null face generix + +/* +//======================================================================= +//function : IsInside +//purpose : +//======================================================================= +Standard_Boolean IsInside(const TopoDS_Shape& theHole, + const TopoDS_Shape& theF2, + IntTools_PContext& theContext) +{ + Standard_Real aT, aU, aV; + TopExp_Explorer aExp; + TopAbs_State aState=TopAbs_UNKNOWN; + gp_Pnt2d aP2D; + // + const TopoDS_Face& aF2=TopoDS::Face(theF2); + // + aExp.Init(theHole, TopAbs_EDGE); + if (aExp.More()){ + const TopoDS_Edge& aE = TopoDS::Edge(aExp.Current()); + aT=BOPTools_Tools2D::IntermediatePoint(aE); + BOPTools_Tools2D::PointOnSurface(aE, aF2, aT, aU, aV); + aP2D.SetCoord(aU, aV); + // + IntTools_FClass2d& aClsf=theContext->FClass2d(aF2); + aState=aClsf.Perform(aP2D); + } + return (aState==TopAbs_IN); +} +*/ diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.hxx new file mode 100644 index 000000000..96a038954 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderFace.hxx @@ -0,0 +1,91 @@ + +// 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_BuilderFace.hxx +// Created: +// Author: Peter KURNEV +// +#ifndef _GEOMAlgo_BuilderFace_HeaderFile +#define _GEOMAlgo_BuilderFace_HeaderFile + +#include +#include +#include +#include + +//! The algorithm to build faces from set of edges
+//======================================================================= +//class : GEOMAlgo_BuilderFace +//purpose : +//======================================================================= +class GEOMAlgo_BuilderFace : public GEOMAlgo_BuilderArea +{ + public: + + //! Empty constructor
+ Standard_EXPORT + GEOMAlgo_BuilderFace(); + + Standard_EXPORT + virtual ~GEOMAlgo_BuilderFace(); + + //! Sets the face generatix
+ Standard_EXPORT + void SetFace(const TopoDS_Face& theFace) ; + + //! Returns the face generatix
+ Standard_EXPORT + const TopoDS_Face& Face() const; + + //! Performs the algorithm
+ Standard_EXPORT + virtual void Perform() ; + + protected: + //! Collect the edges that
+ //! a) are internal
+ //! b) are the same and have different orientation
+ Standard_EXPORT + virtual void PerformShapesToAvoid() ; + + //! Build draft wires
+ //! a)myLoops - draft wires that consist of
+ //! boundary edges
+ //! b)myLoopsInternal - draft wires that contains
+ //! inner edges
+ Standard_EXPORT + virtual void PerformLoops() ; + + //! Build draft faces that contains boundary edges
+ Standard_EXPORT + virtual void PerformAreas() ; + + //! Build finalized faces with internals
+ Standard_EXPORT + virtual void PerformInternalShapes() ; + + + TopoDS_Face myFace; +}; + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.cxx new file mode 100644 index 000000000..ecccd52a2 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.cxx @@ -0,0 +1,133 @@ +// 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_BuilderShape.cxx +// Created: +// Author: Peter KURNEV +// +#include +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_BuilderShape::GEOMAlgo_BuilderShape() +: + GEOMAlgo_Algo() +{ + myHasDeleted=Standard_False; + myHasGenerated=Standard_False; + myHasModified=Standard_False; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_BuilderShape::~GEOMAlgo_BuilderShape() +{ +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + const TopoDS_Shape& GEOMAlgo_BuilderShape::Shape() const +{ + return myShape; +} +// +//======================================================================= +//function : Generated +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_BuilderShape::Generated(const TopoDS_Shape& ) +{ + myHistShapes.Clear(); + return myHistShapes; +} +//======================================================================= +//function : Modified +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_BuilderShape::Modified(const TopoDS_Shape& ) +{ + myHistShapes.Clear(); + return myHistShapes; +} +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_BuilderShape::IsDeleted(const TopoDS_Shape& theS) +{ + Standard_Boolean bRet; + // + bRet=!myMapShape.Contains(theS); + return bRet; +} +//======================================================================= +//function : HasDeleted +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_BuilderShape::HasDeleted()const +{ + return myHasDeleted; +} +//======================================================================= +//function : HasGenerated +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_BuilderShape::HasGenerated()const +{ + return myHasGenerated; +} +//======================================================================= +//function : HasModified +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_BuilderShape::HasModified()const +{ + return myHasModified; +} +//======================================================================= +//function : PrepareHistory +//purpose : +//======================================================================= + void GEOMAlgo_BuilderShape::PrepareHistory() +{ + myHistShapes.Clear(); + myMapShape.Clear(); + myHasDeleted=Standard_False; + myHasGenerated=Standard_False; + myHasModified=Standard_False; + //modified by NIZNHY-PKV Thu Dec 7 11:14:15 2006 + myImagesResult.Clear(); + //modified by NIZNHY-PKV Thu Dec 7 11:14:17 2006t +} +//modified by NIZNHY-PKV Thu Dec 7 11:57:00 2006f +//======================================================================= +//function : ImagesResult +//purpose : +//======================================================================= + const TopTools_IndexedDataMapOfShapeListOfShape& GEOMAlgo_BuilderShape::ImagesResult()const +{ + return myImagesResult; +} +//modified by NIZNHY-PKV Thu Dec 7 11:57:04 2006t diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.hxx new file mode 100644 index 000000000..58580489c --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderShape.hxx @@ -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 +// + +// File: GEOMAlgo_BuilderShape.hxx +// Created: +// Author: Peter KURNEV +// +#ifndef _GEOMAlgo_BuilderShape_HeaderFile +#define _GEOMAlgo_BuilderShape_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + + +//! Root class for algorithms that has shape as result
+//======================================================================= +//class : GEOMAlgo_BuilderShape +//purpose : +//======================================================================= +class GEOMAlgo_BuilderShape : public GEOMAlgo_Algo +{ + public: + //! Returns the result of algorithm
+ Standard_EXPORT + const TopoDS_Shape& Shape() const; + + //! Returns the list of shapes generated from the
+ //! shape theS.
+ Standard_EXPORT + virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ; + + //! Returns the list of shapes modified from the
+ //! shape theS.
+ Standard_EXPORT + virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ; + + //! Returns true if the shape theS has been deleted.
+ Standard_EXPORT + virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ; + + //! Returns true if the at least one shape(or sub-shape)
+ //! of arguments has been deleted.
+ Standard_EXPORT + Standard_Boolean HasDeleted() const; + + //! Returns true if the at least one shape(or sub-shape)
+ //! of arguments has generated shapes.
+ Standard_EXPORT + Standard_Boolean HasGenerated() const; + + //! Returns true if the at least one shape(or sub-shape)
+ //! of arguments has modified shapes.
+ Standard_EXPORT + Standard_Boolean HasModified() const; + + Standard_EXPORT + const TopTools_IndexedDataMapOfShapeListOfShape& ImagesResult() const; + +protected: + //! Empty constructor
+ Standard_EXPORT + GEOMAlgo_BuilderShape(); + + Standard_EXPORT + virtual ~GEOMAlgo_BuilderShape(); + + //! Prepare information for history support
+ Standard_EXPORT + virtual void PrepareHistory() ; + + + TopoDS_Shape myShape; + TopTools_ListOfShape myHistShapes; + TopTools_MapOfShape myMapShape; + Standard_Boolean myHasDeleted; + Standard_Boolean myHasGenerated; + Standard_Boolean myHasModified; + TopTools_IndexedDataMapOfShapeListOfShape myImagesResult; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.cxx new file mode 100644 index 000000000..fe5b1d554 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.cxx @@ -0,0 +1,914 @@ +// 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_BuilderSolid.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 +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +// +static + Standard_Boolean IsGrowthShell(const TopoDS_Shape& , + const TopTools_IndexedMapOfShape& ); +static + Standard_Boolean IsHole(const TopoDS_Shape& , + const Handle(IntTools_Context)& ); +static + Standard_Boolean IsInside(const TopoDS_Shape& , + const TopoDS_Shape& , + const Handle(IntTools_Context)& ); +static + void MakeInternalShells(const TopTools_MapOfShape& , + TopTools_ListOfShape& ); + +static + Standard_Boolean IsClosedShell(const TopoDS_Shell& ); + +static + Standard_Boolean RefineShell(const TopoDS_Shell& , + TopoDS_Shell& ); + +//======================================================================= +//function : +//purpose : +//======================================================================= +GEOMAlgo_BuilderSolid::GEOMAlgo_BuilderSolid() +: + GEOMAlgo_BuilderArea() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_BuilderSolid::~GEOMAlgo_BuilderSolid() +{ +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_BuilderSolid::Perform() +{ + myErrorStatus=0; + // + // Initialize the context + GEOMAlgo_BuilderArea::Perform(); + // + TopoDS_Compound aC; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aIt; + + aBB.MakeCompound(aC); + aIt.Initialize(myShapes); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aBB.Add(aC, aF); + } + // + PerformShapesToAvoid(); + if (myErrorStatus) { + return; + } + // + PerformLoops(); + if (myErrorStatus) { + return; + } + PerformAreas(); + if (myErrorStatus) { + return; + } + if (myComputeInternalShapes) { + PerformInternalShapes(); + if (myErrorStatus) { + return; + } + } +} +//======================================================================= +//function :PerformShapesToAvoid +//purpose : +//======================================================================= +void GEOMAlgo_BuilderSolid::PerformShapesToAvoid() +{ + Standard_Boolean bFound; + Standard_Integer i, iCnt, aNbE, aNbF; + TopAbs_Orientation aOrE; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + TopTools_ListIteratorOfListOfShape aIt; + // + myShapesToAvoid.Clear(); + // + iCnt=0; + while (1) { + ++iCnt; + bFound=Standard_False; + // + // 1. MEF + aMEF.Clear(); + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (!myShapesToAvoid.Contains(aF)) { + TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + /* + else { + int a=0; + } + */ + } + aNbE=aMEF.Extent(); + // + // 2. myFacesToAvoid + for (i=1; i<=aNbE; ++i) { + const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aMEF.FindKey(i))); + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + TopTools_ListOfShape& aLF=aMEF.ChangeFromKey(aE); + // + aNbF=aLF.Extent(); + if (!aNbF) { + continue; + } + // + aOrE=aE.Orientation(); + // + const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First())); + if (aNbF==1) { + if (aOrE==TopAbs_INTERNAL) { + continue; + } + bFound=Standard_True; + myShapesToAvoid.Add(aF1); + } + else if (aNbF==2) { + const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last())); + if (aF2.IsSame(aF1)) { + if (BRep_Tool::IsClosed(aE, aF1)) { + continue; + } + // + if (aOrE==TopAbs_INTERNAL) { + continue; + } + // + bFound=Standard_True; + myShapesToAvoid.Add(aF1); + myShapesToAvoid.Add(aF2); + } + } + /*//DEB + else { + TopTools_ListIteratorOfListOfShape aItLF; + // + aItLF.Initialize (aLF); + for (; aItLF.More(); aItLF.Next()) { + const TopoDS_Shape& aFx=aItLF.Value(); + int a=0; + } + } + *///DEB + }// for (i=1; i<=aNbE; ++i) { + // + if (!bFound) { + break; + } + // + }//while (1) +} +//======================================================================= +//function : PerformLoops +//purpose : +//======================================================================= +void GEOMAlgo_BuilderSolid::PerformLoops() +{ + myErrorStatus=0; + // + myLoops.Clear(); + // + Standard_Integer aNbLF, aNbOff, aNbFP; + TopAbs_Orientation anOr; + TopoDS_Edge aEL; + BRep_Builder aBB; + NMTTools_CoupleOfShape aCSOff; + TopTools_MapOfOrientedShape AddedFacesMap; + TopTools_IndexedDataMapOfShapeListOfShape aEFMap, aMEFP; + TopTools_ListIteratorOfListOfShape aItF, aIt; + TopTools_MapIteratorOfMapOfOrientedShape aItM; + TopoDS_Iterator aItS; + // + //================================================= + // + // 1. Shells Usual + // + aItF.Initialize (myShapes); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Shape& aFF = aItF.Value(); + TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap); + } + // + aItF.Initialize (myShapes); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Shape& aFF = aItF.Value(); + if (myShapesToAvoid.Contains(aFF)) { + continue; + } + if (!AddedFacesMap.Add(aFF)) { + continue; + } + // + // make a new shell + TopoDS_Shell aShell; + aBB.MakeShell(aShell); + aBB.Add(aShell, aFF); + // + aMEFP.Clear(); + TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aMEFP); + // + // loop on faces added to Shell; add their neighbor faces to Shell and so on + TopoDS_Iterator aItAddedF (aShell); + for (; aItAddedF.More(); aItAddedF.Next()) { + const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value())); + // + // loop on edges of aF; find a good neighbor face of aF by aE + TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE); + for (; aEdgeExp.More(); aEdgeExp.Next()) { + const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aEdgeExp.Current())); + // + //1 + if (aMEFP.Contains(aE)) { + const TopTools_ListOfShape& aLFP=aMEFP.FindFromKey(aE); + aNbFP=aLFP.Extent(); + if (aNbFP>1) { + continue; + } + } + //2 + anOr=aE.Orientation(); + if (anOr==TopAbs_INTERNAL) { + continue; + } + //3 + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + // candidate faces list + const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE); + aNbLF=aLF.Extent(); + if (!aNbLF) { + continue; + } + // + // try to select one of neighbors + // check if a face already added to Shell shares E + Standard_Boolean bFound; + TopTools_ListIteratorOfListOfShape aItLF; + NMTTools_ListOfCoupleOfShape aLCSOff; + // + aItLF.Initialize(aLF); + for (; aItLF.More(); aItLF.Next()) { + const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItLF.Value())); + if (myShapesToAvoid.Contains(aFL)) { + continue; + } + if (aF.IsSame(aFL)) { + continue; + } + if (AddedFacesMap.Contains(aFL)){ + continue; + } + // + bFound=GEOMAlgo_Tools3D::GetEdgeOff(aE, aFL, aEL); + if (!bFound) { + continue; + } + // + aCSOff.SetShape1(aEL); + aCSOff.SetShape2(aFL); + aLCSOff.Append(aCSOff); + }//for (; aItLF.More(); aItLF.Next()) { + // + aNbOff=aLCSOff.Extent(); + if (!aNbOff){ + continue; + } + // + TopoDS_Face aSelF; + if (aNbOff==1) { + aSelF=*((TopoDS_Face*)(&aLCSOff.First().Shape2())); + } + else if (aNbOff>1){ + GEOMAlgo_Tools3D::GetFaceOff(aE, aF, aLCSOff, aSelF); + } + // + if (!aSelF.IsNull() && AddedFacesMap.Add(aSelF)) { + aBB.Add(aShell, aSelF); + TopExp::MapShapesAndAncestors(aSelF, TopAbs_EDGE, TopAbs_FACE, aMEFP); + } + } // for (; aEdgeExp.More(); aEdgeExp.Next()) { + } //for (; aItAddedF.More(); aItAddedF.Next()) { + // + if (IsClosedShell(aShell)) { + myLoops.Append(aShell); + } + //modified by NIZNHY-PKV Wed Oct 27 07:10:41 2010f + else { + Standard_Boolean bRefine; + TopoDS_Shell aShx; + // + bRefine=RefineShell(aShell, aShx); + if (bRefine) { + myLoops.Append(aShx); + } + } + //modified by NIZNHY-PKV Wed Oct 27 07:10:44 2010t + } // for (; aItF.More(); aItF.Next()) { + // + // Post Treatment + TopTools_MapOfOrientedShape aMP; + // + // a. collect all edges that are in loops + aIt.Initialize (myLoops); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aItS.Initialize(aS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aF=aItS.Value(); + aMP.Add(aF); + } + } + // + // b. collect all faces that are to avoid + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + aMP.Add(aF); + } + // + // c. add all faces that are not processed to myShapesToAvoid + aIt.Initialize (myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (!aMP.Contains(aF)) { + myShapesToAvoid.Add(aF); + } + } + //================================================= + // + // 2.Internal Shells + // + myLoopsInternal.Clear(); + // + aEFMap.Clear(); + AddedFacesMap.Clear(); + // + if (myComputeInternalShapes) { + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aFF=aItM.Key(); + TopExp::MapShapesAndAncestors(aFF, TopAbs_EDGE, TopAbs_FACE, aEFMap); + } + // + aItM.Initialize(myShapesToAvoid); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aFF=aItM.Key(); + if (!AddedFacesMap.Add(aFF)) { + continue; + } + // + // make a new shell + TopoDS_Shell aShell; + aBB.MakeShell(aShell); + aBB.Add(aShell, aFF); + // + TopoDS_Iterator aItAddedF (aShell); + for (; aItAddedF.More(); aItAddedF.Next()) { + const TopoDS_Face& aF = *((TopoDS_Face*)(&aItAddedF.Value())); + // + TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE); + for (; aEdgeExp.More(); aEdgeExp.Next()) { + const TopoDS_Edge& aE = *((TopoDS_Edge*)(&aEdgeExp.Current())); + const TopTools_ListOfShape& aLF=aEFMap.FindFromKey(aE); + aItF.Initialize(aLF); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Face& aFL=*((TopoDS_Face*)(&aItF.Value())); + if (AddedFacesMap.Add(aFL)){ + aBB.Add(aShell, aFL); + } + } + } + } + myLoopsInternal.Append(aShell); + } + } +} +//======================================================================= +//function : PerformAreas +//purpose : +//======================================================================= +void GEOMAlgo_BuilderSolid::PerformAreas() +{ + myErrorStatus=0; + // + Standard_Boolean bIsGrowthShell, bIsHole; + TopTools_ListOfShape aNewSolids, aHoleShells; + TopoDS_Shape anInfinitePointShape; + TopTools_DataMapOfShapeShape aInOutMap; + TopTools_DataMapOfShapeListOfShape aMSH; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH; + TopTools_ListIteratorOfListOfShape aShellIt, aSolidIt; + TopTools_IndexedMapOfShape aMHF; + BRep_Builder aBB; + // + myAreas.Clear(); + // + // Draft solids [aNewSolids] + aShellIt.Initialize(myLoops); + for ( ; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aShell = aShellIt.Value(); + // + bIsGrowthShell=IsGrowthShell(aShell, aMHF); + if (bIsGrowthShell) { + // make a growth solid from a shell + TopoDS_Solid Solid; + aBB.MakeSolid(Solid); + aBB.Add (Solid, aShell); + // + aNewSolids.Append (Solid); + } + else{ + // check if a shell is a hole + bIsHole=IsHole(aShell, myContext); + // + if (bIsHole) { + aHoleShells.Append(aShell); + TopExp::MapShapes(aShell, TopAbs_FACE, aMHF); + } + else { + // make a growth solid from a shell + TopoDS_Solid Solid; + aBB.MakeSolid(Solid); + aBB.Add (Solid, aShell); + // + aNewSolids.Append (Solid); + } + } + } + // + // 2. Find outer growth shell that is most close to each hole shell + aShellIt.Initialize(aHoleShells); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aHole = aShellIt.Value(); + // + aSolidIt.Initialize(aNewSolids); + for ( ; aSolidIt.More(); aSolidIt.Next()) { + const TopoDS_Shape& aSolid = aSolidIt.Value(); + // + if (!IsInside(aHole, aSolid, myContext)){ + continue; + } + // + if ( aInOutMap.IsBound (aHole)){ + const TopoDS_Shape& aSolid2 = aInOutMap(aHole); + if (IsInside(aSolid, aSolid2, myContext)) { + aInOutMap.UnBind(aHole); + aInOutMap.Bind (aHole, aSolid); + } + } + else{ + aInOutMap.Bind (aHole, aSolid); + } + } + // + // Add aHole to a map Solid/ListOfHoles [aMSH] + if (aInOutMap.IsBound(aHole)){ + const TopoDS_Shape& aSolid=aInOutMap(aHole); + if (aMSH.IsBound(aSolid)) { + TopTools_ListOfShape& aLH=aMSH.ChangeFind(aSolid); + aLH.Append(aHole); + } + else { + TopTools_ListOfShape aLH; + aLH.Append(aHole); + aMSH.Bind(aSolid, aLH); + } + //aBB.Add (aSolid, aHole); + } + }// for (; aShellIt.More(); aShellIt.Next()) { + // + // 3. Add aHoles to Solids + aItMSH.Initialize(aMSH); + for (; aItMSH.More(); aItMSH.Next()) { + TopoDS_Solid aSolid=*((TopoDS_Solid*)(&aItMSH.Key())); + // + const TopTools_ListOfShape& aLH=aItMSH.Value(); + aShellIt.Initialize(aLH); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aHole = aShellIt.Value(); + aBB.Add (aSolid, aHole); + } + // + // update classifier + BRepClass3d_SolidClassifier& aSC=myContext->SolidClassifier(aSolid); + aSC.Load(aSolid); + // + } + // + // These aNewSolids are draft solids that + // do not contain any internal shapes + // + myAreas.Append(aNewSolids); +} +//======================================================================= +//function : PerformInternalShapes +//purpose : +//======================================================================= +void GEOMAlgo_BuilderSolid::PerformInternalShapes() +{ + myErrorStatus=0; + // + Standard_Integer aNbFI=myLoopsInternal.Extent(); + if (!aNbFI) {// nothing to do + return; + } + // + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aShellIt, aSolidIt; + TopoDS_Iterator aIt; + TopTools_MapOfShape aMF, aMFP; + TopTools_MapIteratorOfMapOfShape aItMF; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + TopTools_ListOfShape aLSI; + // + // 1. All internal faces + aShellIt.Initialize(myLoopsInternal); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aShell=aShellIt.Value(); + aIt.Initialize(aShell); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMF.Add(aF); + } + } + aNbFI=aMF.Extent(); + // + // 2 Process solids + aSolidIt.Initialize(myAreas); + for ( ; aSolidIt.More(); aSolidIt.Next()) { + TopoDS_Solid& aSolid=*((TopoDS_Solid*)(&aSolidIt.Value())); + // + aMEF.Clear(); + TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMEF); + // + // 2.1 Separate faces to process aMFP + aMFP.Clear(); + aItMF.Initialize(aMF); + for (; aItMF.More(); aItMF.Next()) { + const TopoDS_Face& aF=*((TopoDS_Face*)(&aItMF.Key())); + if (GEOMAlgo_Tools3D::IsInternalFace(aF, aSolid, aMEF, 1.e-14, myContext)) { + aMFP.Add(aF); + } + } + // + // 2.2 Make Internal Shells + aLSI.Clear(); + MakeInternalShells(aMFP, aLSI); + // + // 2.3 Add them to aSolid + aShellIt.Initialize(aLSI); + for (; aShellIt.More(); aShellIt.Next()) { + const TopoDS_Shape& aSI=aShellIt.Value(); + aBB.Add (aSolid, aSI); + } + // + // 2.4 Remove faces aMFP from aMF + aItMF.Initialize(aMFP); + for (; aItMF.More(); aItMF.Next()) { + const TopoDS_Shape& aF=aItMF.Key(); + aMF.Remove(aF); + } + // + aNbFI=aMF.Extent(); + if (!aNbFI) { + break; + } + } //for ( ; aSolidIt.More(); aSolidIt.Next()) { +} + +//======================================================================= +//function : MakeInternalShells +//purpose : +//======================================================================= +void MakeInternalShells(const TopTools_MapOfShape& theMF, + TopTools_ListOfShape& theShells) +{ + TopTools_MapIteratorOfMapOfShape aItM; + TopTools_MapOfShape aAddedFacesMap; + TopTools_ListIteratorOfListOfShape aItF; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + BRep_Builder aBB; + // + aItM.Initialize(theMF); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + // + aItM.Initialize(theMF); + for (; aItM.More(); aItM.Next()) { + TopoDS_Shape aFF=aItM.Key(); + if (!aAddedFacesMap.Add(aFF)) { + continue; + } + // + // make a new shell + TopoDS_Shell aShell; + aBB.MakeShell(aShell); + aFF.Orientation(TopAbs_INTERNAL); + aBB.Add(aShell, aFF); + // + TopoDS_Iterator aItAddedF (aShell); + for (; aItAddedF.More(); aItAddedF.Next()) { + const TopoDS_Shape& aF =aItAddedF.Value(); + // + TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE); + for (; aEdgeExp.More(); aEdgeExp.Next()) { + const TopoDS_Shape& aE =aEdgeExp.Current(); + const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE); + aItF.Initialize(aLF); + for (; aItF.More(); aItF.Next()) { + TopoDS_Shape aFL=aItF.Value(); + if (aAddedFacesMap.Add(aFL)){ + aFL.Orientation(TopAbs_INTERNAL); + aBB.Add(aShell, aFL); + } + } + } + } + theShells.Append(aShell); + } +} +//======================================================================= +//function : IsHole +//purpose : +//======================================================================= +Standard_Boolean IsHole(const TopoDS_Shape& theS2, + const Handle(IntTools_Context)& theContext) +{ + TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2; + BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2); + // + aClsf.PerformInfinitePoint(::RealSmall()); + // + return (aClsf.State()==TopAbs_IN); +} +//======================================================================= +//function : IsInside +//purpose : +//======================================================================= +Standard_Boolean IsInside(const TopoDS_Shape& theS1, + const TopoDS_Shape& theS2, + const Handle(IntTools_Context)& theContext) +{ + TopExp_Explorer aExp; + TopAbs_State aState; + // + TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2; + // + aExp.Init(theS1, TopAbs_FACE); + if (!aExp.More()){ + BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2); + aClsf.PerformInfinitePoint(::RealSmall()); + aState=aClsf.State(); + } + else { + TopTools_IndexedMapOfShape aBounds; + const TopoDS_Face& aF = TopoDS::Face(aExp.Current()); + aState=GEOMAlgo_Tools3D::ComputeState(aF, *pS2, 1.e-14, aBounds, theContext); + } + return (aState==TopAbs_IN); +} +//======================================================================= +//function : IsGrowthShell +//purpose : +//======================================================================= +Standard_Boolean IsGrowthShell(const TopoDS_Shape& theShell, + const TopTools_IndexedMapOfShape& theMHF) +{ + Standard_Boolean bRet; + TopoDS_Iterator aIt; + // + bRet=Standard_False; + if (theMHF.Extent()) { + aIt.Initialize(theShell); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (theMHF.Contains(aF)) { + return !bRet; + } + } + } + return bRet; +} +//======================================================================= +//function : IsClosedShell +//purpose : +//======================================================================= +Standard_Boolean IsClosedShell(const TopoDS_Shell& theShell) +{ + Standard_Integer aNbE; + Standard_Boolean bRet; + TopoDS_Iterator aIt; + TopExp_Explorer aExp; + TopTools_MapOfShape aM; + // + bRet=Standard_False; + aIt.Initialize(theShell); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Face& aF=TopoDS::Face(aIt.Value()); + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aExp.Current())); + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + if (aE.Orientation()==TopAbs_INTERNAL) { + continue; + } + // + if (!aM.Add(aE)) { + aM.Remove(aE); + } + } + } + // + aNbE=aM.Extent(); + if (!aNbE) { + bRet=!bRet; + } + return bRet; +} +//======================================================================= +//function : RefineShell +//purpose : +//======================================================================= + Standard_Boolean RefineShell(const TopoDS_Shell& aShell, + TopoDS_Shell& aShx) + +{ + Standard_Boolean bRet; + Standard_Integer i, aNbE, aNbF; + TopAbs_Orientation aOrE; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + TopTools_MapOfOrientedShape aMFx; + // + bRet=Standard_False; + // + TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF); + aNbE=aMEF.Extent(); + for (i=1; i<=aNbE; ++i) { + const TopoDS_Edge &aE=*((TopoDS_Edge*)(&aMEF.FindKey(i))); + // + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + aOrE=aE.Orientation(); + // + const TopTools_ListOfShape& aLF=aMEF(i); + aNbF=aLF.Extent(); + if (!aNbF) { + continue; + } + // + const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First())); + if (aNbF==1) { + if (aOrE==TopAbs_INTERNAL) { + continue; + } + aMFx.Add(aF1); + } + // + else if (aNbF==2) { + const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last())); + if (aF2.IsSame(aF1)) { + if (BRep_Tool::IsClosed(aE, aF1)) { + continue; + } + if (aOrE==TopAbs_INTERNAL) { + continue; + } + aMFx.Add(aF1); + aMFx.Add(aF2); + } + } + } + // + aNbF=aMFx.Extent(); + if (!aNbF) { + return bRet; + } + // + BRep_Builder aBB; + TopoDS_Iterator aIt; + // + aNbF=0; + aBB.MakeShell(aShx); + aIt.Initialize(aShell); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (!aMFx.Contains(aF)) { + aBB.Add(aShx, aF); + ++aNbF; + } + } + // + if (aNbF) { + bRet=IsClosedShell(aShx); + } + // + return bRet; +} +// +// ErrorStatus : +// 11 - Null Context diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.hxx new file mode 100644 index 000000000..4ba96d50f --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderSolid.hxx @@ -0,0 +1,77 @@ +// 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_BuilderSolid.hxx +// Created: +// Author: Peter KURNEV +// +#ifndef _GEOMAlgo_BuilderSolid_HeaderFile +#define _GEOMAlgo_BuilderSolid_HeaderFile + +#include +#include +#include + +//! The algorithm to build solids from set of faces
+//======================================================================= +//function : GEOMAlgo_BuilderSolid +//purpose : +//======================================================================= +class GEOMAlgo_BuilderSolid : public GEOMAlgo_BuilderArea +{ + public: + //! Empty constructor
+ Standard_EXPORT + GEOMAlgo_BuilderSolid(); + + Standard_EXPORT + virtual ~GEOMAlgo_BuilderSolid(); + + //! Performs the algorithm
+ Standard_EXPORT + virtual void Perform() ; + + protected: + //! Collect the faces that
+ //! a) are internal
+ //! b) are the same and have different orientation
+ Standard_EXPORT + virtual void PerformShapesToAvoid() ; + + //! Build draft shells
+ //! a)myLoops - draft shells that consist of
+ //! boundary faces
+ //! b)myLoopsInternal - draft shells that contains
+ //! inner faces
+ Standard_EXPORT + virtual void PerformLoops() ; + + //! Build draft solids that contains boundary faces
+ Standard_EXPORT + virtual void PerformAreas() ; + + //! Build finalized solids with internal shells
+ Standard_EXPORT + virtual void PerformInternalShapes() ; + +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.cxx new file mode 100644 index 000000000..a02db1146 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.cxx @@ -0,0 +1,291 @@ +// 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_BuilderTools.cxx +// Author: Peter KURNEV + +#include + +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version +#include +#include +#endif + +#include +#include +#include +#include +#include + +static + Standard_Integer ComputeProps(const TopoDS_Face& aF, + Standard_Real& aA, + Standard_Real& aV); +static + void BuildTriangulation(const TopoDS_Face& aF); + +//======================================================================= +//function : IsHole +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_BuilderTools::IsHole(const TopoDS_Shape& aW, + const TopoDS_Shape& aFace) +{ + Standard_Boolean bIsHole; + Standard_Integer i, aNbS; + Standard_Real aT1, aT2, aS; + Standard_Real aU1, aU2, aU, dU; + Standard_Real aX1, aY1, aX0, aY0; + TopAbs_Orientation aOr; + + gp_Pnt2d aP2D0, aP2D1; + Handle(Geom2d_Curve) aC2D; + TopoDS_Face aF, aFF; + TopoDS_Iterator aItW; + // + bIsHole=Standard_False; + // + aF=TopoDS::Face(aFace); + aFF=aF; + aFF.Orientation(TopAbs_FORWARD); + // + aS=0.; + aItW.Initialize(aW); + for (; aItW.More(); aItW.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aItW.Value()); + aOr=aE.Orientation(); + if (!(aOr==TopAbs_FORWARD || + aOr==TopAbs_REVERSED)) { + continue; + } + // + aC2D=BRep_Tool::CurveOnSurface(aE, aFF, aT1, aT2); + if (aC2D.IsNull()) { + break; //xx + } + // + BRepAdaptor_Curve2d aBAC2D(aE, aFF); + aNbS=Geom2dInt_Geom2dCurveTool::NbSamples(aBAC2D); + if (aNbS>2) { + aNbS*=4; + } + // + dU=(aT2-aT1)/(Standard_Real)(aNbS-1); + aU =aT1; + aU1=aT1; + aU2=aT2; + if (aOr==TopAbs_REVERSED) { + aU =aT2; + aU1=aT2; + aU2=aT1; + dU=-dU; + } + // + aC2D->D0(aU, aP2D0); + for(i=2; i<=aNbS; i++) { + aU=aU1+(i-1)*dU; + aC2D->D0(aU, aP2D1); + aP2D0.Coord(aX0, aY0); + aP2D1.Coord(aX1, aY1); + // + aS=aS+(aY0+aY1)*(aX1-aX0); + // + aP2D0=aP2D1; + } + }//for (; aItW.More(); aItW.Next()) { + bIsHole=(aS>0.); + return bIsHole; +} +//======================================================================= +//function : IsHole +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_BuilderTools::IsHole(const TopoDS_Shape& aShell) +{ + Standard_Boolean bIsHole; + Standard_Integer iRet; + Standard_Real aAi, aA, aV, aVi; + TopExp_Explorer aExp; + // + aA=0.; + aV=0.; + aExp.Init(aShell, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Face& aF=TopoDS::Face(aExp.Current()); + iRet=ComputeProps(aF, aAi, aVi); + if (!iRet) { + aA+=aAi; + aV+=aVi; + } + } + // + bIsHole=aV<0.; + return bIsHole; +} +//======================================================================= +//function : ComputeProps +//purpose : +//======================================================================= +Standard_Integer ComputeProps(const TopoDS_Face& aF, + Standard_Real& aA, + Standard_Real& aV) +{ + Standard_Integer j, i, i1, i2, aNbNodes, aNbTrigs, n[3]; + Standard_Real aAi, aVi; + gp_Pnt aP[3], aGC, aGC1; + TopLoc_Location aLoc; + TopAbs_Orientation aOr; + Handle(Poly_Triangulation) aTri; + // + aA=0.; + aV=0.; + // + aTri=BRep_Tool::Triangulation(aF, aLoc); + if(aTri.IsNull()) { + BuildTriangulation(aF); + aTri=BRep_Tool::Triangulation(aF, aLoc); + if(aTri.IsNull()) { + return 1;// a face is without triangulation + } + } + // + aNbNodes=aTri->NbNodes(); + aNbTrigs=aTri->NbTriangles(); + if (!aNbTrigs){ + return 2;//no triangles + } + // + aOr=aF.Orientation(); + // + const TColgp_Array1OfPnt& aNodes=aTri->Nodes(); + const Poly_Array1OfTriangle& aTriangles=aTri->Triangles(); + // + i1=aTriangles.Lower(); + i2=aTriangles.Upper(); + // + for (i=i1; i<=i2; ++i){ + const Poly_Triangle& aTriangle=aTriangles.Value(i); + aTriangle.Get(n[0], n[1], n[2]); + aGC.SetCoord(0.,0.,0.); + for (j=0; j<3; ++j) { + aP[j]=aNodes.Value(n[j]); + aGC.ChangeCoord()+=aP[j].XYZ(); + } + aGC.ChangeCoord()*=0.333333333333; + // + // Normal + gp_Vec aV01(aP[0], aP[1]); + gp_Vec aV12(aP[1], aP[2]); + gp_Vec aVN=aV01^aV12; + aAi=aVN.Magnitude(); + aA=aA+aAi; + // + if (aAi>0.0000001) { + Standard_Real aSx, aZx; + gp_Dir aDN(aVN); + if (aOr==TopAbs_REVERSED) { + aDN.Reverse(); + } + // + aSx=aAi*aDN.Z(); + aZx=aGC.Z(); + aVi=aZx*aSx; + aV=aV+aVi; + } + } + return 0; +} +//======================================================================= +//function : BuildTriangulation +//purpose : +//======================================================================= +void BuildTriangulation(const TopoDS_Face& aF) +{ + Standard_Boolean bWithShare; + Standard_Real aDiscret, aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; + Standard_Real dX, dY, dZ, dMax, aCoeff, aAngle; + Bnd_Box aBox; + // + bWithShare=Standard_False; + aAngle=0.5; + // + BRepBndLib::Add(aF, aBox); + // + // aDiscret + aBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + dX=aXmax-aXmin; + dY=aYmax-aYmin; + dZ=aZmax-aZmin; + dMax=dX; + if (dY>dMax) { + dMax=dY; + } + if (dZ>dMax) { + dMax=dZ; + } + // + aCoeff=0.1; + aDiscret=aCoeff*dMax; + // + BRepMesh_FastDiscret aMesher(aDiscret, + aAngle, + aBox, + bWithShare, + Standard_True, + Standard_False, + Standard_True); + +#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version + TopTools_IndexedDataMapOfShapeListOfShape anAncestors; + TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, anAncestors); + aMesher.Add(aF, anAncestors); +#else + aMesher.Add(aF); +#endif +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.hxx new file mode 100644 index 000000000..892f7753b --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_BuilderTools.hxx @@ -0,0 +1,47 @@ +// 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_BuilderTools.hxx +// Author: Peter KURNEV + +#ifndef _GEOMAlgo_BuilderTools_HeaderFile +#define _GEOMAlgo_BuilderTools_HeaderFile + +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_BuilderTools +//purpose : +//======================================================================= +class GEOMAlgo_BuilderTools +{ + public: + Standard_EXPORT + static Standard_Boolean IsHole(const TopoDS_Shape& aW, + const TopoDS_Shape& aF) ; + + Standard_EXPORT + static Standard_Boolean IsHole(const TopoDS_Shape& aShell) ; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Builder_0.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_0.cxx new file mode 100644 index 000000000..bd7594caf --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_0.cxx @@ -0,0 +1,64 @@ +// 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 + +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : Shapes1 +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_Builder::Shapes1(const Standard_Integer theType)const +{ + return myShapes1[theType]; +} +//======================================================================= +//function : Images +//purpose : +//======================================================================= + const BRepAlgo_Image& GEOMAlgo_Builder::Images()const +{ + return myImages; +} +//======================================================================= +//function : InParts +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_Builder::InParts(const TopoDS_Shape& theS)const +{ + static TopTools_ListOfShape sLS; + // + if (myInParts.Contains(theS)) { + return myInParts.FindFromKey(theS); + } + return sLS; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Builder_1.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_1.cxx new file mode 100644 index 000000000..d033afd26 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_1.cxx @@ -0,0 +1,360 @@ +// 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_Builder_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 + + + +static + void FillImagesCompounds(const TopTools_MapOfShape& , + BRepAlgo_Image& ); + +static + void FillImagesCompound(const TopoDS_Shape& , + BRepAlgo_Image& , + TopTools_MapOfShape& ); + +//======================================================================= +//function : FillImagesVertices +//purpose : +//======================================================================= + void GEOMAlgo_Builder::FillImagesVertices() +{ + myErrorStatus=0; + // + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + // + Standard_Integer i, aNb, iV; + // + aNb=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aV=aDS.Shape(i); + if (aV.ShapeType()==TopAbs_VERTEX) { + iV=pPF->FindSDVertex(i); + if (iV) { + const TopoDS_Shape& aVSD=aDS.Shape(iV); + if (!myImages.HasImage(aV)) { + myImages.Bind(aV, aVSD); + // + mySameDomainShapes.Add(aV, aVSD); + } + } + } + } +} +//======================================================================= +// function: FillImagesEdges +// purpose: +//======================================================================= + void GEOMAlgo_Builder::FillImagesEdges() +{ + myErrorStatus=0; + // + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + const BOPTools_SplitShapesPool& aSSP=pPF->SplitShapesPool(); + const Handle(IntTools_Context)& aCtx=pPF->Context(); + // + Standard_Boolean bToReverse; + Standard_Integer i, aNb, aNbSp, nSp, nSpR, nSpx, aIsCB, aNbLB; + TColStd_ListIteratorOfListOfInteger aItLB; + TColStd_ListOfInteger aLB; + TopoDS_Edge aEE, aESpR; + TopTools_MapOfShape aMFence; + TopTools_ListOfShape aLSp; + TopTools_ListIteratorOfListOfShape aIt1; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + // + aNb=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aE=aDS.Shape(i); + if (aE.ShapeType()!=TopAbs_EDGE) { + continue; + } + // + if (!aMFence.Add(aE)) { + continue; + } + // + const BOPTools_ListOfPaveBlock& aLPB=aSSP(aDS.RefEdge(i)); + aNbSp=aLPB.Extent(); + if (!aNbSp) { + continue; + } + // + aEE=TopoDS::Edge(aE); + aLSp.Clear(); + // + if (aNbSp==1) { + const BOPTools_PaveBlock& aPB=aLPB.First(); + nSp=aPB.Edge(); + const TopoDS_Shape& aSp=aDS.Shape(nSp); + // + const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB); + //modified by NIZNHY-PKV Wed Oct 27 11:19:30 2010f + aNbLB=aLB.Extent(); + if (aIsCB && aNbLB<2) { + aIsCB=0; + } + //modified by NIZNHY-PKV Wed Oct 27 11:19:34 2010t + // + nSpR=aPBR.Edge(); + const TopoDS_Shape& aSpR=aDS.Shape(nSpR); + if (aSpR.IsSame(aSp) && aSpR.IsSame(aE) && !aIsCB) { + continue; + } + // + aESpR=TopoDS::Edge(aSpR); + bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aESpR, aEE, aCtx); + if (bToReverse) { + aESpR.Reverse(); + } + aLSp.Append(aESpR); + // + aItLB.Initialize(aLB); + for (; aItLB.More(); aItLB.Next()) { + nSpx=aItLB.Value(); + const TopoDS_Shape& aSpx=aDS.Shape(nSpx); + mySameDomainShapes.Add(aSpx ,aSpR); + } + // + // + }// if (aNbSp==1) { + else { + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + const BOPTools_PaveBlock& aPBR=pPF->RealPaveBlock(aPB, aLB, aIsCB); + nSpR=aPBR.Edge(); + const TopoDS_Shape& aSpR=aDS.Shape(nSpR); + // + aESpR=TopoDS::Edge(aSpR); + bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aESpR, aEE, aCtx); + if (bToReverse) { + aESpR.Reverse(); + } + aLSp.Append(aESpR); + // + aItLB.Initialize(aLB); + for (; aItLB.More(); aItLB.Next()) { + nSpx=aItLB.Value(); + const TopoDS_Shape& aSpx=aDS.Shape(nSpx); + mySameDomainShapes.Add(aSpx ,aSpR); + } + } + } + // + myImages.Bind(aE, aLSp); + + }//for (i=1; i<=aNb; ++i) +} +//======================================================================= +// function: FillImagesContainers +// purpose: +//======================================================================= + void GEOMAlgo_Builder::FillImagesContainers(const TopAbs_ShapeEnum theType) +{ + myErrorStatus=0; + // + Standard_Boolean bInterferred, bToReverse; + Standard_Integer i, aNbS; + TopAbs_ShapeEnum aType; + BRep_Builder aBB; + TopoDS_Iterator aIt; + TopTools_ListIteratorOfListOfShape aItIm; + TopTools_MapOfShape aMS; + TopTools_MapIteratorOfMapOfShape aItS; + // + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + const Handle(IntTools_Context)& aCtx= pPF->Context(); + // + aNbS=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aC=aDS.Shape(i); + aType=aC.ShapeType(); + if (aType==theType) { + aMS.Add(aC); + } + } + // + if (theType==TopAbs_COMPOUND) { + FillImagesCompounds(aMS, myImages); + return; + } + // + aItS.Initialize(aMS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aC=aItS.Key(); + // whether the shape has image + bInterferred=Standard_False; + aIt.Initialize(aC); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (myImages.HasImage(aF)) { + bInterferred=!bInterferred; + break; + } + } + if (!bInterferred){ + continue; + } + // + TopoDS_Shape aCIm; + GEOMAlgo_Tools3D::MakeContainer(theType, aCIm); + // + aIt.Initialize(aC); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + if (myImages.HasImage(aF)) { + const TopTools_ListOfShape& aLFIm=myImages.Image(aF); + aItIm.Initialize(aLFIm); + for (; aItIm.More(); aItIm.Next()) { + TopoDS_Shape aFIm=aItIm.Value(); + // + bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFIm, aF, aCtx); + if (bToReverse) { + aFIm.Reverse(); + } + aBB.Add(aCIm, aFIm); + } + } + else { + aBB.Add(aCIm, aF); + } + } + myImages.Bind(aC, aCIm); + }// for (; aItS.More(); aItS.Next()) { +} +//======================================================================= +// function: FillImagesCompounds +// purpose: +//======================================================================= +void FillImagesCompounds(const TopTools_MapOfShape& theMS, + BRepAlgo_Image& theImages) +{ + TopTools_MapOfShape aMFP; + TopTools_MapIteratorOfMapOfShape aItS; + // + aItS.Initialize(theMS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aC=aItS.Key(); + FillImagesCompound(aC, theImages, aMFP); + } +} +//======================================================================= +//function : FillImagesCompound +//purpose : +//======================================================================= +void FillImagesCompound(const TopoDS_Shape& theS, + BRepAlgo_Image& theImages, + TopTools_MapOfShape& theMFP) +{ + Standard_Boolean bInterferred; + TopAbs_ShapeEnum aTypeX; + TopAbs_Orientation aOrX; + TopoDS_Iterator aIt; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aItIm; + // + if (!theMFP.Add(theS)) { + return; + } + // + bInterferred=Standard_False; + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSX=aIt.Value(); + aTypeX=aSX.ShapeType(); + if (aTypeX==TopAbs_COMPOUND) { + FillImagesCompound(aSX, theImages, theMFP); + } + if (theImages.HasImage(aSX)) { + bInterferred=Standard_True; + } + } + if (!bInterferred){ + return; + } + // + TopoDS_Shape aCIm; + GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCIm); + // + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSX=aIt.Value(); + aOrX=aSX.Orientation(); + if (theImages.HasImage(aSX)) { + const TopTools_ListOfShape& aLFIm=theImages.Image(aSX); + aItIm.Initialize(aLFIm); + for (; aItIm.More(); aItIm.Next()) { + TopoDS_Shape aSXIm=aItIm.Value(); + aSXIm.Orientation(aOrX); + aBB.Add(aCIm, aSXIm); + } + } + else { + aBB.Add(aCIm, aSX); + } + } + theImages.Bind(theS, aCIm); +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Builder_2.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_2.cxx new file mode 100644 index 000000000..7a3fa9be0 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_2.cxx @@ -0,0 +1,947 @@ +// 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_Builder_2.cxx +// 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 +#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 +#include +#include + +static + void UpdateCandidates(const Standard_Integer , + const Standard_Integer , + NMTTools_IndexedDataMapOfIndexedMapOfInteger& ); + + +//======================================================================= +//function : FillImagesFaces +//purpose : +//======================================================================= +void GEOMAlgo_Builder::FillImagesFaces() +{ + myErrorStatus=0; + // + FillIn2DParts(); + BuildSplitFaces(); + FillSameDomainFaces(); + FillImagesFaces1(); + FillInternalVertices(); +} + +//======================================================================= +// function: FillIn2DParts +// purpose: +//======================================================================= +void GEOMAlgo_Builder::FillIn2DParts() +{ + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + NMTDS_InterfPool* pIP=pPF->IP(); + BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences(); + NMTTools_CommonBlockPool& aCBP=pPF->ChangeCommonBlockPool(); + // + Standard_Integer j, nSpIn, nSpSc, aNbCurves; + Standard_Integer aNbS, nF, aNbCBP, n1, n2, aNbFFs, aNbSpIn; + TopTools_MapOfShape aMFence; + TopTools_ListOfShape aLSpIn; + TopoDS_Face aF; + NMTTools_ListIteratorOfListOfCommonBlock aItCB; + BOPTools_ListIteratorOfListOfPaveBlock aItPB; + // + myInParts.Clear(); + // + aNbFFs=aFFs.Extent(); + aNbCBP=aCBP.Extent(); + // + aNbS=aDS.NumberOfShapesOfTheObject(); + for (nF=1; nF<=aNbS; ++nF) { + if (aDS.GetShapeType(nF)!=TopAbs_FACE) { + continue; + } + // + aF=TopoDS::Face(aDS.Shape(nF)); + // + aMFence.Clear(); + aLSpIn.Clear(); + // + // 1. In Parts + BOPTools_ListOfPaveBlock aLPBIn; + // + pPF->RealSplitsInFace(nF, aLPBIn); + // + aItPB.Initialize(aLPBIn); + for (; aItPB.More(); aItPB.Next()) { + const BOPTools_PaveBlock& aPB1=aItPB.Value(); + nSpIn=aPB1.Edge(); + const TopoDS_Shape& aSpIn=aDS.Shape(nSpIn); + aLSpIn.Append(aSpIn); + } + // + // 2. Section Parts + for (j=1; j<=aNbFFs; ++j) { + BOPTools_SSInterference& aFF=aFFs(j); + aFF.Indices(n1, n2); + if (!(n1==nF || n2==nF)) { + continue; + } + BOPTools_SequenceOfCurves& aSC=aFF.Curves(); + aNbCurves=aSC.Length(); + if (!aNbCurves) { + continue; + } + // + const BOPTools_Curve& aBC=aSC(1); + const BOPTools_ListOfPaveBlock& aLPB=aBC.NewPaveBlocks(); + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + const BOPTools_PaveBlock& aPBSc=aItPB.Value(); + nSpSc=aPBSc.Edge(); + const TopoDS_Shape& aSpSc=aDS.Shape(nSpSc); + if (aMFence.Add(aSpSc)){ + aLSpIn.Append(aSpSc); + } + } + } + aNbSpIn=aLSpIn.Extent(); + if (aNbSpIn) { + myInParts.Add(aF, aLSpIn); + } + }//for (nF=1; nF<=aNbS; ++nF) { +} + +//======================================================================= +// function: BuildSplitFaces +// purpose: +//======================================================================= +void GEOMAlgo_Builder::BuildSplitFaces() +{ + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + NMTDS_InterfPool* pIP=pPF->IP(); + BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences(); + const Handle(IntTools_Context)& aCtx= pPF->Context(); + // + Standard_Boolean bToReverse, bIsClosed, bIsDegenerated; + Standard_Integer i, aNb, aNbF, nF; + TopTools_MapOfShape aMFence; + TColStd_IndexedMapOfInteger aMFP; + TopExp_Explorer anExp; + TopoDS_Face aFF; + TopoDS_Edge aSp, aEE; + TopTools_ListIteratorOfListOfShape aIt; + TopAbs_Orientation anOriF, anOriE; + // + mySplitFaces.Clear(); + // + // 1. Select Faces to process (MFP) + aNb=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aF=aDS.Shape(i); + if (aF.ShapeType()!=TopAbs_FACE) { + continue; + } + if (!aMFence.Add(aF)) { + continue; + } + // + if (myInParts.Contains(aF)) { + aMFP.Add(i); + continue; + } + // + anExp.Init(aF, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Shape& aE=anExp.Current(); + if (myImages.HasImage(aE)) { + aMFP.Add(i); + break; + } + } + // + //=== + { + Standard_Integer aNbFFs, aNbSE, j, n1, n2; + // + aNbFFs=aFFs.Extent(); + for (j=1; j<=aNbFFs; ++j) { + BOPTools_SSInterference& aFFj=aFFs(j); + aFFj.Indices(n1, n2); + if (!(n1==i || n2==i)) { + continue; + } + // + const TColStd_ListOfInteger& aLSE=aFFj.SharedEdges(); + aNbSE=aLSE.Extent(); + if (aNbSE) { + aMFP.Add(i); + break; + } + } + } + //=== + // + }// for (i=1; i<=aNb; ++i) + // + // 2. ProcessFaces + aNbF=aMFP.Extent(); + for (i=1; i<=aNbF; ++i) { + nF=aMFP(i); + const TopoDS_Face& aF=TopoDS::Face(aDS.Shape(nF)); + anOriF=aF.Orientation(); + aFF=aF; + aFF.Orientation(TopAbs_FORWARD); + // + aMFence.Clear(); + // + // 2.1. Fill WES + GEOMAlgo_WireEdgeSet aWES; + aWES.SetFace(aFF); + // + // 2.1.1. Add Split parts + anExp.Init(aFF, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current()); + anOriE=aE.Orientation(); + // + if (!myImages.HasImage(aE)) { + if (anOriE==TopAbs_INTERNAL) { + aEE=aE; + aEE.Orientation(TopAbs_FORWARD); + aWES.AddStartElement(aEE); + aEE.Orientation(TopAbs_REVERSED); + aWES.AddStartElement(aEE); + } + else { + aWES.AddStartElement(aE); + } + continue; + } + // + bIsDegenerated=BRep_Tool::Degenerated(aE); + bIsClosed=BRep_Tool::IsClosed(aE, aF); + // + const TopTools_ListOfShape& aLIE=myImages.Image(aE); + aIt.Initialize(aLIE); + for (; aIt.More(); aIt.Next()) { + aSp=TopoDS::Edge(aIt.Value()); + // + if (bIsDegenerated) { + aSp.Orientation(anOriE); + aWES.AddStartElement(aSp); + continue; + } + // + if (anOriE==TopAbs_INTERNAL) { + aSp.Orientation(TopAbs_FORWARD); + aWES.AddStartElement(aSp); + aSp.Orientation(TopAbs_REVERSED); + aWES.AddStartElement(aSp); + continue; + } + // + if (bIsClosed){ + if (aMFence.Add(aSp)) { + // + if (!BRep_Tool::IsClosed(aSp, aF)){ + BOPTools_Tools3D::DoSplitSEAMOnFace(aSp, aF); + } + // + aSp.Orientation(TopAbs_FORWARD); + aWES.AddStartElement(aSp); + aSp.Orientation(TopAbs_REVERSED); + aWES.AddStartElement(aSp); + } + continue; + }// if (aMFence.Add(aSp)) + // + aSp.Orientation(anOriE); + bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, aCtx); + if (bToReverse) { + aSp.Reverse(); + } + aWES.AddStartElement(aSp); + }// for (; aIt.More(); aIt.Next()) { + }// for (; anExp.More(); anExp.Next()) { + // + // 2.1.2. Add In2D Parts + if (myInParts.Contains(aF)) { + const TopTools_ListOfShape& aLE=myInParts.FindFromKey(aF); + aIt.Initialize(aLE); + for (; aIt.More(); aIt.Next()) { + aSp=TopoDS::Edge(aIt.Value()); + // + aSp.Orientation(TopAbs_FORWARD); + aWES.AddStartElement(aSp); + // + aSp.Orientation(TopAbs_REVERSED); + aWES.AddStartElement(aSp); + } + } + // + // 2.2. Build images Faces + TopTools_ListOfShape aLFR; + GEOMAlgo_ShapeSet aS1, aS2; + // + const TopTools_ListOfShape& aSE=aWES.StartElements(); + aS1.Add(aSE); + aS2.Add(aFF, TopAbs_EDGE); + if (aS1.IsEqual(aS2)) { + aLFR.Append(aF); + } + else { + GEOMAlgo_BuilderFace aBF; + // + aBF.SetFace(aFF); + aBF.SetContext(aCtx); + aBF.SetShapes(aSE); + // <-DEB + aBF.Perform(); + // + const TopTools_ListOfShape& aLF=aBF.Areas(); + aIt.Initialize(aLF); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape& aFR=aIt.Value(); + if (anOriF==TopAbs_REVERSED) { + aFR.Orientation(TopAbs_REVERSED); + } + aLFR.Append(aFR); + } + } + // + // 2.3. Collect draft images Faces + mySplitFaces.Bind(aF, aLFR); + }//for (i=1; i<=aNbF; ++i) +} + +//======================================================================= +// function: FillSameDomainFaces +// purpose: +//======================================================================= +void GEOMAlgo_Builder::FillSameDomainFaces() +{ + Standard_Boolean bIsSDF, bHasImage1, bHasImage2, bForward; + Standard_Integer i, j, aNbFF, nF1, nF2, aNbPBInOn, aNbC, aNbSE; + Standard_Integer aNbF1, aNbF2, i2s, aNbSD; + TopTools_MapOfShape aMFence; + TopTools_ListOfShape aLX1, aLX2; + TopTools_ListIteratorOfListOfShape aItF1, aItF2; + NMTTools_ListOfCoupleOfShape aLCS; + // + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + NMTDS_InterfPool* pIP=pPF->IP(); + BOPTools_CArray1OfSSInterference& aFFs=pIP->SSInterferences(); + const Handle(IntTools_Context)& aCtx= pPF->Context(); + // + // + //mySameDomainShapes.Clear(); + // + // 1. For each FF find among images of faces + // all pairs of same domain faces (SDF) [=> aLCS] + aNbFF=aFFs.Extent(); + for (i=1; i<=aNbFF; ++i) { + BOPTools_SSInterference& aFF=aFFs(i); + aFF.Indices(nF1, nF2); + // + const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); + // + // if there are no in/on 2D split parts the faces nF1, nF2 + // can not be SDF + const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks(); + aNbPBInOn=aLPBInOn.Extent(); + // + //=== + const TColStd_ListOfInteger& aLSE=aFF.SharedEdges(); + aNbSE=aLSE.Extent(); + if (!aNbPBInOn && !aNbSE) { + continue; + } + //=== + // + // if there is at least one section edge between faces nF1, nF2 + // they can not be SDF + BOPTools_SequenceOfCurves& aSC=aFF.Curves(); + aNbC=aSC.Length(); + if (aNbC) { + continue; + } + // + // the faces are suspected to be SDF. + // Try to find SDF among images of nF1, nF2 + aMFence.Clear(); + // + //-------------------------------------------------------- + bHasImage1=mySplitFaces.HasImage(aF1); + bHasImage2=mySplitFaces.HasImage(aF2); + // + aLX1.Clear(); + if (!bHasImage1) { + aLX1.Append(aF1); + } + // + aLX2.Clear(); + if (!bHasImage2) { + aLX2.Append(aF2); + } + // + const TopTools_ListOfShape& aLF1r=(bHasImage1)? mySplitFaces.Image(aF1) : aLX1; + const TopTools_ListOfShape& aLF2r=(bHasImage2)? mySplitFaces.Image(aF2) : aLX2; + // + TopTools_DataMapOfIntegerShape aMIS; + TColStd_ListIteratorOfListOfInteger aItLI; + NMTDS_BoxBndTreeSelector aSelector; + NMTDS_BoxBndTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + aNbF1=aLF1r.Extent(); + aNbF2=aLF2r.Extent(); + bForward=(aNbF1DS(); + // + aNb=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aDS.Shape(i); + if (aS.ShapeType()!=TopAbs_FACE) { + continue; + } + // + if (!mySplitFaces.HasImage(aS)) { + continue; + } + // + aF=*((TopoDS_Face*)&aS); + // + aLFx.Clear(); + const TopTools_ListOfShape& aLF=mySplitFaces.Image(aF); + aIt.Initialize(aLF); + for (; aIt.More(); aIt.Next()) { + aFSp=*((TopoDS_Face*)(&aIt.Value())); + if (!mySameDomainShapes.Contains(aFSp)) { + aLFx.Append(aFSp); + } + else { + const TopoDS_Shape& aSx=mySameDomainShapes.FindFromKey(aFSp); + aFSD=*((TopoDS_Face*)(&aSx)); + iSense=GEOMAlgo_Tools3D::Sense(aFSp, aFSD); + if (iSense<0) { + aFSD.Reverse(); + } + aLFx.Append(aFSD); + } + } + // + if (!myImages.HasImage(aF)) { + aNbLFx=aLFx.Extent(); + if (aNbLFx==1) { + const TopoDS_Shape& aFx=aLFx.First(); + if (aF.IsSame(aFx)) { + continue; + } + } + myImages.Bind(aF, aLFx); + } + } +} + +//======================================================================= +// function: FillInternalVertices +// purpose: +//======================================================================= +void GEOMAlgo_Builder::FillInternalVertices() +{ + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + NMTDS_InterfPool* pIP=pPF->IP(); + const Handle(IntTools_Context)& aCtx= pPF->Context(); + // + BOPTools_CArray1OfVSInterference& aVFs=pIP->VSInterferences(); + BOPTools_CArray1OfESInterference& aEFs=pIP->ESInterferences(); + const NMTTools_IndexedDataMapOfIndexedMapOfInteger& aMAV=pPF->AloneVertices(); + // + Standard_Boolean bHasImage; + Standard_Integer i, j, nF, aNbS, nV, nVSD, n1, n2, iFlag; + Standard_Integer aNbVFs, aNbAVF, aNbEFs, aNbVC, aNbE, aNbV; + Standard_Real aU1, aU2, aTol; + NMTTools_IndexedDataMapOfIndexedMapOfInteger aMFMV; + TopTools_MapOfShape aMFence; + TopTools_ListIteratorOfListOfShape aIt, aItV; + BRep_Builder aBB; + // + // 1. Collect face-vertex candidates [aMFMV] + // + // 1.1. VFs + aNbVFs=aVFs.Extent(); + for (i=1; i<=aNbVFs; ++i) { + const BOPTools_VSInterference& aVS=aVFs(i); + aVS.Indices(n1, n2); + nF=n2; + nV=n1; + if (aDS.Shape(n1).ShapeType()==TopAbs_FACE) { + nF=n1; + nV=n2; + } + nVSD=pPF->FindSDVertex(nV); + if (nVSD) { + nV=nVSD; + } + // + UpdateCandidates(nF, nV, aMFMV); + } + // + // 1.2 EFs + aNbEFs=aEFs.Extent(); + for (i=1; i<=aNbEFs; ++i) { + const BOPTools_ESInterference& aEF=aEFs(i); + aEF.Indices(n1, n2); + nV=aEF.NewShape(); + if (!nV) { + continue; + } + const TopoDS_Shape& aSnew=aDS.Shape(nV); + if (aSnew.ShapeType()!=TopAbs_VERTEX) { + continue; + } + // + nF=(aDS.Shape(n1).ShapeType()==TopAbs_FACE) ? n1 : n2; + nVSD=pPF->FindSDVertex(nV); + if (nVSD) { + nV=nVSD; + } + UpdateCandidates(nF, nV, aMFMV); + } + // + aNbS=aDS.NumberOfShapesOfTheObject(); + for (nF=1; nF<=aNbS; ++nF) { + const TopoDS_Shape& aF=aDS.Shape(nF); + // + if (aF.ShapeType()!=TopAbs_FACE) { + continue; + } + if (!aMFence.Add(aF)) { + continue; + } + // + const TopoDS_Face& aFF=TopoDS::Face(aF); + aTol=BRep_Tool::Tolerance(aFF); + // + // 1.3 FFs + if (aMAV.Contains(nF)) { + const TColStd_IndexedMapOfInteger& aMAVF=aMAV.FindFromKey(nF); + aNbAVF=aMAVF.Extent(); + for (j=1; j<=aNbAVF; ++j) { + nV=aMAVF(j); + nVSD=pPF->FindSDVertex(nV); + if (nVSD) { + nV=nVSD; + } + // + UpdateCandidates(nF, nV, aMFMV); + } + } + // + // 1.4 Internal vertices of the face nF + BooleanOperations_OnceExplorer aExp(aDS); + aExp.Init(nF, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + nV=aExp.Current(); + const TopoDS_Shape& aV=aDS.Shape(nV); + if (aV.Orientation()==TopAbs_INTERNAL) { + nVSD=pPF->FindSDVertex(nV); + if (nVSD) { + nV=nVSD; + } + // + UpdateCandidates(nF, nV, aMFMV); + } + } + // + // 2. Process face nF + if (!aMFMV.Contains(nF)) { + continue; + } + // + const TColStd_IndexedMapOfInteger& aMVC=aMFMV.FindFromKey(nF); + aNbVC=aMVC.Extent(); + if (!aNbVC) { + continue; + } + // + // 2.1 Refine candidates + TopTools_IndexedDataMapOfShapeListOfShape aMVE; + TopTools_ListOfShape aLV; + // + bHasImage=myImages.HasImage(aF); + if (bHasImage) { + const TopTools_ListOfShape& aLFx=myImages.Image(aF); + aIt.Initialize(aLFx); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aFx=aIt.Value(); + TopExp::MapShapesAndAncestors(aFx, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + } + } + else { + Standard_Boolean bFaceToProcess; + // + TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + bFaceToProcess=Standard_False; + for (j=1; j<=aNbVC; ++j) { + nV=aMVC(j); + const TopoDS_Shape& aV=aDS.Shape(nV); + if (!aMVE.Contains(aV)) { + bFaceToProcess=!bFaceToProcess; + break; + } + } + if (!bFaceToProcess) { + continue; + } + }// else + // + for (j=1; j<=aNbVC; ++j) { + nV=aMVC(j); + const TopoDS_Shape& aV=aDS.Shape(nV); + if (aMVE.Contains(aV)) { + const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aV); + aNbE=aLE.Extent(); + if (aNbE) { + continue; + } + } + aLV.Append(aV); + } + // + aNbV=aLV.Extent(); + if (aNbV) { + // 3. Try to put vertices into the face(s) + aItV.Initialize(aLV); + for (; aItV.More(); aItV.Next()) { + TopoDS_Vertex aV=TopoDS::Vertex(aItV.Value()); + aV.Orientation(TopAbs_INTERNAL); + // + bHasImage=myImages.HasImage(aF); + if (bHasImage) { + const TopTools_ListOfShape& aLFx=myImages.Image(aF); + aIt.Initialize(aLFx); + for (; aIt.More(); aIt.Next()) { + TopoDS_Face aFx=TopoDS::Face(aIt.Value()); + // update classifier + IntTools_FClass2d& aClsf=aCtx->FClass2d(aFx); + aClsf.Init(aFx, aTol); + // + iFlag=aCtx->ComputeVS (aV, aFx, aU1, aU2); + if (!iFlag) { + aBB.Add(aFx, aV); + break; + } + } + } + else { + const TopoDS_Face& aFx=TopoDS::Face(aF); + // update classifier + IntTools_FClass2d& aClsf=aCtx->FClass2d(aFx); + aClsf.Init(aFx, aTol); + // + iFlag=aCtx->ComputeVS (aV, aFx, aU1, aU2); + if (!iFlag) { + TopoDS_Face aFz; + // + GEOMAlgo_Tools3D::CopyFace(aFx, aFz); + aBB.Add(aFz, aV); + myImages.Bind(aF, aFz); + } + } + }// for (; aItV.More(); aItV.Next()) { + }// if (aNbV) { + }// for (nF=1; nF<=aNb; ++nF) { +} + +//======================================================================= +// function: UpdateCandidates +// purpose: +//======================================================================= +void UpdateCandidates(const Standard_Integer theNF, + const Standard_Integer theNV, + NMTTools_IndexedDataMapOfIndexedMapOfInteger& theMFMV) +{ + if (theMFMV.Contains(theNF)) { + TColStd_IndexedMapOfInteger& aMV=theMFMV.ChangeFromKey(theNF); + aMV.Add(theNV); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(theNV); + theMFMV.Add(theNF, aMV); + } +} + +/* + { + TopoDS_Compound aCx; + BRep_Builder aBBx; + TopTools_ListIteratorOfListOfShape aItx; + // + aBBx.MakeCompound(aCx); + aBBx.Add(aCx, aFF); + aItx.Initialize(aSE); + for (; aItx.More(); aItx.Next()) { + TopoDS_Shape& aEx=aItx.Value(); + aBBx.Add(aCx, aEx); + } + int a=0; + } + */ diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Builder_3.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_3.cxx new file mode 100644 index 000000000..9dc978395 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_3.cxx @@ -0,0 +1,768 @@ +// 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_Builder_3.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 + +#include +#include +#include +#include +#include + + + +static + void OwnInternalShapes(const TopoDS_Shape& , + TopTools_IndexedMapOfShape& ); + +//======================================================================= +//function : FillImagesSolids +//purpose : +//======================================================================= + void GEOMAlgo_Builder::FillImagesSolids() +{ + myErrorStatus=0; + // + FillIn3DParts(); + BuildSplitSolids(); + FillInternalShapes(); +} +//======================================================================= +//function : BuildDraftSolid +//purpose : +//======================================================================= +void GEOMAlgo_Builder::BuildDraftSolid (const TopoDS_Shape& theSolid, + TopoDS_Shape& theDraftSolid, + TopTools_ListOfShape& theLIF) +{ + myErrorStatus=0; + // + NMTTools_PaveFiller* pPF=myPaveFiller; + const Handle(IntTools_Context)& aCtx= pPF->Context(); + // + Standard_Boolean bToReverse; + Standard_Integer iFlag; + TopAbs_Orientation aOrF, aOrSh, aOrSd; + TopoDS_Iterator aIt1, aIt2; + TopTools_ListIteratorOfListOfShape aItS; + BRep_Builder aBB; + TopoDS_Shell aShD; + TopoDS_Shape aFSDx, aFx; + // + aOrSd=theSolid.Orientation(); + theDraftSolid.Orientation(aOrSd); + // + aIt1.Initialize(theSolid); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aSh=aIt1.Value(); + if(aSh.ShapeType()!=TopAbs_SHELL) { + continue; // mb internal edges,vertices + } + // + aOrSh=aSh.Orientation(); + aBB.MakeShell(aShD); + aShD.Orientation(aOrSh); + iFlag=0; + // + aIt2.Initialize(aSh); + for (; aIt2.More(); aIt2.Next()) { + const TopoDS_Shape& aF=aIt2.Value(); + aOrF=aF.Orientation(); + // + if (myImages.HasImage(aF)) { + const TopTools_ListOfShape& aLSp=myImages.Image(aF); + aItS.Initialize(aLSp); + for (; aItS.More(); aItS.Next()) { + aFx=aItS.Value(); + // + if (mySameDomainShapes.Contains(aFx)) { + aFSDx=mySameDomainShapes.FindFromKey(aFx); + // + if (aOrF==TopAbs_INTERNAL) { + aFSDx.Orientation(aOrF); + theLIF.Append(aFSDx); + } + else { + bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFSDx, aF, aCtx); + if (bToReverse) { + aFSDx.Reverse(); + } + // + iFlag=1; + aBB.Add(aShD, aFSDx); + } + }// if (mySameDomainShapes.Contains(aFx)) { + else { + aFx.Orientation(aOrF); + if (aOrF==TopAbs_INTERNAL) { + theLIF.Append(aFx); + } + else{ + iFlag=1; + aBB.Add(aShD, aFx); + } + } + } + } //if (myImages.HasImage(aF)) { + // + else { + if (aOrF==TopAbs_INTERNAL) { + theLIF.Append(aF); + } + else{ + iFlag=1; + aBB.Add(aShD, aF); + } + } + } //for (; aIt2.More(); aIt2.Next()) { + // + if (iFlag) { + aBB.Add(theDraftSolid, aShD); + } + } //for (; aIt1.More(); aIt1.Next()) { +} +//======================================================================= +//function : FillIn3DParts +//purpose : +//======================================================================= + void GEOMAlgo_Builder::FillIn3DParts() +{ + myErrorStatus=0; + // + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + const Handle(IntTools_Context)& aCtx= pPF->Context(); + // + Standard_Boolean bIsIN, bHasImage; + Standard_Integer aNbS, aNbSolids, i, j, aNbFaces, aNbFP, aNbFPx, aNbFIN, aNbLIF; + TopAbs_ShapeEnum aType; + TopAbs_State aState; + TopTools_IndexedMapOfShape aMSolids, aMS, aMFaces, aMFIN; + TopTools_MapOfShape aMFDone; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + TopTools_ListIteratorOfListOfShape aItS; + TopoDS_Iterator aIt, aItF; + BRep_Builder aBB; + TopoDS_Solid aSolidSp; + TopoDS_Face aFP; + // + myDraftSolids.Clear(); + // + aNbS=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aS=aDS.Shape(i); + // + aType=aS.ShapeType(); + if (aType==TopAbs_SOLID) { + // all solids from DS + aMSolids.Add(aS); + } + else if (aType==TopAbs_FACE) { + // all faces (originals from DS or theirs images) + if (myImages.HasImage(aS)) { + const TopTools_ListOfShape& aLS=myImages.Image(aS); + aItS.Initialize(aLS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFx=aItS.Value(); + // + if (mySameDomainShapes.Contains(aFx)) { + const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aFx); + aMFaces.Add(aFSDx); + } + else { + aMFaces.Add(aFx); + } + } + } + else { + if (mySameDomainShapes.Contains(aS)) { + const TopoDS_Shape& aFSDx=mySameDomainShapes.FindFromKey(aS); + aMFaces.Add(aFSDx); + } + else { + aMFaces.Add(aS); + } + } + } + } + // + aNbFaces=aMFaces.Extent(); + aNbSolids=aMSolids.Extent(); + // + for (i=1; i<=aNbSolids; ++i) { + const TopoDS_Solid& aSolid=TopoDS::Solid(aMSolids(i)); + aMFDone.Clear(); + aMFIN.Clear(); + aMEF.Clear(); + // + aBB.MakeSolid(aSolidSp); + // + TopTools_ListOfShape aLIF; + // + BuildDraftSolid(aSolid, aSolidSp, aLIF); + aNbLIF=aLIF.Extent(); + // + // 1 all faces/edges from aSolid [ aMS ] + bHasImage=Standard_False; + aMS.Clear(); + aIt.Initialize(aSolid); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aShell=aIt.Value(); + // + if (myImages.HasImage(aShell)) { + bHasImage=Standard_True; + // + const TopTools_ListOfShape& aLS=myImages.Image(aShell); + aItS.Initialize(aLS); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSx=aItS.Value(); + aMS.Add(aSx); + TopExp::MapShapes(aSx, TopAbs_FACE, aMS); + TopExp::MapShapes(aSx, TopAbs_EDGE, aMS); + TopExp::MapShapesAndAncestors(aSx, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + } + else { + //aMS.Add(aShell); + TopExp::MapShapes(aShell, TopAbs_FACE, aMS); + //modified by NIZNHY-PKV Fri Dec 03 11:18:45 2010f + TopExp::MapShapes(aShell, TopAbs_EDGE, aMS); + //modified by NIZNHY-PKV Fri Dec 03 11:18:51 2010t + TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + } + // + // 2 all faces that are not from aSolid [ aLFP1 ] + Standard_Integer aNbEFP; + TopTools_IndexedDataMapOfShapeListOfShape aMEFP; + TopTools_ListIteratorOfListOfShape aItFP, aItEx; + TopTools_MapOfShape aMFence; + TopTools_ListOfShape aLFP1, aLFP2, aLFP, aLCBF, aLFIN, aLEx;//*pLFP, + // + // for all non-solid faces build EF map [ aMEFP ] + for (j=1; j<=aNbFaces; ++j) { + const TopoDS_Shape& aFace=aMFaces(j); + if (!aMS.Contains(aFace)) { + TopExp::MapShapesAndAncestors(aFace, TopAbs_EDGE, TopAbs_FACE, aMEFP); + } + } + // + // among all faces from aMEFP select these that have same edges + // with the solid (i.e aMEF). These faces will be treated first + // to prevent the usage of 3D classifier. + // The full list of faces to process is aLFP1. + aNbEFP=aMEFP.Extent(); + for (j=1; j<=aNbEFP; ++j) { + const TopoDS_Shape& aE=aMEFP.FindKey(j); + // + if (aMEF.Contains(aE)) { // !! + const TopTools_ListOfShape& aLF=aMEFP(j); + aItFP.Initialize(aLF); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aF=aItFP.Value(); + if (aMFence.Add(aF)) { + aLFP1.Append(aF); + } + } + } + else { + aLEx.Append(aE); + } + } + // + aItEx.Initialize(aLEx); + for (; aItEx.More(); aItEx.Next()) { + const TopoDS_Shape& aE=aItEx.Value(); + const TopTools_ListOfShape& aLF=aMEFP.FindFromKey(aE); + aItFP.Initialize(aLF); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aF=aItFP.Value(); + if (aMFence.Add(aF)) { + aLFP2.Append(aF); + } + } + } + aLFP1.Append(aLFP2); + //========== + // + // 3 Process faces aLFP1 + aNbFP=aLFP1.Extent(); + aItFP.Initialize(aLFP1); + for (; aItFP.More(); aItFP.Next()) { + const TopoDS_Shape& aSP=aItFP.Value(); + if (!aMFDone.Add(aSP)) { + continue; + } + + // + // first face to process + aFP=TopoDS::Face(aSP); + bIsIN= GEOMAlgo_Tools3D::IsInternalFace(aFP, aSolidSp, aMEF, 1.e-14, aCtx); + aState=(bIsIN) ? TopAbs_IN : TopAbs_OUT; + // + // collect faces to process [ aFP is the first ] + aLFP.Clear(); + aLFP.Append(aFP); + aItS.Initialize(aLFP1); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSk=aItS.Value(); + if (!aMFDone.Contains(aSk)) { + aLFP.Append(aSk); + } + } + // + // Connexity Block that spreads from aFP the Bound + // or till the end of the block itself + aLCBF.Clear(); + GEOMAlgo_Tools3D::MakeConnexityBlock(aLFP, aMS, aLCBF); + // + // fill states for the Connexity Block + aItS.Initialize(aLCBF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSx=aItS.Value(); + aMFDone.Add(aSx); + if (aState==TopAbs_IN) { + aMFIN.Add(aSx); + } + } + // + aNbFPx=aMFDone.Extent(); + if (aNbFPx==aNbFP) { + break; + } + }//for (; aItFP.More(); aItFP.Next()) + // + // faces Inside aSolid + aLFIN.Clear(); + aNbFIN=aMFIN.Extent(); + if (aNbFIN || aNbLIF) { + for (j=1; j<=aNbFIN; ++j) { + const TopoDS_Shape& aFIN=aMFIN(j); + aLFIN.Append(aFIN); + } + // + aItS.Initialize(aLIF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFIN=aItS.Value(); + aLFIN.Append(aFIN); + } + // + myInParts.Add(aSolid, aLFIN); + } + if (aNbFIN || bHasImage) { + myDraftSolids.Add(aSolid, aSolidSp); + } + }//for (i=1; i<=aNbSolids; ++i) { // next solid +} +//======================================================================= +//function : BuildSplitSolids +//purpose : +//======================================================================= + void GEOMAlgo_Builder::BuildSplitSolids() +{ + myErrorStatus=0; + // + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + const Handle(IntTools_Context)& aCtx= pPF->Context(); + // + Standard_Integer i, aNbS, iErr; + TopExp_Explorer aExp; + TopTools_ListOfShape aSFS, aLSEmpty; + TopTools_MapOfShape aMFence; + TopTools_ListIteratorOfListOfShape aIt; + GEOMAlgo_BuilderSolid aSB; + GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet aItSS; + GEOMAlgo_DataMapOfShapeShapeSet aMSS; + GEOMAlgo_ShapeSet aSSi; + // + // 0. Find same domain solids for non-interferred solids + aNbS=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aS=aDS.Shape(i); + if (aS.ShapeType()!=TopAbs_SOLID) { + continue; + } + if (!aMFence.Add(aS)) { + continue; + } + if(myDraftSolids.Contains(aS)) { + continue; + } + // + aSSi.Clear(); + aSSi.Add(aS, TopAbs_FACE); + // + aMSS.Bind(aS, aSSi); + } //for (i=1; i<=aNbS; ++i) + // + // 1. Build solids for interferred source solids + aSB.SetContext(aCtx); + aSB.ComputeInternalShapes(myComputeInternalShapes); + aNbS=myDraftSolids.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aS =myDraftSolids.FindKey(i); + const TopoDS_Shape& aSD=myDraftSolids.FindFromIndex(i); + const TopTools_ListOfShape& aLFIN= + (myInParts.Contains(aS)) ? myInParts.FindFromKey(aS) : aLSEmpty; + // + // 1.1 Fill Shell Faces Set + aSFS.Clear(); + + aExp.Init(aSD, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aF=aExp.Current(); + aSFS.Append(aF); + } + // + aIt.Initialize(aLFIN); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape aF=aIt.Value(); + // + aF.Orientation(TopAbs_FORWARD); + aSFS.Append(aF); + aF.Orientation(TopAbs_REVERSED); + aSFS.Append(aF); + } + // + Standard_Integer aNbSFS; + aNbSFS=aSFS.Extent(); + // + // 1.2 + // Check whether aSFS contains a subsets of faces + // of solids that have been already built. + // If yes, shrink aSFS by these subsets. + aSSi.Clear(); + aSSi.Add(aSFS); + // + aItSS.Initialize(aMSS); + for (; aItSS.More(); aItSS.Next()) { + const TopoDS_Shape& aSR=aItSS.Key(); + const GEOMAlgo_ShapeSet& aSSR=aItSS.Value(); + if (aSSi.Contains(aSSR)) { + // the aSR is SD solid for aS + aSSi.Subtract(aSSR); + // update images + if(myImages.HasImage(aS)) { + myImages.Add(aS, aSR); + } + else { + myImages.Bind(aS, aSR); + } + // + // update SD Shapes + mySameDomainShapes.Add(aSR, aSR); + } + } + const TopTools_ListOfShape& aSFS1=aSSi.GetSet(); + aNbSFS=aSFS1.Extent(); + //modified by NIZNHY-PKV Wed Oct 27 09:53:15 2010f + if (!aNbSFS) { + continue; + } + //modified by NIZNHY-PKV Wed Oct 27 09:53:18 2010t + // + // 1.3 Build new solids + aSB.SetContext(aCtx); + aSB.SetShapes(aSFS1); + aSB.Perform(); + iErr=aSB.ErrorStatus(); + if (iErr) { + myErrorStatus=30; // SolidBuilder failed + return; + } + // + const TopTools_ListOfShape& aLSR=aSB.Areas(); + // + // 1.4 Collect resulting solids and theirs set of faces + aIt.Initialize(aLSR); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSR=aIt.Value(); + // + aSSi.Clear(); + aExp.Init(aSR, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aF=aExp.Current(); + aSSi.Add(aF); + } + aMSS.Bind(aSR, aSSi); + } + // + // Update images + if (myImages.HasImage(aS)) { + myImages.Add(aS, aLSR); + } + else { + myImages.Bind(aS, aLSR); + } + } // for (i=1; i<=aNbS; ++i) { +} +//======================================================================= +//function :FillInternalShapes +//purpose : +//======================================================================= + void GEOMAlgo_Builder::FillInternalShapes() +{ + myErrorStatus=0; + // + const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS(); + NMTTools_PaveFiller* pPF=myPaveFiller; + const Handle(IntTools_Context)& aCtx= pPF->Context(); + // + //Standard_Boolean bHasImage; + Standard_Integer i, j, jT, aNbS, aNbSI, aNbSx, aNbSd; + TopAbs_ShapeEnum aType, aT[]={ TopAbs_VERTEX, TopAbs_EDGE }; + TopAbs_State aState; + TopTools_ListIteratorOfListOfShape aIt, aIt1; + TopTools_IndexedDataMapOfShapeListOfShape aMSx; + TopTools_IndexedMapOfShape aMx; + TopTools_MapOfShape aMSI, aMFence, aMSOr; + TopTools_MapIteratorOfMapOfShape aItM; + TopTools_ListOfShape aLSI, aLSd; + TopoDS_Iterator aItS; + BRep_Builder aBB; + // + // 1. Shapes to process + // + // 1.1 Shapes from pure arguments aMSI + // 1.1.1 vertex, edge + for (i=0; i<2; ++i) { + jT=(Standard_Integer)aT[i]; + const TopTools_ListOfShape &aLS=myShapes1[jT]; + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if (aMFence.Add(aS)) { + aLSI.Append(aS); + } + } + } + // 1.1.2 wire + { + jT=(Standard_Integer)TopAbs_WIRE; + const TopTools_ListOfShape &aLW=myShapes1[jT]; + aIt.Initialize(aLW); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aW=aIt.Value(); + aItS.Initialize(aW); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aE=aItS.Value(); + if (aMFence.Add(aE)) { + aLSI.Append(aE); + } + } + } + } + // 1.1.3 theirs images/sources + aIt1.Initialize(aLSI); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aS=aIt1.Value(); + if (myImages.HasImage(aS)) { + const TopTools_ListOfShape &aLSp=myImages.Image(aS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSI=aIt.Value(); + aMSI.Add(aSI); + } + } + else { + aMSI.Add(aS); + } + } + aLSI.Clear(); + aNbSI=aMSI.Extent(); + // + // 2. Internal vertices, edges from source solids + aMFence.Clear(); + aLSd.Clear(); + // + aNbS=aDS.NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aS=aDS.Shape(i); + aType=aS.ShapeType(); + if (aType==TopAbs_SOLID) { + // + aMx.Clear(); + OwnInternalShapes(aS, aMx); + // + aNbSx=aMx.Extent(); + for (j=1; j<=aNbSx; ++j) { + const TopoDS_Shape& aSI=aMx(j); + if (myImages.HasImage(aSI)) { + const TopTools_ListOfShape &aLSp=myImages.Image(aSI); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + aMSI.Add(aSp); + } + } + else { + aMSI.Add(aSI); + } + } + // + // build aux map from splits of solids + if (myImages.HasImage(aS)) { + const TopTools_ListOfShape &aLSp=myImages.Image(aS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + if (aMFence.Add(aSp)) { + TopExp::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_EDGE, aMSx); + TopExp::MapShapesAndAncestors(aSp, TopAbs_VERTEX, TopAbs_FACE, aMSx); + TopExp::MapShapesAndAncestors(aSp, TopAbs_EDGE , TopAbs_FACE, aMSx); + aLSd.Append(aSp); + } + } + } + else { + if (aMFence.Add(aS)) { + TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_EDGE, aMSx); + TopExp::MapShapesAndAncestors(aS, TopAbs_VERTEX, TopAbs_FACE, aMSx); + TopExp::MapShapesAndAncestors(aS, TopAbs_EDGE , TopAbs_FACE, aMSx); + aLSd.Append(aS); + aMSOr.Add(aS); + } + } + }//if (aType==TopAbs_SOLID) + } + // + aNbSd=aLSd.Extent(); + // + // 3. Some shapes of aMSI can be already tied with faces of + // split solids + aItM.Initialize(aMSI); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aSI=aItM.Key(); + if (aMSx.Contains(aSI)) { + const TopTools_ListOfShape &aLSx=aMSx.FindFromKey(aSI); + aNbSx=aLSx.Extent(); + if (aNbSx) { + aMSI.Remove(aSI); + } + } + } + // + // 4. Just check it + aNbSI=aMSI.Extent(); + if (!aNbSI) { + return; + } + // + // 5 Settle internal vertices and edges into solids + aMx.Clear(); + aIt.Initialize(aLSd); + for (; aIt.More(); aIt.Next()) { + TopoDS_Solid aSd=TopoDS::Solid(aIt.Value()); + // + aItM.Initialize(aMSI); + for (; aItM.More(); aItM.Next()) { + TopoDS_Shape aSI=aItM.Key(); + aSI.Orientation(TopAbs_INTERNAL); + // + aState=GEOMAlgo_Tools3D::ComputeStateByOnePoint(aSI, aSd, 1.e-11, aCtx); + if (aState==TopAbs_IN) { + // + if(aMSOr.Contains(aSd)) { + // + TopoDS_Solid aSdx; + // + aBB.MakeSolid(aSdx); + aItS.Initialize(aSd); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aSh=aItS.Value(); + aBB.Add(aSdx, aSh); + } + // + aBB.Add(aSdx, aSI); + // + myImages.Bind(aSd, aSdx); + aMSOr.Remove(aSd); + aSd=aSdx; + } + else { + aBB.Add(aSd, aSI); + } + // + aMSI.Remove(aSI); + } //if (aState==TopAbs_IN) { + }// for (; aItM.More(); aItM.Next()) { + }//for (; aIt1.More(); aIt1.Next()) { +} +//======================================================================= +//function : OwnInternalShapes +//purpose : +//======================================================================= + void OwnInternalShapes(const TopoDS_Shape& theS, + TopTools_IndexedMapOfShape& theMx) +{ + TopoDS_Iterator aIt; + // + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + if (aSx.ShapeType()!=TopAbs_SHELL) { + theMx.Add(aSx); + } + } +} +// +// ErrorStatus +// 30 - SolidBuilder failed diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Builder_4.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_4.cxx new file mode 100644 index 000000000..7b21d51cc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Builder_4.cxx @@ -0,0 +1,316 @@ +// 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_Builder_4.cxx +// Created: +// Author: Peter KURNEV +// +#include + +#include + +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +static + void MapShapes(const TopoDS_Shape& aS, + TopTools_MapOfShape& aM); + +//======================================================================= +//function : Generated +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_Builder::Generated(const TopoDS_Shape& theS) +{ + NMTTools_PaveFiller* pPF=myPaveFiller; + const Handle(IntTools_Context)& aCtx=pPF->Context(); + // + Standard_Boolean bHasImage, bToReverse; + TopAbs_ShapeEnum aType; + TopTools_ListIteratorOfListOfShape aIt; + // + myHistShapes.Clear(); + // + if (theS.IsNull()) { + return myHistShapes; + } + // + bHasImage=myImages.HasImage(theS); + if (!bHasImage) { + return myHistShapes; + } + // + aType=theS.ShapeType(); + // + if (aType==TopAbs_EDGE || aType==TopAbs_FACE || + aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + const TopTools_ListOfShape& aLSp=myImages.Image(theS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + if (mySameDomainShapes.Contains(aSp)) { + if (myMapShape.Contains(aSp)) { + TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp); + // + if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + aSpR.Orientation(theS.Orientation()); + } + else { + bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSpR, theS, aCtx); + if (bToReverse) { + aSpR.Reverse(); + } + } + // + myHistShapes.Append(aSpR); + } + } + } + } + // + return myHistShapes; +} +//======================================================================= +//function : Modified +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_Builder::Modified(const TopoDS_Shape& theS) +{ + NMTTools_PaveFiller* pPF=myPaveFiller; + const Handle(IntTools_Context)& aCtx=pPF->Context(); + // + Standard_Boolean bHasImage, bToReverse; + TopAbs_ShapeEnum aType; + TopTools_ListIteratorOfListOfShape aIt; + // + myHistShapes.Clear(); + // + if (theS.IsNull()) { + return myHistShapes; + } + // + bHasImage=myImages.HasImage(theS); + if (!bHasImage) { + return myHistShapes; + } + // + aType=theS.ShapeType(); + // + if (aType==TopAbs_EDGE || aType==TopAbs_FACE || + aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + const TopTools_ListOfShape& aLSp=myImages.Image(theS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape aSp=aIt.Value(); + if (!mySameDomainShapes.Contains(aSp)) { + if (myMapShape.Contains(aSp)) { + // + if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + aSp.Orientation(theS.Orientation()); + } + else { + bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSp, theS, aCtx); + if (bToReverse) { + aSp.Reverse(); + } + } + // + myHistShapes.Append(aSp); + } + } + } + } + // + return myHistShapes; +} +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_Builder::IsDeleted(const TopoDS_Shape& theS) +{ + Standard_Boolean bRet, bHasImage, bContains; + TopAbs_ShapeEnum aType; + TopTools_ListIteratorOfListOfShape aIt; + // + bRet=Standard_False; + // + if (theS.IsNull()) { + return !bRet; //true + } + // + bContains=myMapShape.Contains(theS); + if (bContains) { + return bRet; //false + } + // + bHasImage=myImages.HasImage(theS); + if (!bHasImage) { + return !bRet; //true + } + // + aType=theS.ShapeType(); + if (aType==TopAbs_EDGE || aType==TopAbs_FACE || + aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + const TopTools_ListOfShape& aLSp=myImages.Image(theS); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape aSp=aIt.Value(); + // + if (!mySameDomainShapes.Contains(aSp)) { + if (myMapShape.Contains(aSp)) { + return bRet; //false + } + } + else { + TopoDS_Shape aSpR=mySameDomainShapes.FindFromKey(aSp); + if (myMapShape.Contains(aSpR)) { + return bRet; //false + } + } + } + } + return !bRet; // true +} +//======================================================================= +//function : PrepareHistory +//purpose : +//======================================================================= + void GEOMAlgo_Builder::PrepareHistory() +{ + if(myShape.IsNull()) { + return; + } + // + Standard_Boolean bHasImage, bContainsSD; + TopAbs_ShapeEnum aType; + TopTools_MapOfShape aMS; + TopTools_ListIteratorOfListOfShape aIt; + TopTools_MapIteratorOfMapOfShape aItM; + // + // 1. Clearing + GEOMAlgo_BuilderShape::PrepareHistory(); + // + // 2. myMapShape - all shapes of result with theirs sub-shapes + MapShapes(myShape, myMapShape); + // + // 3. MS - all argument shapes with theirs sub-shapes + aIt.Initialize(myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + MapShapes(aSx, aMS); + } + // + // 4. Treatment + aItM.Initialize(aMS); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aSx=aItM.Key(); + aType=aSx.ShapeType(); + //modified by NIZNHY-PKV Thu Dec 7 11:34:05 2006f + // + // 4.1 .myImagesResult + TopTools_ListOfShape aLSx; + // + bHasImage=myImages.HasImage(aSx); + if (!bHasImage) { + if (myMapShape.Contains(aSx)) { + aLSx.Append(aSx); + myImagesResult.Add(aSx, aLSx); + } + } + else { + const TopTools_ListOfShape& aLSp=myImages.Image(aSx); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + if (myMapShape.Contains(aSp)) { + aLSx.Append(aSp); + } + } + myImagesResult.Add(aSx, aLSx); + } + // + //modified by NIZNHY-PKV Thu Dec 7 11:34:10 2006t + // + // 4.2 As it was + if (!myHasDeleted) { + myHasDeleted=IsDeleted(aSx);//xx + } + // + if (!myHasGenerated || !myHasModified) { + if (aType==TopAbs_EDGE || aType==TopAbs_FACE || + aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + //modified by NIZNHY-PKV Thu Dec 7 11:53:01 2006f + //bHasImage=myImages.HasImage(aSx); + //modified by NIZNHY-PKV Thu Dec 7 11:53:04 2006t + if (bHasImage) { + const TopTools_ListOfShape& aLSp=myImages.Image(aSx); + aIt.Initialize(aLSp); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSp=aIt.Value(); + // + if (myMapShape.Contains(aSp)) { + bContainsSD=mySameDomainShapes.Contains(aSp); + // + if (!myHasGenerated) { + if (bContainsSD) { + myHasGenerated=Standard_True; + } + } + if (!myHasModified) { + if (!bContainsSD) { + myHasModified=Standard_True; + } + } + } // if (myMapShape.Contains(aSp)) + } + } + } + } + } + +} +//======================================================================= +//function : MapShapes +//purpose : +//======================================================================= + void MapShapes(const TopoDS_Shape& theS, + TopTools_MapOfShape& theM) +{ + theM.Add(theS); + TopoDS_Iterator anIt; + anIt.Initialize(theS); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aSx=anIt.Value(); + MapShapes(aSx, theM); + } +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Clsf.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Clsf.cxx new file mode 100644 index 000000000..9abb550a9 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Clsf.cxx @@ -0,0 +1,107 @@ +// 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_Clsf.cxx +// Created: Wed Nov 22 10:23:04 2006 +// Author: Peter KURNEV +// +// +#include + +IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_Clsf, GEOMAlgo_HAlgo); +IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_Clsf, GEOMAlgo_HAlgo); + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_Clsf::GEOMAlgo_Clsf() +: + GEOMAlgo_HAlgo() +{ + myState=TopAbs_UNKNOWN; + myPnt.SetCoord(99.,99.,99.); + myTolerance=0.0001; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_Clsf::~GEOMAlgo_Clsf() +{ +} +//======================================================================= +//function : SetTolerance +//purpose : +//======================================================================= + void GEOMAlgo_Clsf::SetTolerance(const Standard_Real aT) +{ + myTolerance=aT; +} +//======================================================================= +//function : Tolerance +//purpose : +//======================================================================= + Standard_Real GEOMAlgo_Clsf::Tolerance()const +{ + return myTolerance; +} +//======================================================================= +//function : SetPnt +//purpose : +//======================================================================= + void GEOMAlgo_Clsf::SetPnt(const gp_Pnt& aP) +{ + myPnt=aP; +} +//======================================================================= +//function : Pnt +//purpose : +//======================================================================= + const gp_Pnt& GEOMAlgo_Clsf::Pnt()const +{ + return myPnt; +} +//======================================================================= +//function : State +//purpose : +//======================================================================= + TopAbs_State GEOMAlgo_Clsf::State() const +{ + return myState; +} +//======================================================================= +//function : CanBeON +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_Clsf::CanBeON(const Handle(Geom_Curve)& ) const +{ + return Standard_True; +} +//======================================================================= +//function : CanBeON +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_Clsf::CanBeON(const Handle(Geom_Surface)& ) const +{ + return Standard_True; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Clsf.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_Clsf.hxx new file mode 100644 index 000000000..38fd2cefe --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Clsf.hxx @@ -0,0 +1,87 @@ +// 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_Clsf.hxx +// Created: Wed Nov 22 10:23:04 2006 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_Clsf_HeaderFile +#define _GEOMAlgo_Clsf_HeaderFile + +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(GEOMAlgo_Clsf, GEOMAlgo_HAlgo); + +//======================================================================= +//class : GEOMAlgo_Clsf +//purpose : +//======================================================================= +class GEOMAlgo_Clsf : public GEOMAlgo_HAlgo +{ + public: + Standard_EXPORT + void SetPnt(const gp_Pnt& aP) ; + + Standard_EXPORT + const gp_Pnt& Pnt() const; + + Standard_EXPORT + void SetTolerance(const Standard_Real aT) ; + + Standard_EXPORT + Standard_Real Tolerance() const; + + Standard_EXPORT + TopAbs_State State() const; + + Standard_EXPORT + virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aCT) const; + + Standard_EXPORT + virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const; + + DEFINE_STANDARD_RTTI(GEOMAlgo_Clsf); + + protected: + Standard_EXPORT + GEOMAlgo_Clsf(); + + Standard_EXPORT + virtual ~GEOMAlgo_Clsf(); + + TopAbs_State myState; + gp_Pnt myPnt; + Standard_Real myTolerance; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ClsfBox.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfBox.cxx new file mode 100644 index 000000000..891c0a66e --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfBox.cxx @@ -0,0 +1,222 @@ +// 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_ClsfBox.cxx +// Created: Wed Nov 22 10:41:47 2006 +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf) +IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf) + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_ClsfBox::GEOMAlgo_ClsfBox() +: + GEOMAlgo_Clsf() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_ClsfBox::~GEOMAlgo_ClsfBox() +{ +} +//======================================================================= +//function : SetBox +//purpose : +//======================================================================= + void GEOMAlgo_ClsfBox::SetBox(const TopoDS_Shape& aBox) +{ + myBox=aBox; +} +//======================================================================= +//function : Box +//purpose : +//======================================================================= + const TopoDS_Shape& GEOMAlgo_ClsfBox::Box() const +{ + return myBox; +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= + void GEOMAlgo_ClsfBox::CheckData() +{ + Standard_Integer i, aNbF; + TopAbs_ShapeEnum aTypeShape; + TopAbs_Orientation aOr; + GeomAbs_SurfaceType aType; + Handle(Geom_Surface) aS; + TopTools_IndexedMapOfShape aMF; + // + myErrorStatus=0; + // + if(myBox.IsNull()) { + myErrorStatus=10; // myBox=NULL + return; + } + // + aTypeShape=myBox.ShapeType(); + if (aTypeShape!=TopAbs_SOLID) { + myErrorStatus=11; // unallowed shape type + return; + } + // + TopExp::MapShapes(myBox, TopAbs_FACE, aMF); + aNbF=aMF.Extent(); + if (aNbF!=6) { + myErrorStatus=12; // wrong number of faces + return; + } + // + for (i=1; i<=aNbF; ++i) { + const TopoDS_Face& aF=TopoDS::Face(aMF(i)); + aOr=aF.Orientation(); + if (!(aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED)) { + myErrorStatus=12; // unallowed orientation of face + return; + } + // + aS=BRep_Tool::Surface(aF); + myGAS[i-1].Load(aS); + aType=myGAS[i-1].GetType(); + if (!aType==GeomAbs_Plane) { + myErrorStatus=13; // unallowed surface type + return; + } + // + if(aOr==TopAbs_REVERSED) { + gp_Ax1 aAx1; + gp_Pln aPln; + gp_Pnt aP; + gp_Dir aD; + Handle(Geom_Plane) aSR; + // + aPln=myGAS[i-1].Plane(); + aAx1=aPln.Axis(); + aP=aAx1.Location(); + aD=aAx1.Direction(); + aD.Reverse(); + aSR=new Geom_Plane(aP, aD); + myGAS[i-1].Load(aSR); + } + } +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void GEOMAlgo_ClsfBox::Perform() +{ + myErrorStatus=0; + // + const Standard_Integer aNbS=6; + Standard_Integer i, aNbON, aNbIN, iNext; + TopAbs_State aSt; + /* + CheckData(); + if(myErrorStatus) { + return; + } + */ + iNext=1; + aNbON=0; + aNbIN=0; + for(i=0; i +// +#ifndef _GEOMAlgo_ClsfBox_HeaderFile +#define _GEOMAlgo_ClsfBox_HeaderFile + +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf) + +//======================================================================= +//function : GEOMAlgo_ClsfBox +//purpose : +//======================================================================= +class GEOMAlgo_ClsfBox : public GEOMAlgo_Clsf +{ + public: + Standard_EXPORT + GEOMAlgo_ClsfBox(); + + Standard_EXPORT + virtual ~GEOMAlgo_ClsfBox(); + + Standard_EXPORT + void SetBox(const TopoDS_Shape& aS) ; + + Standard_EXPORT + const TopoDS_Shape& Box() const; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aC) const; + + Standard_EXPORT + virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const; + + DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfBox) + + protected: + TopoDS_Shape myBox; + GeomAdaptor_Surface myGAS[6]; + + +private: + + + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.cxx new file mode 100644 index 000000000..39b8f43d0 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.cxx @@ -0,0 +1,141 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_ClsfSolid.cxx +// Created: Mon Jan 29 10:35:46 2007 +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf) +IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf) + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_ClsfSolid::GEOMAlgo_ClsfSolid() +: + GEOMAlgo_Clsf() +{ + myPClsf=NULL; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_ClsfSolid::~GEOMAlgo_ClsfSolid() +{ + if (myPClsf) { + BRepClass3d_SolidClassifier* pSC; + // + pSC=(BRepClass3d_SolidClassifier*)myPClsf; + delete pSC; + } +} +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= + void GEOMAlgo_ClsfSolid::SetShape(const TopoDS_Shape& aS) +{ + myShape=aS; +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + const TopoDS_Shape& GEOMAlgo_ClsfSolid::Shape()const +{ + return myShape; +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= + void GEOMAlgo_ClsfSolid::CheckData() +{ + myErrorStatus=0; + // + BRepClass3d_SolidClassifier* pSC; + TopAbs_ShapeEnum aType; + BRep_Builder aBB; + TopoDS_Solid aS; + // + if (myShape.IsNull()) { + myErrorStatus=10; // mySolid=NULL + return; + } + // + aType=myShape.ShapeType(); + if (!(aType==TopAbs_SOLID || aType==TopAbs_SHELL)) { + myErrorStatus=12; + return; + } + // + //=== + if (aType==TopAbs_SOLID) { + aS=TopoDS::Solid(myShape); + } + else { + aBB.MakeSolid(aS); + aBB.Add(aS, myShape); + } + // + if (myPClsf) { + pSC=(BRepClass3d_SolidClassifier*)myPClsf; + delete pSC; + } + // + pSC=new BRepClass3d_SolidClassifier(aS); + myPClsf=pSC; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void GEOMAlgo_ClsfSolid::Perform() +{ + myErrorStatus=0; + // + if (!myPClsf) { + myErrorStatus=11; + return; + } + // + BRepClass3d_SolidClassifier* pSC; + // + pSC=(BRepClass3d_SolidClassifier*)myPClsf; + pSC->Perform(myPnt, myTolerance); + myState=pSC->State(); +} +// +// myErrorStatus : +// +// 10 - mySolid=NULL +// 11 - myPClsf=NULL +// 12 - unallowed type of myShape + diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.hxx new file mode 100644 index 000000000..dc2c67b38 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSolid.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_ClsfSolid.hxx +// Created: Mon Jan 29 10:35:46 2007 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_ClsfSolid_HeaderFile +#define _GEOMAlgo_ClsfSolid_HeaderFile + +#include +#include +//#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf) + +//======================================================================= +//class : GEOMAlgo_ClsfSolid +//purpose : +//======================================================================= +class GEOMAlgo_ClsfSolid : public GEOMAlgo_Clsf +{ + public: + Standard_EXPORT + GEOMAlgo_ClsfSolid(); + + Standard_EXPORT + virtual ~GEOMAlgo_ClsfSolid(); + + Standard_EXPORT + void SetShape(const TopoDS_Shape& aS) ; + + Standard_EXPORT + const TopoDS_Shape& Shape() const; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + virtual void CheckData() ; + + DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfSolid) + + protected: + TopoDS_Shape myShape; + Standard_Address myPClsf; + +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.cxx new file mode 100644 index 000000000..48d459498 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.cxx @@ -0,0 +1,141 @@ +// 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_ClsfSurf.cxx +// Created: Wed Nov 22 10:41:47 2006 +// Author: Peter KURNEV +// +// +#include +#include +#include +#include + +IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf); +IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf); + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_ClsfSurf::GEOMAlgo_ClsfSurf() +: + GEOMAlgo_Clsf() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_ClsfSurf::~GEOMAlgo_ClsfSurf() +{ +} +//======================================================================= +//function : SetSurface +//purpose : +//======================================================================= + void GEOMAlgo_ClsfSurf::SetSurface(const Handle(Geom_Surface)& aS) +{ + myS=aS; +} +//======================================================================= +//function : Surface +//purpose : +//======================================================================= + const Handle(Geom_Surface)& GEOMAlgo_ClsfSurf::Surface() const +{ + return myS; +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= + void GEOMAlgo_ClsfSurf::CheckData() +{ + GeomAbs_SurfaceType aType; + // + myErrorStatus=0; + // + if(myS.IsNull()) { + myErrorStatus=10; // mySurface=NULL + return; + } + // + myGAS.Load(myS); + aType=myGAS.GetType(); + if (!(aType==GeomAbs_Plane || + aType==GeomAbs_Cylinder || + aType==GeomAbs_Sphere)) { + myErrorStatus=11; // unallowed surface type + } +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void GEOMAlgo_ClsfSurf::Perform() +{ + myErrorStatus=0; + /* + CheckData(); + if(myErrorStatus) { + return; + } + */ + GEOMAlgo_SurfaceTools::GetState(myPnt, myGAS, myTolerance, myState); +} +//======================================================================= +//function : CanBeON +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_ClsfSurf::CanBeON(const Handle(Geom_Curve)& aC) const +{ + GeomAbs_SurfaceType aST; + GeomAbs_CurveType aCT; + GeomAdaptor_Curve aGAC; + // + aGAC.Load(aC); + aCT=aGAC.GetType(); + // + aST=myGAS.GetType(); + if (aCT==GeomAbs_Line && aST==GeomAbs_Sphere) { + return Standard_False; + } + return Standard_True; +} +//======================================================================= +//function : CanBeON +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_ClsfSurf::CanBeON(const Handle(Geom_Surface)& aS1) const +{ + Standard_Boolean bRet; + GeomAbs_SurfaceType aST, aST1; + GeomAdaptor_Surface aGAS1; + // + aST=myGAS.GetType(); + aGAS1.Load(aS1); + aST1=aGAS1.GetType(); + bRet=(aST1==aST); + // + return bRet; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.hxx new file mode 100644 index 000000000..35261d279 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ClsfSurf.hxx @@ -0,0 +1,81 @@ +// 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_ClsfSurf.hxx +// Created: Wed Nov 22 10:41:47 2006 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_ClsfSurf_HeaderFile +#define _GEOMAlgo_ClsfSurf_HeaderFile + +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include + +DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf) + +//======================================================================= +// class : GEOMAlgo_ClsfSurf +//purpose : +//======================================================================= +class GEOMAlgo_ClsfSurf : public GEOMAlgo_Clsf +{ + public: + Standard_EXPORT + GEOMAlgo_ClsfSurf(); + + Standard_EXPORT + virtual ~GEOMAlgo_ClsfSurf(); + + Standard_EXPORT + void SetSurface(const Handle(Geom_Surface)& aS) ; + + Standard_EXPORT + const Handle_Geom_Surface& Surface() const; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aC) const; + + Standard_EXPORT + virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const; + + DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfSurf); + + protected: + Handle_Geom_Surface myS; + GeomAdaptor_Surface myGAS; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.cxx new file mode 100644 index 000000000..993beb8e2 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.cxx @@ -0,0 +1,86 @@ +// 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 +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_CoupleOfShapes.cxx +// Created: Wed Dec 15 13:03:52 2004 +// Author: Peter KURNEV +// +// +#include +//======================================================================= +//function : GEOMAlgo_CoupleOfShapes +//purpose : +//======================================================================= +GEOMAlgo_CoupleOfShapes::GEOMAlgo_CoupleOfShapes() +{} +//======================================================================= +//function : SetShapes +//purpose : +//======================================================================= +void GEOMAlgo_CoupleOfShapes::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) +{ + myShape1=aS1; + myShape2=aS2; +} +//======================================================================= +//function : Shapes +//purpose : +//======================================================================= +void GEOMAlgo_CoupleOfShapes::Shapes(TopoDS_Shape& aS1, + TopoDS_Shape& aS2)const +{ + aS1=myShape1; + aS2=myShape2; +} +//======================================================================= +//function : SetShape1 +//purpose : +//======================================================================= +void GEOMAlgo_CoupleOfShapes::SetShape1(const TopoDS_Shape& aS1) +{ + myShape1=aS1; +} +//======================================================================= +//function : SetShape2 +//purpose : +//======================================================================= +void GEOMAlgo_CoupleOfShapes::SetShape2(const TopoDS_Shape& aS2) +{ + myShape2=aS2; +} +//======================================================================= +//function : Shape1 +//purpose : +//======================================================================= +const TopoDS_Shape& GEOMAlgo_CoupleOfShapes::Shape1()const +{ + return myShape1; +} +//======================================================================= +//function : Shape2 +//purpose : +//======================================================================= +const TopoDS_Shape& GEOMAlgo_CoupleOfShapes::Shape2()const +{ + return myShape2; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.hxx new file mode 100644 index 000000000..30a0f94b8 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_CoupleOfShapes.hxx @@ -0,0 +1,64 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_CoupleOfShapes.hxx +// Created: Wed Dec 15 13:03:52 2004 +// Author: Peter KURNEV +// +// + +#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile +#define _GEOMAlgo_CoupleOfShapes_HeaderFile + +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_CoupleOfShapes +//purpose : +//======================================================================= +class GEOMAlgo_CoupleOfShapes +{ + public: + Standard_EXPORT + GEOMAlgo_CoupleOfShapes(); + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS1,const TopoDS_Shape& aS2) ; + + Standard_EXPORT + void SetShape1(const TopoDS_Shape& aS1) ; + + Standard_EXPORT + void SetShape2(const TopoDS_Shape& aS2) ; + + Standard_EXPORT + void Shapes(TopoDS_Shape& aS1,TopoDS_Shape& aS2) const; + + Standard_EXPORT + const TopoDS_Shape& Shape1() const; + + Standard_EXPORT + const TopoDS_Shape& Shape2() const; + +protected: + TopoDS_Shape myShape1; + TopoDS_Shape myShape2; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx new file mode 100644 index 000000000..2e2bccc1e --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx +// Created: Wed Feb 22 11:05:01 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape_HeaderFile +#define GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape_HeaderFile + +#ifndef GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx new file mode 100644 index 000000000..5212bf5d8 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapIteratorOfDataMapOfPassKeyInteger.hxx +// Created: Wed Feb 22 10:58:14 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger_HeaderFile +#define GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger_HeaderFile + +#ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile +#include +#endif +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx new file mode 100644 index 000000000..f37bd53b2 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx +// Created: Wed Feb 22 11:01:34 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape_HeaderFile +#define GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape_HeaderFile + +#ifndef GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile +#include +#endif +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx new file mode 100644 index 000000000..284e5555c --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapIteratorOfDataMapOfRealListOfShape.hxx +// Created: Wed Feb 22 10:53:47 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape_HeaderFile +#define GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape_HeaderFile + +#ifndef GEOMAlgo_DataMapOfRealListOfShape_HeaderFile +#include +#endif +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx new file mode 100644 index 000000000..2b41d723f --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx +// Created: Wed Feb 22 11:08:26 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile +#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile + +#ifndef GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile +#include +#endif +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx new file mode 100644 index 000000000..c72a4cc58 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapIteratorOfDataMapOfShapePnt.hxx +// Created: Wed Feb 22 11:11:09 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile +#define GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile + +#ifndef GEOMAlgo_DataMapOfShapePnt_HeaderFile +#include +#endif +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx new file mode 100644 index 000000000..3c3128565 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapIteratorOfDataMapOfShapeReal.hxx +// Created: Wed Feb 22 10:49:11 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal_HeaderFile +#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal_HeaderFile + +#ifndef GEOMAlgo_DataMapOfShapeReal_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx new file mode 100644 index 000000000..cd44f6aa3 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapIteratorOfDataMapOfShapeShapeSet.hxx +// Created: Wed Feb 22 08:39:02 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet_HeaderFile +#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet_HeaderFile + +#ifndef GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfOrientedShapeShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfOrientedShapeShape.hxx new file mode 100644 index 000000000..d9dc23111 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfOrientedShapeShape.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapOfOrientedShapeShape.hxx +// Created: Wed Feb 22 11:03:36 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile +#define GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_DataMap GEOMAlgo_DataMapOfOrientedShapeShape; +typedef GEOMAlgo_DataMapOfOrientedShapeShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyInteger.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyInteger.hxx new file mode 100644 index 000000000..d04744be5 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyInteger.hxx @@ -0,0 +1,41 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapOfPassKeyInteger.hxx +// Created: Wed Feb 22 10:55:55 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile +#define GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile + +#include +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_DataMap GEOMAlgo_DataMapOfPassKeyInteger; +typedef GEOMAlgo_DataMapOfPassKeyInteger::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyShapeShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyShapeShape.hxx new file mode 100644 index 000000000..fe0fd1376 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfPassKeyShapeShape.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapOfPassKeyShapeShape.hxx +// Created: Wed Feb 22 11:00:16 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile +#define GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_DataMap GEOMAlgo_DataMapOfPassKeyShapeShape; +typedef GEOMAlgo_DataMapOfPassKeyShapeShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape; + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfRealListOfShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfRealListOfShape.hxx new file mode 100644 index 000000000..b308f2097 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfRealListOfShape.hxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapOfRealListOfShape.hxx +// Created: Wed Feb 22 10:51:48 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapOfRealListOfShape_HeaderFile +#define GEOMAlgo_DataMapOfRealListOfShape_HeaderFile + +#include +#include +#include + + +#define _NCollection_MapHasher +#include + +typedef NCollection_DataMap GEOMAlgo_DataMapOfRealListOfShape; +typedef GEOMAlgo_DataMapOfRealListOfShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeMapOfShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeMapOfShape.hxx new file mode 100644 index 000000000..bc0228692 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeMapOfShape.hxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapOfShapeMapOfShape.hxx +// Created: Wed Feb 22 11:07:16 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile +#define GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile + + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_DataMap GEOMAlgo_DataMapOfShapeMapOfShape; +typedef GEOMAlgo_DataMapOfShapeMapOfShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapePnt.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapePnt.hxx new file mode 100644 index 000000000..8285a4b8b --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapePnt.hxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapOfShapePnt.hxx +// Created: Wed Feb 22 11:10:15 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapOfShapePnt_HeaderFile +#define GEOMAlgo_DataMapOfShapePnt_HeaderFile + + +#include +#include +#include + +#define _NCollection_MapHasher +#include +#include + +typedef NCollection_DataMap GEOMAlgo_DataMapOfShapePnt; +typedef GEOMAlgo_DataMapOfShapePnt::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeReal.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeReal.hxx new file mode 100644 index 000000000..6ce7d5361 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeReal.hxx @@ -0,0 +1,41 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapOfShapeReal.hxx +// Created: Wed Feb 22 10:47:23 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapOfShapeReal_HeaderFile +#define GEOMAlgo_DataMapOfShapeReal_HeaderFile + +#include +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_DataMap GEOMAlgo_DataMapOfShapeReal; +typedef GEOMAlgo_DataMapOfShapeReal::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeShapeSet.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeShapeSet.hxx new file mode 100644 index 000000000..cf356a4aa --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_DataMapOfShapeShapeSet.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_DataMapOfShapeShapeSet.hxx +// Created: Wed Feb 22 08:36:15 2012 +// Author: +// + + +#ifndef GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile +#define GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_DataMap GEOMAlgo_DataMapOfShapeShapeSet; +typedef GEOMAlgo_DataMapOfShapeShapeSet::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.cxx new file mode 100644 index 000000000..f9759ac95 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.cxx @@ -0,0 +1,616 @@ +// 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_FinderShapeOn.cxx +// Created: Tue Jan 11 14:44:31 2005 +// Author: Peter KURNEV + +#include + +#include + +#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version +#include +#endif + +#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 +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_FinderShapeOn +//purpose : +//======================================================================= +GEOMAlgo_FinderShapeOn::GEOMAlgo_FinderShapeOn() +: + GEOMAlgo_ShapeAlgo() +{ + myTolerance=0.0001; + myShapeType=TopAbs_VERTEX; + myState=GEOMAlgo_ST_UNKNOWN; + myIsAnalytic=Standard_True; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_FinderShapeOn::~GEOMAlgo_FinderShapeOn() +{ +} +//======================================================================= +//function : SetSurface +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::SetSurface(const Handle(Geom_Surface)& aS) +{ + mySurface=aS; +} +//======================================================================= +//function : Surface +//purpose : +//======================================================================= +const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn::Surface() const +{ + return mySurface; +} +//======================================================================= +//function : SetShapeType +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::SetShapeType(const TopAbs_ShapeEnum aType) +{ + myShapeType=aType; +} +//======================================================================= +//function : ShapeType +//purpose : +//======================================================================= +TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn::ShapeType()const +{ + return myShapeType; +} +//======================================================================= +//function : SetState +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::SetState(const GEOMAlgo_State aState) +{ + myState=aState; +} +//======================================================================= +//function : State +//purpose : +//======================================================================= +GEOMAlgo_State GEOMAlgo_FinderShapeOn::State() const +{ + return myState; +} +//======================================================================= +// function: Shapes +// purpose: +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn::Shapes() const +{ + Standard_Boolean bIsConformState; + Standard_Integer i, aNb; + TopAbs_State aSt; + TopTools_ListOfShape* pL; + // + pL=(TopTools_ListOfShape*) &myLS; + pL->Clear(); + // + aNb=myMSS.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=myMSS.FindKey(i); + aSt=myMSS.FindFromIndex(i); + // + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + if (bIsConformState) { + pL->Append(aS); + } + } + return myLS; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::Perform() +{ + myErrorStatus=0; + myWarningStatus=0; + myLS.Clear(); + myMSS.Clear(); + // + if (!myResult.IsNull()){ + myResult.Nullify(); + } + // + CheckData(); + if(myErrorStatus) { + return; + } + // + // Initialize the context + GEOMAlgo_ShapeAlgo::Perform(); + // + myIsAnalytic=GEOMAlgo_SurfaceTools::IsAnalytic(mySurface); + // + MakeArgument1(); + if(myErrorStatus) { + return; + } + // + if (myIsAnalytic && myShapeType==TopAbs_VERTEX) { + FindVertices(); + return; + } + // + MakeArgument2(); + if(myErrorStatus) { + return; + } + // + Find(); + if(myErrorStatus || myWarningStatus) { + return; + } + // +} +//======================================================================= +//function : FindVertices +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::FindVertices() +{ + Standard_Integer i, aNb, iErr; + TopAbs_State aSt; + TopAbs_Orientation aOr; + gp_Pnt aP; + TopTools_IndexedMapOfShape aM; + // + TopExp::MapShapes(myArg1, TopAbs_FACE, aM); + const TopoDS_Face& aF=TopoDS::Face(aM(1)); + aOr=aF.Orientation(); + // + aM.Clear(); + TopExp::MapShapes(myShape, myShapeType, aM); + aNb=aM.Extent(); + if (!aNb) { + myWarningStatus=10; // No found sub-shapes of type myShapeType + return; + } + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aM(i); + const TopoDS_Vertex& aV=TopoDS::Vertex(aS); + aP=BRep_Tool::Pnt(aV); + iErr=GEOMAlgo_SurfaceTools::GetState(aP, mySurface, myTolerance, aSt); + if (aOr==TopAbs_REVERSED) { + aSt=GEOMAlgo_SurfaceTools::ReverseState(aSt); + } + myMSS.Add(aS, aSt); + } +} +//======================================================================= +//function : Find +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::Find() +{ + Standard_Integer i, aNb; + Standard_Boolean bICS; + TopTools_IndexedMapOfShape aM; + // + TopExp::MapShapes(myArg2, myShapeType, aM); + // + aNb=aM.Extent(); + if (!aNb) { + myWarningStatus=10; // No found sub-shapes of type myShapeType + return; + } + // + bICS=GEOMAlgo_Tools::IsCompositeShape(myArg2); + if (!bICS || myIsAnalytic) { + TopoDS_Compound aCmp; + BRep_Builder aBB; + // + aBB.MakeCompound(aCmp); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aSi=aM(i); + aBB.Add(aCmp, aSi); + } + // + aM.Clear(); + aM.Add(aCmp); + aNb=1; + } + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aM(i); + Find(aS); + if (myErrorStatus) { + return; + } + } +} +//======================================================================= +//function : Find +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::Find(const TopoDS_Shape& aS) +{ + myErrorStatus=0; + // + Standard_Boolean bIsDone; + Standard_Integer i, iErr; + TopAbs_State aSts[]={TopAbs_IN, TopAbs_OUT, TopAbs_ON}; + TopTools_ListIteratorOfListOfShape aIt; + BOPTools_DSFiller aDF; + // + // 1. Prepare DSFiller + aDF.SetShapes (myArg1, aS); + bIsDone=aDF.IsDone(); + if (!bIsDone) { + myErrorStatus=30; // wrong args are used for DSFiller + return; + } + aDF.Perform(); + bIsDone=aDF.IsDone(); + if (!bIsDone) { + myErrorStatus=31; // DSFiller failed + return; + } + // + // 2. Find shapes + GEOMAlgo_ShapeSolid* pSS; + GEOMAlgo_VertexSolid aVXS; + GEOMAlgo_WireSolid aWRS; + GEOMAlgo_ShellSolid aSHS; + GEOMAlgo_SolidSolid aSLS; + // + pSS=NULL; + // + switch (myShapeType) { + case TopAbs_VERTEX: + pSS=&aVXS; + break; + case TopAbs_EDGE: + pSS=&aWRS; + break; + case TopAbs_FACE: + pSS=&aSHS; + break; + case TopAbs_SOLID: + aSLS.SetShape2(myArg2); + pSS=&aSLS; + break; + default: + myErrorStatus=12; // unallowed sub-shape type + return; + } + // + pSS->SetFiller(aDF); + pSS->Perform(); + iErr=pSS->ErrorStatus(); + if (iErr) { + myErrorStatus=32; // builder ShapeSolid failed + return; + } + // + for (i=0; i<3; ++i) { + const TopTools_ListOfShape& aLS=pSS->Shapes(aSts[i]); + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSImage=aIt.Value(); + if (myImages.IsBound(aSImage)) { + const TopoDS_Shape& aSx=myImages.Find(aSImage); + myMSS.Add(aSx, aSts[i]); + } + else { + myErrorStatus=33;// can not find original shape + return; + } + } + } +} +//======================================================================= +//function : MakeArgument1 +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::MakeArgument1() +{ + myErrorStatus=0; + // + Standard_Integer i, aNb; + TopAbs_ShapeEnum aType; + BRepLib_FaceError aFErr; + BRepLib_MakeFace aMF; + TopTools_IndexedMapOfShape aM; + BRep_Builder aBB; + TopoDS_Face aFace; + TopoDS_Shell aSh; + TopoDS_Solid aSd; + // + // Argument 1 + if (!myIsAnalytic) { +#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version + aMF.Init(mySurface, Standard_True, Precision::Confusion()); +#else + aMF.Init(mySurface, Standard_True); +#endif + aFErr=aMF.Error(); + if (aFErr!=BRepLib_FaceDone) { + myErrorStatus=20; // can not build the face + return; + } + // + const TopoDS_Shape& aF=aMF.Shape(); + aFace=TopoDS::Face(aF); + // + // update tolerances + aM.Add(aF); + TopExp::MapShapes(aF, TopAbs_VERTEX, aM); + TopExp::MapShapes(aF, TopAbs_EDGE, aM); + aNb=aM.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aM(i); + aType=aS.ShapeType(); + switch (aType) { + case TopAbs_VERTEX: { + const TopoDS_Vertex& aVx=TopoDS::Vertex(aS); + aBB.UpdateVertex(aVx, myTolerance); + } + break; + case TopAbs_EDGE: { + const TopoDS_Edge& aEx=TopoDS::Edge(aS); + aBB.UpdateEdge(aEx, myTolerance); + } + break; + case TopAbs_FACE: { + const TopoDS_Face& aFx=TopoDS::Face(aS); + aBB.UpdateFace(aFx, myTolerance); + } + break; + default: + break; + } + } + } // + else { + aBB.MakeFace(aFace, mySurface, myTolerance); + } + // + // make solid + aBB.MakeShell(aSh); + aBB.Add(aSh, aFace); + aBB.MakeSolid(aSd); + aBB.Add(aSd, aSh); + myArg1=aSd; +} +//======================================================================= +//function : MakeArgument2 +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::MakeArgument2() +{ + myErrorStatus=0; + // + TopoDS_Shape aSC; + TopTools_DataMapOfShapeShape aOriginals; + // + myImages.Clear(); + // + GEOMAlgo_FinderShapeOn::CopySource(myShape, myImages, aOriginals, aSC); + // + myArg2=aSC; +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::CheckData() +{ + myErrorStatus=0; + // + if(mySurface.IsNull()) { + myErrorStatus=10; // mySurface=NULL + return; + } + // + if (myShape.IsNull()) { + myErrorStatus=11; // myShape=NULL + return; + } + // + if (!(myShapeType==TopAbs_VERTEX || + myShapeType==TopAbs_EDGE || + myShapeType==TopAbs_FACE || + myShapeType==TopAbs_SOLID)) { + myErrorStatus=12; // unallowed sub-shape type + return; + } + // + if (myState==GEOMAlgo_ST_UNKNOWN || + myState==GEOMAlgo_ST_INOUT) { + myErrorStatus=13; // unallowed state type + return; + } +} +// +//======================================================================= +//function : CopySource +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn::CopySource(const TopoDS_Shape& aE, + TopTools_DataMapOfShapeShape& aImages, + TopTools_DataMapOfShapeShape& aOriginals, + TopoDS_Shape& aEx) +{ + Standard_Boolean bFree; + TopAbs_ShapeEnum aType; + Standard_Integer aR; + BRep_Builder BB; + TopoDS_Iterator aIt; + // + aType=aE.ShapeType(); + // + if (aOriginals.IsBound(aE)) { + aEx=aOriginals.ChangeFind(aE); + return; + } + else { + aEx=aE.EmptyCopied(); + aOriginals.Bind(aE, aEx); + aImages.Bind(aEx, aE); + } + // + aR=(Standard_Integer)aType+1; + if (aR>TopAbs_VERTEX) { + return; + } + // + bFree=aEx.Free(); + aEx.Free(Standard_True); + // + aType=(TopAbs_ShapeEnum) aR; + // + aIt.Initialize(aE);//, Standard_False); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aV=aIt.Value(); + TopoDS_Shape aVx; + // + CopySource (aV, aImages, aOriginals, aVx); + // + aVx.Orientation(aV.Orientation()); + BB.Add(aEx, aVx); + } + // + aEx.Free(bFree); +} +// +//======================================================================= +//function : BuildTriangulation +//purpose : +//======================================================================= +Standard_Boolean + GEOMAlgo_FinderShapeOn::BuildTriangulation (const TopoDS_Shape& theShape) +{ + // calculate deflection + Standard_Real aDeviationCoefficient = 0.001; + + Bnd_Box B; + BRepBndLib::Add(theShape, B); + Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; + B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); + + Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin; + Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4; + Standard_Real aHLRAngle = 0.349066; + + // build triangulation + BRepMesh_IncrementalMesh Inc (theShape, aDeflection, Standard_False, aHLRAngle); + + // check triangulation + bool isTriangulation = true; + + TopExp_Explorer exp (theShape, TopAbs_FACE); + if (exp.More()) + { + TopLoc_Location aTopLoc; + Handle(Poly_Triangulation) aTRF; + aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc); + if (aTRF.IsNull()) { + isTriangulation = false; + } + } + else // no faces, try edges + { + TopExp_Explorer expe (theShape, TopAbs_EDGE); + if (!expe.More()) { + isTriangulation = false; + } + else { + TopLoc_Location aLoc; + Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc); + if (aPE.IsNull()) { + isTriangulation = false; + } + } + } + + return isTriangulation; +} + +// +// myErrorStatus : +// +// 10 -mySurface=NULL +// 11 -myShape=NULL +// 12 -unallowed type of sub-shapes +// 13 -unallowed state +// 20 -can not build the face +// 30 -wrong args are used for DSFiller +// 31 -DSFiller failed +// 32 -builder ShapeSolid failed +// 33 -can not find original shape +// +// myWarningStatus +// +// 10 - sub-shapes of type myShapeType can not be fond in myShape diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.hxx new file mode 100644 index 000000000..8d6cbdb83 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn.hxx @@ -0,0 +1,120 @@ + +// 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_FinderShapeOn.hxx +// Created: Tue Jan 11 14:44:31 2005 +// Author: Peter KURNEV + +#ifndef _GEOMAlgo_FinderShapeOn_HeaderFile +#define _GEOMAlgo_FinderShapeOn_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_FinderShapeOn +//purpose : +//======================================================================= +class GEOMAlgo_FinderShapeOn : public GEOMAlgo_ShapeAlgo +{ + public: + Standard_EXPORT + GEOMAlgo_FinderShapeOn(); + + Standard_EXPORT + virtual ~GEOMAlgo_FinderShapeOn(); + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + void SetSurface(const Handle(Geom_Surface)& aS) ; + + Standard_EXPORT + void SetShapeType(const TopAbs_ShapeEnum aST) ; + + Standard_EXPORT + void SetState(const GEOMAlgo_State aSF) ; + + Standard_EXPORT + const Handle_Geom_Surface& Surface() const; + + Standard_EXPORT + TopAbs_ShapeEnum ShapeType() const; + + Standard_EXPORT + GEOMAlgo_State State() const; + + Standard_EXPORT + const TopTools_ListOfShape& Shapes() const; + + Standard_EXPORT + static void CopySource(const TopoDS_Shape& aS, + TopTools_DataMapOfShapeShape& aImages, + TopTools_DataMapOfShapeShape& aOriginals, + TopoDS_Shape& aSC) ; + + Standard_EXPORT + static Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ; + +protected: + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + void MakeArgument1() ; + + Standard_EXPORT + void MakeArgument2() ; + + Standard_EXPORT + void Find() ; + + Standard_EXPORT + void Find(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void FindVertices() ; + + + Handle_Geom_Surface mySurface; + TopAbs_ShapeEnum myShapeType; + GEOMAlgo_State myState; + TopoDS_Shape myArg1; + TopoDS_Shape myArg2; + TopTools_ListOfShape myLS; + TopTools_DataMapOfShapeShape myImages; + GEOMAlgo_IndexedDataMapOfShapeState myMSS; + Standard_Boolean myIsAnalytic; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn1.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn1.cxx new file mode 100644 index 000000000..eb28835e9 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn1.cxx @@ -0,0 +1,854 @@ +// 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_FinderShapeOn1.cxx +// Created: Fri Mar 4 10:31:06 2005 +// 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 + +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_FinderShapeOn1 +//purpose : +//======================================================================= +GEOMAlgo_FinderShapeOn1::GEOMAlgo_FinderShapeOn1() +: + GEOMAlgo_ShapeAlgo() +{ + myTolerance=0.0001; + myShapeType=TopAbs_VERTEX; + myState=GEOMAlgo_ST_UNKNOWN; + myNbPntsMin=3; + myNbPntsMax=0; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_FinderShapeOn1::~GEOMAlgo_FinderShapeOn1() +{ +} +//======================================================================= +//function : SetSurface +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::SetSurface(const Handle(Geom_Surface)& aS) +{ + mySurface=aS; +} +//======================================================================= +//function : Surface +//purpose : +//======================================================================= +const Handle(Geom_Surface)& GEOMAlgo_FinderShapeOn1::Surface() const +{ + return mySurface; +} +//======================================================================= +//function : SetShapeType +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::SetShapeType(const TopAbs_ShapeEnum aType) +{ + myShapeType=aType; +} +//======================================================================= +//function : ShapeType +//purpose : +//======================================================================= +TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn1::ShapeType()const +{ + return myShapeType; +} +//======================================================================= +//function : SetState +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::SetState(const GEOMAlgo_State aState) +{ + myState=aState; +} +//======================================================================= +//function : State +//purpose : +//======================================================================= +GEOMAlgo_State GEOMAlgo_FinderShapeOn1::State() const +{ + return myState; +} +//======================================================================= +//function : SetNbPntsMin +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::SetNbPntsMin(const Standard_Integer aNb) +{ + myNbPntsMin=aNb; +} +//======================================================================= +//function : NbPntsMin +//purpose : +//======================================================================= +Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMin()const +{ + return myNbPntsMin; +} +//======================================================================= +//function : SetNbPntsMax +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::SetNbPntsMax(const Standard_Integer aNb) +{ + myNbPntsMax=aNb; +} +//======================================================================= +//function : NbPntsMax +//purpose : +//======================================================================= +Standard_Integer GEOMAlgo_FinderShapeOn1::NbPntsMax()const +{ + return myNbPntsMax; +} +//======================================================================= +// function: MSS +// purpose: +//======================================================================= +const GEOMAlgo_IndexedDataMapOfShapeState& GEOMAlgo_FinderShapeOn1::MSS() const +{ + return myMSS; +} +//======================================================================= +// function: Shapes +// purpose: +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn1::Shapes() const +{ + Standard_Integer i, aNb; + TopTools_ListOfShape* pL; + // + pL=(TopTools_ListOfShape*) &myLS; + pL->Clear(); + // + aNb=myMSS.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=myMSS.FindKey(i); + if (aS.ShapeType()==myShapeType) { + pL->Append(aS); + } + } + return myLS; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::Perform() +{ + myErrorStatus=0; + myWarningStatus=0; + myLS.Clear(); + myMSS.Clear(); + // + CheckData(); + if(myErrorStatus) { + return; + } + // + // Initialize the context + GEOMAlgo_ShapeAlgo::Perform(); + // + // 1 + ProcessVertices(); + if(myErrorStatus) { + return; + } + if (myShapeType==TopAbs_VERTEX) { + return; + } + // + // 2 + ProcessEdges(); + if(myErrorStatus) { + return; + } + if (myShapeType==TopAbs_EDGE) { + return; + } + // + // 3 + ProcessFaces(); + if(myErrorStatus) { + return; + } + if (myShapeType==TopAbs_FACE) { + return; + } + // + // 4 + ProcessSolids(); + // +} +//======================================================================= +//function : ProcessVertices +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::ProcessVertices() +{ + myErrorStatus=0; + // + Standard_Boolean bIsConformState; + Standard_Integer i, aNb; + gp_Pnt aP; + TopTools_IndexedMapOfShape aM; + TopAbs_State aSt; + // + TopExp::MapShapes(myShape, TopAbs_VERTEX, aM); + aNb=aM.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aM(i)); + aP=BRep_Tool::Pnt(aV); + // + aSt = GetPointState( aP ); + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + // + if (myShapeType==TopAbs_VERTEX){ + if (bIsConformState) { + myMSS.Add(aV, aSt); + } + } + else if (bIsConformState || aSt==TopAbs_ON) { + myMSS.Add(aV, aSt); + } + } +} +//======================================================================= +//function : ProcessEdges +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::ProcessEdges() +{ + myErrorStatus=0; + // + Standard_Boolean bIsConformState, bIsToBreak; + Standard_Integer i, aNb, iCnt; + TopAbs_State aSt; + TopTools_IndexedMapOfShape aM; + TopExp_Explorer aExp; + GEOMAlgo_ListIteratorOfListOfPnt aIt; + GeomAbs_SurfaceType aType1; + // + aType1=myGAS.GetType(); + // + TopExp::MapShapes(myShape, TopAbs_EDGE, aM); + aNb=aM.Extent(); + for (i=1; i<=aNb; ++i) { + GEOMAlgo_ListOfPnt aLP; + GEOMAlgo_StateCollector aSC; + // + const TopoDS_Edge& aE=TopoDS::Edge(aM(i)); + // + aExp.Init(aE, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aV=aExp.Current(); + // + bIsConformState=myMSS.Contains(aV); + if (!bIsConformState) { + break;// vertex has non-conformed state + } + else { + aSt=myMSS.FindFromKey(aV); + aSC.AppendState(aSt); + } + } + // + if (!bIsConformState) { + continue; // vertex has non-conformed state,skip edge + } + // + if (BRep_Tool::Degenerated(aE)) { + myMSS.Add(aE, aSt); + continue; + } + // + if (myState==GEOMAlgo_ST_ON && aType1==GeomAbs_Sphere) { + Standard_Real aT1, aT2; + Handle(Geom_Curve) aC; + GeomAdaptor_Curve aGAC; + GeomAbs_CurveType aType2; + // + aC=BRep_Tool::Curve(aE, aT1, aT2); + aGAC.Load(aC); + // + aType2=aGAC.GetType(); + if (aType2==GeomAbs_Line) { + continue; + } + } + // + InnerPoints(aE, aLP); + if (myErrorStatus) { + return; + } + // + bIsConformState=Standard_True; + aIt.Initialize(aLP); + for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) { + if (myNbPntsMax) { + if (iCnt > myNbPntsMax) { + break; + } + } + // + const gp_Pnt& aP=aIt.Value(); + aSt = GetPointState( aP ); + bIsToBreak=aSC.AppendState(aSt); + if (bIsToBreak) { + break; + } + } + // + aSt=aSC.State(); + // + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + if (myShapeType==TopAbs_EDGE) { + if (bIsConformState) { + myMSS.Add(aE, aSt); + } + } + else if (bIsConformState || aSt==TopAbs_ON) { + myMSS.Add(aE, aSt); + } + } // for (i=1; i<=aNb; ++i) next edge +} +//======================================================================= +//function : ProcessFaces +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::ProcessFaces() +{ + myErrorStatus=0; + // + Standard_Boolean bIsConformState, bIsToBreak; + Standard_Integer i, aNbF, iCnt; + TopAbs_State aSt; + TopTools_IndexedMapOfShape aM; + TopExp_Explorer aExp; + GEOMAlgo_ListIteratorOfListOfPnt aIt; + GeomAbs_SurfaceType aType1, aType2; + // + aType1=myGAS.GetType(); + // + TopExp::MapShapes(myShape, TopAbs_FACE, aM); + aNbF=aM.Extent(); + for (i=1; i<=aNbF; ++i) { + GEOMAlgo_StateCollector aSC; + GEOMAlgo_ListOfPnt aLP; + // + const TopoDS_Face& aF=TopoDS::Face(aM(i)); + // + if (myState==GEOMAlgo_ST_ON) { + Handle(Geom_Surface) aS; + GeomAdaptor_Surface aGAS; + // + aS=BRep_Tool::Surface(aF); + aGAS.Load(aS); + aType2=aGAS.GetType(); + if (aType2!=aType1) { + continue; + } + } + // + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aE=aExp.Current(); + bIsConformState=myMSS.Contains(aE); + if (!bIsConformState) { + break;// edge has non-conformed state + } + else { + aSt=myMSS.FindFromKey(aE); + aSC.AppendState(aSt); + } + } + // + if (!bIsConformState) { + continue; // edge has non-conformed state,skip face + } + // + InnerPoints(aF, aLP); + if (myErrorStatus) { + return; + } + // + bIsConformState=Standard_True; + aIt.Initialize(aLP); + for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) { + if (myNbPntsMax) { + if (iCnt > myNbPntsMax) { + break; + } + } + // + const gp_Pnt& aP=aIt.Value(); + aSt = GetPointState( aP ); + bIsToBreak=aSC.AppendState(aSt); + if (bIsToBreak) { + break; + } + } + // + aSt=aSC.State(); + // + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + if (myShapeType==TopAbs_FACE) { + if (bIsConformState) { + myMSS.Add(aF, aSt); + } + } + else if (bIsConformState || aSt==TopAbs_ON) { + myMSS.Add(aF, aSt); + } + }// for (i=1; i<=aNb; ++i) next face +} +//======================================================================= +//function : ProcessSolids +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::ProcessSolids() +{ + myErrorStatus=0; + // + Standard_Boolean bIsConformState; + Standard_Integer i, aNbS, j, aNbF; + TopTools_IndexedMapOfShape aM, aMF; + TopAbs_State aSt; + // + TopExp::MapShapes(myShape, TopAbs_SOLID, aM); + aNbS=aM.Extent(); + for (i=1; i<=aNbS; ++i) { + GEOMAlgo_StateCollector aSC; + // + const TopoDS_Shape& aSd=aM(i); + aMF.Clear(); + TopExp::MapShapes(aSd, TopAbs_FACE, aMF); + aNbF=aMF.Extent(); + for (j=1; j<=aNbF; ++j) { + const TopoDS_Shape& aF=aMF(j); + bIsConformState=myMSS.Contains(aF); + if (!bIsConformState) { + break;// face has non-conformed state + } + else { + aSt=myMSS.FindFromKey(aF); + aSC.AppendState(aSt); + } + } + // + if (!bIsConformState) { + continue; // face has non-conformed state,skip solid + } + // + aSt=aSC.State(); + // + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + if (bIsConformState) { + myMSS.Add(aSd, aSt); + } + } +} +// +//======================================================================= +//function : InnerPoints +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Face& aF, + GEOMAlgo_ListOfPnt& aLP) +{ + myErrorStatus=0; + // + Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds; + TopLoc_Location aLoc; + Handle(Poly_Triangulation) aTRF; + TColStd_MapOfInteger aMBN; + GEOMAlgo_DataMapOfPassKeyInteger aMPKI; + GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt; + gp_Pnt aP, aP1, aP2; + // + aLP.Clear(); + // + aTRF=BRep_Tool::Triangulation(aF, aLoc); + if (aTRF.IsNull()) { + if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aF)) { + myWarningStatus=20; // no triangulation found + return; + } + aTRF=BRep_Tool::Triangulation(aF, aLoc); + } + // + const gp_Trsf& aTrsf=aLoc.Transformation(); + const Poly_Array1OfTriangle& aTrs=aTRF->Triangles(); + const TColgp_Array1OfPnt& aNodes=aTRF->Nodes(); + // + // map link/nbtriangles + j1=aTrs.Lower(); + j2=aTrs.Upper(); + for (j=j1; j<=j2; ++j) { + const Poly_Triangle& aTr=aTrs(j); + aTr.Get(n[0], n[1], n[2]); + n[3]=n[0]; + for (k=0; k<3; ++k) { + GEOMAlgo_PassKey aPK; + // + aPK.SetIds(n[k], n[k+1]); + if (aMPKI.IsBound(aPK)) { + Standard_Integer& iCntX=aMPKI.ChangeFind(aPK); + ++iCntX; + } + else { + aMPKI.Bind(aPK, 1); + } + } + } + // + // boundary nodes aMBN + aNbLinks=aMPKI.Extent(); + aIt.Initialize(aMPKI); + for (; aIt.More(); aIt.Next()) { + iCnt=aIt.Value(); + if (iCnt==1) { + const GEOMAlgo_PassKey& aPK=aIt.Key(); + // + aNx=(Standard_Integer)aPK.Id(1); + aMBN.Add(aNx); + aNx=(Standard_Integer)aPK.Id(2); + aMBN.Add(aNx); + } + } + // + // inner nodes=all_nodes - boundary_nodes + j1=aNodes.Lower(); + j2=aNodes.Upper(); + for (j=j1; j<=j2; ++j) { + if (!aMBN.Contains(j)) { + aP=aNodes(j).Transformed(aTrsf); + aLP.Append(aP); + } + } + // + aNb=aLP.Extent(); + // + if (!aNb && myNbPntsMin) { + // try to fill it yourself + Standard_Boolean bIsDone; + Standard_Integer aN1, aN2; + Handle(Geom_Surface) aS; + GeomAdaptor_Surface aGAS; + GeomAbs_SurfaceType aType; + // + aS=BRep_Tool::Surface(aF); + aGAS.Load(aS); + aType=aGAS.GetType(); + if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) { + // inner links + aNbLinks=aMPKI.Extent(); + aIt.Initialize(aMPKI); + for (; aIt.More(); aIt.Next()) { + iCnt=aIt.Value(); + if (iCnt>1) { + // take the first having occured inner link + // and discretize it + const GEOMAlgo_PassKey& aPK=aIt.Key(); + // + aN1=(Standard_Integer)aPK.Id(1); + aN2=(Standard_Integer)aPK.Id(2); + // + aP1=aNodes(aN1).Transformed(aTrsf); + aP2=aNodes(aN2).Transformed(aTrsf); + // + if (aType==GeomAbs_Cylinder) { + Standard_Real aTolSM; + gp_Cylinder aCyl; + // + aTolSM=1.523e-6;//~1.-cos(0.1 deg) + aCyl=aGAS.Cylinder(); + if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) { + continue; + } + } + // + BRepLib_MakeEdge aBME(aP1, aP2); + bIsDone=aBME.IsDone(); + if (!bIsDone) { + myErrorStatus=30; //can not obtain the line fron the link + return; + } + // + const TopoDS_Shape& aSx=aBME.Shape(); + const TopoDS_Edge& aE=TopoDS::Edge(aSx); + // + InnerPoints(aE, myNbPntsMin, aLP); + break; + }// if (iCnt>1) + }// for (; aIt.More(); aIt.Next()) + }// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) + }// if (!aNb && myNbPntsMin) { +} +//modified by NIZNHY-PKV Thu Jan 26 09:56:20 2012f +//======================================================================= +//function : InnerPoints +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE, + GEOMAlgo_ListOfPnt& aLP) +{ + Standard_Integer aNbPntsMin; + // + myErrorStatus=0; + aNbPntsMin=21; + // + aLP.Clear(); + InnerPoints(aE, aNbPntsMin, aLP); +} +//modified by NIZNHY-PKV Thu Jan 26 09:56:32 2012t +//======================================================================= +//function : InnerPoints +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE, + const Standard_Integer aNbPntsMin, + GEOMAlgo_ListOfPnt& aLP) +{ + Standard_Boolean bInf1, bInf2; + Standard_Integer j, aNbT; + Standard_Real dT, aT, aT1, aT2; + gp_Pnt aP; + Handle(Geom_Curve) aC3D; + // + aC3D=BRep_Tool::Curve(aE, aT1, aT2); + if (aC3D.IsNull()) { + return; + } + // + bInf1=Precision::IsNegativeInfinite(aT1); + bInf2=Precision::IsPositiveInfinite(aT2); + if (bInf1 || bInf2) { + return; + } + // + //modified by NIZNHY-PKV Thu Jan 26 09:51:20 2012f + /* + aNbT=myNbPntsMin+1; + dT=(aT2-aT1)/aNbT; + for (j=1; j<=aNbPntsMin; ++j) { + aT=aT1+j*dT; + aC3D->D0(aT, aP); + aLP.Append(aP); + } + */ + aNbT=aNbPntsMin+1; + dT=(aT2-aT1)/aNbT; + for (j=1; jD0(aT, aP); + aLP.Append(aP); + } + //modified by NIZNHY-PKV Thu Jan 26 09:51:24 2012t +} + +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::CheckData() +{ + myErrorStatus=0; + // + if(mySurface.IsNull()) { + myErrorStatus=10; // mySurface=NULL + return; + } + // + if (myShape.IsNull()) { + myErrorStatus=11; // myShape=NULL + return; + } + // + if (!(myShapeType==TopAbs_VERTEX || + myShapeType==TopAbs_EDGE || + myShapeType==TopAbs_FACE || + myShapeType==TopAbs_SOLID)) { + myErrorStatus=12; // unallowed subshape type + return; + } + // + if (myState==GEOMAlgo_ST_UNKNOWN || + myState==GEOMAlgo_ST_INOUT) { + myErrorStatus=13; // unallowed state type + return; + } + // + GeomAbs_SurfaceType aType; + // + myGAS.Load(mySurface); + aType=myGAS.GetType(); + if (!(aType==GeomAbs_Plane || + aType==GeomAbs_Cylinder || + aType==GeomAbs_Sphere)) { + myErrorStatus=14; // unallowed surface type + } +} + +//======================================================================= +//function : GetPointState +//purpose : +//======================================================================= + +TopAbs_State GEOMAlgo_FinderShapeOn1::GetPointState(const gp_Pnt& aP) +{ + TopAbs_State aSt; + GEOMAlgo_SurfaceTools::GetState(aP, myGAS, myTolerance, aSt); + return aSt; +} + + +// +// myErrorStatus : +// +// 10 -mySurface=NULL +// 11 -myShape=NULL +// 12 -unallowed type of subshapes +// 13 -unallowed state +// 14 -unallowed surface type +// 15 -unallowed surface type +// 20- no triangulation found +// 30- can not obtain the line from the link + +//modified by NIZNHY-PKV Thu Jan 26 10:01:14 2012f +/* +//======================================================================= +//function : InnerPoints +//purpose : +//======================================================================= +void GEOMAlgo_FinderShapeOn1::InnerPoints(const TopoDS_Edge& aE, + GEOMAlgo_ListOfPnt& aLP) +{ + myErrorStatus=0; + // + Standard_Integer j, aNbNodes, aIndex, aNb; + Handle(Poly_PolygonOnTriangulation) aPTE; + Handle(Poly_Triangulation) aTRE; + TopLoc_Location aLoc; + gp_Pnt aP; + // + aLP.Clear(); + BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc); + if (aTRE.IsNull() || aPTE.IsNull()) { + Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc); + if (aPE.IsNull()) { + if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aE)) { + myErrorStatus=20; // no triangulation found + return; + } + aPE = BRep_Tool::Polygon3D(aE, aLoc); + } + const gp_Trsf& aTrsf=aLoc.Transformation(); + const TColgp_Array1OfPnt& aNodes=aPE->Nodes(); + // + aNbNodes=aPE->NbNodes(); + Standard_Integer low = aNodes.Lower(), up = aNodes.Upper(); + for (j=low+1; jNodes(); + // + aNbNodes=aPTE->NbNodes(); + const TColStd_Array1OfInteger& aInds=aPTE->Nodes(); + for (j=2; j +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_FinderShapeOn1 +//purpose : +//======================================================================= +class GEOMAlgo_FinderShapeOn1 : public GEOMAlgo_ShapeAlgo +{ + public: + Standard_EXPORT + GEOMAlgo_FinderShapeOn1(); + + Standard_EXPORT + virtual ~GEOMAlgo_FinderShapeOn1(); + + Standard_EXPORT + void SetSurface(const Handle(Geom_Surface)& aS) ; + + Standard_EXPORT + void SetShapeType(const TopAbs_ShapeEnum aST) ; + + Standard_EXPORT + void SetState(const GEOMAlgo_State aSF) ; + + Standard_EXPORT + void SetNbPntsMin(const Standard_Integer aNb) ; + + Standard_EXPORT + Standard_Integer NbPntsMin() const; + + Standard_EXPORT + void SetNbPntsMax(const Standard_Integer aNb) ; + + Standard_EXPORT + Standard_Integer NbPntsMax() const; + + Standard_EXPORT + const Handle_Geom_Surface& Surface() const; + + Standard_EXPORT + TopAbs_ShapeEnum ShapeType() const; + + Standard_EXPORT + GEOMAlgo_State State() const; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + const TopTools_ListOfShape& Shapes() const; + + Standard_EXPORT + const GEOMAlgo_IndexedDataMapOfShapeState& MSS() const; + + protected: + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + void ProcessVertices() ; + + Standard_EXPORT + void ProcessEdges() ; + + Standard_EXPORT + void ProcessFaces() ; + + Standard_EXPORT + void ProcessSolids() ; + + Standard_EXPORT + void InnerPoints(const TopoDS_Face& aF, + GEOMAlgo_ListOfPnt& aLP) ; + + Standard_EXPORT + void InnerPoints(const TopoDS_Edge& aE, + GEOMAlgo_ListOfPnt& aLP) ; + + Standard_EXPORT + void InnerPoints(const TopoDS_Edge& aE, + const Standard_Integer aNbPnts, + GEOMAlgo_ListOfPnt& aLP) ; + + Standard_EXPORT + virtual TopAbs_State GetPointState(const gp_Pnt& aP) ; + + + Handle_Geom_Surface mySurface; + TopAbs_ShapeEnum myShapeType; + GEOMAlgo_State myState; + Standard_Integer myNbPntsMin; + Standard_Integer myNbPntsMax; + GeomAdaptor_Surface myGAS; + TopTools_ListOfShape myLS; + GEOMAlgo_IndexedDataMapOfShapeState myMSS; +}; + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.cxx new file mode 100644 index 000000000..e437f0c04 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.cxx @@ -0,0 +1,845 @@ +// 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_FinderShapeOn2.cxx +// Created: Fri Mar 4 10:31:06 2005 +// 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 + +#include + +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_FinderShapeOn1 +//purpose : +//======================================================================= + GEOMAlgo_FinderShapeOn2::GEOMAlgo_FinderShapeOn2() +: + GEOMAlgo_ShapeAlgo() +{ + myTolerance=0.0001; + myShapeType=TopAbs_VERTEX; + myState=GEOMAlgo_ST_UNKNOWN; + myNbPntsMin=3; + myNbPntsMax=0; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_FinderShapeOn2::~GEOMAlgo_FinderShapeOn2() +{ +} +//======================================================================= +//function : SetClsf +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::SetClsf(const Handle(GEOMAlgo_Clsf)& aClsf) +{ + myClsf=aClsf; +} +//======================================================================= +//function : Clsf +//purpose : +//======================================================================= + const Handle(GEOMAlgo_Clsf)& GEOMAlgo_FinderShapeOn2::Clsf() const +{ + return myClsf; +} +//======================================================================= +//function : SetShapeType +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::SetShapeType(const TopAbs_ShapeEnum aType) +{ + myShapeType=aType; +} +//======================================================================= +//function : ShapeType +//purpose : +//======================================================================= + TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn2::ShapeType()const +{ + return myShapeType; +} +//======================================================================= +//function : SetState +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::SetState(const GEOMAlgo_State aState) +{ + myState=aState; +} +//======================================================================= +//function : State +//purpose : +//======================================================================= + GEOMAlgo_State GEOMAlgo_FinderShapeOn2::State() const +{ + return myState; +} +//======================================================================= +//function : SetNbPntsMin +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::SetNbPntsMin(const Standard_Integer aNb) +{ + myNbPntsMin=aNb; +} +//======================================================================= +//function : NbPntsMin +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_FinderShapeOn2::NbPntsMin()const +{ + return myNbPntsMin; +} +//======================================================================= +//function : SetNbPntsMax +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::SetNbPntsMax(const Standard_Integer aNb) +{ + myNbPntsMax=aNb; +} +//======================================================================= +//function : NbPntsMax +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_FinderShapeOn2::NbPntsMax()const +{ + return myNbPntsMax; +} +//======================================================================= +// function: MSS +// purpose: +//======================================================================= + const GEOMAlgo_IndexedDataMapOfShapeState& GEOMAlgo_FinderShapeOn2::MSS() const +{ + return myMSS; +} +//======================================================================= +// function: Shapes +// purpose: +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_FinderShapeOn2::Shapes() const +{ + Standard_Integer i, aNb; + TopTools_ListOfShape* pL; + // + pL=(TopTools_ListOfShape*) &myLS; + pL->Clear(); + // + aNb=myMSS.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=myMSS.FindKey(i); + if (aS.ShapeType()==myShapeType) { + pL->Append(aS); + } + } + return myLS; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::Perform() +{ + myErrorStatus=0; + myWarningStatus=0; + myLS.Clear(); + myMSS.Clear(); + // + CheckData(); + if(myErrorStatus) { + return; + } + // + // Initialize the context + GEOMAlgo_ShapeAlgo::Perform(); + // + myClsf->SetTolerance(myTolerance); + // + // 1 + ProcessVertices(); + if(myErrorStatus) { + return; + } + if (myShapeType==TopAbs_VERTEX) { + return; + } + // + // 2 + ProcessEdges(); + if(myErrorStatus) { + return; + } + if (myShapeType==TopAbs_EDGE) { + return; + } + // + // 3 + ProcessFaces(); + if(myErrorStatus) { + return; + } + if (myShapeType==TopAbs_FACE) { + return; + } + // + // 4 + ProcessSolids(); + // +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::CheckData() +{ + Standard_Integer iErr; + // + myErrorStatus=0; + // + if(myClsf.IsNull()) { + myErrorStatus=10; // myClsf=NULL + return; + } + // + myClsf->CheckData(); + iErr=myClsf->ErrorStatus(); + if (iErr) { + myErrorStatus=41; // invalid data for classifier + return; + } + // + if (myShape.IsNull()) { + myErrorStatus=11; // myShape=NULL + return; + } + // + if (!(myShapeType==TopAbs_VERTEX || + myShapeType==TopAbs_EDGE || + myShapeType==TopAbs_FACE || + myShapeType==TopAbs_SOLID)) { + myErrorStatus=12; // unallowed sub-shape type + return; + } + // + if (myState==GEOMAlgo_ST_UNKNOWN || + myState==GEOMAlgo_ST_INOUT) { + myErrorStatus=13; // unallowed state type + return; + } +} +//======================================================================= +//function : ProcessVertices +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::ProcessVertices() +{ + myErrorStatus=0; + // + Standard_Boolean bIsConformState; + Standard_Integer i, aNb, iErr; + gp_Pnt aP; + TopTools_IndexedMapOfShape aM; + TopAbs_State aSt; + // + TopExp::MapShapes(myShape, TopAbs_VERTEX, aM); + aNb=aM.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aM(i)); + aP=BRep_Tool::Pnt(aV); + // + myClsf->SetPnt(aP); + myClsf->Perform(); + iErr=myClsf->ErrorStatus(); + if (iErr) { + myErrorStatus=40; // point can not be classified + return; + } + // + aSt=myClsf->State(); + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + // + if (myShapeType==TopAbs_VERTEX){ + if (bIsConformState) { + myMSS.Add(aV, aSt); + } + } + else if (bIsConformState || aSt==TopAbs_ON) { + myMSS.Add(aV, aSt); + } + } +} +//======================================================================= +//function : ProcessEdges +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::ProcessEdges() +{ + myErrorStatus=0; + // + Standard_Boolean bIsConformState, bIsToBreak; + Standard_Integer i, aNb, iCnt, iErr; + TopAbs_State aSt; + TopTools_IndexedMapOfShape aM; + TopExp_Explorer aExp; + GEOMAlgo_ListIteratorOfListOfPnt aIt; + // + TopExp::MapShapes(myShape, TopAbs_EDGE, aM); + aNb=aM.Extent(); + for (i=1; i<=aNb; ++i) { + GEOMAlgo_ListOfPnt aLP; + GEOMAlgo_StateCollector aSC; + // + const TopoDS_Edge& aE=TopoDS::Edge(aM(i)); + // + aExp.Init(aE, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aV=aExp.Current(); + // + bIsConformState=myMSS.Contains(aV); + if (!bIsConformState) { + break;// vertex has non-conformed state + } + else { + aSt=myMSS.FindFromKey(aV); + aSC.AppendState(aSt); + } + } + // + if (!bIsConformState) { + continue; // vertex has non-conformed state,skip edge + } + // + if (BRep_Tool::Degenerated(aE)) { + myMSS.Add(aE, aSt); + continue; + } + // + if (myState==GEOMAlgo_ST_ON) { + Standard_Boolean bCanBeON; + Standard_Real aT1, aT2; + Handle(Geom_Curve) aC; + // + aC=BRep_Tool::Curve(aE, aT1, aT2); + bCanBeON=myClsf->CanBeON(aC); + if(!bCanBeON) { + continue; + } + } + // + InnerPoints(aE, aLP); + if (myErrorStatus) { + return; + } + // + bIsConformState=Standard_True; + aIt.Initialize(aLP); + for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) { + if (myNbPntsMax) { + if (iCnt > myNbPntsMax) { + break; + } + } + // + const gp_Pnt& aP=aIt.Value(); + // + myClsf->SetPnt(aP); + myClsf->Perform(); + iErr=myClsf->ErrorStatus(); + if (iErr) { + myErrorStatus=40; // point can not be classified + return; + } + // + aSt=myClsf->State(); + // + bIsToBreak=aSC.AppendState(aSt); + if (bIsToBreak) { + break; + } + } + // + aSt=aSC.State(); + // + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + if (myShapeType==TopAbs_EDGE) { + if (bIsConformState) { + myMSS.Add(aE, aSt); + } + } + else if (bIsConformState || aSt==TopAbs_ON) { + myMSS.Add(aE, aSt); + } + } // for (i=1; i<=aNb; ++i) next edge +} +//======================================================================= +//function : ProcessFaces +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::ProcessFaces() +{ + myErrorStatus=0; + // + Standard_Boolean bIsConformState, bIsToBreak, bCanBeON; + Standard_Integer i, aNbF, iCnt, iErr; + TopAbs_State aSt; + TopTools_IndexedMapOfShape aM; + TopExp_Explorer aExp; + GEOMAlgo_ListIteratorOfListOfPnt aIt; + // + TopExp::MapShapes(myShape, TopAbs_FACE, aM); + aNbF=aM.Extent(); + for (i=1; i<=aNbF; ++i) { + GEOMAlgo_StateCollector aSC; + GEOMAlgo_ListOfPnt aLP; + // + const TopoDS_Face& aF=TopoDS::Face(aM(i)); + // + if (myState==GEOMAlgo_ST_ON) { + Handle(Geom_Surface) aS; + // + aS=BRep_Tool::Surface(aF); + bCanBeON=myClsf->CanBeON(aS); + if(!bCanBeON) { + continue; + } + } + // + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aE=aExp.Current(); + bIsConformState=myMSS.Contains(aE); + if (!bIsConformState) { + break;// edge has non-conformed state + } + else { + aSt=myMSS.FindFromKey(aE); + aSC.AppendState(aSt); + } + } + // + if (!bIsConformState) { + continue; // edge has non-conformed state,skip face + } + // + InnerPoints(aF, aLP); + if (myErrorStatus) { + return; + } + // + bIsConformState=Standard_True; + aIt.Initialize(aLP); + for (iCnt=0; aIt.More(); aIt.Next(), ++iCnt) { + if (myNbPntsMax) { + if (iCnt > myNbPntsMax) { + break; + } + } + // + const gp_Pnt& aP=aIt.Value(); + // + myClsf->SetPnt(aP); + myClsf->Perform(); + iErr=myClsf->ErrorStatus(); + if (iErr) { + myErrorStatus=40; // point can not be classified + return; + } + // + aSt=myClsf->State(); + // + bIsToBreak=aSC.AppendState(aSt); + if (bIsToBreak) { + break; + } + } + // + aSt=aSC.State(); + // + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + if (myShapeType==TopAbs_FACE) { + if (bIsConformState) { + myMSS.Add(aF, aSt); + } + } + else if (bIsConformState || aSt==TopAbs_ON) { + myMSS.Add(aF, aSt); + } + }// for (i=1; i<=aNb; ++i) next face +} +//======================================================================= +//function : ProcessSolids +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::ProcessSolids() +{ + myErrorStatus=0; + // + Standard_Boolean bIsConformState; + Standard_Integer i, aNbS, j, aNbF; + TopTools_IndexedMapOfShape aM, aMF; + TopAbs_State aSt; + // + TopExp::MapShapes(myShape, TopAbs_SOLID, aM); + aNbS=aM.Extent(); + for (i=1; i<=aNbS; ++i) { + GEOMAlgo_StateCollector aSC; + // + const TopoDS_Shape& aSd=aM(i); + aMF.Clear(); + TopExp::MapShapes(aSd, TopAbs_FACE, aMF); + aNbF=aMF.Extent(); + for (j=1; j<=aNbF; ++j) { + const TopoDS_Shape& aF=aMF(j); + bIsConformState=myMSS.Contains(aF); + if (!bIsConformState) { + break;// face has non-conformed state + } + else { + aSt=myMSS.FindFromKey(aF); + aSC.AppendState(aSt); + } + } + // + if (!bIsConformState) { + continue; // face has non-conformed state,skip solid + } + // + aSt=aSC.State(); + // + bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState); + if (bIsConformState) { + myMSS.Add(aSd, aSt); + } + } +} +// +//======================================================================= +//function : InnerPoints +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Face& aF, + GEOMAlgo_ListOfPnt& aLP) +{ + myErrorStatus=0; + // + Standard_Integer j, j1, j2, k, n[4], aNbLinks, aNx, aNb, iCnt;//, aNbMax, *pIds; + TopLoc_Location aLoc; + Handle(Poly_Triangulation) aTRF; + TColStd_MapOfInteger aMBN; + GEOMAlgo_DataMapOfPassKeyInteger aMPKI; + GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger aIt; + gp_Pnt aP, aP1, aP2; + // + aLP.Clear(); + // + aTRF=BRep_Tool::Triangulation(aF, aLoc); + if (aTRF.IsNull()) { + if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aF)) { + myWarningStatus=20; // no triangulation found + return; + } + aTRF=BRep_Tool::Triangulation(aF, aLoc); + } + // + const gp_Trsf& aTrsf=aLoc.Transformation(); + const Poly_Array1OfTriangle& aTrs=aTRF->Triangles(); + const TColgp_Array1OfPnt& aNodes=aTRF->Nodes(); + // + // map link/nbtriangles + j1=aTrs.Lower(); + j2=aTrs.Upper(); + for (j=j1; j<=j2; ++j) { + const Poly_Triangle& aTr=aTrs(j); + aTr.Get(n[0], n[1], n[2]); + n[3]=n[0]; + for (k=0; k<3; ++k) { + GEOMAlgo_PassKey aPK; + // + aPK.SetIds(n[k], n[k+1]); + if (aMPKI.IsBound(aPK)) { + Standard_Integer& iCntX=aMPKI.ChangeFind(aPK); + ++iCntX; + } + else { + aMPKI.Bind(aPK, 1); + } + } + } + // + // boundary nodes aMBN + aNbLinks=aMPKI.Extent(); + aIt.Initialize(aMPKI); + for (; aIt.More(); aIt.Next()) { + iCnt=aIt.Value(); + if (iCnt==1) { + const GEOMAlgo_PassKey& aPK=aIt.Key(); + //qf + /* + aNbMax=aPK.NbMax(); + pIds=(Standard_Integer*)aPK.Key(); + for (k=1; k<3; ++k) { + aNx=*(pIds+aNbMax-k); + aMBN.Add(aNx); + } + */ + aNx=(Standard_Integer)aPK.Id(1); + aMBN.Add(aNx); + aNx=(Standard_Integer)aPK.Id(2); + aMBN.Add(aNx); + //qt + } + } + // + // inner nodes=all_nodes - boundary_nodes + j1=aNodes.Lower(); + j2=aNodes.Upper(); + for (j=j1; j<=j2; ++j) { + if (!aMBN.Contains(j)) { + aP=aNodes(j).Transformed(aTrsf); + aLP.Append(aP); + } + } + // + aNb=aLP.Extent(); + // + if (!aNb && myNbPntsMin) { + // try to fill it yourself + Standard_Boolean bIsDone; + Standard_Integer aN1, aN2; + Handle(Geom_Surface) aS; + GeomAdaptor_Surface aGAS; + GeomAbs_SurfaceType aType; + // + aS=BRep_Tool::Surface(aF); + aGAS.Load(aS); + aType=aGAS.GetType(); + if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) { + // inner links + aNbLinks=aMPKI.Extent(); + aIt.Initialize(aMPKI); + for (; aIt.More(); aIt.Next()) { + iCnt=aIt.Value(); + if (iCnt>1) { + // take the first having occured inner link + // and discretize it + const GEOMAlgo_PassKey& aPK=aIt.Key(); + //qf + /* + aNbMax=aPK.NbMax(); + pIds=(Standard_Integer*)aPK.Key(); + aN1=*(pIds+aNbMax-1); + aN2=*(pIds+aNbMax-2); + */ + // + aN1=(Standard_Integer)aPK.Id(1); + aN2=(Standard_Integer)aPK.Id(2); + //qt + aP1=aNodes(aN1).Transformed(aTrsf); + aP2=aNodes(aN2).Transformed(aTrsf); + // + if (aType==GeomAbs_Cylinder) { + Standard_Real aTolSM; + gp_Cylinder aCyl; + // + aTolSM=1.523e-6;//~1.-cos(0.1 deg) + aCyl=aGAS.Cylinder(); + if (!GEOMAlgo_SurfaceTools::IsCoaxial(aP1, aP2, aCyl, aTolSM)) { + continue; + } + } + // + BRepLib_MakeEdge aBME(aP1, aP2); + bIsDone=aBME.IsDone(); + if (!bIsDone) { + myErrorStatus=30; //can not obtain the line fron the link + return; + } + // + const TopoDS_Shape& aSx=aBME.Shape(); + const TopoDS_Edge& aE=TopoDS::Edge(aSx); + // + InnerPoints(aE, myNbPntsMin, aLP); + break; + }// if (iCnt>1) + }// for (; aIt.More(); aIt.Next()) + }// if (aType==GeomAbs_Plane || aType==GeomAbs_Cylinder) + }// if (!aNb && myNbPntsMin) { +} +//======================================================================= +//function : InnerPoints +//purpose : +//======================================================================= + void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE, + GEOMAlgo_ListOfPnt& aLP) +{ + myErrorStatus=0; + // + Standard_Integer j, aNbNodes, aIndex, aNb; + Handle(Poly_PolygonOnTriangulation) aPTE; + Handle(Poly_Triangulation) aTRE; + TopLoc_Location aLoc; + gp_Pnt aP; + // + aLP.Clear(); + BRep_Tool::PolygonOnTriangulation(aE, aPTE, aTRE, aLoc); + if (aTRE.IsNull() || aPTE.IsNull()) { + Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(aE, aLoc); + if (aPE.IsNull()) { + if (!GEOMAlgo_FinderShapeOn::BuildTriangulation(aE)) { + myErrorStatus=20; // no triangulation found + return; + } + aPE = BRep_Tool::Polygon3D(aE, aLoc); + } + const gp_Trsf& aTrsf=aLoc.Transformation(); + const TColgp_Array1OfPnt& aNodes=aPE->Nodes(); + // + aNbNodes=aPE->NbNodes(); + Standard_Integer low = aNodes.Lower(), up = aNodes.Upper(); + for (j=low+1; jNodes(); + // + aNbNodes=aPTE->NbNodes(); + const TColStd_Array1OfInteger& aInds=aPTE->Nodes(); + for (j=2; jD0(aT, aP); + aLP.Append(aP); + } +} + +// +// myErrorStatus : +// +// 10 -myClsf=NULL +// 11 -myShape=NULL +// 12 -unallowed type of sub-shapes +// 13 -unallowed state +// 15 -unallowed surface type +// 20- no triangulation found +// 30- can not obtain the line from the link +// 40- point can not be classified +// 41- invalid data for classifier diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.hxx new file mode 100644 index 000000000..d05875763 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOn2.hxx @@ -0,0 +1,136 @@ +// 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_FinderShapeOn2.hxx +// Created: Fri Mar 4 10:31:06 2005 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_FinderShapeOn2_HeaderFile +#define _GEOMAlgo_FinderShapeOn2_HeaderFile + +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_FinderShapeOn2 +//purpose : +//======================================================================= +class GEOMAlgo_FinderShapeOn2 : public GEOMAlgo_ShapeAlgo +{ + public: + Standard_EXPORT + GEOMAlgo_FinderShapeOn2(); + + Standard_EXPORT + virtual ~GEOMAlgo_FinderShapeOn2(); + + Standard_EXPORT + void SetClsf(const Handle(GEOMAlgo_Clsf)& aClsf) ; + + Standard_EXPORT + const Handle_GEOMAlgo_Clsf& Clsf() const; + + Standard_EXPORT + void SetShapeType(const TopAbs_ShapeEnum aST) ; + + Standard_EXPORT + TopAbs_ShapeEnum ShapeType() const; + + Standard_EXPORT + void SetState(const GEOMAlgo_State aSF) ; + + Standard_EXPORT + GEOMAlgo_State State() const; + + Standard_EXPORT + void SetNbPntsMin(const Standard_Integer aNb) ; + + Standard_EXPORT + Standard_Integer NbPntsMin() const; + + Standard_EXPORT + void SetNbPntsMax(const Standard_Integer aNb) ; + + Standard_EXPORT + Standard_Integer NbPntsMax() const; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + const TopTools_ListOfShape& Shapes() const; + + Standard_EXPORT + const GEOMAlgo_IndexedDataMapOfShapeState& MSS() const; + +protected: + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + void ProcessVertices() ; + + Standard_EXPORT + void ProcessEdges() ; + + Standard_EXPORT + void ProcessFaces() ; + + Standard_EXPORT + void ProcessSolids() ; + + Standard_EXPORT + void InnerPoints(const TopoDS_Face& aF, + GEOMAlgo_ListOfPnt& aLP) ; + + Standard_EXPORT + void InnerPoints(const TopoDS_Edge& aE, + GEOMAlgo_ListOfPnt& aLP) ; + + Standard_EXPORT + void InnerPoints(const TopoDS_Edge& aE, + const Standard_Integer aNbPnts, + GEOMAlgo_ListOfPnt& aLP) ; + + + TopAbs_ShapeEnum myShapeType; + GEOMAlgo_State myState; + Standard_Integer myNbPntsMin; + Standard_Integer myNbPntsMax; + Handle_GEOMAlgo_Clsf myClsf; + TopTools_ListOfShape myLS; + GEOMAlgo_IndexedDataMapOfShapeState myMSS; +}; + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.cxx new file mode 100644 index 000000000..7805ad133 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.cxx @@ -0,0 +1,144 @@ +// 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_FinderShapeOnQuad.cxx +// Created : Mon Oct 17 17:31:45 2005 +// Author : Edward AGAPOV (eap) +// +#include "GEOMAlgo_FinderShapeOnQuad.hxx" +#include "GEOMAlgo_SurfaceTools.hxx" + +#include +#include +#include + + +GEOMAlgo_FinderShapeOnQuad::GEOMAlgo_FinderShapeOnQuad(const gp_Pnt & theTopLeftPoint, + const gp_Pnt & theTopRigthPoint, + const gp_Pnt & theBottomLeftPoint, + const gp_Pnt & theBottomRigthPoint) +{ + myPoints.resize(6); + myPoints[0] = theTopLeftPoint ; + myPoints[1] = theTopRigthPoint ; + myPoints[2] = theBottomRigthPoint; + myPoints[3] = theBottomLeftPoint ; + myPoints[4] = myPoints[0]; + myPoints[5] = myPoints[1]; + + // Find plane normal defined by corner points, it will be used to define a plane + // for each quadrangle side. + myQuadNormal.SetCoord (0,0,0); + for ( int i = 1; i <= 4; ++i ) + myQuadNormal += gp_Vec( myPoints[i], myPoints[i+1] ) ^ gp_Vec( myPoints[i], myPoints[i-1] ); + //std::cout< point2 vector + gp_Vec aSideVec( myPoints[ i ], myPoints[ i + 1 ]); + //std::cout<<" Y Vec : "<Axis().Direction(); + gp_Vec aSideVec = myQuadNormal ^ aSideNorm; + gp_Vec c1p ( myPoints[i], aP ); + gp_Vec pc2 ( aP, myPoints[i+1] ); + if ( aSideVec * c1p >= 0. && aSideVec * pc2 >= 0. ) + return TopAbs_ON; + // consider to be IN (???????????) + //nbIn += myConcaveSide[i] ? 0.5 : 1.0; + } + } + Standard_Real inThreshold = myPlanes.size(); // usually 4.0 + if ( myConcaveQuad ) + inThreshold = 2.5; // 1.0 + 1.0 + 0.5 + + if ( nbIn >= inThreshold ) + return TopAbs_IN; + + return TopAbs_OUT; +} + diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.hxx new file mode 100644 index 000000000..d24d64c8d --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_FinderShapeOnQuad.hxx @@ -0,0 +1,61 @@ +// 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_FinderShapeOnQuad.hxx +// Created : Mon Oct 17 17:15:59 2005 +// Author : Edward AGAPOV (eap) +// +#ifndef GEOMAlgo_FinderShapeOnQuad_HeaderFile +#define GEOMAlgo_FinderShapeOnQuad_HeaderFile + +#include "GEOMAlgo_FinderShapeOn1.hxx" + +#include + +#include + + +class GEOMAlgo_FinderShapeOnQuad: public GEOMAlgo_FinderShapeOn1 +{ +public: + + Standard_EXPORT + GEOMAlgo_FinderShapeOnQuad(const gp_Pnt & theTopLeftPoint, + const gp_Pnt & theTopRigthPoint, + const gp_Pnt & theBottomLeftPoint, + const gp_Pnt & theBottomRigthPoint); + +protected: + + virtual void CheckData() ; + + virtual TopAbs_State GetPointState(const gp_Pnt& aP) ; + +private: + + bool myConcaveQuad; + std::vector myConcaveSide; + std::vector myPoints; + std::vector myPlanes; + gp_Vec myQuadNormal; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace.cxx new file mode 100644 index 000000000..5edc9fffc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace.cxx @@ -0,0 +1,1151 @@ +// 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; + } + // + // Initialize the context + GEOMAlgo_GluerAlgo::Perform(); + // + 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); + //modified by NIZNHY-PKV Fri Jun 10 08:20:03 2011f + //aBox1.SetGap(myTolerance); + aBox1.Enlarge(myTolerance); + //modified by NIZNHY-PKV Fri Jun 10 08:20:06 2011t + // + 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); + //modified by NIZNHY-PKV Fri Jun 10 08:20:23 2011f + //aBox2.SetGap(myTolerance); + aBox2.Enlarge(myTolerance); + //modified by NIZNHY-PKV Fri Jun 10 08:20:25 2011t + // + 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; + 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; + 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; + 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; + 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; + 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 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_NEW/GEOMAlgo_GetInPlace.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace.hxx new file mode 100644 index 000000000..cf3c61f0b --- /dev/null +++ b/src/GEOMAlgo_NEW/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_NEW/GEOMAlgo_GetInPlace_1.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_1.cxx new file mode 100644 index 000000000..3bdce9c51 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_1.cxx @@ -0,0 +1,401 @@ +// 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 +// 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; + Standard_Integer iErr; + Standard_Real aTol2; + 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_NEW/GEOMAlgo_GetInPlace_2.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_2.cxx new file mode 100644 index 000000000..7378e0e51 --- /dev/null +++ b/src/GEOMAlgo_NEW/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_NEW/GEOMAlgo_GetInPlace_3.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_GetInPlace_3.cxx new file mode 100644 index 000000000..6f86b5442 --- /dev/null +++ b/src/GEOMAlgo_NEW/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_NEW/GEOMAlgo_GlueAnalyser.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.cxx new file mode 100644 index 000000000..1f5999aa6 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.cxx @@ -0,0 +1,466 @@ +// 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_GlueDetector.cxx +// Created: Wed Dec 15 11:08:09 2004 +// 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 + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_GlueAnalyser::GEOMAlgo_GlueAnalyser() +: + GEOMAlgo_Gluer() +{} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_GlueAnalyser::~GEOMAlgo_GlueAnalyser() +{} +//======================================================================= +//function : HasSolidsToGlue +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_GlueAnalyser::HasSolidsToGlue()const +{ + return !mySolidsToGlue.IsEmpty(); +} +//======================================================================= +//function : HasSolidsAlone +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_GlueAnalyser::HasSolidsAlone()const +{ + return !mySolidsAlone.IsEmpty(); +} +//======================================================================= +//function : SolidsToGlue +//purpose : +//======================================================================= + const GEOMAlgo_ListOfCoupleOfShapes& GEOMAlgo_GlueAnalyser::SolidsToGlue()const +{ + return mySolidsToGlue; +} +//======================================================================= +//function : SolidsAlone +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_GlueAnalyser::SolidsAlone()const +{ + return mySolidsAlone; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::Perform() +{ + myErrorStatus=0; + myWarningStatus=0; + // + mySolidsToGlue.Clear(); + mySolidsAlone.Clear(); + // + CheckData(); + if (myErrorStatus) { + return; + } + // + // Initialize the context + GEOMAlgo_ShapeAlgo::Perform(); + // + InnerTolerance(); + if (myErrorStatus) { + return; + } + // + DetectVertices(); + if (myErrorStatus) { + return; + } + // + DetectEdges(); + if (myErrorStatus) { + return; + } + // + DetectFaces(); + if (myErrorStatus) { + return; + } + // + DetectSolids(); + if (myErrorStatus) { + return; + } +} +//======================================================================= +//function : DetectVertices +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectVertices() +{ + myErrorStatus=0; + // + Standard_Integer j, i, aNbV, aIndex, aNbVSD; + TColStd_ListIteratorOfListOfInteger aIt; + Handle(Bnd_HArray1OfBox) aHAB; + Bnd_BoundSortBox aBSB; + TopoDS_Shape aSTmp, aVF; + TopoDS_Vertex aVnew; + TopTools_IndexedMapOfShape aMV, aMVProcessed; + TopTools_ListIteratorOfListOfShape aItS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; + GEOMAlgo_IndexedDataMapOfShapeBox aMSB; + // + TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV); + aNbV=aMV.Extent(); + if (!aNbV) { + myErrorStatus=2; // no vertices in source shape + return; + } + // + aHAB=new Bnd_HArray1OfBox(1, aNbV); + // + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + Bnd_Box aBox; + // + aBox.SetGap(myTol); + BRepBndLib::Add(aV, aBox); + aHAB->SetValue(i, aBox); + aMIS.Add(i, aV); + aMSB.Add(aV, aBox); + } + // + aBSB.Initialize(aHAB); + // + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + // + if (aMVProcessed.Contains(aV)) { + continue; + } + // + const Bnd_Box& aBoxV=aMSB.FindFromKey(aV); + const TColStd_ListOfInteger& aLI=aBSB.Compare(aBoxV); + aNbVSD=aLI.Extent(); + if (!aNbVSD) { + myErrorStatus=3; // it must not be + return; + } + // + // Images + TopTools_ListOfShape aLVSD; + // + aIt.Initialize(aLI); + for (j=0; aIt.More(); aIt.Next(), ++j) { + aIndex=aIt.Value(); + const TopoDS_Shape& aVx=aMIS.FindFromKey(aIndex); + if(!j) { + aVF=aVx; + } + aLVSD.Append(aVx); + aMVProcessed.Add(aVx); + } + myImages.Bind(aVF, aLVSD); + } + // Origins + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + // + aItS.Initialize(aLVSD); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aVSD=aItS.Value(); + if (!myOrigins.IsBound(aVSD)) { + myOrigins.Bind(aVSD, aV); + } + } + } +} +//======================================================================= +//function : DetectFaces +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectFaces() +{ + DetectShapes(TopAbs_FACE); +} +//======================================================================= +//function : DetectEdges +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectEdges() +{ + DetectShapes(TopAbs_EDGE); +} +//======================================================================= +//function : DetectShapes +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectShapes(const TopAbs_ShapeEnum aType) +{ + myErrorStatus=0; + // + Standard_Integer i, aNbF, aNbSDF, iErr; + TopoDS_Shape aNewShape; + TopTools_IndexedMapOfShape aMF; + TopTools_ListIteratorOfListOfShape aItS; + GEOMAlgo_PassKeyShape aPKF; + GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLF; + // + TopExp::MapShapes(myShape, aType, aMF); + // + aNbF=aMF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aS=aMF(i); + // + //aPKF.Clear();//qft + if (aType==TopAbs_FACE) { + const TopoDS_Face& aF=TopoDS::Face(aS); + FacePassKey(aF, aPKF); + } + else if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aE=TopoDS::Edge(aS); + EdgePassKey(aE, aPKF); + } + // + if (myErrorStatus) { + return; + } + // + if (aMPKLF.Contains(aPKF)) { + TopTools_ListOfShape& aLSDF=aMPKLF.ChangeFromKey(aPKF); + aLSDF.Append(aS); + } + else { + TopTools_ListOfShape aLSDF; + // + aLSDF.Append(aS); + aMPKLF.Add(aPKF, aLSDF); + } + } + // check geometric coincidence + if (myCheckGeometry) { + iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTol, myContext); //XX + if (iErr) { + myErrorStatus=200; + return; + } + } + // + // Images/Origins + aNbF=aMPKLF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopTools_ListOfShape& aLSDF=aMPKLF(i); + aNbSDF=aLSDF.Extent(); + if (!aNbSDF) { + myErrorStatus=4; // it must not be + } + // + const TopoDS_Shape& aS1=aLSDF.First(); + aNewShape=aS1; + // + myImages.Bind(aNewShape, aLSDF); + // origins + aItS.Initialize(aLSDF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFSD=aItS.Value(); + if (!myOrigins.IsBound(aFSD)) { + myOrigins.Bind(aFSD, aNewShape); + } + } + } +} +//======================================================================= +//function : DetectSolids +//purpose : +//======================================================================= + void GEOMAlgo_GlueAnalyser::DetectSolids() +{ + myErrorStatus=0; + // + Standard_Integer i, aNbF, aNbS, aNbC, aNbX; + TopoDS_Compound aCmp; + BRep_Builder aBB; + TopTools_IndexedDataMapOfShapeListOfShape aMFS; + TopTools_IndexedMapOfShape aMx, aMS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + GEOMAlgo_CoupleOfShapes aCS; + // + GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLS; + GEOMAlgo_PassKeyShape aPKSx; + // + aBB.MakeCompound(aCmp); + // + TopExp::MapShapesAndAncestors(myShape, TopAbs_FACE, TopAbs_SOLID, aMFS); + // + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aIm=aItIm.Key(); + if (aIm.ShapeType()!=TopAbs_FACE) { + continue; + } + // + const TopTools_ListOfShape& aLF=aItIm.Value(); + aNbF=aLF.Extent(); + if (aNbF!=2) { + continue; + } + // + TopoDS_Shape aSx[2], aFx[2]; + // + aFx[0]=aLF.First(); + aFx[1]=aLF.Last(); + for (i=0; i<2; ++i) { + if (!aMFS.Contains(aFx[i])) { + continue;// it must not be so + } + // + const TopTools_ListOfShape& aLS=aMFS.FindFromKey(aFx[i]); + aNbS=aLS.Extent(); + if (aNbS!=1) { + continue; + } + aSx[i]=aLS.First(); + } + // + if (aSx[0].IsNull() || aSx[1].IsNull()) { + continue; + } + // + //aPKSx.Clear();//qft + //qf + //aPKSx.SetIds(aSx[0], aSx[1]); + aPKSx.SetShapes(aSx[0], aSx[1]); + //qt + // + if (!aMPKLS.Contains(aPKSx)) { + TopTools_ListOfShape aLSx; + // + aLSx.Append(aSx[0]); + aLSx.Append(aSx[1]); + // + aMPKLS.Add(aPKSx, aLSx); + } + } + // + mySolidsToGlue.Clear(); + mySolidsAlone.Clear(); + + // + aNbC=aMPKLS.Extent(); + if (!aNbC) { + return; + } + // + for (i=1; i<=aNbC; ++i) { + const TopTools_ListOfShape& aLSx=aMPKLS(i); + const TopoDS_Shape& aSx1=aLSx.First(); + const TopoDS_Shape& aSx2=aLSx.Last(); + aCS.SetShape1(aSx1); + aCS.SetShape2(aSx2); + mySolidsToGlue.Append(aCS); + // + if (!aMx.Contains(aSx1)) { + aBB.Add(aCmp, aSx1); + aMx.Add(aSx1); + } + if (!aMx.Contains(aSx2)) { + aBB.Add(aCmp, aSx2); + aMx.Add(aSx2); + } + } + myResult=aCmp; + // + // check alone solids + TopExp::MapShapes(myShape, TopAbs_SOLID, aMS); + // + aNbX=aMx.Extent(); + for (i=1; i<=aNbX; ++i) { + const TopoDS_Shape& aSx=aMx(i); + if (!aMS.Contains(aSx)) { + mySolidsAlone.Append(aSx); + } + } +} + +/* +// A + // Make vertices + aMV.Clear(); + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + aMV.Add(aV); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + MakeVertex(aLVSD, aVnew);//ZZ + myImages.Bind(aVnew, aLVSD); + } + // + aNbV=aMV.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + myImages.UnBind(aV); + } + // + */ diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.hxx new file mode 100644 index 000000000..d79c8294f --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_GlueAnalyser.hxx @@ -0,0 +1,86 @@ +// 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_GlueDetector.hxx +// Created: Wed Dec 15 11:08:09 2004 +// Author: Peter KURNEV + +#ifndef _GEOMAlgo_GlueAnalyser_HeaderFile +#define _GEOMAlgo_GlueAnalyser_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_GlueAnalyser +//purpose : +//======================================================================= +class GEOMAlgo_GlueAnalyser : public GEOMAlgo_Gluer +{ + public: + Standard_EXPORT + GEOMAlgo_GlueAnalyser(); + + Standard_EXPORT + virtual ~GEOMAlgo_GlueAnalyser(); + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + Standard_Boolean HasSolidsToGlue() const; + + Standard_EXPORT + const GEOMAlgo_ListOfCoupleOfShapes& SolidsToGlue() const; + + Standard_EXPORT + Standard_Boolean HasSolidsAlone() const; + + Standard_EXPORT + const TopTools_ListOfShape& SolidsAlone() const; + + protected: + Standard_EXPORT + void DetectVertices() ; + + Standard_EXPORT + void DetectEdges() ; + + Standard_EXPORT + void DetectFaces() ; + + Standard_EXPORT + void DetectShapes(const TopAbs_ShapeEnum aType) ; + + Standard_EXPORT + void DetectSolids() ; + + + GEOMAlgo_ListOfCoupleOfShapes mySolidsToGlue; + TopTools_ListOfShape mySolidsAlone; +}; + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_GlueDetector.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_GlueDetector.cxx new file mode 100644 index 000000000..e0471cfe3 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_GlueDetector.cxx @@ -0,0 +1,430 @@ +// 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_GlueDetector.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 +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= +GEOMAlgo_GlueDetector::GEOMAlgo_GlueDetector() +: + GEOMAlgo_GluerAlgo(), + GEOMAlgo_Algo() +{} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_GlueDetector::~GEOMAlgo_GlueDetector() +{} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_GlueDetector::Perform() +{ + myErrorStatus=0; + myWarningStatus=0; + // + CheckData(); + if (myErrorStatus) { + return; + } + // + // Initialize the context + GEOMAlgo_GluerAlgo::Perform(); + // + DetectVertices(); + if (myErrorStatus) { + return; + } + // + DetectEdges(); + if (myErrorStatus) { + return; + } + // + DetectFaces(); + if (myErrorStatus) { + return; + } +} +//======================================================================= +//function : DetectVertices +//purpose : +//======================================================================= +void GEOMAlgo_GlueDetector::DetectVertices() +{ + Standard_Integer j, i, aNbV, aNbVSD; + Standard_Real aTolV; + gp_Pnt aPV; + TColStd_ListIteratorOfListOfInteger aIt; + TopoDS_Shape aVF; + TopTools_IndexedMapOfShape aMV; + TopTools_MapOfShape aMVProcessed; + TopTools_ListIteratorOfListOfShape aItS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + TopTools_DataMapOfShapeListOfShape aMVV; + GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; + NMTDS_IndexedDataMapOfShapeBndSphere aMSB; + // + NMTDS_BndSphereTreeSelector aSelector; + NMTDS_BndSphereTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + myErrorStatus=0; + // + TopExp::MapShapes(myArgument, TopAbs_VERTEX, aMV); + aNbV=aMV.Extent(); + if (!aNbV) { + myErrorStatus=2; // no vertices in source shape + return; + } + // + for (i=1; i<=aNbV; ++i) { + NMTDS_BndSphere aBox; + // + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aMV(i)); + aPV=BRep_Tool::Pnt(aV); + aTolV=BRep_Tool::Tolerance(aV); + // + aBox.SetGap(myTolerance); + aBox.SetCenter(aPV); + aBox.SetRadius(aTolV); + // + aTreeFiller.Add(i, aBox); + // + aMIS.Add(i, aV); + aMSB.Add(aV, aBox); + } + // + aTreeFiller.Fill(); + // + //--------------------------------------------------- + // Chains + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + // + if (aMVProcessed.Contains(aV)) { + continue; + } + // + Standard_Integer aNbIP, aIP, aNbIP1, aIP1; + TopTools_ListOfShape aLVSD; + TColStd_MapOfInteger aMIP, aMIP1, aMIPC; + TColStd_MapIteratorOfMapOfInteger aIt1; + // + aMIP.Add(i); + while(1) { + aNbIP=aMIP.Extent(); + aIt1.Initialize(aMIP); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + if (aMIPC.Contains(aIP)) { + continue; + } + // + const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); + const NMTDS_BndSphere& aBoxVP=aMSB.FindFromKey(aVP); + // + aSelector.Clear(); + aSelector.SetBox(aBoxVP); + // + aNbVSD=aBBTree.Select(aSelector); + if (!aNbVSD) { + continue; // it shoild not be so [at least IP itself] + } + // + const TColStd_ListOfInteger& aLI=aSelector.Indices(); + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + aIP1=aIt.Value(); + if (aMIP.Contains(aIP1)) { + continue; + } + aMIP1.Add(aIP1); + } //for (; aIt.More(); aIt.Next()) { + }//for(; aIt1.More(); aIt1.Next()) { + // + aNbIP1=aMIP1.Extent(); + if (!aNbIP1) { + break; + } + // + aIt1.Initialize(aMIP); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + aMIPC.Add(aIP); + } + // + aMIP.Clear(); + aIt1.Initialize(aMIP1); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + aMIP.Add(aIP); + } + aMIP1.Clear(); + }// while(1) + // + // Fill myImages + aNbIP=aMIPC.Extent(); + // + if (!aNbIP) {// no SD vertices is found + aMVProcessed.Add(aV); + continue; + } + //else { // SD vertices founded [ aMIPC ] + aIt1.Initialize(aMIPC); + for(j=0; aIt1.More(); aIt1.Next(), ++j) { + aIP=aIt1.Key(); + const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); + if (!j) { + aVF=aVP; + } + aLVSD.Append(aVP); + aMVProcessed.Add(aVP); + } + //} + myImages.Bind(aVF, aLVSD); + }// for (i=1; i<=aNbV; ++i) { + //------------------------------ + // Origins + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + aItS.Initialize(aLVSD); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aVSD=aItS.Value(); + if (!myOrigins.IsBound(aVSD)) { + myOrigins.Bind(aVSD, aV); + } + } + } +} +//======================================================================= +//function : DetectFaces +//purpose : +//======================================================================= +void GEOMAlgo_GlueDetector::DetectFaces() +{ + DetectShapes(TopAbs_FACE); +} +//======================================================================= +//function : DetectEdges +//purpose : +//======================================================================= +void GEOMAlgo_GlueDetector::DetectEdges() +{ + DetectShapes(TopAbs_EDGE); +} +//======================================================================= +//function : DetectShapes +//purpose : +//======================================================================= +void GEOMAlgo_GlueDetector::DetectShapes(const TopAbs_ShapeEnum aType) +{ + Standard_Boolean bDegenerated; + Standard_Integer i, aNbF, aNbSDF, iErr; + TopTools_IndexedMapOfShape aMF; + TopTools_ListIteratorOfListOfShape aItLS; + GEOMAlgo_PassKeyShape aPKF; + GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLF; + // + myErrorStatus=0; + // + TopExp::MapShapes(myArgument, aType, aMF); + // + aNbF=aMF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aS=aMF(i); + // + if (aType==TopAbs_FACE) { + const TopoDS_Face& aF=*((TopoDS_Face*)&aS); + FacePassKey(aF, aPKF); + } + else if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aE=*((TopoDS_Edge*)&aS); + EdgePassKey(aE, aPKF); + } + // + if (myErrorStatus) { + return; + } + // + if (aMPKLF.Contains(aPKF)) { + TopTools_ListOfShape& aLSDF=aMPKLF.ChangeFromKey(aPKF); + aLSDF.Append(aS); + } + else { + TopTools_ListOfShape aLSDF; + // + aLSDF.Append(aS); + aMPKLF.Add(aPKF, aLSDF); + } + } + // check geometric coincidence + if (myCheckGeometry) { + iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTolerance, myContext); + if (iErr) { + myErrorStatus=200; + return; + } + } + // + // Images/Origins + aNbF=aMPKLF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopTools_ListOfShape& aLSDF=aMPKLF(i); + aNbSDF=aLSDF.Extent(); + if (!aNbSDF) { + myErrorStatus=4; // it must not be + } + // + if (aNbSDF==1) { + continue; + } + // + const TopoDS_Shape& aS1=aLSDF.First(); + // + if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aS1); + bDegenerated=BRep_Tool::Degenerated(aE1); + if (bDegenerated) { + continue; + } + } + // + myImages.Bind(aS1, aLSDF); + // origins + aItLS.Initialize(aLSDF); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aFSD=aItLS.Value(); + if (!myOrigins.IsBound(aFSD)) { + myOrigins.Bind(aFSD, aS1); + } + } + }// for (i=1; i<=aNbF; ++i) +} +//======================================================================= +//function : FacePassKey +//purpose : +//======================================================================= +void GEOMAlgo_GlueDetector::FacePassKey(const TopoDS_Face& aF, + GEOMAlgo_PassKeyShape& aPK) +{ + Standard_Integer i, aNbE; + TopoDS_Shape aER; + TopTools_ListOfShape aLE; + TopTools_IndexedMapOfShape aME; + // + TopExp::MapShapes(aF, TopAbs_EDGE, aME); + // + aNbE=aME.Extent(); + for (i=1; i<=aNbE; ++i) { + const TopoDS_Shape& aE=aME(i); + // + const TopoDS_Edge& aEE=*((TopoDS_Edge*)&aE); + if (BRep_Tool::Degenerated(aEE)) { + continue; + } + // + if (myOrigins.IsBound(aE)) { + aER=myOrigins.Find(aE); + } + else { + aER=aE; + } + aLE.Append(aER); + } + aPK.SetShapes(aLE); +} +//======================================================================= +//function : EdgePassKey +//purpose : +//======================================================================= +void GEOMAlgo_GlueDetector::EdgePassKey(const TopoDS_Edge& aE, + GEOMAlgo_PassKeyShape& aPK) +{ + TopAbs_Orientation aOr; + TopoDS_Shape aVR; + TopoDS_Iterator aIt; + TopTools_ListOfShape aLV; + // + aIt.Initialize(aE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aV=aIt.Value(); + aOr=aV.Orientation(); + if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) { + if (myOrigins.IsBound(aV)) { + aVR=myOrigins.Find(aV); + } + else { + aVR=aV; + } + aLV.Append(aVR); + } + } + // + aPK.SetShapes(aLV); +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_GlueDetector.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_GlueDetector.hxx new file mode 100644 index 000000000..db24754ff --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_GlueDetector.hxx @@ -0,0 +1,67 @@ +// 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_GlueDetector.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_GlueDetector_HeaderFile +#define _GEOMAlgo_GlueDetector_HeaderFile + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_GlueDetector +//purpose : +//======================================================================= +class GEOMAlgo_GlueDetector : public GEOMAlgo_GluerAlgo, + public GEOMAlgo_Algo { +public: + Standard_EXPORT GEOMAlgo_GlueDetector(); + + Standard_EXPORT virtual ~GEOMAlgo_GlueDetector(); + + Standard_EXPORT virtual void Perform() ; + +protected: + Standard_EXPORT void DetectVertices() ; + + Standard_EXPORT void DetectEdges() ; + + Standard_EXPORT void DetectFaces() ; + + Standard_EXPORT void DetectShapes(const TopAbs_ShapeEnum aType) ; + + Standard_EXPORT void EdgePassKey(const TopoDS_Edge& aE, + GEOMAlgo_PassKeyShape& aPK) ; + + Standard_EXPORT void FacePassKey(const TopoDS_Face& aF, + GEOMAlgo_PassKeyShape& aPK) ; + +private: +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Gluer.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer.cxx new file mode 100644 index 000000000..a57d23644 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer.cxx @@ -0,0 +1,1178 @@ +// 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_Gluer.cxx +// Created: Sat Dec 04 12:45:53 2004 +// 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 +#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 GetSubShapes(const TopoDS_Shape& aS, + TopTools_IndexedMapOfShape& aMSS); + +//======================================================================= +//function : GEOMAlgo_Gluer +//purpose : +//======================================================================= +GEOMAlgo_Gluer::GEOMAlgo_Gluer() +: + GEOMAlgo_ShapeAlgo() +{ + myTolerance=0.0001; + myTol=myTolerance; + myCheckGeometry=Standard_True; + myKeepNonSolids=Standard_False; + myNbAlone=0; +} +//======================================================================= +//function : ~GEOMAlgo_Gluer +//purpose : +//======================================================================= +GEOMAlgo_Gluer::~GEOMAlgo_Gluer() +{ +} +//======================================================================= +//function : SetCheckGeometry +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::SetCheckGeometry(const Standard_Boolean aFlag) +{ + myCheckGeometry=aFlag; +} +//======================================================================= +//function : CheckGeometry +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer::CheckGeometry() const +{ + return myCheckGeometry; +} +//======================================================================= +//function : SetKeepNonSolids +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::SetKeepNonSolids(const Standard_Boolean aFlag) +{ + myKeepNonSolids=aFlag; +} +//======================================================================= +//function : KeepNonSolids +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer::KeepNonSolids()const +{ + return myKeepNonSolids; +} +//======================================================================= +//function : AloneShapes +//purpose : +//======================================================================= +Standard_Integer GEOMAlgo_Gluer::AloneShapes()const +{ + return myNbAlone; +} +//======================================================================= +//function : Images +//purpose : +//======================================================================= +const TopTools_DataMapOfShapeListOfShape& GEOMAlgo_Gluer::Images()const +{ + return myImages; +} +//======================================================================= +//function : Origins +//purpose : +//======================================================================= +const TopTools_DataMapOfShapeShape& GEOMAlgo_Gluer::Origins()const +{ + return myOrigins; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::Perform() +{ + const Standard_Integer aNb=8; + Standard_Integer i; + // + myErrorStatus=0; + myWarningStatus=0; + // + // Initialize the context + GEOMAlgo_ShapeAlgo::Perform(); + // + void (GEOMAlgo_Gluer::* pF[aNb])()={ + &GEOMAlgo_Gluer::CheckData, &GEOMAlgo_Gluer::InnerTolerance, + &GEOMAlgo_Gluer::MakeVertices, &GEOMAlgo_Gluer::MakeEdges, + &GEOMAlgo_Gluer::MakeFaces, &GEOMAlgo_Gluer::MakeShells, + &GEOMAlgo_Gluer::MakeSolids, &GEOMAlgo_Gluer::CheckResult + }; + // + for (i=0; i*pF[i])(); + if (myErrorStatus) { + return; + } + } +} + +//======================================================================= +//function : MakeVertices +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeVertices() +{ + myErrorStatus=0; + // + Standard_Integer j, i, aNbV, aNbVSD; + Standard_Real aTolV; + gp_Pnt aPV; + TColStd_ListIteratorOfListOfInteger aIt; + TopoDS_Shape aVF; + TopoDS_Vertex aVnew; + TopTools_IndexedMapOfShape aMV, aMVProcessed; + TopTools_ListIteratorOfListOfShape aItS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + TopTools_DataMapOfShapeListOfShape aMVV; + GEOMAlgo_IndexedDataMapOfIntegerShape aMIS; + //modified by NIZNHY-PKV Thu Jan 21 10:03:07 2010f + //GEOMAlgo_IndexedDataMapOfShapeBox aMSB; + NMTDS_IndexedDataMapOfShapeBndSphere aMSB; + //modified by NIZNHY-PKV Thu Jan 21 10:03:10 2010t + // + NMTDS_BndSphereTreeSelector aSelector; + NMTDS_BndSphereTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + TopExp::MapShapes(myShape, TopAbs_VERTEX, aMV); + aNbV=aMV.Extent(); + if (!aNbV) { + myErrorStatus=2; // no vertices in source shape + return; + } + // + for (i=1; i<=aNbV; ++i) { + NMTDS_BndSphere aBox; + // + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aMV(i)); + aPV=BRep_Tool::Pnt(aV); + aTolV=BRep_Tool::Tolerance(aV); + // + aBox.SetGap(myTol); + aBox.SetCenter(aPV); + aBox.SetRadius(aTolV); + // + aTreeFiller.Add(i, aBox); + // + aMIS.Add(i, aV); + aMSB.Add(aV, aBox); + } + // + aTreeFiller.Fill(); + // + //------------------------------ + // Chains + for (i=1; i<=aNbV; ++i) { + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aMV(i)); + // + if (aMVProcessed.Contains(aV)) { + continue; + } + // + Standard_Integer aNbIP, aIP, aNbIP1, aIP1; + TopTools_ListOfShape aLVSD; + TColStd_MapOfInteger aMIP, aMIP1, aMIPC; + TColStd_MapIteratorOfMapOfInteger aIt1; + // + aMIP.Add(i); + while(1) { + aNbIP=aMIP.Extent(); + aIt1.Initialize(aMIP); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + if (aMIPC.Contains(aIP)) { + continue; + } + // + const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); + //modified by NIZNHY-PKV Thu Jan 21 10:04:09 2010f + const NMTDS_BndSphere& aBoxVP=aMSB.FindFromKey(aVP); + //const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP); + //modified by NIZNHY-PKV Thu Jan 21 10:04:11 2010t + // + aSelector.Clear(); + aSelector.SetBox(aBoxVP); + // + aNbVSD=aBBTree.Select(aSelector); + if (!aNbVSD) { + continue; // it must not be + } + // + const TColStd_ListOfInteger& aLI=aSelector.Indices(); + // + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + aIP1=aIt.Value(); + if (aMIP.Contains(aIP1)) { + continue; + } + aMIP1.Add(aIP1); + } //for (; aIt.More(); aIt.Next()) { + }//for(; aIt1.More(); aIt1.Next()) { + // + aNbIP1=aMIP1.Extent(); + if (!aNbIP1) { + break; + } + // + aIt1.Initialize(aMIP); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + aMIPC.Add(aIP); + } + // + aMIP.Clear(); + aIt1.Initialize(aMIP1); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + aMIP.Add(aIP); + } + aMIP1.Clear(); + }// while(1) + // + // Fill myImages + aNbIP=aMIPC.Extent(); + // + if (!aNbIP) {// no SD vertices founded + aVF=aV; + aLVSD.Append(aV); + aMVProcessed.Add(aV); + } + else { // SD vertices founded [ aMIPC ] + aIt1.Initialize(aMIPC); + for(j=0; aIt1.More(); aIt1.Next(), ++j) { + aIP=aIt1.Key(); + const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); + if (!j) { + aVF=aVP; + } + aLVSD.Append(aVP); + aMVProcessed.Add(aVP); + } + } + myImages.Bind(aVF, aLVSD); + }// for (i=1; i<=aNbV; ++i) { + //------------------------------ + // + // Make new vertices + aMV.Clear(); + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aItIm.Key()); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + aNbVSD=aLVSD.Extent(); + if (aNbVSD>1) { + aMV.Add(aV); + MakeVertex(aLVSD, aVnew); + aMVV.Bind(aVnew, aLVSD); + } + } + // + // UnBind old vertices + aNbV=aMV.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + myImages.UnBind(aV); + } + // + // Bind new vertices + aItIm.Initialize(aMVV); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + myImages.Bind(aV, aLVSD); + } + // + // Origins + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + aItS.Initialize(aLVSD); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aVSD=aItS.Value(); + if (!myOrigins.IsBound(aVSD)) { + myOrigins.Bind(aVSD, aV); + } + } + } +} +//======================================================================= +//function : MakeSubShapes +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeSubShapes (const TopoDS_Shape& theShape, + TopTools_MapOfShape& theMS, + TopoDS_Compound& theResult) +{ + if (theMS.Contains(theShape)) + return; + // + BRep_Builder aBB; + // + theMS.Add(theShape); + // + if (theShape.ShapeType() == TopAbs_COMPOUND || + theShape.ShapeType() == TopAbs_COMPSOLID) { + TopoDS_Iterator It (theShape, Standard_True, Standard_True); + for (; It.More(); It.Next()) { + MakeSubShapes(It.Value(), theMS, theResult); + } + } + else if (theShape.ShapeType() == TopAbs_SOLID) { + // build a solid + TopoDS_Solid aNewSolid; + TopExp_Explorer aExpS, aExp; + // + const TopoDS_Solid& aSolid = TopoDS::Solid(theShape); + // + TopAbs_Orientation anOr = aSolid.Orientation(); + // + aBB.MakeSolid(aNewSolid); + aNewSolid.Orientation(anOr); + // + aExp.Init(aSolid, TopAbs_SHELL); + for (; aExp.More(); aExp.Next()) + { + const TopoDS_Shape& aShell=aExp.Current(); + const TopoDS_Shape& aShellR=myOrigins.Find(aShell); + aBB.Add(aNewSolid, aShellR); + } + // + TopTools_ListOfShape aLS; + // + aLS.Append(aSolid); + myImages.Bind(aNewSolid, aLS); + myOrigins.Bind(aSolid, aNewSolid); + // + aBB.Add(theResult, aNewSolid); + } + else if (theShape.ShapeType() == TopAbs_WIRE) { + if (myKeepNonSolids) { + // just add image + if (!myOrigins.IsBound(theShape)) { + // build wire + const TopoDS_Wire& aW=TopoDS::Wire(theShape); + // + TopoDS_Wire newWire; + aBB.MakeWire(newWire); + // + TopExp_Explorer aExpE (aW, TopAbs_EDGE); + for (; aExpE.More(); aExpE.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current()); + TopoDS_Edge aER=TopoDS::Edge(myOrigins.Find(aE)); + // + aER.Orientation(TopAbs_FORWARD); + if (!BRep_Tool::Degenerated(aER)) { + // build p-curve + //if (bIsUPeriodic) { + // GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(aER, aFFWD, aUMin, aUMax); + //} + //BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aER, aFFWD); + // + // orient image + Standard_Boolean bIsToReverse=BOPTools_Tools3D::IsSplitToReverse1(aER, aE, myContext); + if (bIsToReverse) { + aER.Reverse(); + } + } + else { + aER.Orientation(aE.Orientation()); + } + // + aBB.Add(newWire, aER); + } + // xf + TopTools_ListOfShape aLW; + // + aLW.Append(aW); + myImages.Bind(newWire, aLW); + myOrigins.Bind(aW, newWire); + } + const TopoDS_Shape& aShapeR = myOrigins.Find(theShape); + aBB.Add(theResult, aShapeR); + } + } + else + { + if (myKeepNonSolids) { + // just add image + const TopoDS_Shape& aShapeR = myOrigins.Find(theShape); + aBB.Add(theResult, aShapeR); + } + } +} +//======================================================================= +//function : MakeSolids +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeSolids() +{ + myErrorStatus=0; + // + BRep_Builder aBB; + TopoDS_Compound aCmp; + TopTools_MapOfShape aMS; + // + aBB.MakeCompound(aCmp); + // + // Add images of all initial sub-shapes in the result. + // If myKeepNonSolids==false, add only solids images. + MakeSubShapes(myShape, aMS, aCmp); + // + myResult=aCmp; + // + if (aMS.Extent()) { + BOP_CorrectTolerances::CorrectCurveOnSurface(myResult); + } +} +//======================================================================= +//function : MakeShells +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeShells() +{ + myErrorStatus=0; + // + Standard_Boolean bIsToReverse; + Standard_Integer i, aNbS; + TopAbs_Orientation anOr; + TopoDS_Shell aNewShell; + TopoDS_Face aFR; + TopTools_IndexedMapOfShape aMS; + TopExp_Explorer aExp; + BRep_Builder aBB; + // + TopExp::MapShapes(myShape, TopAbs_SHELL, aMS); + // + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shell& aShell=TopoDS::Shell(aMS(i)); + anOr=aShell.Orientation(); + // + aBB.MakeShell(aNewShell); + aNewShell.Orientation(anOr); + aExp.Init(aShell, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Face& aF=TopoDS::Face(aExp.Current()); + aFR=TopoDS::Face(myOrigins.Find(aF)); + if (aFR.IsSame(aF)) { + aBB.Add(aNewShell, aF); + continue; + } + bIsToReverse=IsToReverse(aFR, aF); + if (bIsToReverse) { + aFR.Reverse(); + } + aBB.Add(aNewShell, aFR); + } + // + TopTools_ListOfShape aLS; + // + aLS.Append(aShell); + myImages.Bind(aNewShell, aLS); + myOrigins.Bind(aShell, aNewShell); + } +} +//======================================================================= +//function : MakeFaces +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeFaces() +{ + MakeShapes(TopAbs_FACE); +} +//======================================================================= +//function : MakeEdges +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeEdges() +{ + MakeShapes(TopAbs_EDGE); +} +//======================================================================= +//function : MakeShapes +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeShapes(const TopAbs_ShapeEnum aType) +{ + myErrorStatus=0; + // + Standard_Boolean bHasNewSubShape; + Standard_Integer i, aNbF, aNbSDF, iErr; + TopoDS_Shape aNewShape; + TopTools_IndexedMapOfShape aMF; + TopTools_ListIteratorOfListOfShape aItS; + GEOMAlgo_PassKeyShape aPKF; + GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape aMPKLF; + // + TopExp::MapShapes(myShape, aType, aMF); + // + aNbF=aMF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aS=aMF(i); + // + if (aType==TopAbs_FACE) { + const TopoDS_Face& aF=TopoDS::Face(aS); + FacePassKey(aF, aPKF); + } + else if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aE=TopoDS::Edge(aS); + EdgePassKey(aE, aPKF); + } + // + if (myErrorStatus) { + return; + } + // + if (aMPKLF.Contains(aPKF)) { + TopTools_ListOfShape& aLSDF=aMPKLF.ChangeFromKey(aPKF); + aLSDF.Append(aS); + } + else { + TopTools_ListOfShape aLSDF; + // + aLSDF.Append(aS); + aMPKLF.Add(aPKF, aLSDF); + } + } + // check geometric coincidence + if (myCheckGeometry) { + iErr=GEOMAlgo_Tools::RefineSDShapes(aMPKLF, myTol, myContext); + if (iErr) { + myErrorStatus=200; + return; + } + } + // + // Images/Origins + // + aNbF=aMPKLF.Extent(); + for (i=1; i<=aNbF; ++i) { + const TopTools_ListOfShape& aLSDF=aMPKLF(i); + aNbSDF=aLSDF.Extent(); + if (!aNbSDF) { + myErrorStatus=4; // it must not be + } + // + const TopoDS_Shape& aS1=aLSDF.First(); + // + bHasNewSubShape=Standard_True; + // prevent creation of a new shape if there are not + // new sub-shapes of aSS among the originals + if (aNbSDF==1) { + bHasNewSubShape=HasNewSubShape(aS1); + if (!bHasNewSubShape) { + aNewShape=aS1; + aNewShape.Orientation(TopAbs_FORWARD); + } + } + // + if (bHasNewSubShape) { + if (aType==TopAbs_FACE) { + TopoDS_Face aNewFace; + // + const TopoDS_Face& aF1=TopoDS::Face(aS1); + MakeFace(aF1, aNewFace); + aNewShape=aNewFace; + } + else if (aType==TopAbs_EDGE) { + TopoDS_Edge aNewEdge; + // + const TopoDS_Edge& aE1=TopoDS::Edge(aS1); + MakeEdge(aE1, aNewEdge); + aNewShape=aNewEdge; + } + } + // + myImages.Bind(aNewShape, aLSDF); + // origins + aItS.Initialize(aLSDF); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aFSD=aItS.Value(); + if (!myOrigins.IsBound(aFSD)) { + myOrigins.Bind(aFSD, aNewShape); + } + } + } +} +//======================================================================= +//function : CheckResult +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::CheckResult() +{ + myErrorStatus=0; + // + if (myResult.IsNull()) { + myErrorStatus=6; + return; + } + // + Standard_Boolean bFound; + Standard_Integer i, j, aNbS, aNbFS, aNbSx; + TopTools_IndexedMapOfShape aMS, aMFS; + TopTools_IndexedDataMapOfShapeListOfShape aMFR; + // + TopExp::MapShapesAndAncestors(myResult, TopAbs_FACE, TopAbs_SOLID, aMFR); + TopExp::MapShapes(myResult, TopAbs_SOLID, aMS); + // + + myNbAlone=0; + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aSolid=aMS(i); + // + aMFS.Clear(); + TopExp::MapShapes(aSolid, TopAbs_FACE, aMFS); + // + bFound=Standard_False; + aNbFS=aMFS.Extent(); + for (j=1; j<=aNbFS; ++j) { + const TopoDS_Shape& aFS=aMFS(j); + if (aMFR.Contains(aFS)) { + const TopTools_ListOfShape& aLSx=aMFR.FindFromKey(aFS); + aNbSx=aLSx.Extent(); + if (aNbSx==2) { + bFound=!bFound; + break; + } + } + } + // + if (!bFound) { + myWarningStatus=1; + ++myNbAlone; + //break; + } + } +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::CheckData() +{ + myErrorStatus=0; + // + if (myShape.IsNull()) { + myErrorStatus=5; + return; + } +} +//======================================================================= +//function : InnerTolerance +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::InnerTolerance() +{ + myErrorStatus=0; + // + /* + Standard_Integer i; + Standard_Real aX[3][2], dH, dHmin, aCoef, aTolTresh; + Bnd_Box aBox; + // + BRepBndLib::Add(myShape, aBox); + aBox.Get(aX[0][0], aX[1][0], aX[2][0], aX[0][1], aX[1][1], aX[2][1]); + // + dHmin=aX[0][1]-aX[0][0]; + for (i=1; i<3; ++i) { + dH=aX[i][1]-aX[i][0]; + if (dHaTolTresh) { + myTol=aTolTresh; + } + */ + myTol=myTolerance; +} +//======================================================================= +//function : FacePassKey +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::FacePassKey(const TopoDS_Face& aF, + GEOMAlgo_PassKeyShape& aPK) +{ + Standard_Integer i, aNbE; + TopTools_ListOfShape aLE; + TopTools_IndexedMapOfShape aME; + // + TopExp::MapShapes(aF, TopAbs_EDGE, aME); + aNbE=aME.Extent(); + // + for (i=1; i<=aNbE; ++i) { + const TopoDS_Shape& aE=aME(i); + if (!myOrigins.IsBound(aE)) { + myErrorStatus=102; + return; + } + const TopoDS_Shape& aER=myOrigins.Find(aE); + aLE.Append(aER); + } + aPK.SetShapes(aLE); +} +//======================================================================= +//function : EdgePassKey +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::EdgePassKey(const TopoDS_Edge& aE, + GEOMAlgo_PassKeyShape& aPK) +{ + TopoDS_Vertex aV1, aV2; + // + TopExp::Vertices(aE, aV1, aV2); + // + if (!myOrigins.IsBound(aV1) || !myOrigins.IsBound(aV2) ) { + myErrorStatus=100; + return; + } + const TopoDS_Shape& aVR1=myOrigins.Find(aV1); + const TopoDS_Shape& aVR2=myOrigins.Find(aV2); + aPK.SetShapes(aVR1, aVR2); +} +//======================================================================= +//function : MakeVertex +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeVertex(const TopTools_ListOfShape& aLV, + TopoDS_Vertex& aNewVertex) +{ + Standard_Integer aNbV; + Standard_Real aTolV, aD, aDmax; + gp_XYZ aGC; + gp_Pnt aP3D, aPGC; + TopoDS_Vertex aVx; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aIt; + // + aNbV=aLV.Extent(); + if (!aNbV) { + return; + } + // + // center of gravity + aGC.SetCoord(0.,0.,0.); + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + aVx=TopoDS::Vertex(aIt.Value()); + aP3D=BRep_Tool::Pnt(aVx); + aGC+=aP3D.XYZ(); + } + aGC/=(Standard_Real)aNbV; + aPGC.SetXYZ(aGC); + // + // tolerance value + aDmax=-1.; + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + aVx=TopoDS::Vertex(aIt.Value()); + aP3D=BRep_Tool::Pnt(aVx); + aTolV=BRep_Tool::Tolerance(aVx); + aD=aPGC.Distance(aP3D)+aTolV; + if (aD>aDmax) { + aDmax=aD; + } + } + // + aBB.MakeVertex (aNewVertex, aPGC, aDmax); +} +//======================================================================= +//function : MakeEdge +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeEdge(const TopoDS_Edge& aE, + TopoDS_Edge& aNewEdge) +{ + myErrorStatus=0; + // + Standard_Boolean bIsDE; + Standard_Real aT1, aT2; + TopoDS_Vertex aV1, aV2, aVR1, aVR2; + TopoDS_Edge aEx; + // + bIsDE=BRep_Tool::Degenerated(aE); + // + aEx=aE; + aEx.Orientation(TopAbs_FORWARD); + // + TopExp::Vertices(aEx, aV1, aV2); + // + aT1=BRep_Tool::Parameter(aV1, aEx); + aT2=BRep_Tool::Parameter(aV2, aEx); + // + aVR1=TopoDS::Vertex(myOrigins.Find(aV1)); + aVR1.Orientation(TopAbs_FORWARD); + aVR2=TopoDS::Vertex(myOrigins.Find(aV2)); + aVR2.Orientation(TopAbs_REVERSED); + // + if (bIsDE) { + Standard_Real aTol; + BRep_Builder aBB; + TopoDS_Edge E; + TopAbs_Orientation anOrE; + // + anOrE=aE.Orientation(); + aTol=BRep_Tool::Tolerance(aE); + // + E=aEx; + E.EmptyCopy(); + // + aBB.Add (E, aVR1); + aBB.Add (E, aVR2); + aBB.Range(E, aT1, aT2); + aBB.Degenerated(E, Standard_True); + aBB.UpdateEdge(E, aTol); + // + aNewEdge=E; + } + // + else { + BOPTools_Tools::MakeSplitEdge(aEx, aVR1, aT1, aVR2, aT2, aNewEdge); + } +} +//======================================================================= +//function : MakeFace +//purpose : +//======================================================================= +void GEOMAlgo_Gluer::MakeFace(const TopoDS_Face& aF, + TopoDS_Face& aNewFace) +{ + myErrorStatus=0; + // + Standard_Boolean bIsToReverse, bIsUPeriodic; + Standard_Real aTol, aUMin, aUMax, aVMin, aVMax; + TopoDS_Edge aER; + TopoDS_Wire newWire; + TopoDS_Face aFFWD, newFace; + TopLoc_Location aLoc; + Handle(Geom_Surface) aS; + Handle(Geom2d_Curve) aC2D; + TopExp_Explorer aExpW, aExpE; + BRep_Builder aBB; + // + aFFWD=aF; + aFFWD.Orientation(TopAbs_FORWARD); + // + aS=BRep_Tool::Surface(aFFWD, aLoc); + bIsUPeriodic=GEOMAlgo_Tools::IsUPeriodic(aS); + aTol=BRep_Tool::Tolerance(aFFWD); + BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax); + // + aBB.MakeFace (newFace, aS, aLoc, aTol); + // + aExpW.Init(aFFWD, TopAbs_WIRE); + for (; aExpW.More(); aExpW.Next()) { + aBB.MakeWire(newWire); + const TopoDS_Wire& aW=TopoDS::Wire(aExpW.Current()); + aExpE.Init(aW, TopAbs_EDGE); + for (; aExpE.More(); aExpE.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current()); + aER=TopoDS::Edge(myOrigins.Find(aE)); + // + aER.Orientation(TopAbs_FORWARD); + if (!BRep_Tool::Degenerated(aER)) { + // build p-curve + if (bIsUPeriodic) { + GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(aER, aFFWD, aUMin, aUMax); + } + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aER, aFFWD); + + // orient image + bIsToReverse=BOPTools_Tools3D::IsSplitToReverse1(aER, aE, myContext); + if (bIsToReverse) { + aER.Reverse(); + } + } + else { + aER.Orientation(aE.Orientation()); + } + // + aBB.Add(newWire, aER); + } + // xf + TopTools_ListOfShape aLW; + // + aLW.Append(aW); + myImages.Bind(newWire, aLW); + myOrigins.Bind(aW, newWire); + // xt + aBB.Add(newFace, newWire); + } + aNewFace=newFace; +} +//======================================================================= +//function : IsToReverse +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer::IsToReverse(const TopoDS_Face& aFR, + const TopoDS_Face& aF) +{ + Standard_Boolean bRet; + Standard_Real aT, aT1, aT2, aTR, aScPr; + TopExp_Explorer aExp; + Handle(Geom_Curve)aC3D; + gp_Pnt aP; + gp_Dir aDNF, aDNFR; + // + bRet=Standard_False; + // + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + // + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + const TopoDS_Edge& aER=TopoDS::Edge(myOrigins.Find(aE)); + // + aC3D=BRep_Tool::Curve(aE, aT1, aT2); + aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); + aC3D->D0(aT, aP); + myContext->ProjectPointOnEdge(aP, aER, aTR); + // + BOPTools_Tools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNF); + if (aF.Orientation()==TopAbs_REVERSED) { + aDNF.Reverse(); + } + // + BOPTools_Tools3D::GetNormalToFaceOnEdge (aER, aFR, aTR, aDNFR); + if (aFR.Orientation()==TopAbs_REVERSED) { + aDNFR.Reverse(); + } + // + aScPr=aDNF*aDNFR; + return (aScPr<0.); + } + return bRet; +} +//======================================================================= +//function : HasNewSubShape +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer::HasNewSubShape(const TopoDS_Shape& aS)const +{ + Standard_Boolean bRet; + Standard_Integer i, aNbSS; + TopTools_IndexedMapOfShape aMSS; + // + GetSubShapes(aS, aMSS); + // + bRet=Standard_False; + aNbSS=aMSS.Extent(); + for (i=1; i<=aNbSS; ++i) { + const TopoDS_Shape& aSS=aMSS(i); + if (aSS.ShapeType()==TopAbs_WIRE) { + continue; + } + // + bRet=!myOrigins.IsBound(aSS); + if (bRet) { + return bRet; + } + // + const TopoDS_Shape& aSSIm=myOrigins.Find(aSS); + bRet=!aSSIm.IsSame(aSS); + if (bRet) { + return bRet; + } + } + return bRet; +} +//======================================================================= +//function : GetSubShapes +//purpose : +//======================================================================= +void GetSubShapes(const TopoDS_Shape& aS, + TopTools_IndexedMapOfShape& aMSS) +{ + Standard_Integer aR; + TopAbs_ShapeEnum aType; + TopoDS_Iterator aIt; + // + aType=aS.ShapeType(); + aR=(Standard_Integer)aType+1; + if (aR>TopAbs_VERTEX) { + return; + } + // + aIt.Initialize(aS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSS=aIt.Value(); + aMSS.Add(aSS); + GetSubShapes(aSS, aMSS); + } +} +//======================================================================= +//function : Modified +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_Gluer::Modified (const TopoDS_Shape& aS) +{ + TopAbs_ShapeEnum aType; + // + myGenerated.Clear(); + // + aType=aS.ShapeType(); + if (aType==TopAbs_VERTEX || + aType==TopAbs_EDGE || + aType==TopAbs_WIRE || + aType==TopAbs_FACE || + aType==TopAbs_SHELL || + aType==TopAbs_SOLID) { + if(myOrigins.IsBound(aS)) { + const TopoDS_Shape& aSnew=myOrigins.Find(aS); + if (!aSnew.IsSame(aS)) { + myGenerated.Append(aSnew); + } + } + } + // + return myGenerated; +} +//======================================================================= +//function : Generated +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_Gluer::Generated(const TopoDS_Shape& ) +{ + myGenerated.Clear(); + return myGenerated; +} +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer::IsDeleted (const TopoDS_Shape& aS) +{ + Standard_Boolean bRet=Standard_False; + // + const TopTools_ListOfShape& aL=Modified(aS); + bRet=!aL.IsEmpty(); + // + return bRet; +} + +// +// ErrorStatus +// +// 1 - the object is just initialized +// 2 - no vertices found in source shape +// 3 - nb same domain vertices for the vertex Vi =0 +// 4 - nb same domain edges(faces) for the edge Ei(face Fi) =0 +// 5 - source shape is Null +// 6 - result shape is Null +// 101 - nb edges > PassKey.NbMax() in FacesPassKey() +// 102 - the edge Ei can not be found in myOrigins Map +// 100 - the vertex Vi can not be found in myOrigins Map +// +// WarningStatus +// +// 1 - some shapes can not be glued by faces +// diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Gluer.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer.hxx new file mode 100644 index 000000000..ee7db356e --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer.hxx @@ -0,0 +1,164 @@ + +// 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_Gluer.hxx +// Created: Sat Dec 04 12:45:53 2004 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_Gluer_HeaderFile +#define _GEOMAlgo_Gluer_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_Gluer +//purpose : +//======================================================================= +class GEOMAlgo_Gluer : public GEOMAlgo_ShapeAlgo { +public: + Standard_EXPORT + GEOMAlgo_Gluer(); + + Standard_EXPORT + virtual ~GEOMAlgo_Gluer(); + + Standard_EXPORT + void SetCheckGeometry(const Standard_Boolean aFlag) ; + + Standard_EXPORT + Standard_Boolean CheckGeometry() const; + + Standard_EXPORT + void SetKeepNonSolids(const Standard_Boolean aFlag) ; + + Standard_EXPORT + Standard_Boolean KeepNonSolids() const; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + Standard_Integer AloneShapes() const; + + Standard_EXPORT + const TopTools_ListOfShape& Modified(const TopoDS_Shape& S) ; + + Standard_EXPORT + const TopTools_ListOfShape& Generated(const TopoDS_Shape& S) ; + + Standard_EXPORT + Standard_Boolean IsDeleted(const TopoDS_Shape& S) ; + + Standard_EXPORT + const TopTools_DataMapOfShapeListOfShape& Images() const; + + Standard_EXPORT + const TopTools_DataMapOfShapeShape& Origins() const; + + protected: + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + virtual void CheckResult() ; + + Standard_EXPORT + void MakeVertices() ; + + Standard_EXPORT + void MakeEdges() ; + + Standard_EXPORT + void MakeFaces() ; + + Standard_EXPORT + void MakeShapes(const TopAbs_ShapeEnum aType) ; + + Standard_EXPORT + void MakeShells() ; + + Standard_EXPORT + void MakeSolids() ; + + Standard_EXPORT + void InnerTolerance() ; + + Standard_EXPORT + void EdgePassKey(const TopoDS_Edge& aE, + GEOMAlgo_PassKeyShape& aPK) ; + + Standard_EXPORT + void FacePassKey(const TopoDS_Face& aF, + GEOMAlgo_PassKeyShape& aPK) ; + + Standard_EXPORT + void MakeVertex(const TopTools_ListOfShape& aLV, + TopoDS_Vertex& aNewV) ; + + Standard_EXPORT + void MakeEdge(const TopoDS_Edge& aEdge, + TopoDS_Edge& aNewEdge) ; + + Standard_EXPORT + void MakeFace(const TopoDS_Face& aFace, + TopoDS_Face& aNewEdge) ; + + Standard_EXPORT + Standard_Boolean IsToReverse(const TopoDS_Face& aFR, + const TopoDS_Face& aF) ; + + Standard_EXPORT + Standard_Boolean HasNewSubShape(const TopoDS_Shape& aS) const; + + Standard_EXPORT + void MakeSubShapes(const TopoDS_Shape& aS, + TopTools_MapOfShape& aM, + TopoDS_Compound& aC) ; + + + Standard_Boolean myCheckGeometry; + Standard_Boolean myKeepNonSolids; + Standard_Real myTol; + TopTools_DataMapOfShapeListOfShape myImages; + TopTools_DataMapOfShapeShape myOrigins; + Standard_Integer myNbAlone; + TopTools_ListOfShape myGenerated; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2.cxx new file mode 100644 index 000000000..4ca6b2bf6 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2.cxx @@ -0,0 +1,634 @@ +// 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_Gluer2.cxx +// Author: Peter KURNEV + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//======================================================================= +//function : GEOMAlgo_Gluer2 +//purpose : +//======================================================================= +GEOMAlgo_Gluer2::GEOMAlgo_Gluer2() +: + GEOMAlgo_GluerAlgo(), + GEOMAlgo_BuilderShape() +{ + myTolerance=0.0001; +} +//======================================================================= +//function : ~GEOMAlgo_Gluer2 +//purpose : +//======================================================================= +GEOMAlgo_Gluer2::~GEOMAlgo_Gluer2() +{ +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::Clear() +{ + myErrorStatus=0; + myWarningStatus=0; + // + GEOMAlgo_GluerAlgo::Clear(); + // + myImagesDetected.Clear(); + myOriginsDetected.Clear(); + myShapesToGlue.Clear(); + myImagesToWork.Clear(); + myOriginsToWork.Clear(); + myKeepNonSolids=Standard_False; +} +//======================================================================= +//function : SetShapesToGlue +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::SetShapesToGlue(const TopTools_DataMapOfShapeListOfShape& aM) +{ + myShapesToGlue=aM; +} +//======================================================================= +//function : ShapesToGlue +//purpose : +//======================================================================= +const TopTools_DataMapOfShapeListOfShape& GEOMAlgo_Gluer2::ShapesToGlue()const +{ + return myShapesToGlue; +} +//======================================================================= +//function : SetKeepNonSolids +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::SetKeepNonSolids(const Standard_Boolean aFlag) +{ + myKeepNonSolids=aFlag; +} +//======================================================================= +//function : KeepNonSolids +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer2::KeepNonSolids()const +{ + return myKeepNonSolids; +} +//======================================================================= +//function : ShapesDetected +//purpose : +//======================================================================= +const TopTools_DataMapOfShapeListOfShape& GEOMAlgo_Gluer2::ShapesDetected()const +{ + return myImagesDetected; +} +//======================================================================= +//function : ImagesToWork +//purpose : +//======================================================================= +const TopTools_DataMapOfShapeListOfShape& GEOMAlgo_Gluer2::ImagesToWork()const +{ + return myImagesToWork; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::Perform() +{ + myErrorStatus=0; + myWarningStatus=0; + // + CheckData(); + if (myErrorStatus) { + return; + } + // + // Initialize the context + GEOMAlgo_GluerAlgo::Perform(); + // + PerformShapesToWork(); + if (myErrorStatus) { + return; + } + if (myWarningStatus==1) {// no shapes to glue + myShape=myArgument; + return; + } + // + FillVertices(); + if (myErrorStatus) { + return; + } + // + FillEdges(); + if (myErrorStatus) { + return; + } + // + FillWires(); + if (myErrorStatus) { + return; + } + // + FillFaces(); + if (myErrorStatus) { + return; + } + // + FillShells(); + if (myErrorStatus) { + return; + } + // + FillSolids(); + if (myErrorStatus) { + return; + } + // + FillCompSolids(); + if (myErrorStatus) { + return; + } + // + FillCompounds(); + if (myErrorStatus) { + return; + } + // + BuildResult(); + if (myErrorStatus) { + return; + } + // + PrepareHistory(); + if (myErrorStatus) { + return; + } + // + BRepLib::SameParameter(myShape, myTolerance, Standard_True); +} +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::CheckData() +{ + Standard_Integer aNbSG, i; + TopAbs_ShapeEnum aType, aTypeX; + TopTools_ListIteratorOfListOfShape aItLS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; + // + myErrorStatus=0; + myWarningStatus=0; + // + aNbSG=myShapesToGlue.Extent(); + if (aNbSG) { + // Check myShapesToGlue + aItDMSLS.Initialize(myShapesToGlue); + for (; aItDMSLS.More(); aItDMSLS.Next()) { + //const TopoDS_Shape& aSkey=aItDMSLS.Key(); + const TopTools_ListOfShape& aLSG=aItDMSLS.Value(); + aItLS.Initialize(aLSG); + for (i=0; aItLS.More(); aItLS.Next(), ++i) { + const TopoDS_Shape& aSG=aItLS.Value(); + aTypeX=aSG.ShapeType(); + if (!i) { + aType=aTypeX; + if (!(aType==TopAbs_VERTEX || + aType==TopAbs_EDGE || + aType==TopAbs_FACE)) { + myErrorStatus=21;// non-brep shapes + return; + } + continue; + } + if (aTypeX!=aType) { + myErrorStatus=20;// non-homogeneous shapes + return; + } + } + } + }// if (aNbSG) { +} +//======================================================================= +//function : FillEdges +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillEdges() +{ + FillBRepShapes(TopAbs_EDGE); +} +//======================================================================= +//function : FillFaces +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillFaces() +{ + FillBRepShapes(TopAbs_FACE); +} +//======================================================================= +//function : FillWires +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillWires() +{ + FillContainers(TopAbs_WIRE); +} +//======================================================================= +//function : FillShells +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillShells() +{ + FillContainers(TopAbs_SHELL); +} +//======================================================================= +//function : FillSolids +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillSolids() +{ + FillContainers(TopAbs_SOLID); +} +//======================================================================= +//function : FillCompSolids +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillCompSolids() +{ + FillContainers(TopAbs_COMPSOLID); +} +//======================================================================= +//function : FillVertices +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillVertices() +{ + TopAbs_ShapeEnum aType; + TopoDS_Vertex aVnew; + TopTools_ListIteratorOfListOfShape aItLS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; + // + myErrorStatus=0; + myWarningStatus=0; + // + aItDMSLS.Initialize(myImagesToWork); + for (; aItDMSLS.More(); aItDMSLS.Next()) { + const TopoDS_Shape& aSkey=aItDMSLS.Key(); + aType=aSkey.ShapeType(); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + const TopTools_ListOfShape& aLSD=aItDMSLS.Value(); + // + GEOMAlgo_Gluer2::MakeVertex(aLSD, aVnew); + // + myImages.Bind(aVnew, aLSD); + // + aItLS.Initialize(aLSD); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aV=aItLS.Value(); + myOrigins.Bind(aV, aVnew); + } + } +} +//======================================================================= +//function : FillBRepShapes +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillBRepShapes(const TopAbs_ShapeEnum theType) +{ + Standard_Boolean bHasImage, bIsToWork; + Standard_Integer i, aNbE; + TopoDS_Iterator aItS; + TopoDS_Shape aEnew; + TopTools_IndexedMapOfShape aME; + TopTools_MapOfShape aMFence; + TopTools_ListIteratorOfListOfShape aItLS; + // + myErrorStatus=0; + myWarningStatus=0; + // + TopExp::MapShapes(myArgument, theType, aME); + // + aNbE=aME.Extent(); + for (i=1; i<=aNbE; ++i) { + const TopoDS_Shape& aE=aME(i); + // + if (!aMFence.Add(aE)) { + continue; + } + // + bIsToWork=myOriginsToWork.IsBound(aE); + bHasImage=HasImage(aE); + if (!bHasImage && !bIsToWork) { + continue; + } + // + MakeBRepShapes(aE, aEnew); + // + //myImages / myOrigins + if (bIsToWork) { + const TopoDS_Shape& aSkey=myOriginsToWork.Find(aE); + const TopTools_ListOfShape& aLSD=myImagesToWork.Find(aSkey); + // + myImages.Bind(aEnew, aLSD); + // + aItLS.Initialize(aLSD); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aEx=aItLS.Value(); + myOrigins.Bind(aEx, aEnew); + // + aMFence.Add(aEx); + } + } + else { + TopTools_ListOfShape aLSD; + // + aLSD.Append(aE); + myImages.Bind(aEnew, aLSD); + myOrigins.Bind(aE, aEnew); + } + }//for (i=1; i<=aNbF; ++i) { +} +//======================================================================= +//function : FillContainers +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillContainers(const TopAbs_ShapeEnum aType) +{ + Standard_Boolean bHasImage, bToReverse; + Standard_Integer i, aNbW; + TopoDS_Shape aWnew, aEnew; + TopoDS_Iterator aItS; + BRep_Builder aBB; + TopTools_IndexedMapOfShape aMW; + TopTools_MapOfShape aMFence; + // + myErrorStatus=0; + myWarningStatus=0; + // + TopExp::MapShapes(myArgument, aType, aMW); + // + aNbW=aMW.Extent(); + for (i=1; i<=aNbW; ++i) { + const TopoDS_Shape& aW=aMW(i); + // + if (!aMFence.Add(aW)) { + continue; + } + // + bHasImage=HasImage(aW); + if (!bHasImage) { + continue; + } + // + GEOMAlgo_Tools3D::MakeContainer(aType, aWnew); + //modified by NIZNHY-PKV Tue May 10 13:46:30 2011f + aWnew.Orientation(aW.Orientation()); + //modified by NIZNHY-PKV Tue May 10 13:46:32 2011t + // + aItS.Initialize(aW); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aE=aItS.Value(); + if (myOrigins.IsBound(aE)) { + aEnew=myOrigins.Find(aE); + // + bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aEnew, aE, myContext); + if (bToReverse) { + aEnew.Reverse(); + } + // + aBB.Add(aWnew, aEnew); + } + else { + aBB.Add(aWnew, aE); + } + } + // + //modified by NIZNHY-PKV Tue May 10 13:46:19 2011f + //aWnew.Orientation(aW.Orientation()); + //modified by NIZNHY-PKV Tue May 10 13:46:22 2011t + // + //myImages / myOrigins + TopTools_ListOfShape aLSD; + // + aLSD.Append(aW); + myImages.Bind(aWnew, aLSD); + myOrigins.Bind(aW, aWnew); + // + }//for (i=1; i<=aNbE; ++i) { +} +//======================================================================= +//function : FillCompounds +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillCompounds() +{ + TopAbs_ShapeEnum aType; + TopoDS_Iterator aItC; + // + myErrorStatus=0; + myWarningStatus=0; + // + aItC.Initialize(myArgument); + for (; aItC.More(); aItC.Next()) { + const TopoDS_Shape& aCx=aItC.Value(); + aType=aCx.ShapeType(); + if (aType==TopAbs_COMPOUND) { + FillCompound(aCx); + } + } +} +//======================================================================= +//function : FillCompound +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::FillCompound(const TopoDS_Shape& aC) +{ + Standard_Boolean bHasImage; + TopAbs_ShapeEnum aType; + TopoDS_Shape aCnew, aCXnew; + TopoDS_Iterator aItC; + BRep_Builder aBB; + // + bHasImage=HasImage(aC); + if (!bHasImage) { + return; + } + // + GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCnew); + // + aItC.Initialize(aC); + for (; aItC.More(); aItC.Next()) { + const TopoDS_Shape& aCX=aItC.Value(); + aType=aCX.ShapeType(); + // + if (aType==TopAbs_COMPOUND) { + FillCompound(aCX); + } + // + if (myOrigins.IsBound(aCX)) { + aCXnew=myOrigins.Find(aCX); + aCXnew.Orientation(aCX.Orientation()); + aBB.Add(aCnew, aCXnew); + } + else { + aBB.Add(aCnew, aCX); + } + } + // + //myImages / myOrigins + TopTools_ListOfShape aLSD; + // + aLSD.Append(aC); + myImages.Bind(aCnew, aLSD); + myOrigins.Bind(aC, aCnew); +} +//======================================================================= +//function : HasImage +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer2::HasImage(const TopoDS_Shape& aC) +{ + Standard_Boolean bRet; + TopAbs_ShapeEnum aType; + TopoDS_Iterator aItC; + // + bRet=Standard_False; + aItC.Initialize(aC); + for (; aItC.More(); aItC.Next()) { + const TopoDS_Shape& aCx=aItC.Value(); + aType=aCx.ShapeType(); + // + if (aType==TopAbs_COMPOUND) { + bRet=HasImage(aCx); + if (bRet) { + return bRet; + } + } + else { + bRet=myOrigins.IsBound(aCx); + if (bRet) { + return bRet; + } + } + } + // + bRet=myOrigins.IsBound(aC); + // + return bRet; +} +//======================================================================= +//function : BuildResult +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::BuildResult() +{ + Standard_Boolean bHasImage; + TopoDS_Shape aCnew, aCXnew; + TopoDS_Iterator aItC; + BRep_Builder aBB; + // + myErrorStatus=0; + myWarningStatus=0; + // + aItC.Initialize(myArgument); + for (; aItC.More(); aItC.Next()) { + const TopoDS_Shape& aCx=aItC.Value(); + bHasImage=HasImage(aCx); + if (bHasImage) { + break; + } + } + // + if (!bHasImage) { + myShape=myArgument; + return; + } + // + GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCnew); + // + aItC.Initialize(myArgument); + for (; aItC.More(); aItC.Next()) { + const TopoDS_Shape& aCX=aItC.Value(); + if (myOrigins.IsBound(aCX)) { + aCXnew=myOrigins.Find(aCX); + aCXnew.Orientation(aCX.Orientation()); + aBB.Add(aCnew, aCXnew); + } + else { + aBB.Add(aCnew, aCX); + } + } + // + if (!myKeepNonSolids) { + Standard_Integer i, aNb; + TopoDS_Shape aCnew1; + TopTools_IndexedMapOfShape aM; + // + GEOMAlgo_Tools3D::MakeContainer(TopAbs_COMPOUND, aCnew1); + // + TopExp::MapShapes(aCnew, TopAbs_SOLID, aM); + + aNb=aM.Extent(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=aM(i); + aBB.Add(aCnew1, aS); + } + aCnew=aCnew1; + } + // + myShape=aCnew; +} +//-------------------------------------------------------- +// +// ErrorStatus +// 11 - GEOMAlgo_GlueDetector failed +// 13 - PerformImagesToWork failed +// 14 - PerformImagesToWork failed +// +// WarningStatus +// 1 - no shapes to glue diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2.hxx new file mode 100644 index 000000000..d6182bbab --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2.hxx @@ -0,0 +1,144 @@ +// 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_Gluer2.hxx +// Created: +// Author: Peter KURNEV +// + +#ifndef _GEOMAlgo_Gluer2_HeaderFile +#define _GEOMAlgo_Gluer2_HeaderFile + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_Gluer2 +//purpose : +//======================================================================= +class GEOMAlgo_Gluer2 : public GEOMAlgo_GluerAlgo, + public GEOMAlgo_BuilderShape { +public: + + Standard_EXPORT GEOMAlgo_Gluer2(); + + Standard_EXPORT virtual ~GEOMAlgo_Gluer2(); + + Standard_EXPORT void SetShapesToGlue(const TopTools_DataMapOfShapeListOfShape& aM) ; + + Standard_EXPORT const TopTools_DataMapOfShapeListOfShape& ShapesToGlue() const; + + Standard_EXPORT void SetKeepNonSolids(const Standard_Boolean theFlag) ; + + Standard_EXPORT Standard_Boolean KeepNonSolids() const; + + Standard_EXPORT virtual void Clear() ; + + Standard_EXPORT virtual void Perform() ; + + Standard_EXPORT virtual void CheckData() ; + + Standard_EXPORT void Detect() ; + + Standard_EXPORT const TopTools_DataMapOfShapeListOfShape& ShapesDetected() const; + + Standard_EXPORT const TopTools_DataMapOfShapeListOfShape& ImagesToWork() const; + + Standard_EXPORT virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ; + + Standard_EXPORT virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ; + + Standard_EXPORT virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ; + + Standard_EXPORT static void MakeVertex(const TopTools_ListOfShape& theLV, + TopoDS_Vertex& theV) ; + + Standard_EXPORT static void MapBRepShapes(const TopoDS_Shape& theS, + TopTools_MapOfShape& theM) ; + + Standard_EXPORT static void MapShapes(const TopoDS_Shape& theS, + TopTools_MapOfShape& theM) ; + + +protected: + + Standard_EXPORT void PerformShapesToWork() ; + + Standard_EXPORT void FillVertices() ; + + Standard_EXPORT void FillEdges() ; + + Standard_EXPORT void FillWires() ; + + Standard_EXPORT void FillFaces() ; + + Standard_EXPORT void FillShells() ; + + Standard_EXPORT void FillSolids() ; + + Standard_EXPORT void FillCompSolids() ; + + Standard_EXPORT void FillCompounds() ; + + Standard_EXPORT void BuildResult() ; + + Standard_EXPORT void FillBRepShapes(const TopAbs_ShapeEnum theType) ; + + Standard_EXPORT void FillContainers(const TopAbs_ShapeEnum theType) ; + + Standard_EXPORT void FillCompound(const TopoDS_Shape& theC) ; + + Standard_EXPORT virtual void PrepareHistory() ; + + Standard_EXPORT Standard_Boolean HasImage(const TopoDS_Shape& theC) ; + + Standard_EXPORT void MakeBRepShapes(const TopoDS_Shape& theS, + TopoDS_Shape& theSnew) ; + + Standard_EXPORT void MakeEdge(const TopoDS_Edge& theE, + TopoDS_Edge& theEnew) ; + + Standard_EXPORT void MakeFace(const TopoDS_Face& theF, + TopoDS_Face& theFnew) ; + + Standard_EXPORT void TreatPair(const NMTTools_CoupleOfShape& theCS, + NMTTools_ListOfCoupleOfShape& theLCS) ; + +protected: + TopTools_DataMapOfShapeListOfShape myShapesToGlue; + TopTools_DataMapOfShapeListOfShape myImagesDetected; + TopTools_DataMapOfShapeShape myOriginsDetected; + TopTools_DataMapOfShapeListOfShape myImagesToWork; + TopTools_DataMapOfShapeShape myOriginsToWork; + Standard_Boolean myKeepNonSolids; + +private: +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_1.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_1.cxx new file mode 100644 index 000000000..e14f54b55 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_1.cxx @@ -0,0 +1,322 @@ +// 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_Gluer2_1.cxx +// 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 + +//======================================================================= +//function : MakeBRepShapes +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::MakeBRepShapes(const TopoDS_Shape& theS, + TopoDS_Shape& theSnew) +{ + TopAbs_ShapeEnum aType; + // + aType=theS.ShapeType(); + if (aType==TopAbs_EDGE) { + TopoDS_Edge aEE, aEEnew; + // + aEE=*((TopoDS_Edge*)&theS); + MakeEdge(aEE, aEEnew); + if (myErrorStatus) { + return; + } + // + theSnew=aEEnew; + } + else if (aType==TopAbs_FACE) { + TopoDS_Face aFF, aFFnew; + // + aFF=*((TopoDS_Face*)&theS); + MakeFace(aFF, aFFnew); + if (myErrorStatus) { + return; + } + // + theSnew=aFFnew; + } +} +//======================================================================= +//function : MakeFace +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::MakeFace(const TopoDS_Face& theF, + TopoDS_Face& theFnew) +{ + Standard_Boolean bIsToReverse, bIsUPeriodic; + Standard_Integer iRet; + Standard_Real aTol, aUMin, aUMax, aVMin, aVMax; + TopAbs_Orientation aOrE; + Handle(Geom_Surface) aS; + TopLoc_Location aLoc; + TopoDS_Shape aW, aWr; + TopoDS_Edge aEx; + TopoDS_Face aFF, aFnew; + TopoDS_Iterator aItW, aItE; + BRep_Builder aBB; + TopTools_ListOfShape aLEr; + TopTools_ListIteratorOfListOfShape aItLE; + // + myErrorStatus=0; + // + aFF=theF; + aFF.Orientation(TopAbs_FORWARD); + // + aTol=BRep_Tool::Tolerance(aFF); + aS=BRep_Tool::Surface(aFF, aLoc); + bIsUPeriodic=GEOMAlgo_Tools::IsUPeriodic(aS); + BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax); + // + aBB.MakeFace (aFnew, aS, aLoc, aTol); + // + aItW.Initialize(aFF); + for (; aItW.More(); aItW.Next()) { + const TopoDS_Shape& aW=aItW.Value(); + // + if (!myOrigins.IsBound(aW)) { + aBB.Add(aFnew, aW); + continue; + } + // + aWr=myOrigins.Find(aW); + // + // clear contents of Wr + aLEr.Clear(); + aItE.Initialize(aWr); + for (; aItE.More(); aItE.Next()) { + const TopoDS_Shape& aEr=aItE.Value(); + aLEr.Append(aEr); + } + // + aItLE.Initialize(aLEr); + for (; aItLE.More(); aItLE.Next()) { + const TopoDS_Shape& aEr=aItLE.Value(); + aBB.Remove(aWr, aEr); + } + // + // refill contents of Wr + aItE.Initialize(aW); + for (; aItE.More(); aItE.Next()) { + const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aItE.Value())); + // + aEx=aE; + if (myOrigins.IsBound(aE)) { + aEx=*((TopoDS_Edge*)(&myOrigins.Find(aE))); + } + // + if (!BRep_Tool::Degenerated(aEx)) { + aEx.Orientation(TopAbs_FORWARD); + if (bIsUPeriodic) { + GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(aEx, aFF, aUMin, aUMax); + } + // + //modified by NIZNHY-PKV Fri Feb 03 11:18:17 2012f + iRet=GEOMAlgo_Tools::BuildPCurveForEdgeOnFace(aE, aEx, aFF, myContext); + if (iRet) { + continue; + } + //BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aEx, aFF); + //modified by NIZNHY-PKV Fri Feb 03 11:18:20 2012t + // + bIsToReverse=BOPTools_Tools3D::IsSplitToReverse1(aEx, aE, myContext); + if (bIsToReverse) { + aEx.Reverse(); + } + } + else { + aEx.Orientation(aE.Orientation()); + } + aBB.Add(aWr, aEx); + }// for (; aItE.More(); aItE.Next()) { + // + aBB.Add(aFnew, aWr); + }// for (; aItW.More(); aItW.Next()) { + theFnew=aFnew; +} +//======================================================================= +//function : MakeEdge +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::MakeEdge(const TopoDS_Edge& aE, + TopoDS_Edge& aNewEdge) +{ + myErrorStatus=0; + // + Standard_Boolean bIsDE; + Standard_Real aT1, aT2; + TopoDS_Vertex aV1, aV2, aVR1, aVR2; + TopoDS_Edge aEx; + // + bIsDE=BRep_Tool::Degenerated(aE); + // + aEx=aE; + aEx.Orientation(TopAbs_FORWARD); + // + TopExp::Vertices(aEx, aV1, aV2); + // + aT1=BRep_Tool::Parameter(aV1, aEx); + aT2=BRep_Tool::Parameter(aV2, aEx); + // + aVR1=aV1; + if (myOrigins.IsBound(aV1)) { + aVR1=*((TopoDS_Vertex*)&myOrigins.Find(aV1)); + } + aVR1.Orientation(TopAbs_FORWARD); + // + aVR2=aV2; + if (myOrigins.IsBound(aV2)) { + aVR2=*((TopoDS_Vertex*)&myOrigins.Find(aV2)); + } + aVR2.Orientation(TopAbs_REVERSED); + // + if (!bIsDE) { + BOPTools_Tools::MakeSplitEdge(aEx, aVR1, aT1, aVR2, aT2, aNewEdge); + } + else { + Standard_Real aTol; + BRep_Builder aBB; + TopoDS_Edge E; + // + aTol=BRep_Tool::Tolerance(aE); + // + E=aEx; + E.EmptyCopy(); + // + aBB.Add (E, aVR1); + aBB.Add (E, aVR2); + aBB.Range(E, aT1, aT2); + aBB.Degenerated(E, Standard_True); + aBB.UpdateEdge(E, aTol); + // + aNewEdge=E; + } +} +//======================================================================= +//function : MakeVertex +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::MakeVertex(const TopTools_ListOfShape& aLV, + TopoDS_Vertex& aNewVertex) +{ + Standard_Integer aNbV; + Standard_Real aTolV, aD, aDmax; + gp_XYZ aGC; + gp_Pnt aP3D, aPGC; + TopoDS_Vertex aVx; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aIt; + // + aNbV=aLV.Extent(); + if (!aNbV) { + return; + } + // + // center of gravity + aGC.SetCoord(0.,0.,0.); + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + aVx=*((TopoDS_Vertex*)(&aIt.Value())); + aP3D=BRep_Tool::Pnt(aVx); + aGC+=aP3D.XYZ(); + } + aGC/=(Standard_Real)aNbV; + aPGC.SetXYZ(aGC); + // + // tolerance value + aDmax=-1.; + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + aVx=*((TopoDS_Vertex*)(&aIt.Value())); + aP3D=BRep_Tool::Pnt(aVx); + aTolV=BRep_Tool::Tolerance(aVx); + aD=aPGC.Distance(aP3D)+aTolV; + if (aD>aDmax) { + aDmax=aD; + } + } + // + aBB.MakeVertex (aNewVertex, aPGC, aDmax); +} +//======================================================================= +//function : MapBRepShapes +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::MapBRepShapes(const TopoDS_Shape& aS, + TopTools_MapOfShape& aM) +{ + //Standard_Boolean bHasBRep; + TopAbs_ShapeEnum aType; + TopoDS_Iterator aIt; + // + aType=aS.ShapeType(); + if (aType==TopAbs_VERTEX || + aType==TopAbs_EDGE || + aType==TopAbs_FACE) { + aM.Add(aS); + } + // + aIt.Initialize(aS); + for(; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + aType=aSx.ShapeType(); + GEOMAlgo_Gluer2::MapBRepShapes(aSx, aM); + } +} + +// +// ErrorStatus +// +// 40 - GEOMAlgo_GlueDetector is failed diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_2.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_2.cxx new file mode 100644 index 000000000..91c620053 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_2.cxx @@ -0,0 +1,156 @@ +// 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_Gluer2_2.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +#include + +#include +#include + +#include +#include + +//======================================================================= +//function : PrepareHistory +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::PrepareHistory() +{ + //Standard_Boolean bHasImage, bContainsSD; + // + // 1. Clearing + GEOMAlgo_BuilderShape::PrepareHistory(); + // + if(myShape.IsNull()) { + return; + } + // + GEOMAlgo_Gluer2::MapShapes(myShape, myMapShape); + // +} +//======================================================================= +//function : Generated +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_Gluer2::Generated(const TopoDS_Shape& ) +{ + myHistShapes.Clear(); + return myHistShapes; +} +//======================================================================= +//function : Modified +//purpose : +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_Gluer2::Modified(const TopoDS_Shape& theS) +{ + Standard_Boolean bIsDeleted, bHasImage, bToReverse; + TopAbs_ShapeEnum aType; + TopoDS_Shape aSim; + // + myHistShapes.Clear(); + // + aType=theS.ShapeType(); + if (!(aType==TopAbs_VERTEX || aType==TopAbs_EDGE || + aType==TopAbs_FACE || aType==TopAbs_SOLID)) { + return myHistShapes; + } + // + bIsDeleted=IsDeleted(theS); + if (bIsDeleted) { + return myHistShapes; + } + // + bHasImage=myOrigins.IsBound(theS); + if (!bHasImage) { + return myHistShapes; + } + // + aSim=myOrigins.Find(theS); + if (aSim.IsSame(theS)){ + return myHistShapes; + } + // + if (aType==TopAbs_VERTEX || aType==TopAbs_SOLID) { + aSim.Orientation(theS.Orientation()); + } + else { + bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aSim, theS, myContext); + if (bToReverse) { + aSim.Reverse(); + } + } + // + myHistShapes.Append(aSim); + // + return myHistShapes; +} +//======================================================================= +//function : IsDeleted +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Gluer2::IsDeleted(const TopoDS_Shape& theS) +{ + Standard_Boolean bRet, bContains, bHasImage; + // + bRet=Standard_False; + // + if (theS.IsNull()) { + return !bRet; //true + } + // + bContains=myMapShape.Contains(theS); + if (bContains) { + return bRet; //false + } + // + bHasImage=myOrigins.IsBound(theS); + if (bHasImage) { + const TopoDS_Shape& aSim=myOrigins.Find(theS); + bContains=myMapShape.Contains(aSim); + if (bContains) { + return bRet; //false + } + } + // + return !bRet; //true +} +//======================================================================= +//function : MapShapes +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::MapShapes(const TopoDS_Shape& theS, + TopTools_MapOfShape& theM) +{ + TopoDS_Iterator aIt; + // + theM.Add(theS); + aIt.Initialize(theS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + GEOMAlgo_Gluer2::MapShapes(aSx, theM); + } +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_3.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_3.cxx new file mode 100644 index 000000000..06aaf308d --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Gluer2_3.cxx @@ -0,0 +1,371 @@ +// 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_Gluer2_3.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 + + +static + void MapShapes1(const TopoDS_Shape& aS, + const TopAbs_ShapeEnum aType, + TopTools_IndexedMapOfShape& aM); + +//======================================================================= +//function : Detect +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::Detect() +{ + Standard_Boolean bCheckGeometry; + Standard_Integer iErr, aNbSD; + TopTools_ListIteratorOfListOfShape aItLS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; + GEOMAlgo_GlueDetector aDetector; + // + myErrorStatus=0; + myWarningStatus=0; + // + myImagesDetected.Clear(); + myOriginsDetected.Clear(); + // + bCheckGeometry=Standard_True; + aDetector.SetArgument(myArgument); + aDetector.SetTolerance(myTolerance); + aDetector.SetCheckGeometry(bCheckGeometry); + // + aDetector.Perform(); + iErr=aDetector.ErrorStatus(); + if (iErr) { + myErrorStatus=11;// Detector failed + return; + } + // + const TopTools_DataMapOfShapeListOfShape& aImages=aDetector.Images(); + aItDMSLS.Initialize(aImages); + for (; aItDMSLS.More(); aItDMSLS.Next()) { + const TopoDS_Shape& aSkey=aItDMSLS.Key(); + const TopTools_ListOfShape& aLSD=aItDMSLS.Value(); + aNbSD=aLSD.Extent(); + myImagesDetected.Bind(aSkey, aLSD); + } + // + aItDMSLS.Initialize(myImagesDetected); + for (; aItDMSLS.More(); aItDMSLS.Next()) { + const TopoDS_Shape& aSkey=aItDMSLS.Key(); + const TopTools_ListOfShape& aLSD=aItDMSLS.Value(); + aItLS.Initialize(aLSD); + for (; aItLS.More(); aItLS.Next()) { + const TopoDS_Shape& aSx=aItLS.Value(); + myOriginsDetected.Bind(aSx, aSkey); + } + } +} +//======================================================================= +//function : PerformShapesToWork +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::PerformShapesToWork() +{ + Standard_Integer aNbSG, i, j, aNbC, aNb, aNbSD; + TopTools_ListIteratorOfListOfShape aItLS1, aItLS2; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; + NMTTools_CoupleOfShape aCS; + NMTTools_ListOfCoupleOfShape aLCS; + NMTTools_ListIteratorOfListOfCoupleOfShape aItCS; + // + myErrorStatus=0; + myWarningStatus=0; + // + myImagesToWork.Clear(); + myOriginsToWork.Clear(); + // + aNbSD=myImagesDetected.Extent(); + if (!aNbSD) {// no shapes to glue detected + myWarningStatus=1; + return; + } + // + aNbSG=myShapesToGlue.Extent(); + if (!aNbSG) { + // glue all possible + myImagesToWork=myImagesDetected; + // + aItDMSLS.Initialize(myImagesToWork); + for (; aItDMSLS.More(); aItDMSLS.Next()) { + const TopoDS_Shape& aSkey=aItDMSLS.Key(); + const TopTools_ListOfShape& aLSD=aItDMSLS.Value(); + aItLS1.Initialize(aLSD); + for (; aItLS1.More(); aItLS1.Next()) { + const TopoDS_Shape& aSx=aItLS1.Value(); + myOriginsToWork.Bind(aSx, aSkey); + } + } + return; + }// if (!aNbSG) { + // + // 1. Make pairs + aItDMSLS.Initialize(myShapesToGlue); + for (; aItDMSLS.More(); aItDMSLS.Next()) { + //const TopoDS_Shape& aSkey=aItDMSLS.Key(); + const TopTools_ListOfShape& aLSG=aItDMSLS.Value(); + aItLS1.Initialize(aLSG); + for (i=0; aItLS1.More(); aItLS1.Next(), ++i) { + aItLS2.Initialize(aLSG); + for (j=0; aItLS2.More(); aItLS2.Next(), ++j) { + if (j>i) { + const TopoDS_Shape& aSG1=aItLS1.Value(); + const TopoDS_Shape& aSG2=aItLS2.Value(); + aCS.SetShape1(aSG1); + aCS.SetShape2(aSG2); + TreatPair(aCS, aLCS); + } + } + } + } + // + // 2. Find Chains + TopTools_ListOfShape aLSX; + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC; + // + NMTTools_Tools::FindChains(aLCS, aMC); + // + // 3. myImagesToWork, myOriginsToWork + aNbC=aMC.Extent(); + for (i=1; i<=aNbC; ++i) { + const TopoDS_Shape& aSkey=aMC.FindKey(i); + const TopTools_IndexedMapOfShape& aM=aMC(i); + aLSX.Clear(); + aNb=aM.Extent(); + for (j=1; j<=aNb; ++j) { + const TopoDS_Shape& aS=aM(j); + aLSX.Append(aS); + myOriginsToWork.Bind(aS, aSkey); + } + myImagesToWork.Bind(aSkey, aLSX); + } +} +//======================================================================= +//function : TreatPair +//purpose : +//======================================================================= +void GEOMAlgo_Gluer2::TreatPair(const NMTTools_CoupleOfShape& aCS, + NMTTools_ListOfCoupleOfShape& aLCS) +{ + if (myErrorStatus) { + return; + } + // + Standard_Integer i, aNbS1, aNbS2, aNbS; + TopAbs_ShapeEnum aType, aTypeS; + TopTools_ListIteratorOfListOfShape aItLS; + TopTools_IndexedMapOfShape aMS1, aMS2; + TopTools_DataMapOfShapeListOfShape aDMSLS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS; + NMTTools_CoupleOfShape aCSS; + // + // 1. Checking the pair on whether it can be glued at all + // 1.1 + const TopoDS_Shape& aS1=aCS.Shape1(); + if (!myOriginsDetected.IsBound(aS1)) { + myErrorStatus=30; + return; + } + const TopoDS_Shape& aSkey1=myOriginsDetected.Find(aS1); + // 1.2 + const TopoDS_Shape& aS2=aCS.Shape2(); + if (!myOriginsDetected.IsBound(aS2)) { + myErrorStatus=30; + return; + } + const TopoDS_Shape& aSkey2=myOriginsDetected.Find(aS2); + // 1.3 + if (!aSkey1.IsSame(aSkey2)) { + myErrorStatus=33; + return; + } + // + // 2. Append the pair to the aLCS + aLCS.Append(aCS); + // + // 3. Treatment the sub-shapes of the pair + aType=aS1.ShapeType(); + if (aType==TopAbs_VERTEX) { + return; + } + aTypeS=TopAbs_EDGE; + if (aType==aTypeS) { + aTypeS=TopAbs_VERTEX; + } + // + MapShapes1(aS1, aTypeS, aMS1); + MapShapes1(aS2, aTypeS, aMS2); + // + aNbS1=aMS1.Extent(); + aNbS2=aMS2.Extent(); + if (aNbS1!=aNbS2) { + myErrorStatus=31; + return; + } + // + // 1. + for (i=1; i<=aNbS1; ++i) { + const TopoDS_Shape& aSS1=aMS1(i); + if (aMS2.Contains(aSS1)) { + continue; + } + // + if (!myOriginsDetected.IsBound(aSS1)) { + myErrorStatus=30; + return; + } + // + const TopoDS_Shape& aSkey=myOriginsDetected.Find(aSS1); + if (aDMSLS.IsBound(aSkey)) { + TopTools_ListOfShape& aLS=aDMSLS.ChangeFind(aSkey); + aLS.Append(aSS1); + } + else { + TopTools_ListOfShape aLS; + // + aLS.Append(aSS1); + aDMSLS.Bind(aSkey, aLS); + } + } + // + // 2. + for (i=1; i<=aNbS2; ++i) { + const TopoDS_Shape& aSS2=aMS2(i); + if (aMS1.Contains(aSS2)) { + continue; + } + // + if (!myOriginsDetected.IsBound(aSS2)) { + myErrorStatus=30; + return; + } + // + const TopoDS_Shape& aSkey=myOriginsDetected.Find(aSS2); + if (aDMSLS.IsBound(aSkey)) { + TopTools_ListOfShape& aLS=aDMSLS.ChangeFind(aSkey); + aLS.Append(aSS2); + } + else { + TopTools_ListOfShape aLS; + // + aLS.Append(aSS2); + aDMSLS.Bind(aSkey, aLS); + } + } + // + // 3. + aItDMSLS.Initialize(aDMSLS); + for (; aItDMSLS.More(); aItDMSLS.Next()) { + //const TopoDS_Shape& aSkey=aItDMSLS.Key(); + const TopTools_ListOfShape& aLS=aItDMSLS.Value(); + aNbS=aLS.Extent(); + if (aNbS!=2) { + myErrorStatus=32; + return; + } + // + const TopoDS_Shape& aSS1=aLS.First(); + const TopoDS_Shape& aSS2=aLS.Last(); + aCSS.SetShape1(aSS1); + aCSS.SetShape2(aSS2); + TreatPair(aCSS, aLCS); + } +} +//======================================================================= +//function : MapShapes1 +//purpose : +//======================================================================= +void MapShapes1(const TopoDS_Shape& aS, + const TopAbs_ShapeEnum aType, + TopTools_IndexedMapOfShape& aM) +{ + TopExp_Explorer aExp; + + aExp.Init (aS, aType); + for ( ;aExp.More(); aExp.Next()) { + const TopoDS_Shape aSx=aExp.Current(); + if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aEx=*((TopoDS_Edge*)&aSx); + if (BRep_Tool::Degenerated(aEx)) { + continue; + } + } + aM.Add(aSx); + } +} +/* +//======================================================================= +//function : MapShapes1 +//purpose : +//======================================================================= +void MapShapes1(const TopoDS_Shape& aS, + const TopAbs_ShapeEnum aType, + TopTools_IndexedMapOfShape& aM) +{ + TopExp_Explorer aExp (aS, aType); + while (aExp.More()) { + const TopoDS_Shape aSx=aExp.Current(); + if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aEx=*((TopoDS_Edge*)&aSx); + if (BRep_Tool::Degenerated(aEx)) { + aExp.Next(); + continue; + } + } + aM.Add(aSx); + aExp.Next(); + } +} +*/ diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_GluerAlgo.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_GluerAlgo.cxx new file mode 100644 index 000000000..dac56165f --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_GluerAlgo.cxx @@ -0,0 +1,146 @@ +// 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_GluerAlgo.cxx +// Created: +// Author: Peter KURNEV +// +// +#include +#include + + +//======================================================================= +//function : GEOMAlgo_GluerAlgo +//purpose : +//======================================================================= +GEOMAlgo_GluerAlgo::GEOMAlgo_GluerAlgo() +{ + myTolerance=0.0001; + myCheckGeometry=Standard_True; +} +//======================================================================= +//function : ~GEOMAlgo_GluerAlgo +//purpose : +//======================================================================= +GEOMAlgo_GluerAlgo::~GEOMAlgo_GluerAlgo() +{ +} +//======================================================================= +//function : SetArgument +//purpose : +//======================================================================= +void GEOMAlgo_GluerAlgo::SetArgument(const TopoDS_Shape& theShape) +{ + myArgument=theShape; +} +//======================================================================= +//function : Argument +//purpose : +//======================================================================= +const TopoDS_Shape& GEOMAlgo_GluerAlgo::Argument()const +{ + return myArgument; +} +//======================================================================= +//function : SetTolerance +//purpose : +//======================================================================= +void GEOMAlgo_GluerAlgo::SetTolerance(const Standard_Real aT) +{ + myTolerance=aT; +} +//======================================================================= +//function : Tolerance +//purpose : +//======================================================================= +Standard_Real GEOMAlgo_GluerAlgo::Tolerance()const +{ + return myTolerance; +} + +//======================================================================= +//function : SetCheckGeometry +//purpose : +//======================================================================= +void GEOMAlgo_GluerAlgo::SetCheckGeometry(const Standard_Boolean aFlag) +{ + myCheckGeometry=aFlag; +} +//======================================================================= +//function : CheckGeometry +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_GluerAlgo::CheckGeometry() const +{ + return myCheckGeometry; +} +//======================================================================= +//function : SetContext +//purpose : +//======================================================================= +void GEOMAlgo_GluerAlgo::SetContext(const Handle(IntTools_Context)& theContext) +{ + myContext=theContext; +} +//======================================================================= +//function : Context +//purpose : +//======================================================================= +const Handle(IntTools_Context)& GEOMAlgo_GluerAlgo::Context() +{ + return myContext; +} +//======================================================================= +//function : Images +//purpose : +//======================================================================= +const TopTools_DataMapOfShapeListOfShape& GEOMAlgo_GluerAlgo::Images()const +{ + return myImages; +} +//======================================================================= +//function : Origins +//purpose : +//======================================================================= +const TopTools_DataMapOfShapeShape& GEOMAlgo_GluerAlgo::Origins()const +{ + return myOrigins; +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= +void GEOMAlgo_GluerAlgo::Clear() +{ + myImages.Clear(); + myOrigins.Clear(); +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_GluerAlgo::Perform() +{ + if (myContext.IsNull()) { + myContext=new IntTools_Context; + } +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_GluerAlgo.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_GluerAlgo.hxx new file mode 100644 index 000000000..603484424 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_GluerAlgo.hxx @@ -0,0 +1,98 @@ +// 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_GluerAlgo.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_GluerAlgo_HeaderFile +#define _GEOMAlgo_GluerAlgo_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_GluerAlgo +//purpose : +//======================================================================= +class GEOMAlgo_GluerAlgo { +public: + + Standard_EXPORT + GEOMAlgo_GluerAlgo(); + + Standard_EXPORT + virtual ~GEOMAlgo_GluerAlgo(); + + Standard_EXPORT + virtual void SetArgument(const TopoDS_Shape& theShape) ; + + Standard_EXPORT + const TopoDS_Shape& Argument() const; + + Standard_EXPORT + void SetTolerance(const Standard_Real aT) ; + + Standard_EXPORT + Standard_Real Tolerance() const; + + Standard_EXPORT + void SetCheckGeometry(const Standard_Boolean aFlag) ; + + Standard_EXPORT + Standard_Boolean CheckGeometry() const; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + virtual void Clear() ; + + Standard_EXPORT + void SetContext(const Handle(IntTools_Context)&) ; + + Standard_EXPORT + const Handle(IntTools_Context)& Context() ; + + Standard_EXPORT + const TopTools_DataMapOfShapeListOfShape& Images() const; + + Standard_EXPORT + const TopTools_DataMapOfShapeShape& Origins() const; + +protected: + TopoDS_Shape myArgument; + Standard_Real myTolerance; + Standard_Boolean myCheckGeometry; + Handle(IntTools_Context) myContext; + TopTools_DataMapOfShapeListOfShape myImages; + TopTools_DataMapOfShapeShape myOrigins; + +private: +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_HAlgo.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_HAlgo.cxx new file mode 100644 index 000000000..1629942bc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_HAlgo.cxx @@ -0,0 +1,83 @@ +// 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_Hlgo.cxx +// Created: Sat Dec 04 12:39:47 2004 +// Author: Peter KURNEV +// +// +#include + +IMPLEMENT_STANDARD_HANDLE(GEOMAlgo_HAlgo, MMgt_TShared); +IMPLEMENT_STANDARD_RTTIEXT(GEOMAlgo_HAlgo, MMgt_TShared); + +//======================================================================= +// function: +// purpose: +//======================================================================= + GEOMAlgo_HAlgo::GEOMAlgo_HAlgo() +: + myErrorStatus(1), + myWarningStatus(0) +{} +//======================================================================= +// function: ~ +// purpose: +//======================================================================= + GEOMAlgo_HAlgo::~GEOMAlgo_HAlgo() +{ +} +//======================================================================= +// function: CheckData +// purpose: +//======================================================================= + void GEOMAlgo_HAlgo::CheckData() +{ + myErrorStatus=0; +} +//======================================================================= +// function: CheckResult +// purpose: +//======================================================================= + void GEOMAlgo_HAlgo::CheckResult() +{ + myErrorStatus=0; +} +//======================================================================= +// function: ErrorStatus +// purpose: +//======================================================================= + Standard_Integer GEOMAlgo_HAlgo::ErrorStatus()const +{ + return myErrorStatus; +} +//======================================================================= +// function: WarningStatus +// purpose: +//======================================================================= + Standard_Integer GEOMAlgo_HAlgo::WarningStatus()const +{ + return myWarningStatus; +} +// myErrorStatus +// +// 1 - object is just initialized diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_HAlgo.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_HAlgo.hxx new file mode 100644 index 000000000..c1b0cb62e --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_HAlgo.hxx @@ -0,0 +1,75 @@ +// 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_HAlgo.hxx +// Created: Sat Dec 04 12:39:47 2004 +// Author: Peter KURNEV +// +// + +#ifndef _GEOMAlgo_HAlgo_HeaderFile +#define _GEOMAlgo_HAlgo_HeaderFile + +#include +#include +//#include +#include +#include + +DEFINE_STANDARD_HANDLE(GEOMAlgo_HAlgo, MMgt_TShared); + +//======================================================================= +//class : GEOMAlgo_HAlgo +//purpose : +//======================================================================= +class GEOMAlgo_HAlgo : public MMgt_TShared +{ + public: + Standard_EXPORT + virtual void Perform() = 0; + + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + virtual void CheckResult() ; + + Standard_EXPORT + Standard_Integer ErrorStatus() const; + + Standard_EXPORT + Standard_Integer WarningStatus() const; + + DEFINE_STANDARD_RTTI(GEOMAlgo_HAlgo); + + protected: + Standard_EXPORT + GEOMAlgo_HAlgo(); + + Standard_EXPORT + virtual ~GEOMAlgo_HAlgo(); + + Standard_Integer myErrorStatus; + Standard_Integer myWarningStatus; + +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx new file mode 100644 index 000000000..7830f72d5 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_IndexedDataMapOfIntegerShape.hxx +// Created: Wed Feb 22 11:22:18 2012 +// Author: +// + + +#ifndef GEOMAlgo_IndexedDataMapOfIntegerShape_HeaderFile +#define GEOMAlgo_IndexedDataMapOfIntegerShape_HeaderFile + + + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfIntegerShape; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx new file mode 100644 index 000000000..0a2e82979 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_IndexedDataMapOfPassKeyShapeListOfShape.hxx +// Created: Wed Feb 22 11:24:27 2012 +// Author: +// + + +#ifndef GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape_HeaderFile +#define GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape_HeaderFile + +#include +#include +#include + + +#define _NCollection_MapHasher +#include + + +typedef NCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeBox.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeBox.hxx new file mode 100644 index 000000000..3f5d11d64 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeBox.hxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_IndexedDataMapOfShapeBox.hxx +// Created: Wed Feb 22 11:14:14 2012 +// Author: +// + + +#ifndef GEOMAlgo_IndexedDataMapOfShapeBox_HeaderFile +#define GEOMAlgo_IndexedDataMapOfShapeBox_HeaderFile + + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfShapeBox; + +#undef _NCollection_MapHasher + + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx new file mode 100644 index 000000000..8f4a308dc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_IndexedDataMapOfShapeShapeInfo.hxx +// Created: Wed Feb 22 11:16:54 2012 +// Author: +// + + +#ifndef GEOMAlgo_IndexedDataMapOfShapeShapeInfo_HeaderFile +#define GEOMAlgo_IndexedDataMapOfShapeShapeInfo_HeaderFile + + +#include +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfShapeShapeInfo; + +#undef _NCollection_MapHasher + + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeState.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeState.hxx new file mode 100644 index 000000000..06a74a174 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_IndexedDataMapOfShapeState.hxx @@ -0,0 +1,43 @@ +/// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_IndexedDataMapOfShapeState.hxx +// Created: Wed Feb 22 11:19:56 2012 +// Author: +// + + +#ifndef GEOMAlgo_IndexedDataMapOfShapeState_HeaderFile +#define GEOMAlgo_IndexedDataMapOfShapeState_HeaderFile + + + +#include +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfShapeState; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_KindOfBounds.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_KindOfBounds.hxx new file mode 100644 index 000000000..6de8485ad --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_KindOfBounds.hxx @@ -0,0 +1,37 @@ +// 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_KindOfBounds_HeaderFile +#define _GEOMAlgo_KindOfBounds_HeaderFile + + +enum GEOMAlgo_KindOfBounds { +GEOMAlgo_KB_UNKNOWN, +GEOMAlgo_KB_TRIMMED, +GEOMAlgo_KB_INFINITE +}; + +#ifndef _Standard_PrimitiveTypes_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_KindOfClosed.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_KindOfClosed.hxx new file mode 100644 index 000000000..5e7ccdcde --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_KindOfClosed.hxx @@ -0,0 +1,36 @@ +// 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_KindOfClosed_HeaderFile +#define _GEOMAlgo_KindOfClosed_HeaderFile + + +enum GEOMAlgo_KindOfClosed { +GEOMAlgo_KC_UNKNOWN, +GEOMAlgo_KC_CLOSED, +GEOMAlgo_KC_NOTCLOSED +}; + +#ifndef _Standard_PrimitiveTypes_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_KindOfName.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_KindOfName.hxx new file mode 100644 index 000000000..5b1362bcc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_KindOfName.hxx @@ -0,0 +1,54 @@ +// 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_KindOfName_HeaderFile +#define _GEOMAlgo_KindOfName_HeaderFile + + +enum GEOMAlgo_KindOfName { +GEOMAlgo_KN_UNKNOWN, +GEOMAlgo_KN_SPHERE, +GEOMAlgo_KN_CYLINDER, +GEOMAlgo_KN_TORUS, +GEOMAlgo_KN_CONE, +GEOMAlgo_KN_ELLIPSE, +GEOMAlgo_KN_CIRCLE, +GEOMAlgo_KN_PLANE, +GEOMAlgo_KN_LINE, +GEOMAlgo_KN_BOX, +GEOMAlgo_KN_SEGMENT, +GEOMAlgo_KN_ARCCIRCLE, +GEOMAlgo_KN_POLYGON, +GEOMAlgo_KN_POLYHEDRON, +GEOMAlgo_KN_DISKCIRCLE, +GEOMAlgo_KN_DISKELLIPSE, +GEOMAlgo_KN_RECTANGLE, +GEOMAlgo_KN_TRIANGLE, +GEOMAlgo_KN_QUADRANGLE, +GEOMAlgo_KN_ARCELLIPSE +}; + +#ifndef _Standard_PrimitiveTypes_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_KindOfShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_KindOfShape.hxx new file mode 100644 index 000000000..d6a005740 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_KindOfShape.hxx @@ -0,0 +1,44 @@ +// 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_KindOfShape_HeaderFile +#define _GEOMAlgo_KindOfShape_HeaderFile + + +enum GEOMAlgo_KindOfShape { +GEOMAlgo_KS_UNKNOWN, +GEOMAlgo_KS_SPHERE, +GEOMAlgo_KS_CYLINDER, +GEOMAlgo_KS_BOX, +GEOMAlgo_KS_TORUS, +GEOMAlgo_KS_CONE, +GEOMAlgo_KS_ELLIPSE, +GEOMAlgo_KS_PLANE, +GEOMAlgo_KS_CIRCLE, +GEOMAlgo_KS_LINE, +GEOMAlgo_KS_DEGENERATED +}; + +#ifndef _Standard_PrimitiveTypes_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx new file mode 100644 index 000000000..967af8a30 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_ListIteratorOfListOfCoupleOfShapes.hxx +// Created: Wed Feb 22 08:26:34 2012 +// Author: +// + +#ifndef GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_HeaderFile +#define GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_HeaderFile + +#ifndef GEOMAlgo_ListOfCoupleOfShapes_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ListIteratorOfListOfPnt.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ListIteratorOfListOfPnt.hxx new file mode 100644 index 000000000..f30e69409 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ListIteratorOfListOfPnt.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_ListIteratorOfListOfPnt.hxx +// Created: Wed Feb 22 08:33:12 2012 +// Author: +// + + +#ifndef GEOMAlgo_ListIteratorOfListOfPnt_HeaderFile +#define GEOMAlgo_ListIteratorOfListOfPnt_HeaderFile + +#ifndef GEOMAlgo_ListOfPnt_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ListOfCoupleOfShapes.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ListOfCoupleOfShapes.hxx new file mode 100644 index 000000000..594195c7a --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ListOfCoupleOfShapes.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_ListOfCoupleOfShapes.hxx +// Created: Wed Feb 22 08:23:27 2012 +// Author: +// + +#ifndef GEOMAlgo_ListOfCoupleOfShapes_HeaderFile +#define GEOMAlgo_ListOfCoupleOfShapes_HeaderFile + +#include +#include + +typedef NCollection_List GEOMAlgo_ListOfCoupleOfShapes; +typedef GEOMAlgo_ListOfCoupleOfShapes::Iterator GEOMAlgo_ListIteratorOfListOfCoupleOfShapes; + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ListOfPnt.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ListOfPnt.hxx new file mode 100644 index 000000000..9e7469c12 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ListOfPnt.hxx @@ -0,0 +1,35 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_ListOfPnt.hxx +// Created: Wed Feb 22 08:31:47 2012 +// Author: +// + + +#ifndef GEOMAlgo_ListOfPnt_HeaderFile +#define GEOMAlgo_ListOfPnt_HeaderFile + +#include +#include + +typedef NCollection_List GEOMAlgo_ListOfPnt; +typedef GEOMAlgo_ListOfPnt::Iterator GEOMAlgo_ListIteratorOfListOfPnt; + + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PWireEdgeSet.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_PWireEdgeSet.hxx new file mode 100644 index 000000000..d6a2f22a6 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PWireEdgeSet.hxx @@ -0,0 +1,35 @@ +// 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_PWireEdgeSet.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_PWireEdgeSet_HeaderFile +#define _GEOMAlgo_PWireEdgeSet_HeaderFile + +class GEOMAlgo_WireEdgeSet; + +typedef GEOMAlgo_WireEdgeSet* GEOMAlgo_PWireEdgeSet; + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PassKey.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_PassKey.cxx new file mode 100644 index 000000000..2d9301a62 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PassKey.cxx @@ -0,0 +1,240 @@ +// 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_PassKey.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include +#include + +#ifdef WNT +#pragma warning( disable : 4101) +#endif + +static + Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv); + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_PassKey::GEOMAlgo_PassKey() +{ + Clear(); +} +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_PassKey::GEOMAlgo_PassKey(const GEOMAlgo_PassKey& aOther) +{ + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; +} +//======================================================================= +//function :Assign +//purpose : +//======================================================================= + GEOMAlgo_PassKey& GEOMAlgo_PassKey::Assign(const GEOMAlgo_PassKey& aOther) +{ + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; + return *this; +} +//======================================================================= +//function :~ +//purpose : +//======================================================================= + GEOMAlgo_PassKey::~GEOMAlgo_PassKey() +{ +} +//======================================================================= +//function :Clear +//purpose : +//======================================================================= + void GEOMAlgo_PassKey::Clear() +{ + myNbIds=0; + mySum=0; + myMap.Clear(); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void GEOMAlgo_PassKey::SetIds(const Standard_Integer aId1) + +{ + Clear(); + myNbIds=1; + myMap.Add(aId1); + mySum=NormalizedId(aId1, myNbIds); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void GEOMAlgo_PassKey::SetIds(const Standard_Integer aId1, + const Standard_Integer aId2) +{ + TColStd_ListOfInteger aLI; + // + aLI.Append(aId1); + aLI.Append(aId2); + SetIds(aLI); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void GEOMAlgo_PassKey::SetIds(const Standard_Integer aId1, + const Standard_Integer aId2, + const Standard_Integer aId3) +{ + TColStd_ListOfInteger aLI; + // + aLI.Append(aId1); + aLI.Append(aId2); + aLI.Append(aId3); + SetIds(aLI); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void GEOMAlgo_PassKey::SetIds(const Standard_Integer aId1, + const Standard_Integer aId2, + const Standard_Integer aId3, + const Standard_Integer aId4) +{ + TColStd_ListOfInteger aLI; + // + aLI.Append(aId1); + aLI.Append(aId2); + aLI.Append(aId3); + aLI.Append(aId4); + SetIds(aLI); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void GEOMAlgo_PassKey::SetIds(const TColStd_ListOfInteger& aLI) +{ + Standard_Integer i, aId, aIdN; + TColStd_ListIteratorOfListOfInteger aIt; + // + Clear(); + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + aId=aIt.Value(); + myMap.Add(aId); + } + myNbIds=myMap.Extent(); + for(i=1; i<=myNbIds; ++i) { + aId=myMap(i); + aIdN=NormalizedId(aId, myNbIds); + mySum+=aIdN; + } +} +//======================================================================= +//function :NbIds +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKey::NbIds()const +{ + return myNbIds; +} +//======================================================================= +//function :Id +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKey::Id(const Standard_Integer aIndex) const +{ + if (aIndex<1 || aIndex>myNbIds) { + return -1; + } + return myMap(aIndex); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_PassKey::IsEqual(const GEOMAlgo_PassKey& aOther) const +{ + Standard_Boolean bRet; + Standard_Integer i, aId; + // + bRet=Standard_False; + // + if (myNbIds!=aOther.myNbIds) { + return bRet; + } + for (i=1; i<=myNbIds; ++i) { + aId=myMap(i); + if (!aOther.myMap.Contains(aId)) { + return bRet; + } + } + return !bRet; +} +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKey::HashCode(const Standard_Integer aUpper) const +{ + return ::HashCode(mySum, aUpper); +} +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void GEOMAlgo_PassKey::Dump(const Standard_Integer )const +{ +} +//======================================================================= +// function: NormalizedId +// purpose : +//======================================================================= +Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv) +{ + Standard_Integer aMax, aTresh, aIdRet; + // + aIdRet=aId; + aMax=::IntegerLast(); + aTresh=aMax/aDiv; + if (aId>aTresh) { + aIdRet=aId%aTresh; + } + return aIdRet; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PassKey.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_PassKey.hxx new file mode 100644 index 000000000..85040e083 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PassKey.hxx @@ -0,0 +1,104 @@ +// 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_PassKey.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_PassKey_HeaderFile +#define _GEOMAlgo_PassKey_HeaderFile + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_PassKey +//purpose : +//======================================================================= +class GEOMAlgo_PassKey { + public: + Standard_EXPORT + GEOMAlgo_PassKey(); + + Standard_EXPORT + virtual ~GEOMAlgo_PassKey(); + + Standard_EXPORT + GEOMAlgo_PassKey(const GEOMAlgo_PassKey& Other); + + Standard_EXPORT + GEOMAlgo_PassKey& Assign(const GEOMAlgo_PassKey& Other) ; + + GEOMAlgo_PassKey& operator =(const GEOMAlgo_PassKey& Other) { + return Assign(Other); + } + + Standard_EXPORT + void Clear() ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1) ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1, + const Standard_Integer aI2) ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1, + const Standard_Integer aI2, + const Standard_Integer aI3) ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1, + const Standard_Integer aI2, + const Standard_Integer aI3, + const Standard_Integer aI4) ; + + Standard_EXPORT + void SetIds(const TColStd_ListOfInteger& aLS) ; + + Standard_EXPORT + Standard_Integer NbIds() const; + + Standard_EXPORT + Standard_Boolean IsEqual(const GEOMAlgo_PassKey& aOther) const; + + Standard_EXPORT + Standard_Integer HashCode(const Standard_Integer Upper) const; + + Standard_EXPORT + Standard_Integer Id(const Standard_Integer aIndex) const; + + Standard_EXPORT + void Dump(const Standard_Integer aHex = 0) const; + + protected: + Standard_Integer myNbIds; + Standard_Integer mySum; + TColStd_IndexedMapOfInteger myMap; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyMapHasher.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyMapHasher.cxx new file mode 100644 index 000000000..70ab9f3bc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyMapHasher.cxx @@ -0,0 +1,47 @@ +// 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_PassKeyMapHasher.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKeyMapHasher::HashCode(const GEOMAlgo_PassKey& aPK, + const Standard_Integer Upper) +{ + return aPK.HashCode(Upper); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_PassKeyMapHasher::IsEqual(const GEOMAlgo_PassKey& aPK1, + const GEOMAlgo_PassKey& aPK2) +{ + return aPK1.IsEqual(aPK2); +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyMapHasher.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyMapHasher.hxx new file mode 100644 index 000000000..29e4b2d38 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyMapHasher.hxx @@ -0,0 +1,51 @@ +// 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_PassKeyMapHasher.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_PassKeyMapHasher_HeaderFile +#define _GEOMAlgo_PassKeyMapHasher_HeaderFile + +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_PassKeyMapHasher +//purpose : +//======================================================================= +class GEOMAlgo_PassKeyMapHasher { + public: + Standard_EXPORT + static Standard_Integer HashCode(const GEOMAlgo_PassKey& aPKey, + const Standard_Integer Upper) ; + + Standard_EXPORT + static Standard_Boolean IsEqual(const GEOMAlgo_PassKey& aPKey1, + const GEOMAlgo_PassKey& aPKey2) ; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShape.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShape.cxx new file mode 100644 index 000000000..107660912 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShape.cxx @@ -0,0 +1,229 @@ +// 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_PassKeyShape.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +#include +#include + + +static + Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv); +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_PassKeyShape::GEOMAlgo_PassKeyShape() +{ + myUpper=432123; +} +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_PassKeyShape::GEOMAlgo_PassKeyShape(const GEOMAlgo_PassKeyShape& aOther) +{ + myUpper=432123; + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; +} +//======================================================================= +//function :~ +//purpose : +//======================================================================= + GEOMAlgo_PassKeyShape::~GEOMAlgo_PassKeyShape() +{ +} +//======================================================================= +//function :Assign +//purpose : +//======================================================================= + GEOMAlgo_PassKeyShape& GEOMAlgo_PassKeyShape::Assign(const GEOMAlgo_PassKeyShape& aOther) +{ + myUpper=432123; + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; + return *this; +} +//======================================================================= +//function :Clear +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::Clear() +{ + myNbIds=0; + mySum=0; + myMap.Clear(); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1) + +{ + Standard_Integer aHC; + // + Clear(); + myNbIds=1; + myMap.Add(aS1); + aHC=aS1.HashCode(myUpper); + mySum=NormalizedId(aHC, myNbIds); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) +{ + TopTools_ListOfShape aLS; + // + aLS.Append(aS1); + aLS.Append(aS2); + SetShapes(aLS); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3) +{ + TopTools_ListOfShape aLS; + // + aLS.Append(aS1); + aLS.Append(aS2); + aLS.Append(aS3); + SetShapes(aLS); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3, + const TopoDS_Shape& aS4) +{ + TopTools_ListOfShape aLS; + // + aLS.Append(aS1); + aLS.Append(aS2); + aLS.Append(aS3); + aLS.Append(aS4); + SetShapes(aLS); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::SetShapes(const TopTools_ListOfShape& aLS) +{ + Standard_Integer i, aId, aIdN; + TopTools_ListIteratorOfListOfShape aIt; + // + Clear(); + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + myMap.Add(aS); + } + myNbIds=myMap.Extent(); + for(i=1; i<=myNbIds; ++i) { + const TopoDS_Shape& aS=myMap(i); + aId=aS.HashCode(myUpper); + aIdN=NormalizedId(aId, myNbIds); + mySum+=aIdN; + } +} +//======================================================================= +//function :NbIds +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKeyShape::NbIds()const +{ + return myNbIds; +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_PassKeyShape::IsEqual(const GEOMAlgo_PassKeyShape& aOther) const +{ + Standard_Boolean bRet; + Standard_Integer i; + // + bRet=Standard_False; + // + if (myNbIds!=aOther.myNbIds) { + return bRet; + } + for (i=1; i<=myNbIds; ++i) { + const TopoDS_Shape& aS=myMap(i); + if (!aOther.myMap.Contains(aS)) { + return bRet; + } + } + return !bRet; +} +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKeyShape::HashCode(const Standard_Integer aUpper) const +{ + return ::HashCode(mySum, aUpper); +} +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::Dump(const Standard_Integer)const +{ +} +//======================================================================= +// function: NormalizedId +// purpose : +//======================================================================= +Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv) +{ + Standard_Integer aMax, aTresh, aIdRet; + // + aIdRet=aId; + aMax=::IntegerLast(); + aTresh=aMax/aDiv; + if (aId>aTresh) { + aIdRet=aId%aTresh; + } + return aIdRet; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShape.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShape.hxx new file mode 100644 index 000000000..b74bb02b7 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShape.hxx @@ -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 +// + +// File: GEOMAlgo_PassKeyShape.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_PassKeyShape_HeaderFile +#define _GEOMAlgo_PassKeyShape_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//class : GEOMAlgo_PassKeyShape +//purpose : +//======================================================================= +class GEOMAlgo_PassKeyShape { + public: + Standard_EXPORT + GEOMAlgo_PassKeyShape(); + + Standard_EXPORT + virtual ~GEOMAlgo_PassKeyShape(); + + Standard_EXPORT + GEOMAlgo_PassKeyShape(const GEOMAlgo_PassKeyShape& Other); + + Standard_EXPORT + GEOMAlgo_PassKeyShape& Assign(const GEOMAlgo_PassKeyShape& Other) ; + + GEOMAlgo_PassKeyShape& operator =(const GEOMAlgo_PassKeyShape& Other) { + return Assign(Other); + } + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) ; + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3) ; + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3, + const TopoDS_Shape& aS4) ; + + Standard_EXPORT + void SetShapes(const TopTools_ListOfShape& aLS) ; + + Standard_EXPORT + void Clear() ; + + Standard_EXPORT + Standard_Integer NbIds() const; + + Standard_EXPORT + Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aOther) const; + + Standard_EXPORT + Standard_Integer HashCode(const Standard_Integer Upper) const; + + Standard_EXPORT + void Dump(const Standard_Integer aHex = 0) const; + +protected: + Standard_Integer myNbIds; + Standard_Integer mySum; + Standard_Integer myUpper; + TopTools_IndexedMapOfShape myMap; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShapeMapHasher.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShapeMapHasher.cxx new file mode 100644 index 000000000..2c534d892 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShapeMapHasher.cxx @@ -0,0 +1,47 @@ +// 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_PassKeyMapHasher.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKeyShapeMapHasher::HashCode(const GEOMAlgo_PassKeyShape& aPK, + const Standard_Integer Upper) +{ + return aPK.HashCode(Upper); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_PassKeyShapeMapHasher::IsEqual(const GEOMAlgo_PassKeyShape& aPK1, + const GEOMAlgo_PassKeyShape& aPK2) +{ + return aPK1.IsEqual(aPK2); +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShapeMapHasher.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShapeMapHasher.hxx new file mode 100644 index 000000000..018f5f979 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_PassKeyShapeMapHasher.hxx @@ -0,0 +1,52 @@ +// 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_PassKeyMapHasher.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_PassKeyShapeMapHasher_HeaderFile +#define _GEOMAlgo_PassKeyShapeMapHasher_HeaderFile + +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_PassKeyShapeMapHasher +//purpose : +//======================================================================= +class GEOMAlgo_PassKeyShapeMapHasher +{ + public: + Standard_EXPORT + static Standard_Integer HashCode(const GEOMAlgo_PassKeyShape& aPKey, + const Standard_Integer Upper) ; + + Standard_EXPORT + static Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aPKey1, + const GEOMAlgo_PassKeyShape& aPKey2) ; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeAlgo.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeAlgo.cxx new file mode 100644 index 000000000..4e906bffc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeAlgo.cxx @@ -0,0 +1,114 @@ +// 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_ShapeAlgo.cxx +// Created: Tue Dec 7 12:06:54 2004 +// Author: Peter KURNEV +// +// +#include +#include + +//======================================================================= +//function : GEOMAlgo_ShapeAlgo +//purpose : +//======================================================================= +GEOMAlgo_ShapeAlgo::GEOMAlgo_ShapeAlgo() +: + GEOMAlgo_Algo() +{ + myTolerance=0.0001; +} + +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_ShapeAlgo::~GEOMAlgo_ShapeAlgo() +{ +} +//======================================================================= +//function : SetContext +//purpose : +//======================================================================= +void GEOMAlgo_ShapeAlgo::SetContext(const Handle(IntTools_Context)& theContext) +{ + myContext=theContext; +} +//======================================================================= +//function : Context +//purpose : +//======================================================================= +const Handle(IntTools_Context)& GEOMAlgo_ShapeAlgo::Context()const +{ + return myContext; +} +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= +void GEOMAlgo_ShapeAlgo::SetShape(const TopoDS_Shape& aS) +{ + myShape=aS; +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= +const TopoDS_Shape& GEOMAlgo_ShapeAlgo::Shape()const +{ + return myShape; +} +//======================================================================= +//function : SetTolerance +//purpose : +//======================================================================= +void GEOMAlgo_ShapeAlgo::SetTolerance(const Standard_Real aT) +{ + myTolerance=aT; +} +//======================================================================= +//function : Tolerance +//purpose : +//======================================================================= +Standard_Real GEOMAlgo_ShapeAlgo::Tolerance()const +{ + return myTolerance; +} +//======================================================================= +//function : Result +//purpose : +//======================================================================= +const TopoDS_Shape& GEOMAlgo_ShapeAlgo::Result()const +{ + return myResult; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= +void GEOMAlgo_ShapeAlgo::Perform() +{ + if (myContext.IsNull()) { + myContext=new IntTools_Context; + } +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeAlgo.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeAlgo.hxx new file mode 100644 index 000000000..f1e2be117 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeAlgo.hxx @@ -0,0 +1,85 @@ +// 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_ShapeAlgo.hxx +// Created: Tue Dec 7 12:06:54 2004 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_ShapeAlgo_HeaderFile +#define _GEOMAlgo_ShapeAlgo_HeaderFile + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_ShapeAlgo +//purpose : +//======================================================================= +class GEOMAlgo_ShapeAlgo : public GEOMAlgo_Algo +{ + public: + + //! Sets cashed geometrical tools
+ Standard_EXPORT + void SetContext(const Handle(IntTools_Context)& theContext) ; + + //! Returns cashed geometrical tools
+ Standard_EXPORT + const Handle_IntTools_Context& Context() const; + + Standard_EXPORT + void SetShape(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void SetTolerance(const Standard_Real aT) ; + + Standard_EXPORT + const TopoDS_Shape& Shape() const; + + Standard_EXPORT + Standard_Real Tolerance() const; + + Standard_EXPORT + const TopoDS_Shape& Result() const; + + Standard_EXPORT + virtual void Perform() ; + +protected: + Standard_EXPORT + GEOMAlgo_ShapeAlgo(); + + Standard_EXPORT + virtual ~GEOMAlgo_ShapeAlgo(); + + + TopoDS_Shape myShape; + Standard_Real myTolerance; + TopoDS_Shape myResult; + Handle_IntTools_Context myContext; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfo.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfo.cxx new file mode 100644 index 000000000..91f490e70 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfo.cxx @@ -0,0 +1,890 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 + + +static + Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType); +static + void DumpKindOfShape(const GEOMAlgo_KindOfShape aKS); +static + void DumpKindOfClosed(const GEOMAlgo_KindOfClosed aKC); +static + void DumpKindOfBounds(const GEOMAlgo_KindOfBounds aKB); +static + void DumpKindOfName(const GEOMAlgo_KindOfName aKS); +static + void DumpPosition(const gp_Ax3& aAx3); +static + void DumpLocation(const gp_Pnt& aP); +static + void DumpDirection(const gp_Dir& aD); +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_ShapeInfo::GEOMAlgo_ShapeInfo() +{ + Reset(); +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_ShapeInfo::~GEOMAlgo_ShapeInfo() +{ +} +//======================================================================= +//function : Reset +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfo::Reset() +{ + Standard_Integer i; + // + myType=TopAbs_SHAPE; + // + myNbTypes=9; + for (i=0; i=0 && iN=0 && iN +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +//======================================================================= +//class : GEOMAlgo_ShapeInfo +//purpose : +//======================================================================= +class GEOMAlgo_ShapeInfo +{ + public: + Standard_EXPORT + GEOMAlgo_ShapeInfo(); + + Standard_EXPORT + virtual ~GEOMAlgo_ShapeInfo(); + + Standard_EXPORT + void Reset() ; + + Standard_EXPORT + void SetType(const TopAbs_ShapeEnum aType) ; + + Standard_EXPORT + TopAbs_ShapeEnum Type() const; + + Standard_EXPORT + void SetNbSubShapes(const TopAbs_ShapeEnum aType,const Standard_Integer aNb) ; + + Standard_EXPORT + Standard_Integer NbSubShapes(const TopAbs_ShapeEnum aType) const; + + Standard_EXPORT + void SetKindOfShape(const GEOMAlgo_KindOfShape aT) ; + + Standard_EXPORT + GEOMAlgo_KindOfShape KindOfShape() const; + + Standard_EXPORT + void SetKindOfName(const GEOMAlgo_KindOfName aT) ; + + Standard_EXPORT + GEOMAlgo_KindOfName KindOfName() const; + + Standard_EXPORT + void SetKindOfBounds(const GEOMAlgo_KindOfBounds aT) ; + + Standard_EXPORT + GEOMAlgo_KindOfBounds KindOfBounds() const; + + Standard_EXPORT + void SetKindOfClosed(const GEOMAlgo_KindOfClosed aT) ; + + Standard_EXPORT + GEOMAlgo_KindOfClosed KindOfClosed() const; + + Standard_EXPORT + void SetLocation(const gp_Pnt& aP) ; + + Standard_EXPORT + const gp_Pnt& Location() const; + + Standard_EXPORT + void SetDirection(const gp_Dir& aD) ; + + Standard_EXPORT + const gp_Dir& Direction() const; + + Standard_EXPORT + void SetPosition(const gp_Ax2& aAx2) ; + + Standard_EXPORT + void SetPosition(const gp_Ax3& aAx3) ; + + Standard_EXPORT + const gp_Ax3& Position() const; + + Standard_EXPORT + void SetPnt1(const gp_Pnt& aP) ; + + Standard_EXPORT + const gp_Pnt& Pnt1() const; + + Standard_EXPORT + void SetPnt2(const gp_Pnt& aP) ; + + Standard_EXPORT + const gp_Pnt& Pnt2() const; + + Standard_EXPORT + void SetRadius1(const Standard_Real aR) ; + + Standard_EXPORT + Standard_Real Radius1() const; + + Standard_EXPORT + void SetRadius2(const Standard_Real aR) ; + + Standard_EXPORT + Standard_Real Radius2() const; + + Standard_EXPORT + void SetLength(const Standard_Real aL) ; + + Standard_EXPORT + Standard_Real Length() const; + + Standard_EXPORT + void SetWidth(const Standard_Real aW) ; + + Standard_EXPORT + Standard_Real Width() const; + + Standard_EXPORT + void SetHeight(const Standard_Real aH) ; + + Standard_EXPORT + Standard_Real Height() const; + + Standard_EXPORT + void Dump() const; + + protected: + Standard_EXPORT + void DumpVertex() const; + + Standard_EXPORT + void DumpEdge() const; + + Standard_EXPORT + void DumpWire() const; + + Standard_EXPORT + void DumpFace() const; + + Standard_EXPORT + void DumpShell() const; + + Standard_EXPORT + void DumpSolid() const; + + Standard_EXPORT + void DumpCompSolid() const; + + Standard_EXPORT + void DumpCompound() const; + + + TopAbs_ShapeEnum myType; + Standard_Integer myNbSubShapes[9]; + GEOMAlgo_KindOfShape myKindOfShape; + GEOMAlgo_KindOfName myKindOfName; + GEOMAlgo_KindOfBounds myKindOfBounds; + GEOMAlgo_KindOfClosed myKindOfClosed; + gp_Pnt myLocation; + gp_Dir myDirection; + gp_Ax3 myPosition; + Standard_Real myRadius1; + Standard_Real myRadius2; + Standard_Real myLength; + Standard_Real myWidth; + Standard_Real myHeight; + gp_Pnt myPnt1; + gp_Pnt myPnt2; + Standard_Integer myNbTypes; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfoFiller.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfoFiller.cxx new file mode 100644 index 000000000..ff610d962 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfoFiller.cxx @@ -0,0 +1,818 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 + +#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_Boolean IsAllowedType(const GeomAbs_CurveType aCT); +static + Standard_Boolean IsAllowedType(const GeomAbs_SurfaceType aST); +static + Standard_Integer NbWires(const TopoDS_Face& aF); +static + Standard_Integer NbShells(const TopoDS_Solid& aS); + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_ShapeInfoFiller::GEOMAlgo_ShapeInfoFiller() +: + GEOMAlgo_Algo() +{ + myTolerance=0.0001; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_ShapeInfoFiller::~GEOMAlgo_ShapeInfoFiller() +{ +} +//======================================================================= +//function : SetTolerance +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::SetTolerance(const Standard_Real aT) +{ + myTolerance=aT; +} +//======================================================================= +//function : Tolerance +//purpose : +//======================================================================= + Standard_Real GEOMAlgo_ShapeInfoFiller::Tolerance()const +{ + return myTolerance; +} +//======================================================================= +//function : SetShape +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::SetShape(const TopoDS_Shape& aS) +{ + myShape=aS; +} +//======================================================================= +//function : Shape +//purpose : +//======================================================================= + const TopoDS_Shape& GEOMAlgo_ShapeInfoFiller::Shape() const +{ + return myShape; +} +//======================================================================= +//function : Info +//purpose : +//======================================================================= + const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info() const +{ + return Info(myShape); +} +//======================================================================= +//function : Info +//purpose : +//======================================================================= + const GEOMAlgo_ShapeInfo& GEOMAlgo_ShapeInfoFiller::Info(const TopoDS_Shape& aS) const +{ + if (!aS.IsNull()) { + if (myMapInfo.Contains(aS)) { + const GEOMAlgo_ShapeInfo& aInfo=myMapInfo.FindFromKey(aS); + return aInfo; + } + } + return myEmptyInfo; +} + +//======================================================================= +//function : CheckData +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::CheckData() +{ + myErrorStatus=0; + // + if (myShape.IsNull()) { + myErrorStatus=10; + return; + } +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::Perform() +{ + myErrorStatus=0; + // + myMapInfo.Clear(); + // + CheckData(); + if (myErrorStatus) { + return; + } + // + FillShape(myShape); +} +//======================================================================= +//function :FillShape +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillShape(const TopoDS_Shape& aS) +{ + TopAbs_ShapeEnum aType; + // + aType=aS.ShapeType(); + switch(aType) { + // + case TopAbs_VERTEX: + FillVertex(aS); + break; + // + case TopAbs_EDGE: + FillEdge(aS); + break; + // + case TopAbs_FACE: + FillFace(aS); + break; + // + case TopAbs_SOLID: + FillSolid(aS); + break; + // + case TopAbs_WIRE: + case TopAbs_SHELL: + case TopAbs_COMPSOLID: + case TopAbs_COMPOUND: + FillContainer(aS); + break; + // + default: + break; + } +} +//======================================================================= +//function :FillSubShapes +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillSubShapes(const TopoDS_Shape& aS) +{ + TopoDS_Iterator aIt; + // + aIt.Initialize(aS); + for (; aIt.More(); aIt.Next()){ + const TopoDS_Shape& aSx=aIt.Value(); + FillShape(aSx); + } +} +//======================================================================= +//function : FillContainer +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillContainer(const TopoDS_Shape& aS) +{ + myErrorStatus=0; + // + Standard_Boolean bIsClosed; + TopAbs_ShapeEnum aType; + GEOMAlgo_KindOfClosed aKC; + // + aType=aS.ShapeType(); + //---------------------------------------------------- + if (myMapInfo.Contains(aS)) { + return; + } + else { + GEOMAlgo_ShapeInfo aInfoX; + myMapInfo.Add(aS, aInfoX); + } + GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS); + //---------------------------------------------------- + aInfo.SetType(aType); + FillNbSubShapes(aS, aInfo); + // + if (aType==TopAbs_SHELL) { + bIsClosed=BRep_Tool::IsClosed(aS); + aKC=(bIsClosed) ? GEOMAlgo_KC_CLOSED :GEOMAlgo_KC_NOTCLOSED; + aInfo.SetKindOfClosed(aKC); + } + else if (aType==TopAbs_WIRE) { + TopoDS_Wire aW; + TopoDS_Vertex aV1, aV2; + // + aW=TopoDS::Wire(aS); + TopExp::Vertices(aW, aV1, aV2); + // + bIsClosed=aV1.IsSame(aV2); + aKC=(bIsClosed) ? GEOMAlgo_KC_CLOSED :GEOMAlgo_KC_NOTCLOSED; + aInfo.SetKindOfClosed(aKC); + } + // + FillSubShapes(aS); +} +//======================================================================= +//function : FillSolid +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillSolid(const TopoDS_Shape& aS) +{ + Standard_Integer aNbShells; + TopoDS_Solid aSd; + // + myErrorStatus=0; + //---------------------------------------------------- + if (myMapInfo.Contains(aS)) { + return; + } + else { + GEOMAlgo_ShapeInfo aInfoX; + myMapInfo.Add(aS, aInfoX); + } + GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS); + //---------------------------------------------------- + aInfo.SetType(TopAbs_SOLID); + FillNbSubShapes(aS, aInfo); + FillSubShapes(aS); + // + aSd=TopoDS::Solid(aS); + // + aNbShells=NbShells(aSd); + if (aNbShells>1) { + return; + } + // + FillDetails(aSd); +} +//======================================================================= +//function :FillFace +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillFace(const TopoDS_Shape& aS) +{ + myErrorStatus=0; + // + Standard_Boolean bIsAllowedType; + Standard_Integer aNbWires;//, iRet + Standard_Boolean bInf, bInfU1, bInfU2, bInfV1, bInfV2; + Standard_Real aUMin, aUMax, aVMin, aVMax, aR1, aR2; + gp_Pnt aP0; + gp_Dir aDN; + gp_Ax3 aAx3; + GeomAbs_SurfaceType aST; + Handle(Geom_Surface) aSurf; + TopoDS_Face aF; + //GEOMAlgo_KindOfName aKindOfName; + //---------------------------------------------------- + if (myMapInfo.Contains(aS)) { + return; + } + else { + GEOMAlgo_ShapeInfo aInfoX; + myMapInfo.Add(aS, aInfoX); + } + GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS); + //---------------------------------------------------- + aInfo.SetType(TopAbs_FACE); + // + FillNbSubShapes(aS, aInfo); + // + FillSubShapes(aS); + // + aF=TopoDS::Face(aS); + // + aNbWires=NbWires(aF); + // + aSurf=BRep_Tool::Surface(aF); + GeomAdaptor_Surface aGAS(aSurf); + aST=aGAS.GetType(); + bIsAllowedType=IsAllowedType(aST); + if (!bIsAllowedType) { + return; + } + // + // 1. Plane + if (aST==GeomAbs_Plane) { + gp_Pln aPln; + // + aPln=aGAS.Plane(); + aP0=aPln.Location(); + aAx3=aPln.Position(); + // + aInfo.SetKindOfShape(GEOMAlgo_KS_PLANE); + aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED); + aInfo.SetLocation(aP0); + aInfo.SetPosition(aAx3); + // + if (aNbWires>1) return; + // + //aSurf->Bounds(aUMin, aUMax, aVMin, aVMax); + BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax); + bInfU1=Precision::IsNegativeInfinite(aUMin); + bInfU2=Precision::IsPositiveInfinite(aUMax); + bInfV1=Precision::IsNegativeInfinite(aVMin); + bInfV2=Precision::IsPositiveInfinite(aVMax); + // + bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2); + if (bInf) { + aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE); + } + else { + aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED); + } + // + FillDetails(aF, aPln); + }// if (aCT==GeomAbs_Line) { + // + // 2. Sphere + else if (aST==GeomAbs_Sphere) { + gp_Sphere aSphere; + // + aSphere=aGAS.Sphere(); + aP0=aSphere.Location(); + aAx3=aSphere.Position(); + aR1=aSphere.Radius(); + // + aInfo.SetKindOfShape(GEOMAlgo_KS_SPHERE); + aInfo.SetLocation(aP0); + aInfo.SetPosition(aAx3); + aInfo.SetRadius1(aR1); + // + if (aNbWires>1) return; + // + aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED); + aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED); + // + FillDetails(aF, aSphere); + }// else if (aST==GeomAbs_Sphere) { + // + // 3. Cylinder + else if (aST==GeomAbs_Cylinder) { + gp_Cylinder aCyl; + // + aCyl=aGAS.Cylinder(); + aP0=aCyl.Location(); + aAx3=aCyl.Position(); + aR1=aCyl.Radius(); + // + aInfo.SetKindOfShape(GEOMAlgo_KS_CYLINDER); + aInfo.SetLocation(aP0); + aInfo.SetPosition(aAx3); + aInfo.SetRadius1(aR1); + // + if (aNbWires>1) return; + // + BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax); + bInfU1=Precision::IsNegativeInfinite(aUMin); + bInfU2=Precision::IsPositiveInfinite(aUMax); + bInfV1=Precision::IsNegativeInfinite(aVMin); + bInfV2=Precision::IsPositiveInfinite(aVMax); + // + bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2); + if (bInf) { + aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE); + } + else { + aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED); + } + FillDetails(aF, aCyl); + } + // + // 4. Cone + else if (aST==GeomAbs_Cone) { + gp_Cone aCone; + // + aCone=aGAS.Cone(); + aP0=aCone.Location(); + aAx3=aCone.Position(); + //aR1=aCyl.Radius(); + // + aInfo.SetKindOfShape(GEOMAlgo_KS_CONE); + aInfo.SetLocation(aP0); + aInfo.SetPosition(aAx3); + //aInfo.SetRadius1(aR1); + // + if (aNbWires>1) return; + // + BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax); + bInfU1=Precision::IsNegativeInfinite(aUMin); + bInfU2=Precision::IsPositiveInfinite(aUMax); + bInfV1=Precision::IsNegativeInfinite(aVMin); + bInfV2=Precision::IsPositiveInfinite(aVMax); + // + bInf=(bInfU1 || bInfU2 || bInfV1 || bInfV2); + if (bInf) { + aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE); + } + else { + aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED); + } + FillDetails(aF, aCone); + } + // + // 5. Torus + else if (aST==GeomAbs_Torus) { + gp_Torus aTorus; + // + aTorus=aGAS.Torus(); + aP0=aTorus.Location(); + aAx3=aTorus.Position(); + aR1=aTorus.MajorRadius(); + aR2=aTorus.MinorRadius(); + // + aInfo.SetKindOfShape(GEOMAlgo_KS_TORUS); + aInfo.SetLocation(aP0); + aInfo.SetPosition(aAx3); + aInfo.SetRadius1(aR1); + aInfo.SetRadius2(aR2); + // + if (aNbWires>1) return; + // + aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED); + // + FillDetails(aF, aTorus); + } +} +//======================================================================= +//function :FillEdge +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillEdge(const TopoDS_Shape& aS) +{ + myErrorStatus=0; + // + Standard_Boolean bDegenerated, bIsAllowedType; + Standard_Integer aNbV; + Standard_Real aR1, aR2; + gp_Pnt aP, aP1, aP2, aPc; + gp_Dir aD; + gp_Ax2 aAx2; + Standard_Real aT1, aT2; + GeomAbs_CurveType aCT; + Handle(Geom_Curve) aC3D; + TopoDS_Edge aE; + //---------------------------------------------------- + if (myMapInfo.Contains(aS)) { + return; + } + else { + GEOMAlgo_ShapeInfo aInfoX; + myMapInfo.Add(aS, aInfoX); + } + GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS); + //---------------------------------------------------- + aInfo.SetType(TopAbs_EDGE); + // + FillNbSubShapes(aS, aInfo); + // + aE=TopoDS::Edge(aS); + // + bDegenerated=BRep_Tool::Degenerated(aE); + if (bDegenerated) { + aInfo.SetKindOfShape(GEOMAlgo_KS_DEGENERATED); + FillSubShapes(aS); + return; + } + // + aC3D=BRep_Tool::Curve(aE, aT1, aT2); + GeomAdaptor_Curve aGAC(aC3D); + aCT=aGAC.GetType(); + bIsAllowedType=IsAllowedType(aCT); + if (!bIsAllowedType) { + FillSubShapes(aS); + return; + } + // Line + if (aCT==GeomAbs_Line) { + Standard_Boolean bInf1, bInf2; + Standard_Real aLength; + gp_Lin aLin; + gp_XYZ aXYZ1, aXYZ2, aXYZc; + // + aLin=aGAC.Line(); + aP=aLin.Location(); + aD=aLin.Direction(); + // + aInfo.SetKindOfShape(GEOMAlgo_KS_LINE); + aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED); + aInfo.SetLocation(aP); + aInfo.SetDirection(aD); + // + bInf1=Precision::IsNegativeInfinite(aT1); + bInf2=Precision::IsPositiveInfinite(aT2); + if (bInf1||bInf2) { + aInfo.SetKindOfBounds(GEOMAlgo_KB_INFINITE); + aInfo.SetKindOfName(GEOMAlgo_KN_LINE); + } + else { + aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED); + aInfo.SetKindOfName(GEOMAlgo_KN_SEGMENT); + aGAC.D0(aT1, aP1); + aGAC.D0(aT2, aP2); + aInfo.SetPnt1(aP1); + aInfo.SetPnt2(aP2); + // + aLength=aP1.Distance(aP2); + aXYZ1=aP1.XYZ(); + aXYZ2=aP2.XYZ(); + aXYZc=aXYZ1+aXYZ2; + aXYZc.Multiply(0.5); + // + aPc.SetXYZ(aXYZc); + gp_Vec aVec(aPc, aP2); + gp_Dir aDir(aVec); + // + aInfo.SetLocation(aPc); + aInfo.SetDirection(aDir); + aInfo.SetLength(aLength); + } + }// if (aCT==GeomAbs_Line) { + // + // Circle + else if (aCT==GeomAbs_Circle) { + gp_Circ aCirc; + // + aCirc=aGAC.Circle(); + aP=aCirc.Location(); + aAx2=aCirc.Position(); + aR1=aCirc.Radius(); + // + aInfo.SetKindOfShape(GEOMAlgo_KS_CIRCLE); + aInfo.SetLocation(aP); + aInfo.SetPosition(aAx2); + aInfo.SetRadius1(aR1); + // + aNbV=aInfo.NbSubShapes(TopAbs_VERTEX); + if (!aNbV) { + myErrorStatus=11; // circle edge without vertices + return; + } + aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED); + aGAC.D0(aT1, aP1); + aGAC.D0(aT2, aP2); + aInfo.SetPnt1(aP1); + aInfo.SetPnt2(aP2); + // + if (aNbV==1) { + aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED); + aInfo.SetKindOfName(GEOMAlgo_KN_CIRCLE); + } + else { + aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED); + aInfo.SetKindOfName(GEOMAlgo_KN_ARCCIRCLE); + // + gp_Vec aVecX(aP, aP1); + gp_Dir aDirX(aVecX); + gp_Ax2 aAx2new(aP, aAx2.Direction(), aDirX); + aInfo.SetPosition(aAx2new); + } + }// else if (aCT==GeomAbs_Circle) { + // + // Ellipse + else if (aCT==GeomAbs_Ellipse) { + gp_Elips aElips; + // + aElips=aGAC.Ellipse(); + aP=aElips.Location(); + aAx2=aElips.Position(); + aR1=aElips.MajorRadius(); + aR2=aElips.MinorRadius(); + // + aInfo.SetKindOfShape(GEOMAlgo_KS_ELLIPSE); + aInfo.SetLocation(aP); + aInfo.SetPosition(aAx2); + aInfo.SetRadius1(aR1); + aInfo.SetRadius2(aR2); + // + aNbV=aInfo.NbSubShapes(TopAbs_VERTEX); + if (!aNbV) { + myErrorStatus=11; // ellipse edge without vertices + return; + } + aInfo.SetKindOfBounds(GEOMAlgo_KB_TRIMMED); + aGAC.D0(aT1, aP1); + aGAC.D0(aT2, aP2); + aInfo.SetPnt1(aP1); + aInfo.SetPnt2(aP2); + // + if (aNbV==1) { + aInfo.SetKindOfClosed(GEOMAlgo_KC_CLOSED); + aInfo.SetKindOfName(GEOMAlgo_KN_ELLIPSE); + } + else { + aInfo.SetKindOfClosed(GEOMAlgo_KC_NOTCLOSED); + aInfo.SetKindOfName(GEOMAlgo_KN_ARCELLIPSE); + // + gp_Vec aVecX(aP, aP1); + gp_Dir aDirX(aVecX); + gp_Ax2 aAx2new(aP, aAx2.Direction(), aDirX); + aInfo.SetPosition(aAx2new); + } + }// else if (aCT==GeomAbs_Ellipse) { + // + FillSubShapes(aS); +} +//======================================================================= +//function :FillVertex +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillVertex(const TopoDS_Shape& aS) +{ + myErrorStatus=0; + // + gp_Pnt aP; + TopoDS_Vertex aV; + // + if (myMapInfo.Contains(aS)) { + return; + } + else { + GEOMAlgo_ShapeInfo aInfoX; + myMapInfo.Add(aS, aInfoX); + } + GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aS); + // + aV=TopoDS::Vertex(aS); + aP=BRep_Tool::Pnt(aV); + // + aInfo.SetType(TopAbs_VERTEX); + aInfo.SetLocation(aP); + myMapInfo.Add(aS, aInfo); +} +//======================================================================= +//function : FillNbSubshapes +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillNbSubShapes(const TopoDS_Shape& aS, + GEOMAlgo_ShapeInfo& aInfo) +{ + myErrorStatus=0; + // + Standard_Integer i, aNb, aNbS; + TopTools_IndexedMapOfShape aM; + TopAbs_ShapeEnum aST; + TopAbs_ShapeEnum aTypes[]= { + //TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX + TopAbs_COMPOUND, + TopAbs_COMPSOLID, + TopAbs_SOLID, + TopAbs_SHELL, + TopAbs_FACE, + TopAbs_WIRE, + TopAbs_EDGE, + TopAbs_VERTEX + }; + + // + aST=aS.ShapeType(); + aNb=sizeof(aTypes)/sizeof(aTypes[0]); + for (i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_ShapeInfoFiller +//purpose : +//======================================================================= +class GEOMAlgo_ShapeInfoFiller : public GEOMAlgo_Algo +{ + public: + Standard_EXPORT + GEOMAlgo_ShapeInfoFiller(); + + Standard_EXPORT + virtual ~GEOMAlgo_ShapeInfoFiller(); + + Standard_EXPORT + void SetShape(const TopoDS_Shape& aS) ; + + Standard_EXPORT + const TopoDS_Shape& Shape() const; + + Standard_EXPORT + void SetTolerance(const Standard_Real aT) ; + + Standard_EXPORT + Standard_Real Tolerance() const; + + Standard_EXPORT + const GEOMAlgo_ShapeInfo& Info() const; + + Standard_EXPORT + const GEOMAlgo_ShapeInfo& Info(const TopoDS_Shape& aS) const; + + Standard_EXPORT + virtual void Perform() ; + + protected: + Standard_EXPORT + virtual void CheckData() ; + + Standard_EXPORT + void FillNbSubShapes(const TopoDS_Shape& aS,GEOMAlgo_ShapeInfo& aInfo) ; + + Standard_EXPORT + void FillSubShapes(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void FillShape(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void FillVertex(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void FillEdge(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void FillFace(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void FillSolid(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void FillContainer(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void FillDetails(const TopoDS_Face& aF,const gp_Pln& aPln) ; + + Standard_EXPORT + void FillDetails(const TopoDS_Face& aF,const gp_Sphere& aSph) ; + + Standard_EXPORT + void FillDetails(const TopoDS_Face& aF,const gp_Cylinder& aCyl) ; + + Standard_EXPORT + void FillDetails(const TopoDS_Face& aF,const gp_Cone& aCone) ; + + Standard_EXPORT + void FillDetails(const TopoDS_Face& aF,const gp_Torus& aTorus) ; + + Standard_EXPORT + void FillDetails(const TopoDS_Solid& aS) ; + + + TopoDS_Shape myShape; + GEOMAlgo_ShapeInfo myEmptyInfo; + GEOMAlgo_IndexedDataMapOfShapeShapeInfo myMapInfo; + Standard_Real myTolerance; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfoFiller_1.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfoFiller_1.cxx new file mode 100644 index 000000000..a77a09718 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeInfoFiller_1.cxx @@ -0,0 +1,761 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : FillDetails +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Solid& aSd) +{ + Standard_Integer i, aNbF, aNbCyl, aNbCon, aNbPgn, aNbRct, aNbCrc, aNbX; + TopoDS_Shape aFCyl, aFCon; + TopTools_IndexedMapOfShape aMF; + GEOMAlgo_KindOfName aKNF; + // + GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aSd); + aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN); + // + TopExp::MapShapes(aSd, TopAbs_FACE, aMF); + // + aNbF=aMF.Extent(); + if (!aNbF) { + return; + } + // + if (aNbF==1) { + const TopoDS_Shape& aF=aMF(1); + GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aF); + aKNF=aInfoF.KindOfName(); // mb: sphere, torus + if (aKNF==GEOMAlgo_KN_SPHERE || + aKNF==GEOMAlgo_KN_TORUS) { + aInfo.SetKindOfName(aKNF); + aInfo.SetLocation(aInfoF.Location()); + aInfo.SetPosition(aInfoF.Position()); + aInfo.SetRadius1(aInfoF.Radius1()); + if(aKNF==GEOMAlgo_KN_TORUS) { + aInfo.SetRadius2(aInfoF.Radius2()); + } + return; + } + } + // + aNbCyl=0; + aNbCon=0; + aNbPgn=0; + aNbRct=0; + aNbCrc=0; + for (i=1; i<=aNbF; ++i) { + const TopoDS_Shape& aF=aMF(i); + GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aF); + aKNF=aInfoF.KindOfName(); + if (aKNF==GEOMAlgo_KN_CYLINDER) { + aFCyl=aF; + ++aNbCyl; + } + else if (aKNF==GEOMAlgo_KN_CONE) { + aFCon=aF; + ++aNbCon; + } + else if (aKNF==GEOMAlgo_KN_DISKCIRCLE) { + ++aNbCrc; + } + else if (aKNF==GEOMAlgo_KN_POLYGON || + aKNF==GEOMAlgo_KN_TRIANGLE || + aKNF==GEOMAlgo_KN_QUADRANGLE) { + ++aNbPgn; + } + else if (aKNF==GEOMAlgo_KN_RECTANGLE) { + ++aNbPgn; + ++aNbRct; + } + } + // + aNbX=aNbCyl+aNbCrc; + if (aNbCyl==1 && aNbCrc==2 && aNbX==aNbF) { + // cylinder (as they understand it) + GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aFCyl); + aKNF=aInfoF.KindOfName(); + aInfo.SetKindOfName(aKNF); + aInfo.SetLocation(aInfoF.Location()); + aInfo.SetPosition(aInfoF.Position()); + aInfo.SetRadius1(aInfoF.Radius1()); + aInfo.SetHeight(aInfoF.Height()); + return; + } + // + aNbX=aNbCon+aNbCrc; + if (aNbCon==1 && (aNbCrc==1 || aNbCrc==2) && aNbX==aNbF) { + // cone + GEOMAlgo_ShapeInfo& aInfoF=myMapInfo.ChangeFromKey(aFCon); + aKNF=aInfoF.KindOfName(); + aInfo.SetKindOfName(aKNF); + aInfo.SetLocation(aInfoF.Location()); + aInfo.SetPosition(aInfoF.Position()); + aInfo.SetRadius1(aInfoF.Radius1()); + aInfo.SetRadius2(aInfoF.Radius2()); + aInfo.SetHeight(aInfoF.Height()); + return; + } + // + //modified by NIZNHY-PKV Wed Jan 11 11:04:31 2012f + if (aNbF!=aNbPgn) { + return;// -> GEOMAlgo_KN_UNKNOWN + } + //modified by NIZNHY-PKV Wed Jan 11 11:04:37 2012t + if (aNbPgn!=6) { + aInfo.SetKindOfName(GEOMAlgo_KN_POLYHEDRON); + return; + } + // aNbPgn==6 + if (aNbPgn!=aNbRct) { + aInfo.SetKindOfName(GEOMAlgo_KN_POLYHEDRON); + return; + } + //=================================================== + // aNbRct=6; + // box + Standard_Integer j, aNbFi, aNbV, iMax, iMin, iMid; + Standard_Real aDot, aLength, aWidth, aHeight, aDist[3]; + Standard_Real aDistMin, aDistMax; + gp_Pnt aPi, aPc; + gp_Dir aDir[3]; + gp_XYZ aXYZc; + TColStd_IndexedMapOfInteger aMp; + TopTools_IndexedMapOfShape aMV, aMFi; + // + // barycenter aPc + TopExp::MapShapes(aSd, TopAbs_VERTEX, aMV); + aNbV=aMV.Extent(); + if (aNbV!=8) { + return; + } + // + aXYZc.SetCoord(0.,0.,0.); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Vertex& aVi=TopoDS::Vertex(aMV(i)); + aPi=BRep_Tool::Pnt(aVi); + const gp_XYZ& aXYZ=aPi.XYZ(); + aXYZc=aXYZc+aXYZ; + } + // + aXYZc.Divide(aNbV); + aPc.SetXYZ(aXYZc); + // + // 3 faces + for (i=1; i<=aNbF; ++i) { + if (aMp.Contains(i)) { + continue; + } + // + const TopoDS_Shape& aFi=aMF(i); + const GEOMAlgo_ShapeInfo& aIFi=myMapInfo.FindFromKey(aFi); + const gp_Dir& aDNi=aIFi.Position().Direction(); + // + for (j=i+1; j<=aNbF; ++j) { + if (aMp.Contains(j)) { + continue; + } + // + const TopoDS_Shape& aFj=aMF(j); + const GEOMAlgo_ShapeInfo& aIFj=myMapInfo.FindFromKey(aFj); + const gp_Dir& aDNj=aIFj.Position().Direction(); + // + aDot=aDNi*aDNj; + if (fabs(1.-aDot)<0.0001) { + aMp.Add(i); + aMp.Add(j); + aMFi.Add(aFi); + break; + } + // + } + } + aNbFi=aMFi.Extent(); + if (aNbFi!=3) { + return; + } + // + aDistMin=1.e15; + aDistMax=-aDistMin; + for (i=0; iaDistMax) { + aDistMax=aDist[i]; + iMax=i; + } + if (aDist[i] myTolerance) { + aInfo.SetKindOfName(GEOMAlgo_KN_QUADRANGLE); + return; + } + } + // + // rectangle + aInfo.SetKindOfName(GEOMAlgo_KN_RECTANGLE); + // + // shift location to the center and calc. sizes + aXYZc.SetCoord(0.,0.,0.); + TopExp::MapShapes(aF, TopAbs_VERTEX, aMV); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aMV(i)); + aP=BRep_Tool::Pnt(aV); + const gp_XYZ& aXYZ=aP.XYZ(); + aXYZc=aXYZc+aXYZ; + } + // + // Location : aPc in center of rectangle + // Position : 0z is plane normal + // 0x is along length + // + aXYZc.Divide(4.); + aPc.SetXYZ(aXYZc); + // + gp_Lin aL0(aPx[0], aDx[0]); + gp_Lin aL1(aPx[1], aDx[1]); + // + aD0=aL0.Distance(aPc); + aD1=aL1.Distance(aPc); + // + aLength=aD0; + aWidth =aD1; + aDX=aL1.Direction(); + if (aD0aR[1]) { + aRmin=aR[1]; + aRmax=aR[0]; + aPc=aPC[0]; + gp_Vec aVz(aPC[0], aPC[1]); + gp_Vec aVx(aPC[0], aPX[0]); + gp_Dir aDz(aVz); + gp_Dir aDx(aVx); + gp_Ax2 aAx2(aPc, aDz, aDx); + aAx2new=aAx2; + } + else { + aRmin=aR[0]; + aRmax=aR[1]; + aPc=aPC[1]; + gp_Vec aVz(aPC[1], aPC[0]); + gp_Vec aVx(aPC[1], aPX[1]); + gp_Dir aDz(aVz); + gp_Dir aDx(aVx); + gp_Ax2 aAx2(aPc, aDz, aDx); + aAx2new=aAx2; + } + // + gp_Ax3 aAx3(aAx2new); + aInfo.SetLocation(aPc); + aInfo.SetPosition(aAx3); + aInfo.SetRadius1(aRmax); + aInfo.SetRadius2(aRmin); + aInfo.SetHeight(aHeight); + // + aInfo.SetKindOfName(GEOMAlgo_KN_CONE); +} +//======================================================================= +//function : FillDetails +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF, + const gp_Cylinder& aCyl) +{ + Standard_Integer i, aNbV, aNbE, aNbCE, aNbSE; + Standard_Real aT0, aT1, aHeight; + gp_Pnt aPC[3], aPc; + TopoDS_Edge aE; + TopExp_Explorer aExp; + TopTools_MapOfShape aM; + GEOMAlgo_KindOfShape aKS; + GEOMAlgo_KindOfName aKN, aKNE; + GEOMAlgo_KindOfClosed aKCE; + // + GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF); + aKN=GEOMAlgo_KN_UNKNOWN; + aInfo.SetKindOfName(aKN); + // + aKS=aInfo.KindOfShape(); + if (aKS!=GEOMAlgo_KS_CYLINDER) { + return; + } + // + if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) { + return; + } + // + aNbV=aInfo.NbSubShapes(TopAbs_VERTEX); + aNbE=aInfo.NbSubShapes(TopAbs_EDGE); + if (!(aNbV==2 && aNbE==3)) { + return; + } + // + i=0; + aNbCE=0; + aNbSE=0; + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + aE=TopoDS::Edge(aExp.Current()); + if(aM.Add(aE)) { + const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE); + aKNE=aInfoE.KindOfName(); + aKCE=aInfoE.KindOfClosed(); + if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) { + aPC[aNbCE]=aInfoE.Location(); + ++aNbCE; + } + else if (aKNE==GEOMAlgo_KN_SEGMENT) { + if (BRep_Tool::IsClosed(aE, aF)) { + ++aNbSE; + } + } + } + } + // + if (!(aNbCE==2 && aNbSE==1)) { + return; + } + // + const gp_Ax1& aAx1=aCyl.Axis(); + const gp_Dir& aDir=aAx1.Direction(); + const gp_Pnt& aPLoc=aAx1.Location(); + gp_Lin aLin(aPLoc, aDir); + // + aT0=ElCLib::Parameter(aLin, aPC[0]); + aT1=ElCLib::Parameter(aLin, aPC[1]); + // + aPc=aPC[0];; + if (aT0>aT1) { + aPc=aPC[1]; + } + aHeight=aPC[0].Distance(aPC[1]); + // + gp_Ax3 aAx3=aCyl.Position(); + aAx3.SetLocation(aPc); + // + aInfo.SetKindOfName(GEOMAlgo_KN_CYLINDER); + aInfo.SetPosition(aAx3); + aInfo.SetLocation(aPc); + aInfo.SetHeight(aHeight); +} + +//======================================================================= +//function : FillDetails +//purpose : +//======================================================================= + void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF, + const gp_Torus& ) +{ + Standard_Integer aNbV, aNbE, aNbSE; + TopoDS_Edge aE; + TopExp_Explorer aExp; + TopTools_MapOfShape aM; + GEOMAlgo_KindOfShape aKS; + // + GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF); + aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN); + // + aKS=aInfo.KindOfShape(); + if (aKS!=GEOMAlgo_KS_TORUS) { + return; + } + // + aNbV=aInfo.NbSubShapes(TopAbs_VERTEX); + aNbE=aInfo.NbSubShapes(TopAbs_EDGE); + if (!(aNbV==1 && aNbE==2)) { + return; + } + // + aNbSE=0; + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + aE=TopoDS::Edge(aExp.Current()); + if (aM.Add(aE)) { + //const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE); + if (BRep_Tool::IsClosed(aE, aF)) { + ++aNbSE; + } + } + } + // + if (aNbSE!=2) { + return; + } + aInfo.SetKindOfName(GEOMAlgo_KN_TORUS); +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSet.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSet.cxx new file mode 100644 index 000000000..764c19e4a --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSet.cxx @@ -0,0 +1,177 @@ +// 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_ShapeSet.cxx +// Created: +// Author: Peter KURNEV +// +#include + +#include + +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_ShapeSet::GEOMAlgo_ShapeSet() +{ +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void GEOMAlgo_ShapeSet::Clear() +{ + myMap.Clear(); + myList.Clear(); +} +//======================================================================= +//function : Add +//purpose : +//======================================================================= + void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape) +{ + if (myMap.Add(theShape)) { + myList.Append(theShape); + } +} +//======================================================================= +//function : Add +//purpose : +//======================================================================= + void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape, + const TopAbs_ShapeEnum theType) +{ + TopExp_Explorer aExp; + // + aExp.Init(theShape, theType); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aS=aExp.Current(); + if (myMap.Add(aS)) { + myList.Append(aS); + } + } +} +//======================================================================= +//function : Add +//purpose : +//======================================================================= + void GEOMAlgo_ShapeSet::Add(const TopTools_ListOfShape& theLS) +{ + TopTools_ListIteratorOfListOfShape aIt; + // + aIt.Initialize(theLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if (myMap.Add(aS)) { + myList.Append(aS); + } + } +} +//======================================================================= +//function :GetSet +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_ShapeSet::GetSet()const +{ + return myList; +} +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_ShapeSet::Contains(const GEOMAlgo_ShapeSet& theOther)const +{ + Standard_Boolean bRet; + TopAbs_Orientation aOr; + TopTools_ListIteratorOfListOfShape aIt; + // + bRet=Standard_True; + const TopTools_ListOfShape& aLS=theOther.GetSet(); + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aOr=aF.Orientation(); + if (aOr==TopAbs_FORWARD || aOr==TopAbs_REVERSED) { + bRet=myMap.Contains(aF); + if (!bRet) { + break; + } + } + } + return bRet; +} +//======================================================================= +//function : Subtract +//purpose : +//======================================================================= + void GEOMAlgo_ShapeSet::Subtract(const GEOMAlgo_ShapeSet& theOther) +{ + TopTools_ListIteratorOfListOfShape aIt; + TopTools_ListOfShape aLS; + // + myMap.Clear(); + aIt.Initialize(myList); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if (!theOther.myMap.Contains(aS)) { + if(myMap.Add(aS)){ + aLS.Append(aS); + } + } + } + // + myList=aLS; +} +//modified by NIZNHY-PKV Wed Oct 28 13:51:36 2010f +//======================================================================= +//function : IsEqual +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_ShapeSet::IsEqual(const GEOMAlgo_ShapeSet& theOther)const +{ + Standard_Boolean bRet; + Standard_Integer aNb1, aNb2; + TopTools_ListIteratorOfListOfShape aIt; + // + bRet=Standard_True; + aNb1=myList.Extent(); + const TopTools_ListOfShape& aLS2=theOther.GetSet(); + aNb2=aLS2.Extent(); + if (aNb1!=aNb2) { + return !bRet; + } + // + aIt.Initialize(myList); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if(!theOther.myMap.Contains(aS)) { + bRet=!bRet; + break; + } + } + return bRet; +} +//modified by NIZNHY-PKV Wed Oct 28 13:51:38 2010t diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSet.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSet.hxx new file mode 100644 index 000000000..4d031d111 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSet.hxx @@ -0,0 +1,92 @@ +// 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_ShapeSet.hxx +// Created: +// Author: Peter KURNEV +// +#ifndef _GEOMAlgo_ShapeSet_HeaderFile +#define _GEOMAlgo_ShapeSet_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + +//! Implementation some formal
+//! opereations with Set of shapes
+//======================================================================= +//class : GEOMAlgo_ShapeSet +//purpose : +//======================================================================= +class GEOMAlgo_ShapeSet +{ + public: + //! Empty constructor
+ Standard_EXPORT + GEOMAlgo_ShapeSet(); + + //! Adds shapes from the list theLS to the Set
+ Standard_EXPORT + void Add(const TopTools_ListOfShape& theLS) ; + + //! Adds shape theShape to the Set
+ Standard_EXPORT + void Add(const TopoDS_Shape& theShape) ; + + //! Adds sub-shapes of shape theShape,
+ //! that have type theType to the Set
+ Standard_EXPORT + void Add(const TopoDS_Shape& theShape,const TopAbs_ShapeEnum theType) ; + + //! Removes shapes of theSet from the Set
+ Standard_EXPORT + void Subtract(const GEOMAlgo_ShapeSet& theSet) ; + + //! Clears internal fields
+ Standard_EXPORT void Clear() ; + + //! Returns True if the Set contains
+ //! all shapes of theSet
+ Standard_EXPORT + Standard_Boolean Contains(const GEOMAlgo_ShapeSet& theSet) const; + + //! Returns the Set
+ Standard_EXPORT + const TopTools_ListOfShape& GetSet() const; + + //! Returns True if the Set==theSet
+ Standard_EXPORT + Standard_Boolean IsEqual(const GEOMAlgo_ShapeSet& theOther) const; + + Standard_Boolean operator ==(const GEOMAlgo_ShapeSet& theOther) const { + return IsEqual(theOther); + } + + protected: + TopTools_MapOfOrientedShape myMap; + TopTools_ListOfShape myList; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSolid.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSolid.cxx new file mode 100644 index 000000000..4aaa2fb15 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSolid.cxx @@ -0,0 +1,82 @@ +// 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_ShapeSolid.cxx +// Created: Thu Jan 13 12:54:48 2005 +// Author: Peter KURNEV +// +// +#include + +#include +#include + +//======================================================================= +//function : GEOMAlgo_ShapeSolid +//purpose : +//======================================================================= +GEOMAlgo_ShapeSolid::GEOMAlgo_ShapeSolid() +: + GEOMAlgo_Algo(), + myRank(0), + myDSFiller(NULL) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_ShapeSolid::~GEOMAlgo_ShapeSolid() +{ +} +//======================================================================= +//function : SetFiller +//purpose : +//======================================================================= +void GEOMAlgo_ShapeSolid::SetFiller(const BOPTools_DSFiller& aDSFiller) +{ + myDSFiller=(BOPTools_DSFiller*) &aDSFiller; +} +//======================================================================= +// function: Shapes +// purpose: +//======================================================================= +const TopTools_ListOfShape& GEOMAlgo_ShapeSolid::Shapes(const TopAbs_State aState) const +{ + const TopTools_ListOfShape *pL; + // + switch (aState) { + case TopAbs_IN: + pL=&myLSIN; + break; + case TopAbs_OUT: + pL=&myLSOUT; + break; + case TopAbs_ON: + pL=&myLSON; + break; + default: + pL=&myLSON; + break; + } + return *pL; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSolid.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSolid.hxx new file mode 100644 index 000000000..02879b5f8 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShapeSolid.hxx @@ -0,0 +1,73 @@ +// 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_ShapeSolid.hxx +// Created: Thu Jan 13 12:54:48 2005 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_ShapeSolid_HeaderFile +#define _GEOMAlgo_ShapeSolid_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_ShapeSolid +//purpose : +//======================================================================= +class GEOMAlgo_ShapeSolid : public GEOMAlgo_Algo +{ + public: + Standard_EXPORT + void SetFiller(const BOPTools_DSFiller& aDSF) ; + + Standard_EXPORT + virtual ~GEOMAlgo_ShapeSolid(); + + Standard_EXPORT + const TopTools_ListOfShape& Shapes(const TopAbs_State aState) const; + +protected: + Standard_EXPORT + GEOMAlgo_ShapeSolid(); + + Standard_EXPORT + virtual void BuildResult() = 0; + + Standard_EXPORT + virtual void Prepare() = 0; + + + TopTools_ListOfShape myLSIN; + TopTools_ListOfShape myLSOUT; + TopTools_ListOfShape myLSON; + Standard_Integer myRank; + BOPTools_PDSFiller myDSFiller; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShellSolid.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShellSolid.cxx new file mode 100644 index 000000000..a99df120e --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShellSolid.cxx @@ -0,0 +1,371 @@ +// 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_ShellSolid.cxx +// Created: Wed Jan 12 12:49:45 2005 +// 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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_ShellSolid +//purpose : +//======================================================================= +GEOMAlgo_ShellSolid::GEOMAlgo_ShellSolid() +: + GEOMAlgo_ShapeSolid() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_ShellSolid::~GEOMAlgo_ShellSolid() +{ +} +//======================================================================= +// function: +// purpose: +//======================================================================= +void GEOMAlgo_ShellSolid::Perform() +{ + myErrorStatus=0; + // + try { + if (myDSFiller==NULL) { + myErrorStatus=10; + return; + } + if(!myDSFiller->IsDone()) { + myErrorStatus=11; + return; + } + // + Standard_Boolean bIsNewFiller; + // + bIsNewFiller=myDSFiller->IsNewFiller(); + if (bIsNewFiller) { + Prepare(); + myDSFiller->SetNewFiller(!bIsNewFiller); + } + // + myRank=(myDSFiller->DS().Object().ShapeType()==TopAbs_SHELL) ? 1 : 2; + BuildResult(); + } + catch (Standard_Failure) { + myErrorStatus=12; + } +} +//======================================================================= +// function: Prepare +// purpose: +//======================================================================= +void GEOMAlgo_ShellSolid::Prepare() +{ + const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); + // + // 1 States + BOPTools_SolidStateFiller aStateFiller(aPaveFiller); + aStateFiller.Do(); + // + // 2 Project section edges on corresp. faces -> P-Curves on edges. + BOPTools_PCurveMaker aPCurveMaker(aPaveFiller); + aPCurveMaker.Do(); + // + // 3. Degenerated Edges Processing + BOPTools_DEProcessor aDEProcessor(aPaveFiller); + aDEProcessor.Do(); + // + // 4. Detect Same Domain Faces + DetectSDFaces(); +} +//================================================================================= +// function: BuildResult +// purpose: +//================================================================================= +void GEOMAlgo_ShellSolid::BuildResult() +{ + Standard_Boolean bIsTouchCase; + Standard_Integer i, j, nF1, nF2, aNbFFs, aNbS, aNbCurves, nSp, iRank1; + Standard_Integer nE, nF, aNbPB, iBeg, iEnd; + BooleanOperations_StateOfShape aState; + TopExp_Explorer anExp; + TopAbs_ShapeEnum aType; + gp_Pnt2d aP2D; + gp_Pnt aP3D; + // + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + const BOPTools_InterferencePool& anInterfPool=myDSFiller->InterfPool(); + BOPTools_InterferencePool* pInterfPool=(BOPTools_InterferencePool*) &anInterfPool; + BOPTools_CArray1OfSSInterference& aFFs=pInterfPool->SSInterferences(); + const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); + const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); + // + // 1. process pf non-interferring faces + iBeg=1; + iEnd=aDS.NumberOfShapesOfTheObject(); + if (myRank==2) { + iBeg=iEnd+1; + iEnd=aDS.NumberOfSourceShapes(); + } + // + for (i=iBeg; i<=iEnd; ++i) { + aType=aDS.GetShapeType(i); + if (aType!=TopAbs_FACE) { + continue; + } + // + const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(i)); + aState=aDS.GetState(i); + if (aState==BooleanOperations_IN) { + myLSIN.Append(aF1); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aF1); + } + } + // + // 2. process pf interferred faces + aNbFFs=aFFs.Extent(); + for (i=1; i<=aNbFFs; ++i) { + BOPTools_SSInterference& aFFi=aFFs(i); + // + nF1=aFFi.Index1(); + nF2=aFFi.Index2(); + iRank1=aDS.Rank(nF1); + nF=(iRank1==myRank) ? nF1 : nF2; + const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF)); + // + bIsTouchCase=aFFi.IsTangentFaces(); + // + if (bIsTouchCase) { + myLSON.Append(aF1); + continue; + } + // + // Has section edges ? + aNbS=0; + BOPTools_SequenceOfCurves& aBCurves=aFFi.Curves(); + aNbCurves=aBCurves.Length(); + for (j=1; j<=aNbCurves; j++) { + BOPTools_Curve& aBC=aBCurves(j); + const BOPTools_ListOfPaveBlock& aSectEdges=aBC.NewPaveBlocks(); + aNbS=aSectEdges.Extent(); + if (aNbS) { + break; + } + } + // + if (aNbS) { // it has + continue; + } + // + anExp.Init(aF1, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(anExp.Current()); + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + nE=aDS.ShapeIndex(aE, myRank); + const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(nE)); + aNbPB=aLPB.Extent(); + // + if (aNbPB<2) { + nSp=nE; + if (aNbPB) { + const BOPTools_PaveBlock& aPB=aLPB.First(); + nSp=aPB.Edge(); + } + /*const TopoDS_Shape& aSp=*/aDS.Shape(nSp); + // + aState=aDS.GetState(nSp); + if (aState==BooleanOperations_IN) { + myLSIN.Append(aF1); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aF1); + } + else if (aState==BooleanOperations_ON) { + Standard_Real aTol; + TopAbs_State aSt; + // + //const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape((iRank1==myRank)? nF2 : nF1)); + //aTol=BRep_Tool::Tolerance(aF2); + aTol=1.e-7; + // + BOPTools_Tools3D::PointNearEdge(aE, aF1, aP2D, aP3D); + const TopoDS_Solid& aRefSolid=(myRank==1) ? + TopoDS::Solid(aDS.Tool()) : TopoDS::Solid(aDS.Object()); + // + BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)& aPaveFiller; + const Handle(IntTools_Context)& aCtx=pPF->Context(); + // + BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aRefSolid); + aSC.Perform(aP3D, aTol); + aSt=aSC.State(); + if (aSt==TopAbs_IN) { + myLSIN.Append(aF1); + } + else if (aSt==TopAbs_OUT) { + myLSOUT.Append(aF1); + } + } + break; + } // if (aNbPB<2) { + } //for (; anExp.More(); anExp.Next()) + } +} +//======================================================================= +// function: DetectSDFaces +// purpose: +//======================================================================= +void GEOMAlgo_ShellSolid::DetectSDFaces() +{ + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + BOPTools_InterferencePool* pIntrPool=(BOPTools_InterferencePool*)&myDSFiller->InterfPool(); + BOPTools_CArray1OfSSInterference& aFFs=pIntrPool->SSInterferences(); + // + Standard_Boolean bFlag; + Standard_Integer i, aNb, nF1, nF2, iZone, aNbSps, iSenseFlag; + gp_Dir aDNF1, aDNF2; + + aNb=aFFs.Extent(); + for (i=1; i<=aNb; i++) { + bFlag=Standard_False; + + BOPTools_SSInterference& aFF=aFFs(i); + + nF1=aFF.Index1(); + nF2=aFF.Index2(); + const TopoDS_Face& aF1=TopoDS::Face(aDS.Shape(nF1)); + const TopoDS_Face& aF2=TopoDS::Face(aDS.Shape(nF2)); + // + // iSenseFlag; + const BOPTools_ListOfPaveBlock& aLPB=aFF.PaveBlocks(); + aNbSps=aLPB.Extent(); + + if (!aNbSps) { + continue; + } + + const BOPTools_PaveBlock& aPB=aLPB.First(); + const TopoDS_Edge& aSpE=TopoDS::Edge(aDS.Shape(aPB.Edge())); + + BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF1, aDNF1); + BOPTools_Tools3D::GetNormalToFaceOnEdge (aSpE, aF2, aDNF2); + iSenseFlag=BOPTools_Tools3D::SenseFlag (aDNF1, aDNF2); + // + if (iSenseFlag==1 || iSenseFlag==-1) { + // + // + TopoDS_Face aF1FWD=aF1; + aF1FWD.Orientation (TopAbs_FORWARD); + + BOP_WireEdgeSet aWES (aF1FWD); + BOP_SDFWESFiller aWESFiller(nF1, nF2, *myDSFiller); + aWESFiller.SetSenseFlag(iSenseFlag); + aWESFiller.SetOperation(BOP_COMMON); + aWESFiller.Do(aWES); + + BOP_FaceBuilder aFB; + aFB.Do(aWES); + const TopTools_ListOfShape& aLF=aFB.NewFaces(); + + iZone=0; + TopTools_ListIteratorOfListOfShape anIt(aLF); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aFR=anIt.Value(); + + if (aFR.ShapeType()==TopAbs_FACE) { + const TopoDS_Face& aFaceResult=TopoDS::Face(aFR); + // + Standard_Boolean bIsValidIn2D, bNegativeFlag; + bIsValidIn2D=BOPTools_Tools3D::IsValidArea (aFaceResult, bNegativeFlag); + if (bIsValidIn2D) { + //if(CheckSameDomainFaceInside(aFaceResult, aF2)) { + iZone=1; + break; + //} + } + // + } + } + + if (iZone) { + bFlag=Standard_True; + aFF.SetStatesMap(aWESFiller.StatesMap()); + } + + }// if (iSenseFlag) + + aFF.SetTangentFacesFlag(bFlag); + aFF.SetSenseFlag (iSenseFlag); + }// end of for (i=1; i<=aNb; i++) +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_ShellSolid.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_ShellSolid.hxx new file mode 100644 index 000000000..63bed90a1 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_ShellSolid.hxx @@ -0,0 +1,61 @@ +// 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_ShellSolid.hxx +// Created: Wed Jan 12 12:49:45 2005 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_ShellSolid_HeaderFile +#define _GEOMAlgo_ShellSolid_HeaderFile + +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_ShellSolid +//purpose : +//======================================================================= +class GEOMAlgo_ShellSolid : public GEOMAlgo_ShapeSolid +{ + public: + Standard_EXPORT + GEOMAlgo_ShellSolid(); + + Standard_EXPORT + virtual ~GEOMAlgo_ShellSolid(); + + Standard_EXPORT + virtual void Perform() ; + + protected: + Standard_EXPORT + virtual void Prepare() ; + + Standard_EXPORT + virtual void BuildResult() ; + + Standard_EXPORT + void DetectSDFaces() ; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_SolidSolid.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_SolidSolid.cxx new file mode 100644 index 000000000..5ea46988d --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_SolidSolid.cxx @@ -0,0 +1,203 @@ +// 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_SolidSolid.cxx +// Created: Wed Jan 26 12:06:26 2005 +// Author: Peter KURNEV +// +// +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +//======================================================================= +//function : GEOMAlgo_SolidSolid +//purpose : +//======================================================================= +GEOMAlgo_SolidSolid::GEOMAlgo_SolidSolid() +: + GEOMAlgo_ShellSolid() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_SolidSolid::~GEOMAlgo_SolidSolid() +{ +} +//======================================================================= +// function: SetShape2 +// purpose: +//======================================================================= +void GEOMAlgo_SolidSolid::SetShape2(const TopoDS_Shape& aS2) +{ + myS2=aS2; +} +//======================================================================= +// function: Shape2 +// purpose: +//======================================================================= +const TopoDS_Shape& GEOMAlgo_SolidSolid::Shape2()const +{ + return myS2; +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= +void GEOMAlgo_SolidSolid::Perform() +{ + myErrorStatus=0; + try { + if (myDSFiller==NULL) { + myErrorStatus=10; + return; + } + if(!myDSFiller->IsDone()) { + myErrorStatus=11; + return; + } + // + Standard_Boolean bIsNewFiller; + // + bIsNewFiller=myDSFiller->IsNewFiller(); + if (bIsNewFiller) { + Prepare(); + myDSFiller->SetNewFiller(!bIsNewFiller); + } + // + myRank=2; + BuildResult(); + } + catch (Standard_Failure) { + myErrorStatus=12; + } +} +//================================================================================= +// function: BuildResult +// purpose: +//================================================================================= +void GEOMAlgo_SolidSolid::BuildResult() +{ + myErrorStatus=0; + // + Standard_Integer i, j, aNbF, aNbS; + Standard_Integer aNbFIN, aNbFOUT, aNbFON, aNbFINTR; + TopAbs_State aState; + TopTools_ListIteratorOfListOfShape aIt; + TopTools_IndexedMapOfShape aMF, aMS; + GEOMAlgo_IndexedDataMapOfShapeState aMFS; + // + // 1. classify the faces + GEOMAlgo_ShellSolid::BuildResult(); + // + // 2. fill Shape-State map + aIt.Initialize(myLSIN); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMFS.Add(aF, TopAbs_IN); + } + aIt.Initialize(myLSOUT); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMFS.Add(aF, TopAbs_OUT); + } + aIt.Initialize(myLSON); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + aMFS.Add(aF, TopAbs_ON); + } + myLSIN.Clear(); + myLSON.Clear(); + myLSOUT.Clear(); + // + // 3. fill states for solids + TopExp::MapShapes(myS2, TopAbs_SOLID, aMS); + // + aNbS=aMS.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aSolid=aMS(i); + // + aMF.Clear(); + TopExp::MapShapes(aSolid, TopAbs_FACE, aMF); + // + aNbFIN=0; + aNbFOUT=0; + aNbFON=0; + aNbFINTR=0; + // + aNbF=aMF.Extent(); + for(j=1; j +// +#ifndef _GEOMAlgo_SolidSolid_HeaderFile +#define _GEOMAlgo_SolidSolid_HeaderFile + +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_SolidSolid +//purpose : +//======================================================================= +class GEOMAlgo_SolidSolid : public GEOMAlgo_ShellSolid +{ + public: + Standard_EXPORT + GEOMAlgo_SolidSolid(); + + Standard_EXPORT + virtual ~GEOMAlgo_SolidSolid(); + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + void SetShape2(const TopoDS_Shape& aS) ; + + Standard_EXPORT + const TopoDS_Shape& Shape2() const; + +protected: + Standard_EXPORT + virtual void BuildResult() ; + + + TopoDS_Shape myS2; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Splitter.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Splitter.cxx new file mode 100644 index 000000000..61f31aab8 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Splitter.cxx @@ -0,0 +1,339 @@ +// 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_Splitter.cxx +// Author: Peter KURNEV +// +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include + + +static + void TreatCompound(const TopoDS_Shape& aC, + TopTools_ListOfShape& aLSX); + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_Splitter::GEOMAlgo_Splitter() +: + GEOMAlgo_Builder() +{ + myLimit=TopAbs_SHAPE; + myLimitMode=0; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_Splitter::~GEOMAlgo_Splitter() +{ +} +//======================================================================= +//function : AddToolCompound +//purpose : +//======================================================================= + void GEOMAlgo_Splitter::AddToolCompound(const TopoDS_Shape& theShape) +{ + TopoDS_Iterator aIt; + // + aIt.Initialize(theShape); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + AddTool(aS); + } +} +//======================================================================= +//function : AddTool +//purpose : +//======================================================================= + void GEOMAlgo_Splitter::AddTool(const TopoDS_Shape& theShape) +{ + if (myMapTools.Add(theShape)) { + myTools.Append(theShape); + // + AddShape(theShape); + } +} +//======================================================================= +//function : Tools +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_Splitter::Tools()const +{ + return myTools; +} +//======================================================================= +//function : SetLimit +//purpose : +//======================================================================= + void GEOMAlgo_Splitter::SetLimit(const TopAbs_ShapeEnum aLimit) +{ + myLimit=aLimit; +} +//======================================================================= +//function : Limit +//purpose : +//======================================================================= + TopAbs_ShapeEnum GEOMAlgo_Splitter::Limit()const +{ + return myLimit; +} +//======================================================================= +//function : SetLimitMode +//purpose : +//======================================================================= + void GEOMAlgo_Splitter::SetLimitMode(const Standard_Integer aMode) +{ + myLimitMode=aMode; +} +//======================================================================= +//function : LimitMode +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_Splitter::LimitMode()const +{ + return myLimitMode; +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void GEOMAlgo_Splitter::Clear() +{ + myTools.Clear(); + myMapTools.Clear(); + myLimit=TopAbs_SHAPE; + GEOMAlgo_Builder::Clear(); +} +//======================================================================= +//function : BuildResult +//purpose : +//======================================================================= + void GEOMAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType) +{ + myErrorStatus=0; + // + TopAbs_ShapeEnum aType; + BRep_Builder aBB; + TopTools_MapOfShape aM; + TopTools_ListIteratorOfListOfShape aIt, aItIm; + // + aIt.Initialize(myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + aType=aS.ShapeType(); + if (aType==theType && !myMapTools.Contains(aS)) { + if (myImages.HasImage(aS)) { + const TopTools_ListOfShape& aLSIm=myImages.Image(aS); + aItIm.Initialize(aLSIm); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aSIm=aItIm.Value(); + if (aM.Add(aSIm)) { + aBB.Add(myShape, aSIm); + } + } + } + else { + if (aM.Add(aS)) { + aBB.Add(myShape, aS); + } + } + } + } +} +//======================================================================= +//function : PostTreat +//purpose : +//======================================================================= + void GEOMAlgo_Splitter::PostTreat() +{ + if (myLimit!=TopAbs_SHAPE) { + Standard_Integer i, aNbS; + BRep_Builder aBB; + TopoDS_Compound aC; + TopTools_IndexedMapOfShape aMx; + // + aBB.MakeCompound(aC); + // + TopExp::MapShapes(myShape, myLimit, aMx); + aNbS=aMx.Extent(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aS=aMx(i); + aBB.Add(aC, aS); + } + // + if (myLimitMode) { + Standard_Integer iType, iLimit, iTypeX; + TopAbs_ShapeEnum aType, aTypeX; + TopTools_ListOfShape aLSP, aLSX; + TopTools_ListIteratorOfListOfShape aIt, aItX, aItIm; + TopTools_MapOfShape aM; + // + iLimit=(Standard_Integer)myLimit; + // + // 1. Collect the shapes to process aLSP + aIt.Initialize(myShapes); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if (myMapTools.Contains(aS)) { + continue; + } + // + aType=aS.ShapeType(); + iType=(Standard_Integer)aType; + // + if (iType>iLimit) { + aLSP.Append(aS); + } + // + else if (aType==TopAbs_COMPOUND) { + aLSX.Clear(); + // + TreatCompound(aS, aLSX); + // + aItX.Initialize(aLSX); + for (; aItX.More(); aItX.Next()) { + const TopoDS_Shape& aSX=aItX.Value(); + aTypeX=aSX.ShapeType(); + iTypeX=(Standard_Integer)aTypeX; + // + if (iTypeX>iLimit) { + aLSP.Append(aSX); + } + } + } + }// for (; aIt.More(); aIt.Next()) { + // + //modified by NIZNHY-PKV Fri Oct 30 11:07:08 2009 f + aMx.Clear(); + TopExp::MapShapes(aC, aMx); + //modified by NIZNHY-PKV Fri Oct 30 11:12:30 2009t + // + // 2. Add them to aC + aIt.Initialize(aLSP); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + if (myImages.HasImage(aS)) { + const TopTools_ListOfShape& aLSIm=myImages.Image(aS); + aItIm.Initialize(aLSIm); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aSIm=aItIm.Value(); + if (aM.Add(aSIm)) { + //modified by NIZNHY-PKV Fri Oct 30 11:09:57 2009f + if (!aMx.Contains(aSIm)) { + aBB.Add(aC, aSIm); + } + //aBB.Add(aC, aSIm); + //modified by NIZNHY-PKV Fri Oct 30 11:10:02 2009 + } + } + } + else { + if (aM.Add(aS)) { + //modified by NIZNHY-PKV Fri Oct 30 11:10:46 2009f + if (!aMx.Contains(aS)) { + aBB.Add(aC, aS); + } + //aBB.Add(aC, aS); + //modified by NIZNHY-PKV Fri Oct 30 11:11:00 2009t + } + } + } + }// if (myLimitMode) { + myShape=aC; + }//if (myLimit!=TopAbs_SHAPE) { + // + GEOMAlgo_Builder::PostTreat(); +} +//======================================================================= +//function : TreatCompound +//purpose : +//======================================================================= +void TreatCompound(const TopoDS_Shape& aC1, + TopTools_ListOfShape& aLSX) +{ + Standard_Integer aNbC1; + TopAbs_ShapeEnum aType; + TopTools_ListOfShape aLC, aLC1; + TopTools_ListIteratorOfListOfShape aIt, aIt1; + TopoDS_Iterator aItC; + // + aLC.Append (aC1); + while(1) { + aLC1.Clear(); + aIt.Initialize(aLC); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aC=aIt.Value(); //C is compound + // + aItC.Initialize(aC); + for (; aItC.More(); aItC.Next()) { + const TopoDS_Shape& aS=aItC.Value(); + aType=aS.ShapeType(); + if (aType==TopAbs_COMPOUND) { + aLC1.Append(aS); + } + else { + aLSX.Append(aS); + } + } + } + // + aNbC1=aLC1.Extent(); + if (!aNbC1) { + break; + } + // + aLC.Clear(); + aIt.Initialize(aLC1); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSC=aIt.Value(); + aLC.Append(aSC); + } + }// while(1) +} +// +// myErrorStatus +// +// 0 - Ok +// 1 - The object is just initialized +// 2 - PaveFiller is failed +// 10 - No shapes to process +// 30 - SolidBuilder failed diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Splitter.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_Splitter.hxx new file mode 100644 index 000000000..3a4c9ef12 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Splitter.hxx @@ -0,0 +1,98 @@ +// 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_Splitter.hxx +// +// Author: Peter KURNEV +// +#ifndef _GEOMAlgo_Splitter_HeaderFile +#define _GEOMAlgo_Splitter_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + +//! Implementation of Gluing Operation Algorithm (GA)
+//======================================================================= +//function : GEOMAlgo_Splitter +//purpose : +//======================================================================= +class GEOMAlgo_Splitter : public GEOMAlgo_Builder +{ + public: + + //! Empty constructor
+ Standard_EXPORT + GEOMAlgo_Splitter(); + + Standard_EXPORT + virtual ~GEOMAlgo_Splitter(); + + //! Clears internal fields and arguments
+ Standard_EXPORT + virtual void Clear() ; + + //! Adds Tool argument theShape of the operation
+ Standard_EXPORT + virtual void AddTool(const TopoDS_Shape& theShape) ; + + //! Returns the arguments of the operation
+ Standard_EXPORT + const TopTools_ListOfShape& Tools() const; + + Standard_EXPORT + void SetLimit(const TopAbs_ShapeEnum aLimit) ; + + Standard_EXPORT + TopAbs_ShapeEnum Limit() const; + + Standard_EXPORT + void SetLimitMode(const Standard_Integer aLimitMode) ; + + Standard_EXPORT + Standard_Integer LimitMode() const; + //! Adds Tool arguments of the operation as
+ //! shapes of upper level of container shape theShape
+ //! =====================================================
+ Standard_EXPORT + void AddToolCompound(const TopoDS_Shape& theShape) ; + + protected: + //! Build the resulting shapes of type theType
+ Standard_EXPORT + virtual void BuildResult(const TopAbs_ShapeEnum theType) ; + //! Provides post-tratment actions
+ Standard_EXPORT + virtual void PostTreat() ; + + + TopTools_ListOfShape myTools; + TopTools_MapOfShape myMapTools; + TopAbs_ShapeEnum myLimit; + Standard_Integer myLimitMode; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_State.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_State.hxx new file mode 100644 index 000000000..d6dceb72b --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_State.hxx @@ -0,0 +1,40 @@ +// 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_State_HeaderFile +#define _GEOMAlgo_State_HeaderFile +enum GEOMAlgo_State { + GEOMAlgo_ST_UNKNOWN, + GEOMAlgo_ST_IN, + GEOMAlgo_ST_OUT, + GEOMAlgo_ST_ON, + GEOMAlgo_ST_ONIN, + GEOMAlgo_ST_ONOUT, + GEOMAlgo_ST_INOUT +}; + +#ifndef _Standard_PrimitiveTypes_HeaderFile +#include +#endif + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_StateCollector.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_StateCollector.cxx new file mode 100644 index 000000000..6a0754a4f --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_StateCollector.cxx @@ -0,0 +1,92 @@ +// 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_StateCollector.cxx +// Created: Thu Mar 10 09:42:11 2005 +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function : GEOMAlgo_StateCollector +//purpose : +//======================================================================= +GEOMAlgo_StateCollector::GEOMAlgo_StateCollector() +{ + myCounter[0]=0; + myCounter[1]=0; + myCounter[2]=0; +} +//======================================================================= +//function : AppendState +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_StateCollector::AppendState(const TopAbs_State aSt) +{ + Standard_Boolean bIsToBreak; + // + switch(aSt) { + case TopAbs_IN: + ++myCounter[0]; + break; + case TopAbs_OUT: + ++myCounter[1]; + break; + case TopAbs_ON: + ++myCounter[2]; + break; + default: + break; + } + bIsToBreak=(myCounter[0] && myCounter[1]); + // + return bIsToBreak; +} +//======================================================================= +//function : State +//purpose : +//======================================================================= +TopAbs_State GEOMAlgo_StateCollector::State()const +{ + TopAbs_State aSt; + // + aSt=TopAbs_UNKNOWN; + // + if (myCounter[0] && myCounter[1]) { + return aSt; + } + // + else if (myCounter[0] && myCounter[2]>=0) { + aSt=TopAbs_IN; + } + // + else if (myCounter[1] && myCounter[2]>=0) { + aSt=TopAbs_OUT; + } + // + else if (!myCounter[0] && !myCounter[1] && myCounter[2]) { + aSt=TopAbs_ON; + } + // + return aSt; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_StateCollector.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_StateCollector.hxx new file mode 100644 index 000000000..39cad18b8 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_StateCollector.hxx @@ -0,0 +1,56 @@ +// 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_StateCollector.hxx +// Created: Thu Mar 10 09:42:11 2005 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_StateCollector_HeaderFile +#define _GEOMAlgo_StateCollector_HeaderFile + +#include +#include +#include +#include +#include + +//======================================================================= +// class : GEOMAlgo_StateCollector +//purpose : +//======================================================================= +class GEOMAlgo_StateCollector +{ + public: + Standard_EXPORT + GEOMAlgo_StateCollector(); + + Standard_EXPORT + Standard_Boolean AppendState(const TopAbs_State aSt) ; + + Standard_EXPORT + TopAbs_State State() const; + + protected: + Standard_Integer myCounter[3]; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_SurfaceTools.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_SurfaceTools.cxx new file mode 100644 index 000000000..b725fb6af --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_SurfaceTools.cxx @@ -0,0 +1,270 @@ +// 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_SurfaceTools.cxx +// Created: Thu Jan 27 11:05:16 2005 +// Author: Peter KURNEV +// +// +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +//======================================================================= +//function : GetState +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP, + const GeomAdaptor_Surface& aGAS, + const Standard_Real aTol, + TopAbs_State& aState) +{ + Standard_Integer iErr; + Standard_Real aDp, aR; + GeomAbs_SurfaceType aType; + gp_Sphere aSph; + gp_Cylinder aCyl; + gp_Pln aPln; + // + iErr=0; + aState=TopAbs_UNKNOWN; + // + aType=aGAS.GetType(); + switch (aType) { + case GeomAbs_Plane: + aPln=aGAS.Plane(); + aR=0.; + aDp=GEOMAlgo_SurfaceTools::Distance(aP, aPln); + break; + + case GeomAbs_Cylinder: + aCyl=aGAS.Cylinder(); + aR=aCyl.Radius(); + aDp=GEOMAlgo_SurfaceTools::Distance(aP, aCyl); + break; + + case GeomAbs_Sphere: + aSph=aGAS.Sphere(); + aR=aSph.Radius(); + aDp=GEOMAlgo_SurfaceTools::Distance(aP, aSph); + break; + + default: + iErr=1; // unprocessed surface type + break; + } + // + if (!iErr) { + aState=TopAbs_ON; + if (aDp>aR+aTol) { + aState=TopAbs_OUT; + } + else if (aDp aTol) { + return bRet; + } + // + return !bRet; +} +//======================================================================= +//function : IsAnalytic +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_SurfaceTools::IsAnalytic(const Handle(Geom_Surface)& aSurf) +{ + Standard_Boolean bRet; + GeomAbs_SurfaceType aType; + GeomAdaptor_Surface aGAS; + // + aGAS.Load(aSurf); + aType=aGAS.GetType(); + bRet=(aType==GeomAbs_Plane || + aType==GeomAbs_Cylinder || + aType==GeomAbs_Sphere); + return bRet; +} +//======================================================================= +//function : IsConformState +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_SurfaceTools::IsConformState(const TopAbs_State aST1, + const GEOMAlgo_State aST2) +{ + Standard_Boolean bRet=Standard_False; + // + switch (aST2) { + case GEOMAlgo_ST_IN: + if (aST1==TopAbs_IN) { + bRet=!bRet; + } + break; + case GEOMAlgo_ST_OUT: + if (aST1==TopAbs_OUT) { + bRet=!bRet; + } + break; + case GEOMAlgo_ST_ON: + if (aST1==TopAbs_ON) { + bRet=!bRet; + } + break; + case GEOMAlgo_ST_ONIN: + if (aST1==TopAbs_ON || aST1==TopAbs_IN) { + bRet=!bRet; + } + break; + case GEOMAlgo_ST_ONOUT: + if (aST1==TopAbs_ON || aST1==TopAbs_OUT) { + bRet=!bRet; + } + break; + default: + break; + } + return bRet; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_SurfaceTools.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_SurfaceTools.hxx new file mode 100644 index 000000000..c848c2251 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_SurfaceTools.hxx @@ -0,0 +1,94 @@ +// 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_SurfaceTools.hxx +// Created: Thu Jan 27 11:05:16 2005 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_SurfaceTools_HeaderFile +#define _GEOMAlgo_SurfaceTools_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : GEOMAlgo_SurfaceTools +//purpose : +//======================================================================= +class GEOMAlgo_SurfaceTools +{ + public: + Standard_EXPORT + static Standard_Boolean IsAnalytic(const Handle(Geom_Surface)& aS) ; + + Standard_EXPORT + static Standard_Boolean IsCoaxial(const gp_Pnt& aP1, + const gp_Pnt& aP2, + const gp_Cylinder& aCyl, + const Standard_Real aTol) ; + + Standard_EXPORT + static Standard_Boolean IsConformState(const TopAbs_State aST1, + const GEOMAlgo_State aST2) ; + + Standard_EXPORT + static Standard_Integer GetState(const gp_Pnt& aP, + const GeomAdaptor_Surface& aS, + const Standard_Real aTol,TopAbs_State& aSt) ; + + Standard_EXPORT + static Standard_Integer GetState(const gp_Pnt& aP, + const Handle(Geom_Surface)& aS, + const Standard_Real aTol, + TopAbs_State& aSt) ; + + Standard_EXPORT + static Standard_Real Distance(const gp_Pnt& aP, + const gp_Pln& aPln) ; + + Standard_EXPORT + static Standard_Real Distance(const gp_Pnt& aP, + const gp_Cylinder& aCyl) ; + + Standard_EXPORT + static Standard_Real Distance(const gp_Pnt& aP, + const gp_Sphere& aSph) ; + + Standard_EXPORT + static TopAbs_State ReverseState(const TopAbs_State aSt) ; + +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Tools.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Tools.cxx new file mode 100644 index 000000000..556e082dc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Tools.cxx @@ -0,0 +1,612 @@ +// 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_Tools.cxx +// Created: Mon Dec 6 11:35:29 2004 +// 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 + +static + void GetCount(const TopoDS_Shape& aS, + Standard_Integer& iCnt); + +//======================================================================= +//function : IsCompositeShape +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Tools::IsCompositeShape(const TopoDS_Shape& aS) +{ + Standard_Boolean bRet; + Standard_Integer iCnt; + TopoDS_Iterator aIt; + // + iCnt=0; + GetCount(aS, iCnt); + bRet=(iCnt>1); + // + return bRet; +} + +//======================================================================= +//function : GetCount +//purpose : +//======================================================================= +void GetCount(const TopoDS_Shape& aS, + Standard_Integer& iCnt) +{ + TopoDS_Iterator aIt; + TopAbs_ShapeEnum aTS; + // + aTS=aS.ShapeType(); + // + if (aTS==TopAbs_SHAPE) { + return; + } + if (aTS!=TopAbs_COMPOUND) { + ++iCnt; + return; + } + // + aIt.Initialize(aS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aSx=aIt.Value(); + GetCount(aSx, iCnt); + } +} + +//======================================================================= +//function : RefineSDShapes +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_Tools::RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMPKLE, + const Standard_Real aTol, + const Handle(IntTools_Context)& aCtx) +{ + Standard_Integer i, aNbE, iErr, j, aNbEE, aNbToAdd; + TopTools_IndexedDataMapOfShapeListOfShape aMEE, aMSDE, aMEToAdd; + // + iErr=1; + // + aNbE=aMPKLE.Extent(); + for (i=1; i<=aNbE; ++i) { + TopTools_ListOfShape& aLSDE=aMPKLE.ChangeFromIndex(i); + // + aMEE.Clear(); + iErr=GEOMAlgo_Tools::FindSDShapes(aLSDE, aTol, aMEE, aCtx); + if (iErr) { + return iErr; + } + // + aNbEE=aMEE.Extent(); + if (aNbEE==1) { + continue; // nothing to do + } + // + for (j=1; j<=aNbEE; ++j) { + TopTools_ListOfShape& aLEE=aMEE.ChangeFromIndex(j); + // + if (j==1) { + aLSDE.Clear(); + aLSDE.Append(aLEE); + } + else { + const TopoDS_Shape& aE1=aLEE.First(); + aMEToAdd.Add(aE1, aLEE); + } + } + } + // + aNbToAdd=aMEToAdd.Extent(); + if (!aNbToAdd) { + return aNbToAdd; + } + // + for (i=1; i<=aNbToAdd; ++i) { + GEOMAlgo_PassKeyShape aPKE1; + // + const TopoDS_Shape& aE1=aMEToAdd.FindKey(i); + const TopTools_ListOfShape& aLE=aMEToAdd(i); + // + //qf + //aPKE1.SetIds(aE1); + aPKE1.SetShapes(aE1); + //qt + aMPKLE.Add(aPKE1, aLE); + } + // + return 0; +} +//======================================================================= +//function : FindSDShapes +//purpose : +//======================================================================= +Standard_Integer GEOMAlgo_Tools::FindSDShapes(const TopTools_ListOfShape& aLE, + const Standard_Real aTol, + TopTools_IndexedDataMapOfShapeListOfShape& aMEE, + const Handle(IntTools_Context)& aCtx) +{ + Standard_Integer aNbE, aNbEProcessed, aNbESD, iErr; + TopTools_ListOfShape aLESD; + TopTools_ListIteratorOfListOfShape aIt, aIt1; + TopTools_IndexedMapOfShape aMProcessed; + TopAbs_ShapeEnum aType; + // + aNbE=aLE.Extent(); + if (!aNbE) { + return 3; // Err + } + //modified by NIZNHY-PKV Thu Dec 30 10:56:52 2004 f + if (aNbE==1) { + return 0; // Nothing to do + } + //modified by NIZNHY-PKV Thu Dec 30 10:56:56 2004 t + // + while(1) { + aNbEProcessed=aMProcessed.Extent(); + if (aNbEProcessed==aNbE) { + break; + } + // + aIt.Initialize(aLE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + // + if (aMProcessed.Contains(aS)) { + continue; + } + // + //modified by NIZNHY-PKV Thu Dec 30 10:57:01 2004 f + aType=aS.ShapeType(); + if (aType==TopAbs_EDGE) { + const TopoDS_Edge& aE=TopoDS::Edge(aS); + if (BRep_Tool::Degenerated(aE)) { + aMProcessed.Add(aE); + continue; + } + } + //modified by NIZNHY-PKV Thu Dec 30 10:57:03 2004 t + // + aLESD.Clear(); + iErr=GEOMAlgo_Tools::FindSDShapes(aS, aLE, aTol, aLESD, aCtx); + if (iErr) { + return 2; // Err + } + // + aNbESD=aLESD.Extent(); + if (!aNbESD) { + return 1; // Err + } + // + aMEE.Add(aS, aLESD); + // + aIt1.Initialize(aLESD); + for (; aIt1.More(); aIt1.Next()) { + const TopoDS_Shape& aE1=aIt1.Value(); + aMProcessed.Add(aE1); + } + } + } + return 0; +} +//======================================================================= +//function : FindSDShapes +//purpose : +//======================================================================= +Standard_Integer GEOMAlgo_Tools::FindSDShapes(const TopoDS_Shape& aE1, + const TopTools_ListOfShape& aLE, + const Standard_Real aTol, + TopTools_ListOfShape& aLESD, + const Handle(IntTools_Context)& aCtx) +{ + Standard_Boolean bIsDone; + Standard_Real aTol2, aD2; + gp_Pnt aP1, aP2; + TopTools_ListIteratorOfListOfShape aIt; + // + aTol2=aTol*aTol; + GEOMAlgo_Tools::PointOnShape(aE1, aP1); + // + aIt.Initialize(aLE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE2=aIt.Value(); + if (aE2.IsSame(aE1)) { + aLESD.Append(aE2); + } + else { + bIsDone=GEOMAlgo_Tools::ProjectPointOnShape(aP1, aE2, aP2, aCtx); + if (!bIsDone) { + //return 1; + continue; // jfa BUG 20361 + } + aD2=aP1.SquareDistance(aP2); + if(aD2ProjectPointOnEdge(aP1, aE2, aT2); + } + if (!bIsDone) { + return bIsDone; + } + // + GEOMAlgo_Tools::PointOnEdge(aE2, aT2, aP2); + } + break; + // + case TopAbs_FACE: + { + const TopoDS_Face& aF2 = TopoDS::Face(aS); + GeomAPI_ProjectPointOnSurf& aProj = aCtx->ProjPS(aF2); + // + aProj.Perform(aP1); + bIsDone = aProj.IsDone(); + if (!bIsDone) { + return bIsDone; + } + // + aP2 = aProj.NearestPoint(); + } + break; + // + default: + break; // Err + } + return bIsDone; +} +//======================================================================= +//function : PointOnShape +//purpose : +//======================================================================= +void GEOMAlgo_Tools::PointOnShape(const TopoDS_Shape& aS, + gp_Pnt& aP3D) +{ + TopAbs_ShapeEnum aType; + // + aP3D.SetCoord(99.,99.,99.); + aType=aS.ShapeType(); + switch(aType) { + case TopAbs_EDGE: { + const TopoDS_Edge& aE=TopoDS::Edge(aS); + GEOMAlgo_Tools::PointOnEdge(aE, aP3D); + } + break; + // + case TopAbs_FACE: { + const TopoDS_Face& aF=TopoDS::Face(aS); + GEOMAlgo_Tools::PointOnFace(aF, aP3D); + } + break; + // + default: + break; // Err + } +} +//======================================================================= +//function : PointOnFace +//purpose : +//======================================================================= +void GEOMAlgo_Tools::PointOnFace(const TopoDS_Face& aF, + gp_Pnt& aP3D) +{ + Standard_Real aU, aV, aUMin, aUMax, aVMin, aVMax; + // + BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax); + // + aU=BOPTools_Tools2D::IntermediatePoint(aUMin, aUMax); + aV=BOPTools_Tools2D::IntermediatePoint(aVMin, aVMax); + // + GEOMAlgo_Tools::PointOnFace(aF, aU, aV, aP3D); +} +//======================================================================= +//function : PointOnFace +//purpose : +//======================================================================= +void GEOMAlgo_Tools::PointOnFace(const TopoDS_Face& aF, + const Standard_Real aU, + const Standard_Real aV, + gp_Pnt& aP3D) +{ + Handle(Geom_Surface) aS; + // + aS=BRep_Tool::Surface(aF); + aS->D0(aU, aV, aP3D); +} +//======================================================================= +//function : PointOnEdge +//purpose : +//======================================================================= +void GEOMAlgo_Tools::PointOnEdge(const TopoDS_Edge& aE, + gp_Pnt& aP3D) +{ + Standard_Real aTx, aT1, aT2; + // + BRep_Tool::Curve(aE, aT1, aT2); + aTx=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); + GEOMAlgo_Tools::PointOnEdge(aE, aTx, aP3D); +} +//======================================================================= +//function : PointOnEdge +//purpose : +//======================================================================= +void GEOMAlgo_Tools::PointOnEdge(const TopoDS_Edge& aE, + const Standard_Real aT, + gp_Pnt& aP3D) +{ + Standard_Real aT1, aT2; + Handle(Geom_Curve) aC3D; + // + aC3D=BRep_Tool::Curve(aE, aT1, aT2); + aC3D->D0(aT, aP3D); +} +//======================================================================= +//function : RefinePCurveForEdgeOnFace +//purpose : +//======================================================================= +void GEOMAlgo_Tools::RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aUMin, + const Standard_Real aUMax) +{ + Standard_Real aT1, aT2, aTx, aUx, aTol; + gp_Pnt2d aP2D; + Handle(Geom_Surface) aS; + Handle(Geom2d_Curve) aC2D; + BRep_Builder aBB; + // + aC2D=BRep_Tool::CurveOnSurface(aE, aF, aT1, aT2); + if (!aC2D.IsNull()) { + if (BRep_Tool::IsClosed(aE, aF)) { + return; + } + aTx=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); + aC2D->D0(aTx, aP2D); + aUx=aP2D.X(); + if (aUx < aUMin || aUx > aUMax) { + // need to rebuild + Handle(Geom2d_Curve) aC2Dx; + // + aTol=BRep_Tool::Tolerance(aE); + aBB.UpdateEdge(aE, aC2Dx, aF, aTol); + } + } +} +//======================================================================= +//function : IsUPeriodic +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Tools::IsUPeriodic(const Handle(Geom_Surface) &aS) +{ + Standard_Boolean bRet; + GeomAbs_SurfaceType aType; + GeomAdaptor_Surface aGAS; + // + aGAS.Load(aS); + aType=aGAS.GetType(); + bRet=(aType==GeomAbs_Cylinder|| + aType==GeomAbs_Cone || + aType==GeomAbs_Sphere); + // + return bRet; +} + +//modified by NIZNHY-PKV Fri Feb 03 11:16:35 2012f +//======================================================================= +//function : BuildPCurveForEdgeOnFace +//purpose : +//======================================================================= +Standard_Integer + GEOMAlgo_Tools::BuildPCurveForEdgeOnFace(const TopoDS_Edge& aEold, + const TopoDS_Edge& aEnew, + const TopoDS_Face& aF, + const Handle(IntTools_Context)& aCtx) +{ + Standard_Boolean bIsClosed, bUClosed, bHasOld; + Standard_Integer iRet, aNbPoints; + Standard_Real aTS, aTS1, aTS2, aT, aT1, aT2, aScPr, aTol; + Standard_Real aU, aV, aUS1, aVS1, aUS2, aVS2; + gp_Pnt aP; + gp_Pnt2d aP2DS1, aP2DS2, aP2D; + gp_Vec2d aV2DS1, aV2DS2; + Handle(Geom2d_Curve) aC2D, aC2DS1, aC2DS2; + Handle(Geom_Surface) aS; + TopoDS_Edge aES; + // + iRet=0; + // + bHasOld=BOPTools_Tools2D::HasCurveOnSurface(aEnew, aF, aC2D, aT1, aT2, aTol); + if (bHasOld) { + return iRet; + } + // + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aEnew, aF); + aC2D=BRep_Tool::CurveOnSurface(aEnew, aF, aT1, aT2); + if (aC2D.IsNull()){ + iRet=1; + return iRet; + } + // + bIsClosed=BRep_Tool::IsClosed(aEold, aF); + if (!bIsClosed) { + return iRet; + } + // + aTol=1.e-7; + // + // 1. bUClosed - direction of closeness + // + aES=aEold; + aES.Orientation(TopAbs_FORWARD); + aC2DS1=BRep_Tool::CurveOnSurface(aES, aF, aTS1, aTS2); + // + aES.Orientation(TopAbs_REVERSED); + aC2DS2=BRep_Tool::CurveOnSurface(aES, aF, aTS1, aTS2); + // + aTS=BOPTools_Tools2D::IntermediatePoint(aTS1, aTS2); + // + aC2DS1->D1(aTS, aP2DS1, aV2DS1); + aC2DS2->D1(aTS, aP2DS2, aV2DS2); + // + gp_Vec2d aV2DS12(aP2DS1, aP2DS2); + gp_Dir2d aD2DS12(aV2DS12); + const gp_Dir2d& aD2DX=gp::DX2d(); + // + aScPr=aD2DS12*aD2DX; + bUClosed=Standard_True; + if (fabs(aScPr) < aTol) { + bUClosed=!bUClosed; + } + // + // 2. aP2D - point on curve aC2D, that corresponds to aP2DS1 + aP2DS1.Coord(aUS1, aVS1); + aP2DS2.Coord(aUS2, aVS2); + // + aS=BRep_Tool::Surface(aF); + aS->D0(aUS1, aVS1, aP); + // + GeomAPI_ProjectPointOnCurve& aProjPC=aCtx->ProjPC(aEnew); + // + aProjPC.Perform(aP); + aNbPoints=aProjPC.NbPoints(); + if (!aNbPoints) { + iRet=2; + return iRet; + } + // + aT=aProjPC.LowerDistanceParameter(); + + // + // 3. Build the second 2D curve + Standard_Boolean bRevOrder; + gp_Vec2d aV2DT, aV2D; + Handle(Geom2d_Curve) aC2Dnew; + Handle(Geom2d_TrimmedCurve) aC2DTnew; + BRep_Builder aBB; + // + aC2D->D1(aT, aP2D, aV2D); + aP2D.Coord(aU, aV); + // + aC2Dnew=Handle(Geom2d_Curve)::DownCast(aC2D->Copy()); + aC2DTnew = new Geom2d_TrimmedCurve(aC2Dnew, aT1, aT2); + // + aV2DT=aV2DS12; + if (!bUClosed) { // V Closed + if (fabs(aV-aVS2)Translate(aV2DT); + // + // 4 Order the 2D curves + bRevOrder=Standard_False; + aScPr=aV2D*aV2DS1; + if(aScPr<0.) { + bRevOrder=!bRevOrder; + } + // + // 5. Update the edge + aTol=BRep_Tool::Tolerance(aEnew); + if (!bRevOrder) { + aBB.UpdateEdge(aEnew, aC2D, aC2DTnew, aF, aTol); + } + else { + aBB.UpdateEdge(aEnew, aC2DTnew, aC2D , aF, aTol); + } + // + return iRet; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Tools.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_Tools.hxx new file mode 100644 index 000000000..f81530e03 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Tools.hxx @@ -0,0 +1,120 @@ +// 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_Tools.hxx +// Created: Mon Dec 6 11:35:29 2004 +// Author: Peter KURNEV + +#ifndef _GEOMAlgo_Tools_HeaderFile +#define _GEOMAlgo_Tools_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_Tools +//purpose : +//======================================================================= +class GEOMAlgo_Tools + { +public: + Standard_EXPORT + static Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS) ; + + Standard_EXPORT + static Standard_Integer RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMSD, + const Standard_Real aTol, + const Handle(IntTools_Context)& aCtx) ; + + Standard_EXPORT + static Standard_Integer FindSDShapes(const TopTools_ListOfShape& aLE, + const Standard_Real aTol, + TopTools_IndexedDataMapOfShapeListOfShape& aMEE, + const Handle(IntTools_Context)& aCtx) ; + + Standard_EXPORT + static Standard_Integer FindSDShapes(const TopoDS_Shape& aE1, + const TopTools_ListOfShape& aLE, + const Standard_Real aTol, + TopTools_ListOfShape& aLESD, + const Handle(IntTools_Context)& aCtx) ; + + Standard_EXPORT + static Standard_Boolean ProjectPointOnShape(const gp_Pnt& aP1, + const TopoDS_Shape& aS,gp_Pnt& aP2, + const Handle(IntTools_Context)& aCtx) ; + + Standard_EXPORT + static void PointOnShape(const TopoDS_Shape& aS, + gp_Pnt& aP3D) ; + + Standard_EXPORT + static void PointOnEdge(const TopoDS_Edge& aE, + gp_Pnt& aP3D) ; + + Standard_EXPORT + static void PointOnEdge(const TopoDS_Edge& aE, + const Standard_Real aT,gp_Pnt& aP3D) ; + + Standard_EXPORT + static void PointOnFace(const TopoDS_Face& aF, + gp_Pnt& aP3D) ; + + Standard_EXPORT + static void PointOnFace(const TopoDS_Face& aF, + const Standard_Real aU, + const Standard_Real aV, + gp_Pnt& aP3D) ; + + Standard_EXPORT + static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Standard_Real aU1, + const Standard_Real aU2) ; + + Standard_EXPORT + static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface)& aS) ; + + Standard_EXPORT + static Standard_Boolean CorrectWires(const TopoDS_Shape& aS) ; + + Standard_EXPORT + static Standard_Integer BuildPCurveForEdgeOnFace(const TopoDS_Edge& aE, + const TopoDS_Edge& aEold, + const TopoDS_Face& aF, + const Handle(IntTools_Context)& aCtx) ; + +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Tools3D.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Tools3D.cxx new file mode 100644 index 000000000..7ca1bf360 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Tools3D.cxx @@ -0,0 +1,1301 @@ +// 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_Tools3D.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 +#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_Boolean FindFacePairs (const TopoDS_Edge& , + const TopTools_ListOfShape& , + NMTTools_ListOfCoupleOfShape& ); + + +static + Standard_Real AngleWithRef(const gp_Dir& , + const gp_Dir& , + const gp_Dir& ); + +static + void GetApproxNormalToFaceOnEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + Standard_Real aT, + gp_Pnt& aPF, + gp_Dir& aDNF, + const Handle(IntTools_Context)& aCtx); + +//======================================================================= +//function : IsInternalFace +//purpose : +//======================================================================= +Standard_Boolean GEOMAlgo_Tools3D::IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Solid& theSolid, + const TopTools_IndexedDataMapOfShapeListOfShape& theMEF, + const Standard_Real theTol, + const Handle(IntTools_Context)& theContext) +{ + Standard_Boolean bRet; + Standard_Integer aNbF; + TopoDS_Edge aEL; + TopExp_Explorer aExp; + TopTools_ListIteratorOfListOfShape aItF; + // + bRet=Standard_False; + // + // 1 Try to find an edge from theFace in theMEF + aExp.Init(theFace, TopAbs_EDGE); + for(; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + if (!theMEF.Contains(aE)) { + continue; + } + // + const TopTools_ListOfShape& aLF=theMEF.FindFromKey(aE); + aNbF=aLF.Extent(); + if (!aNbF) { + return bRet; // it can not be so + } + else if (aNbF==1) { + // aE is internal edge on aLF.First() + const TopoDS_Face& aF1=TopoDS::Face(aLF.First()); + bRet=GEOMAlgo_Tools3D::IsInternalFace(theFace, aE, aF1, aF1, theContext); + return bRet; + } + else if (aNbF==2) { + const TopoDS_Face& aF1=TopoDS::Face(aLF.First()); + const TopoDS_Face& aF2=TopoDS::Face(aLF.Last()); + // + if (aF2.IsSame(aF1) && BRep_Tool::IsClosed(aE, aF1)) { + // treat as it was for 1 face + bRet=GEOMAlgo_Tools3D::IsInternalFace(theFace, aE, aF1, aF2, theContext); + return bRet; + } + } + if (aNbF%2) { + return bRet; // it can not be so + } + else { // aNbF=2,4,6,8,... + bRet=GEOMAlgo_Tools3D::IsInternalFace(theFace, aE, aLF, theContext); + return bRet; + } + }//for(; aExp.More(); aExp.Next()) { + // + //======================================== + // 2. Classify face using classifier + // + TopAbs_State aState; + TopTools_IndexedMapOfShape aBounds; + // + aState=GEOMAlgo_Tools3D::ComputeState(theFace, theSolid, theTol, aBounds, theContext); + bRet=(aState==TopAbs_IN); + // + return bRet; +} +//======================================================================= +//function : IsInternalFace +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_Tools3D::IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + const TopTools_ListOfShape& theLF, + const Handle(IntTools_Context)& theContext) +{ + Standard_Boolean bRet; + Standard_Boolean aNbF; + // + bRet=Standard_False; + // + aNbF=theLF.Extent(); + if (aNbF==2) { + const TopoDS_Face& aF1=TopoDS::Face(theLF.First()); + const TopoDS_Face& aF2=TopoDS::Face(theLF.Last()); + bRet=GEOMAlgo_Tools3D::IsInternalFace(theFace, theEdge, aF1, aF2, theContext); + return bRet; + } + // + else { + NMTTools_ListOfCoupleOfShape aLCFF; + NMTTools_ListIteratorOfListOfCoupleOfShape aIt; + // + FindFacePairs(theEdge, theLF, aLCFF); + // + aIt.Initialize(aLCFF); + for (; aIt.More(); aIt.Next()) { + const NMTTools_CoupleOfShape& aCSFF=aIt.Value(); + // + const TopoDS_Face& aF1=TopoDS::Face(aCSFF.Shape1()); + const TopoDS_Face& aF2=TopoDS::Face(aCSFF.Shape2()); + bRet=GEOMAlgo_Tools3D::IsInternalFace(theFace, theEdge, aF1, aF2, theContext); + if (bRet) { + return bRet; + } + } + } + return bRet; +} +//======================================================================= +//function : IsInternalFace +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_Tools3D::IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace1, + const TopoDS_Face& theFace2, + const Handle(IntTools_Context)& theContext) +{ + Standard_Boolean bRet; + Standard_Real aT1, aT2, aT, aDt2D, aDt2Dx; + Standard_Real aA12, aA1x, aTwoPI; + gp_Pnt aPx, aPF, aPF1, aPF2; + gp_Pnt2d aP2D, aPF2D; + gp_Dir aDNF1, aDNF2; + TopoDS_Edge aE1, aE2; + Handle(Geom_Curve)aC3D; + // + aC3D =BRep_Tool::Curve(theEdge, aT1, aT2); + aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); + aC3D->D0(aT, aPx); + // + // 1. PF + aDt2D=BOPTools_Tools3D::MinStepIn2d(); + aDt2Dx=10.*aDt2D; + BOPTools_Tools3D::PointNearEdge (theEdge, theFace, aT, aDt2Dx, aPF2D, aPF); + // + // 2. E1, E2 + GEOMAlgo_Tools3D::GetEdgeOnFace(theEdge, theFace1, aE1); + if (aE1.Orientation()==TopAbs_INTERNAL) { + aE2=aE1; + aE1.Orientation(TopAbs_FORWARD); + aE2.Orientation(TopAbs_REVERSED); + } + else if (theFace1==theFace2) { + aE2=aE1; + aE1.Orientation(TopAbs_FORWARD); + aE2.Orientation(TopAbs_REVERSED); + } + else { + GEOMAlgo_Tools3D::GetEdgeOnFace(theEdge, theFace2, aE2); + } + // + // 3 + bRet=Standard_False; + // + GetApproxNormalToFaceOnEdge (aE1, theFace1, aT, aPF1, aDNF1, theContext); + GetApproxNormalToFaceOnEdge (aE2, theFace2, aT, aPF2, aDNF2, theContext); + // + aTwoPI = 2.*M_PI; + gp_Vec aVBF (aPx, aPF ); + gp_Vec aVBF1(aPx, aPF1); + gp_Vec aVBF2(aPx, aPF2); + // + gp_Dir aDTF1; + gp_Dir aDBF (aVBF); + gp_Dir aDBF1(aVBF1); + gp_Dir aDBF2(aVBF2); + // + aDTF1=aDNF1^aDBF1; + aA12=AngleWithRef(aDBF1, aDBF2, aDTF1); + if (aA12<0.) { + aA12=aA12+aTwoPI; + } + + aA1x=AngleWithRef(aDBF1, aDBF , aDTF1); + if (aA1x<0.) { + aA1x=aA1x+aTwoPI; + } + // + if (aA1xD0(aT, aP3D); + } + // + aState=GEOMAlgo_Tools3D::ComputeState(aP3D, theRef, theTol, theCtx); + // + return aState; +} +//======================================================================= +// function: ComputeState +// purpose: +//======================================================================= + TopAbs_State GEOMAlgo_Tools3D::ComputeState(const gp_Pnt& theP, + const TopoDS_Solid& theRef, + const Standard_Real theTol, + const Handle(IntTools_Context)& theCtx) +{ + TopAbs_State aState; + // + BRepClass3d_SolidClassifier& aSC=theCtx->SolidClassifier(theRef); + aSC.Perform(theP, theTol); + // + aState=aSC.State(); + // + return aState; +} +//======================================================================= +// function: IsSplitToReverse +// purpose: +//======================================================================= + Standard_Boolean GEOMAlgo_Tools3D::IsSplitToReverse(const TopoDS_Shape& theSp, + const TopoDS_Shape& theSr, + const Handle(IntTools_Context)& theCtx) +{ + Standard_Boolean bRet; + TopAbs_ShapeEnum aType; + // + bRet=Standard_False; + // + aType=theSp.ShapeType(); + switch (aType) { + case TopAbs_EDGE: { + const TopoDS_Edge& aESp=TopoDS::Edge(theSp); + const TopoDS_Edge& aESr=TopoDS::Edge(theSr); + bRet=GEOMAlgo_Tools3D::IsSplitToReverse(aESp, aESr, theCtx); + } + break; + // + case TopAbs_FACE: { + const TopoDS_Face& aFSp=TopoDS::Face(theSp); + const TopoDS_Face& aFSr=TopoDS::Face(theSr); + bRet=GEOMAlgo_Tools3D::IsSplitToReverse(aFSp, aFSr, theCtx); + } + break; + // + default: + break; + } + return bRet; +} +//======================================================================= +//function :IsSplitToReverse +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_Tools3D::IsSplitToReverse(const TopoDS_Face& theFSp, + const TopoDS_Face& theFSr, + const Handle(IntTools_Context)& theContext) +{ + Standard_Boolean bRet, bFound, bInFace; + Standard_Real aT1, aT2, aT, aU, aV, aScPr; + gp_Pnt aPFSp, aPFSr; + gp_Dir aDNFSp; + gp_Vec aD1U, aD1V; + Handle(Geom_Surface) aSr, aSp; + TopAbs_Orientation aOrSr, aOrSp; + TopExp_Explorer anExp; + TopoDS_Edge aESp; + // + bRet=Standard_False; + // + aSr=BRep_Tool::Surface(theFSr); + aSp=BRep_Tool::Surface(theFSp); + if (aSr==aSp) { + aOrSr=theFSr.Orientation(); + aOrSp=theFSp.Orientation(); + bRet=(aOrSr!=aOrSp); + return bRet; + } + // + bFound=Standard_False; + anExp.Init(theFSp, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + aESp=TopoDS::Edge(anExp.Current()); + if (!BRep_Tool::Degenerated(aESp)) { + if (!BRep_Tool::IsClosed(aESp, theFSp)) { + bFound=!bFound; + break; + } + } + } + // + //modified by NIZNHY-PKV Tue Nov 22 10:50:30 2011f + if (!bFound) { + Standard_Boolean bFlag; + Standard_Integer iErr; + gp_Pnt2d aP2DFSp; + // + iErr=GEOMAlgo_Tools3D::PntInFace(theFSp, aPFSp, aP2DFSp); + if (iErr) { + return bRet; + } + // + aP2DFSp.Coord(aU, aV); + bFlag=BOPTools_Tools3D::GetNormalToSurface(aSp, aU, aV, aDNFSp); + if (!bFlag) { + return bRet; + } + } + else { + BRep_Tool::Range(aESp, aT1, aT2); + aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); + BOPTools_Tools3D::GetApproxNormalToFaceOnEdge(aESp, theFSp, aT, aPFSp, aDNFSp); + } + // + /* + if (!bFound) { + return bRet; + } + BRep_Tool::Range(aESp, aT1, aT2); + aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2); + BOPTools_Tools3D::GetApproxNormalToFaceOnEdge(aESp, theFSp, aT, aPFSp, aDNFSp); + */ + //modified by NIZNHY-PKV Tue Nov 22 10:50:37 2011t + // + // Parts of theContext.ComputeVS(..) + GeomAPI_ProjectPointOnSurf& aProjector=theContext->ProjPS(theFSr); + aProjector.Perform(aPFSp); + if (!aProjector.IsDone()) { + return bRet; + } + // + aProjector.LowerDistanceParameters(aU, aV); + gp_Pnt2d aP2D(aU, aV); + bInFace=theContext->IsPointInFace (theFSr, aP2D); + if (!bInFace) { + return bRet; + } + // + aSr->D1(aU, aV, aPFSr, aD1U, aD1V); + gp_Dir aDD1U(aD1U); + gp_Dir aDD1V(aD1V); + gp_Dir aDNFSr=aDD1U^aDD1V; + if (theFSr.Orientation()==TopAbs_REVERSED){ + aDNFSr.Reverse(); + } + // + aScPr=aDNFSp*aDNFSr; + bRet=(aScPr<0.); + // + return bRet; +} +//======================================================================= +//function :IsSplitToReverse +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_Tools3D::IsSplitToReverse(const TopoDS_Edge& theSplit, + const TopoDS_Edge& theEdge, + const Handle(IntTools_Context)& theContext) +{ + Standard_Boolean bRet, aFlag, bIsDegenerated; + Standard_Real aTE, aTS, aScPr, aTa, aTb, aT1, aT2; + TopAbs_Orientation aOrSr, aOrSp; + Handle(Geom_Curve) aCEdge, aCSplit; + gp_Vec aVE, aVS; + gp_Pnt aP; + // + bRet=Standard_False; + // + bIsDegenerated=(BRep_Tool::Degenerated(theSplit) || + BRep_Tool::Degenerated(theEdge)); + if (bIsDegenerated) { + return bRet; + } + // + aCEdge =BRep_Tool::Curve(theEdge , aT1, aT2); + aCSplit=BRep_Tool::Curve(theSplit, aTa, aTb); + // + if (aCEdge==aCSplit) { + aOrSr=theEdge.Orientation(); + aOrSp=theSplit.Orientation(); + bRet=(aOrSr!=aOrSp); + return bRet; + } + // + aTS=BOPTools_Tools2D::IntermediatePoint(aTa, aTb); + aCSplit->D0(aTS, aP); + aFlag=BOPTools_Tools2D::EdgeTangent(theSplit, aTS, aVS); + gp_Dir aDTS(aVS); + // + aFlag=theContext->ProjectPointOnEdge(aP, theEdge, aTE); + aFlag=BOPTools_Tools2D::EdgeTangent(theEdge, aTE, aVE); + gp_Dir aDTE(aVE); + // + aScPr=aDTS*aDTE; + bRet=(aScPr<0.); + // + return bRet; +} + +//======================================================================= +// function: Sense +// purpose: +//======================================================================= + Standard_Integer GEOMAlgo_Tools3D::Sense (const TopoDS_Face& theF1, + const TopoDS_Face& theF2) +{ + Standard_Integer iSense=0; + gp_Dir aDNF1, aDNF2; + TopoDS_Edge aE1, aE2; + TopExp_Explorer anExp; + // + anExp.Init(theF1, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + aE1=TopoDS::Edge(anExp.Current()); + if (!BRep_Tool::Degenerated(aE1)) { + if (!BRep_Tool::IsClosed(aE1, theF1)) { + break; + } + } + } + // + anExp.Init(theF2, TopAbs_EDGE); + for (; anExp.More(); anExp.Next()) { + aE2=TopoDS::Edge(anExp.Current()); + if (!BRep_Tool::Degenerated(aE2)) { + if (!BRep_Tool::IsClosed(aE2, theF2)) { + if (aE2.IsSame(aE1)) { + iSense=1; + break; + } + } + } + } + // + if (!iSense) { + return iSense; + } + // + BOPTools_Tools3D::GetNormalToFaceOnEdge(aE1, theF1, aDNF1); + BOPTools_Tools3D::GetNormalToFaceOnEdge(aE2, theF2, aDNF2); + // + iSense=BOPTools_Tools3D::SenseFlag(aDNF1, aDNF2); + // + return iSense; +} +//======================================================================= +// function: CopyFace +// purpose: +//======================================================================= + void GEOMAlgo_Tools3D::CopyFace (const TopoDS_Face& theF1, + TopoDS_Face& theF2) +{ + Standard_Real aTol; + TopLoc_Location aLoc; + TopAbs_Orientation aOr; + TopoDS_Iterator aIt; + BRep_Builder aBB; + // + Handle(Geom_Surface) aSurface=BRep_Tool::Surface(theF1, aLoc); + aTol=BRep_Tool::Tolerance(theF1); + aOr=theF1.Orientation(); + // + aBB.MakeFace (theF2, aSurface, aLoc, aTol); + theF2.Orientation(aOr); + // + aIt.Initialize(theF1); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aW=aIt.Value(); + aBB.Add(theF2, aW); + } +} +//======================================================================= +// function: MakeContainer +// purpose: +//======================================================================= + void GEOMAlgo_Tools3D::MakeContainer(const TopAbs_ShapeEnum theType, + TopoDS_Shape& theC) +{ + BRep_Builder aBB; + // + switch(theType) { + case TopAbs_COMPOUND:{ + TopoDS_Compound aC; + aBB.MakeCompound(aC); + theC=aC; + } + break; + // + case TopAbs_COMPSOLID:{ + TopoDS_CompSolid aCS; + aBB.MakeCompSolid(aCS); + theC=aCS; + } + break; + // + case TopAbs_SOLID:{ + TopoDS_Solid aSolid; + aBB.MakeSolid(aSolid); + theC=aSolid; + } + break; + // + // + case TopAbs_SHELL:{ + TopoDS_Shell aShell; + aBB.MakeShell(aShell); + theC=aShell; + } + break; + // + case TopAbs_WIRE: { + TopoDS_Wire aWire; + aBB.MakeWire(aWire); + theC=aWire; + } + break; + // + default: + break; + } +} +//======================================================================= +// function: MakeConnexityBlock. +// purpose: +//======================================================================= + void GEOMAlgo_Tools3D::MakeConnexityBlock (const TopTools_ListOfShape& theLFIn, + const TopTools_IndexedMapOfShape& theMEAvoid, + TopTools_ListOfShape& theLCB) +{ + Standard_Integer aNbF, aNbAdd1; + TopExp_Explorer aExp; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + TopTools_MapIteratorOfMapOfShape aItM, aItM1; + TopTools_MapOfShape aMCB, aMAdd, aMAdd1; + TopTools_ListIteratorOfListOfShape aIt; + // + // 1. aMEF + aNbF=theLFIn.Extent(); + aIt.Initialize(theLFIn); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aF=aIt.Value(); + TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + // + // 2. aMCB + const TopoDS_Shape& aF1=theLFIn.First(); + aMAdd.Add(aF1); + // + while(1) { + aMAdd1.Clear(); + aItM.Initialize(aMAdd); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + // + //aMAdd1.Clear(); + aExp.Init(aF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aE=aExp.Current(); + if (theMEAvoid.Contains(aE)){ + continue; + } + // + const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE); + aIt.Initialize(aLF); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aFx=aIt.Value(); + if (aFx.IsSame(aF)) { + continue; + } + if (aMCB.Contains(aFx)) { + continue; + } + aMAdd1.Add(aFx); + } + }//for (; aExp.More(); aExp.Next()){ + aMCB.Add(aF); + }// for (; aItM.More(); aItM.Next()) { + // + aNbAdd1=aMAdd1.Extent(); + if (!aNbAdd1) { + break; + } + // + aMAdd.Clear(); + aItM1.Initialize(aMAdd1); + for (; aItM1.More(); aItM1.Next()) { + const TopoDS_Shape& aFAdd=aItM1.Key(); + aMAdd.Add(aFAdd); + } + // + }//while(1) { + + // + aNbF=aMCB.Extent(); + aItM.Initialize(aMCB); + for (; aItM.More(); aItM.Next()) { + const TopoDS_Shape& aF=aItM.Key(); + theLCB.Append(aF); + } +} +//======================================================================= +//function : FindFacePairs +//purpose : +//======================================================================= +Standard_Boolean FindFacePairs (const TopoDS_Edge& theE, + const TopTools_ListOfShape& thLF, + NMTTools_ListOfCoupleOfShape& theLCFF) +{ + Standard_Boolean bFound; + Standard_Integer i, aNbCEF; + TopAbs_Orientation aOr, aOrC; + TopTools_MapOfShape aMFP; + TopoDS_Face aF1, aF2; + TopoDS_Edge aEL, aE1; + TopTools_ListIteratorOfListOfShape aItLF; + NMTTools_CoupleOfShape aCEF, aCFF; + NMTTools_ListOfCoupleOfShape aLCEF, aLCEFx; + NMTTools_ListIteratorOfListOfCoupleOfShape aIt; + // + bFound=Standard_True; + // + // Preface aLCEF + aItLF.Initialize(thLF); + for (; aItLF.More(); aItLF.Next()) { + const TopoDS_Face& aFL=TopoDS::Face(aItLF.Value()); + // + bFound=GEOMAlgo_Tools3D::GetEdgeOnFace(theE, aFL, aEL); + if (!bFound) { + return bFound; // it can not be so + } + // + aCEF.SetShape1(aEL); + aCEF.SetShape2(aFL); + aLCEF.Append(aCEF); + } + // + aNbCEF=aLCEF.Extent(); + while(aNbCEF) { + // + // aLCEFx + aLCEFx.Clear(); + aIt.Initialize(aLCEF); + for (i=0; aIt.More(); aIt.Next(), ++i) { + const NMTTools_CoupleOfShape& aCSx=aIt.Value(); + const TopoDS_Shape& aEx=aCSx.Shape1(); + const TopoDS_Shape& aFx=aCSx.Shape2(); + // + aOr=aEx.Orientation(); + // + if (!i) { + aOrC=TopAbs::Reverse(aOr); + aE1=TopoDS::Edge(aEx); + aF1=TopoDS::Face(aFx); + aMFP.Add(aFx); + continue; + } + // + if (aOr==aOrC) { + aLCEFx.Append(aCSx); + aMFP.Add(aFx); + } + } + // + // F2 + GEOMAlgo_Tools3D::GetFaceOff(aE1, aF1, aLCEFx, aF2); + // + aCFF.SetShape1(aF1); + aCFF.SetShape2(aF2); + theLCFF.Append(aCFF); + // + aMFP.Add(aF1); + aMFP.Add(aF2); + // + // refine aLCEF + aLCEFx.Clear(); + aLCEFx=aLCEF; + aLCEF.Clear(); + aIt.Initialize(aLCEFx); + for (; aIt.More(); aIt.Next()) { + const NMTTools_CoupleOfShape& aCSx=aIt.Value(); + const TopoDS_Shape& aFx=aCSx.Shape2(); + if (!aMFP.Contains(aFx)) { + aLCEF.Append(aCSx); + } + } + // + aNbCEF=aLCEF.Extent(); + }//while(aNbCEF) { + // + return bFound; +} +// +//======================================================================= +//function : AngleWithRef +//purpose : +//======================================================================= +Standard_Real AngleWithRef(const gp_Dir& theD1, + const gp_Dir& theD2, + const gp_Dir& theDRef) +{ + Standard_Real aCosinus, aSinus, aBeta, aHalfPI, aScPr; + gp_XYZ aXYZ; + // + aHalfPI=0.5*M_PI; + // + const gp_XYZ& aXYZ1=theD1.XYZ(); + const gp_XYZ& aXYZ2=theD2.XYZ(); + aXYZ=aXYZ1.Crossed(aXYZ2); + aSinus=aXYZ.Modulus(); + aCosinus=theD1*theD2; + // + aBeta=0.; + if (aSinus>=0.) { + aBeta=aHalfPI*(1.-aCosinus); + } + else { + aBeta=2.*M_PI-aHalfPI*(3.+aCosinus); + } + // + aScPr=aXYZ.Dot(theDRef.XYZ()); + if (aScPr<0.) { + aBeta=-aBeta; + } + return aBeta; +} +//======================================================================= +//function : GetApproxNormalToFaceOnEdge +//purpose : +//======================================================================= +void GetApproxNormalToFaceOnEdge (const TopoDS_Edge& aEx, + const TopoDS_Face& aFx, + Standard_Real aT, + gp_Pnt& aPF, + gp_Dir& aDNF, + const Handle(IntTools_Context)& aCtx) +{ + Standard_Boolean bReverse; + Standard_Real aT1, aT2, dT, aU, aV; + gp_Dir aDTT, aDNFT, aDBT; + gp_Pnt aPFT, aPFx; + Handle(Geom_Curve) aC3D; + Handle(Geom_Surface) aS; + GeomAdaptor_Surface aGAS; + GeomAbs_SurfaceType aTS; + TopoDS_Face aF; + TopoDS_Edge aE; + // + bReverse=Standard_False; + aF=aFx; + aE=aEx; + if (aF.Orientation()==TopAbs_REVERSED){ + bReverse=!bReverse; + aE.Reverse(); + // + aF.Orientation(TopAbs_FORWARD); + } + // + // Point at aT + aC3D =BRep_Tool::Curve(aE, aT1, aT2); + aC3D->D0(aT, aPFT); + // + // Normal at aT + BOPTools_Tools3D::GetNormalToFaceOnEdge (aE, aF, aT, aDNFT); + + // Tangent at aT + BOPTools_Tools3D::GetTangentToEdge(aE, aT, aDTT); + // + // Binormal at aT + aDBT=aDNFT^aDTT; + // + dT=BOPTools_Tools3D::MinStepIn2d();//~1.e-5; + dT=10.*dT; + //---------------------------------------------- + { + aS=BRep_Tool::Surface(aF); + aGAS.Load(aS); + aTS=aGAS.GetType(); + if (aTS==GeomAbs_BSplineSurface || + aTS==GeomAbs_BezierSurface || + aTS==GeomAbs_Plane){ + Standard_Real aTolEx, aTolFx, aTol, dUR, dVR, dR; + // + aTolEx=BRep_Tool::Tolerance(aEx); + aTolFx=BRep_Tool::Tolerance(aFx); + aTol=2.*aTolEx+aTolFx; + dUR=aGAS.UResolution(aTol); + dVR=aGAS.VResolution(aTol); + dR=(dUR>dVR)? dUR : dVR; + if (dR>dT) { + dT=dR; + } + } + else if (GeomAbs_Torus || + aTS==GeomAbs_Cylinder){ + Standard_Real aTolEx, aTolFx, aTol; + // + aTolEx=BRep_Tool::Tolerance(aEx); + aTolFx=BRep_Tool::Tolerance(aFx); + aTol=2.*aTolEx+aTolFx; + if (aTol>dT) { + dT=aTol; + } + } + } + //---------------------------------------------- + // + aPFx.SetXYZ(aPFT.XYZ()+dT*aDBT.XYZ()); + // + aPF=aPFx; + aDNF=aDNFT; + if (bReverse) { + aDNF.Reverse(); + } + // + GeomAPI_ProjectPointOnSurf& aProjector=aCtx->ProjPS(aF); + // + aProjector.Perform(aPFx); + if(aProjector.IsDone()) { + aProjector.LowerDistanceParameters (aU, aV); + aS->D0(aU, aV, aPF); + BOPTools_Tools3D::GetNormalToSurface (aS, aU, aV, aDNF); + if (bReverse){ + aDNF.Reverse(); + } + } +} + +//modified by NIZNHY-PKV Tue Nov 22 10:36:59 2011f +//======================================================================= +//function : PntInFace +//purpose : +//======================================================================= +Standard_Integer GEOMAlgo_Tools3D::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; +} +//modified by NIZNHY-PKV Tue Nov 22 10:37:01 2011t diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Tools3D.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_Tools3D.hxx new file mode 100644 index 000000000..b62fb00c6 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Tools3D.hxx @@ -0,0 +1,240 @@ +// 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_Tools3D.hxx +// Created : +// Author : Peter KURNEV + +#ifndef _GEOMAlgo_Tools3D_HeaderFile +#define _GEOMAlgo_Tools3D_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//! Auxiliary tools for Algorithms
+//======================================================================= +//class : GEOMAlgo_Tools3D +//purpose : +//======================================================================= +class GEOMAlgo_Tools3D { + public: + //! Returns True if the shape theSplit has opposite
+ //! direction than theShape
+ //! theContext - cashed geometrical tools
+ Standard_EXPORT + static Standard_Boolean IsSplitToReverse(const TopoDS_Shape& theSplit, + const TopoDS_Shape& theShape, + const Handle(IntTools_Context)& theContext) ; + + //! Returns True if normal direction of the face
+ //! theShape is not the same as for the face
+ //! theSplit
+ //! theContext - cashed geometrical tools
+ Standard_EXPORT + static Standard_Boolean IsSplitToReverse(const TopoDS_Face& theSplit, + const TopoDS_Face& theShape, + const Handle(IntTools_Context)& theContext) ; + + //! Returns True if tangent direction of the edge
+ //! theEdge is not the same as for the edge
+ //! theSplit
+ //! theContext - cashed geometrical tools
+ Standard_EXPORT + static Standard_Boolean IsSplitToReverse(const TopoDS_Edge& theEdge, + const TopoDS_Edge& theSplit, + const Handle(IntTools_Context)& theContext) ; + + //! For the couple of faces theF1, theF2
+ //! computes sense value
+ //! Returns 0 if the faces are not sensible
+ //! Returns 1 if the faces have same sense
+ //! Returns 2 if the faces have opposite sense
+ Standard_EXPORT + static Standard_Integer Sense(const TopoDS_Face& theF1, + const TopoDS_Face& theF2) ; + + //! Makes new face theF2 from surface and wires
+ //! of the face theF1
+ Standard_EXPORT + static void CopyFace(const TopoDS_Face& theF1, + TopoDS_Face& theF2) ; + + //! Makes empty shape theShape of the type theType
+ Standard_EXPORT + static void MakeContainer(const TopAbs_ShapeEnum theType, + TopoDS_Shape& theShape) ; + + //! For the list of faces theLS build block
+ //! theLSCB in terms of connexity by edges
+ //! theMapAvoid - set of edges to avoid for
+ //! the treatment
+ Standard_EXPORT + static void MakeConnexityBlock(const TopTools_ListOfShape& theLS, + const TopTools_IndexedMapOfShape& theMapAvoid, + TopTools_ListOfShape& theLSCB) ; + + //! Computes the 3-D state of the shape theShape
+ //! toward solid theSolid.
+ //! theTol - value of precision of computation
+ //! theContext- cahed geometrical tools
+ //! Returns 3-D state.
+ Standard_EXPORT + static TopAbs_State ComputeStateByOnePoint(const TopoDS_Shape& theShape, + const TopoDS_Solid& theSolid, + const Standard_Real theTol, + const Handle(IntTools_Context)& theContext) ; + + //! Computes the 3-D state of the point thePoint
+ //! toward solid theSolid.
+ //! theTol - value of precision of computation
+ //! theContext- cahed geometrical tools
+ //! Returns 3-D state.
+ Standard_EXPORT + static TopAbs_State ComputeState(const gp_Pnt& thePoint, + const TopoDS_Solid& theSolid, + const Standard_Real theTol, + const Handle(IntTools_Context)& theContext) ; + + //! Computes the 3-D state of the vertex theVertex
+ //! toward solid theSolid.
+ //! theTol - value of precision of computation
+ //! theContext- cahed geometrical tools
+ //! Returns 3-D state.
+ Standard_EXPORT + static TopAbs_State ComputeState(const TopoDS_Vertex& theVertex, + const TopoDS_Solid& theSolid, + const Standard_Real theTol, + const Handle(IntTools_Context)& theContext) ; + + //! Computes the 3-D state of the edge theEdge
+ //! toward solid theSolid.
+ //! theTol - value of precision of computation
+ //! theContext- cahed geometrical tools
+ //! Returns 3-D state.
+ Standard_EXPORT + static TopAbs_State ComputeState(const TopoDS_Edge& theEdge, + const TopoDS_Solid& theSolid, + const Standard_Real theTol, + const Handle(IntTools_Context)& theContext) ; + + //! Computes the 3-D state of the face theFace
+ //! toward solid theSolid.
+ //! theTol - value of precision of computation
+ //! theBounds - set of edges of theFace to avoid
+ //! theContext- cahed geometrical tools
+ //! Returns 3-D state.
+ Standard_EXPORT + static TopAbs_State ComputeState(const TopoDS_Face& theFace, + const TopoDS_Solid& theSolid, + const Standard_Real theTol, + const TopTools_IndexedMapOfShape& theBounds, + const Handle(IntTools_Context)& theContext) ; + + //! Returns True if the face theFace is inside of the
+ //! couple of faces theFace1, theFace2.
+ //! The faces theFace, theFace1, theFace2 must
+ //! share the edge theEdge
+ Standard_EXPORT + static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace1, + const TopoDS_Face& theFace2, + const Handle(IntTools_Context)& theContext) ; + + //! Returns True if the face theFace is inside of the
+ //! appropriate couple of faces (from the set theLF) .
+ //! The faces of the set theLF and theFace must
+ //! share the edge theEdge
+ Standard_EXPORT + static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Edge& theEdge, + const TopTools_ListOfShape& theLF, + const Handle(IntTools_Context)& theContext) ; + + //! Returns True if the face theFace is inside the
+ //! solid theSolid.
+ //! theMEF - Map Edge/Faces for theSolid
+ //! theTol - value of precision of computation
+ //! theContext- cahed geometrical tools
+ Standard_EXPORT + static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace, + const TopoDS_Solid& theSolid, + const TopTools_IndexedDataMapOfShapeListOfShape& theMEF, + const Standard_Real theTol, + const Handle(IntTools_Context)& theContext) ; + + //! For the face theFace and its edge theEdge
+ //! finds the face suitable to produce shell.
+ //! theLCEF - set of faces to search. All faces
+ //! from theLCEF must share edge theEdge
+ Standard_EXPORT + static void GetFaceOff(const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + const NMTTools_ListOfCoupleOfShape& theLCEF, + TopoDS_Face& theFaceOff) ; + + //! For the face theFace gets the edge theEdgeOnF
+ //! that is the same as theEdge
+ //! Returns True if such edge exists
+ //! Returns False if there is no such edge
+ Standard_EXPORT + static Standard_Boolean GetEdgeOnFace(const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + TopoDS_Edge& theEdgeOnF) ; + + //! Returns True if the face theFace contains
+ //! the edge theEdge but with opposite orientation.
+ //! If the method returns True theEdgeOff is the
+ //! edge founded
+ Standard_EXPORT + static Standard_Boolean GetEdgeOff(const TopoDS_Edge& theEdge, + const TopoDS_Face& theFace, + TopoDS_Edge& theEdgeOff) ; + + //! Computes a point inside the face .
+ //! - 2D representation of
+ //! on the surface of
+ //! Returns 0 in case of success.
+ Standard_EXPORT + static Standard_Integer PntInFace(const TopoDS_Face& theF, + gp_Pnt& theP, + gp_Pnt2d& theP2D) ; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_Tools_1.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_Tools_1.cxx new file mode 100644 index 000000000..2ad9095e2 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_Tools_1.cxx @@ -0,0 +1,341 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_Tools_1.cxx +// Created: Thu May 6 10:46:21 2010 +// 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 + +static + inline Standard_Boolean IsEqual(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) { + return TopTools_ShapeMapHasher::IsEqual(aS1, aS2); +} +// +static + Standard_Boolean CorrectWire(const TopoDS_Wire& aW, + const TopoDS_Face& aF); + +//======================================================================= +//function : CorrectWires +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_Tools::CorrectWires(const TopoDS_Shape& aShape) +{ + Standard_Boolean bRet; + TopoDS_Iterator aItF; + TopExp_Explorer aExp; + TopTools_MapOfShape aMF; + GeomAdaptor_Surface aGAS; + GeomAbs_SurfaceType aTS; + TopLoc_Location aLoc; + // + bRet=Standard_False; + // + aExp.Init(aShape, TopAbs_FACE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Face& aF=*((TopoDS_Face*)&aExp.Current()); + if (aMF.Add(aF)) { + const Handle(Geom_Surface)& aS=BRep_Tool::Surface(aF, aLoc); + aGAS.Load(aS); + aTS=aGAS.GetType(); + if (aTS==GeomAbs_Cylinder || aTS==GeomAbs_Plane) { + aItF.Initialize(aF); + for (; aItF.More(); aItF.Next()) { + const TopoDS_Wire& aW=*((TopoDS_Wire*)&aItF.Value()); + if (CorrectWire(aW, aF)) { + bRet=Standard_True; + } + } + } + } + } + return bRet; +} +//======================================================================= +//class: GEOMAlgo_InfoEdge +//purpose : +//======================================================================= +class GEOMAlgo_InfoEdge { + public: + // + GEOMAlgo_InfoEdge() { + myErrorStatus=0; + myTolInt=1.0e-10; + }; + // + ~GEOMAlgo_InfoEdge(){ + }; + // + void Init(const TopoDS_Edge& aE, + const TopoDS_Face& aF); + // + void SetTolInt(const Standard_Real aTolInt) { + myTolInt=aTolInt; + }; + // + const Standard_Real TolInt() const { + return myTolInt; + } + // + const Geom2dAdaptor_Curve& Adaptor() const { + return myGAC2D; + } + // + const IntRes2d_Domain& Domain()const { + return myDomain; + } + // + const Handle(Geom2d_Curve)& CurveOnSurface()const { + return myC2D; + } + // + const Handle(Geom_Curve)& Curve()const { + return myC3D; + } + // + Standard_Integer ErrorStatus()const { + return myErrorStatus; + } + // + protected: + Standard_Integer myErrorStatus; + Standard_Real myTolInt; + Geom2dAdaptor_Curve myGAC2D; + IntRes2d_Domain myDomain; + Handle(Geom2d_Curve) myC2D; + Handle(Geom_Curve) myC3D; +}; +// +typedef NCollection_DataMap GEOMAlgo_DataMapOfShapeInfoEdge; +typedef GEOMAlgo_DataMapOfShapeInfoEdge::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeInfoEdge; + +//======================================================================= +//function : Init +//purpose : +//======================================================================= + void GEOMAlgo_InfoEdge::Init(const TopoDS_Edge& aE, + const TopoDS_Face& aF) +{ + Standard_Real aT1, aT2, aT1x, aT2x; + gp_Pnt2d aP2D1, aP2D2; + // + myErrorStatus=0; + // + myC3D=BRep_Tool::Curve(aE, aT1, aT2); + myC2D=BRep_Tool::CurveOnSurface(aE ,aF, aT1, aT2); + if (!myC2D.IsNull() && aT2>aT1) { + myGAC2D.Load(myC2D); + if(!myGAC2D.IsPeriodic()) { + aT1x=myGAC2D.FirstParameter(); + aT2x=myGAC2D.LastParameter(); + if(aT1x > aT1) { + aT1=aT1x; + } + if(aT2x < aT2) { + aT2=aT2x; + } + } + // + BRep_Tool::UVPoints(aE, aF, aP2D1, aP2D2); + myDomain.SetValues(aP2D1, aT1, myTolInt, aP2D2, aT2, myTolInt); + } + else { + myErrorStatus=10; + return; + } +} +//======================================================================= +//function : CorrectWire +//purpose : +//======================================================================= +Standard_Boolean CorrectWire(const TopoDS_Wire& aW, + const TopoDS_Face& aF) +{ + Standard_Boolean bRet; + Standard_Real aTolInt; + Standard_Integer iErr, aNbV, aNbE; + TopoDS_Iterator aItW, aItE; + Geom2dInt_GInter aInter; + GEOMAlgo_DataMapOfShapeInfoEdge aDMEIE; + TopTools_DataMapOfShapeListOfShape aDMVLE; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMVLE; + // + bRet=Standard_False; + aTolInt=1.0e-10; + // + aItW.Initialize(aW); + for (; aItW.More(); aItW.Next()) { + const TopoDS_Edge& aE=*((TopoDS_Edge*)&aItW.Value()); + + aItE.Initialize(aE); + for (aNbV=0; aItE.More(); aItE.Next(), ++aNbV) { + } + if (aNbV<2) { + return bRet; // + } + // + if (!aDMEIE.IsBound(aE)) { + GEOMAlgo_InfoEdge aInfoEdge; + // + aInfoEdge.Init (aE, aF); + iErr=aInfoEdge.ErrorStatus(); + if (iErr) { + return bRet; // + } + // + aDMEIE.Bind(aE, aInfoEdge); + } + // + aItE.Initialize(aE); + for (; aItE.More(); aItE.Next()) { + const TopoDS_Shape& aV=aItE.Value(); + if (aDMVLE.IsBound(aV)) { + TopTools_ListOfShape& aLE=aDMVLE.ChangeFind(aV); + aLE.Append(aE); + } + else { + TopTools_ListOfShape aLE; + aLE.Append(aE); + aDMVLE.Bind(aV, aLE); + } + } + } + // + // 2 + Standard_Real aTolV, aD1, aD2, aDmax, aCoeff; + gp_Pnt aPV; + Handle(Geom_Surface) aS; + BRep_Builder aBB; + // + aCoeff=1.1; + aS=BRep_Tool::Surface(aF); + // + aItDMVLE.Initialize(aDMVLE); + for(; aItDMVLE.More(); aItDMVLE.Next()) { + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)&aItDMVLE.Key()); + const TopTools_ListOfShape& aLE=aItDMVLE.Value(); + aNbE=aLE.Extent(); + if (aNbE!=2) { + continue; + } + // + aPV=BRep_Tool::Pnt(aV); + aTolV=BRep_Tool::Tolerance(aV); + // + const TopoDS_Edge& aE1=*((TopoDS_Edge*)&aLE.First()); + const GEOMAlgo_InfoEdge& aIE1=aDMEIE.Find(aE1); + const Geom2dAdaptor_Curve& aGAC1=aIE1.Adaptor(); + const IntRes2d_Domain& aDomain1=aIE1.Domain(); + // + const TopoDS_Edge& aE2=*((TopoDS_Edge*)&aLE.Last()); + const GEOMAlgo_InfoEdge& aIE2=aDMEIE.Find(aE2); + const Geom2dAdaptor_Curve& aGAC2=aIE2.Adaptor(); + const IntRes2d_Domain& aDomain2=aIE2.Domain(); + // + aInter.Perform(aGAC1, aDomain1,aGAC2, aDomain2, aTolInt, aTolInt); + if(!aInter.IsDone()) { + continue; + } + // + Standard_Integer i, aNbP; + Standard_Real aIP_ParamOnFirst, aIP_ParamOnSecond; + gp_Pnt aP3D1, aP3D2; + gp_Pnt2d aP2D1, aP2D2; + IntRes2d_Transition aTr1, aTr2; + // + aNbP=aInter.NbPoints(); + for (i=1; i<=aNbP; ++i) { + const IntRes2d_IntersectionPoint& aIP = aInter.Point(i); + aIP_ParamOnFirst = aIP.ParamOnFirst(); + aIP_ParamOnSecond = aIP.ParamOnSecond(); + aTr1 =aIP.TransitionOfFirst(); + aTr2 =aIP.TransitionOfSecond(); + if(aTr1.PositionOnCurve()==IntRes2d_Middle || + aTr2.PositionOnCurve()==IntRes2d_Middle) { + // + const Handle(Geom_Curve)& aC3D1=aIE1.Curve(); + if (!aC3D1.IsNull()) { + aP3D1=aC3D1->Value(aIP_ParamOnFirst); + } + else { + aP2D1=aGAC1.Value(aIP_ParamOnFirst); + aS->D0(aP2D1.X(), aP2D1.Y(), aP3D1); + } + // + const Handle(Geom_Curve)& aC3D2=aIE2.Curve(); + if (!aC3D2.IsNull()) { + aP3D2=aC3D2->Value(aIP_ParamOnSecond); + } + else { + aP2D2=aGAC2.Value(aIP_ParamOnSecond); + aS->D0(aP2D2.X(), aP2D2.Y(), aP3D2); + } + // + aD1=aPV.Distance(aP3D1); + aD2=aPV.Distance(aP3D2); + aDmax=(aD1>aD2)? aD1 : aD2; + if (aDmax>aCoeff*aTolV) { + if (aDmax<10.*aTolV){ + aBB.UpdateVertex(aV, aDmax); + bRet=Standard_True; + } + } + }// + }//for (i=1; i<=aNbP; ++i) { + }//for(; aItDMVLE.More(); aItDMVLE.Next()) { + return bRet; +} + + diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_VertexSolid.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_VertexSolid.cxx new file mode 100644 index 000000000..f1c6743e6 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_VertexSolid.cxx @@ -0,0 +1,239 @@ +// 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_VertexSolid.cxx +// Created: Wed Jan 12 16:36:40 2005 +// 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 + +//======================================================================= +//function : GEOMAlgo_VertexSolid +//purpose : +//======================================================================= +GEOMAlgo_VertexSolid::GEOMAlgo_VertexSolid() +: + GEOMAlgo_ShapeSolid() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_VertexSolid::~GEOMAlgo_VertexSolid() +{ +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= +void GEOMAlgo_VertexSolid::Perform() +{ + myErrorStatus=0; + // + try { + if (myDSFiller==NULL) { + myErrorStatus=10; + return; + } + if(!myDSFiller->IsDone()) { + myErrorStatus=11; + return; + } + // + Standard_Boolean bIsNewFiller; + Standard_Integer aNbF; + TopTools_IndexedMapOfShape aM; + // + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + const TopoDS_Shape& aObj=aDS.Object(); + // + TopExp::MapShapes(aObj, TopAbs_FACE, aM); + aNbF=aM.Extent(); + myRank=(aNbF) ? 2 : 1; + // + bIsNewFiller=myDSFiller->IsNewFiller(); + + if (bIsNewFiller) { + Prepare(); + myDSFiller->SetNewFiller(!bIsNewFiller); + } + BuildResult(); + } + // + catch (Standard_Failure) { + myErrorStatus = 12; + } +} +//======================================================================= +// function: Prepare +// purpose: +//======================================================================= +void GEOMAlgo_VertexSolid::Prepare() +{ + Standard_Integer i, iBeg, iEnd, aNbVV, j, n1, n2, iFound; + Standard_Real aTol; + TopAbs_State aSt; + TopAbs_ShapeEnum aType; + BooleanOperations_StateOfShape aState; + gp_Pnt aP3D; + // + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + BooleanOperations_ShapesDataStructure* pDS=(BooleanOperations_ShapesDataStructure*)&aDS; + const BOPTools_InterferencePool& aIP=myDSFiller->InterfPool(); + BOPTools_InterferencePool* pIP=(BOPTools_InterferencePool*) &aIP; + BOPTools_CArray1OfVVInterference& aVVs=pIP->VVInterferences(); + const BOPTools_PaveFiller& aPF=myDSFiller->PaveFiller(); + BOPTools_PaveFiller* pPF=(BOPTools_PaveFiller*)&aPF; + const Handle(IntTools_Context)& aCtx=pPF->Context(); + // + const TopoDS_Shape& aObj=aDS.Object(); + const TopoDS_Shape& aTool=aDS.Tool(); + // + const TopoDS_Solid& aSolid=(myRank==1) ? TopoDS::Solid(aTool) : TopoDS::Solid(aObj); + // + BRepClass3d_SolidClassifier& aSC=aCtx->SolidClassifier(aSolid); + // + iBeg=1; + iEnd=aDS.NumberOfShapesOfTheObject(); + if (myRank==2) { + iBeg=iEnd+1; + iEnd=aDS.NumberOfSourceShapes(); + } + // + for (i=iBeg; i<=iEnd; ++i) { + aType=aDS.GetShapeType(i); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + const TopoDS_Vertex& aV=TopoDS::Vertex(aDS.Shape(i)); + // + aState=aDS.GetState(i); + if (aState==BooleanOperations_ON || + aState==BooleanOperations_IN || + aState==BooleanOperations_OUT) { + continue; + } + // + iFound=0; + aNbVV=aVVs.Extent(); + for (j=1; j<=aNbVV; ++j) { + BOPTools_VVInterference& aVV=aVVs(j); + aVV.Indices(n1, n2); + if (n1==i || n2==i) { + pDS->SetState (n1, BooleanOperations_ON); + pDS->SetState (n2, BooleanOperations_ON); + iFound=1; + break; + } + } + if (iFound) { + continue; + } + // + aP3D=BRep_Tool::Pnt(aV); + aTol=1.E-7; + aSC.Perform(aP3D, aTol); + aSt=aSC.State(); + if (aSt==TopAbs_IN) { + pDS->SetState (i, BooleanOperations_IN); + } + else if (aSt==TopAbs_OUT) { + pDS->SetState (i, BooleanOperations_OUT); + } + } +} +//======================================================================= +// function: BuildResult +// purpose: +//======================================================================= +void GEOMAlgo_VertexSolid::BuildResult() +{ + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + // + Standard_Integer i, iBeg, iEnd; + TopAbs_ShapeEnum aType; + BooleanOperations_StateOfShape aState; + // + myLSIN.Clear(); + myLSOUT.Clear(); + myLSON.Clear(); + // + iBeg=1; + iEnd=aDS.NumberOfShapesOfTheObject(); + if (myRank==2) { + iBeg=iEnd+1; + iEnd=aDS.NumberOfSourceShapes(); + } + // + for (i=iBeg; i<=iEnd; ++i) { + aType=aDS.GetShapeType(i); + if (aType!=TopAbs_VERTEX) { + continue; + } + const TopoDS_Shape& aV=aDS.Shape(i); + aState=aDS.GetState(i); + // + if (aState==BooleanOperations_IN) { + myLSIN.Append(aV); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aV); + } + else if (aState==BooleanOperations_ON) { + myLSON.Append(aV); + } + } +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_VertexSolid.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_VertexSolid.hxx new file mode 100644 index 000000000..84dc807ad --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_VertexSolid.hxx @@ -0,0 +1,58 @@ +// 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_VertexSolid.hxx +// Created: Wed Jan 12 16:36:40 2005 +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_VertexSolid_HeaderFile +#define _GEOMAlgo_VertexSolid_HeaderFile + +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_VertexSolid +//purpose : +//======================================================================= +class GEOMAlgo_VertexSolid : public GEOMAlgo_ShapeSolid +{ + public: + Standard_EXPORT + GEOMAlgo_VertexSolid(); + + Standard_EXPORT + virtual ~GEOMAlgo_VertexSolid(); + + Standard_EXPORT + virtual void Perform() ; + +protected: + Standard_EXPORT + virtual void Prepare() ; + + Standard_EXPORT + virtual void BuildResult() ; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WESCorrector.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_WESCorrector.cxx new file mode 100644 index 000000000..05356acc4 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WESCorrector.cxx @@ -0,0 +1,434 @@ +// 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: NMTAlgo_WESCorrector.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 + +static + void MakeWire(const TopTools_ListOfShape& aLE, + TopoDS_Wire& newWire); + + +static + Standard_Boolean IsToScale(const TopoDS_Face& aF, + Standard_Real& aScale); + +//======================================================================= +// function: +// purpose: +//======================================================================= + GEOMAlgo_WESCorrector::GEOMAlgo_WESCorrector() +: + GEOMAlgo_Algo() +{ +} +//======================================================================= +// function: ~ +// purpose: +//======================================================================= + GEOMAlgo_WESCorrector::~GEOMAlgo_WESCorrector() +{ +} +//======================================================================= +// function: SetWES +// purpose: +//======================================================================= + void GEOMAlgo_WESCorrector::SetWES (const GEOMAlgo_WireEdgeSet& aWES) +{ + GEOMAlgo_WireEdgeSet* pWES=(GEOMAlgo_WireEdgeSet*) &aWES; + myWES=pWES; +} +//======================================================================= +// function: WES +// purpose: +//======================================================================= + GEOMAlgo_WireEdgeSet& GEOMAlgo_WESCorrector::WES () +{ + return *myWES; +} +//======================================================================= +// function: NewWES +// purpose: +//======================================================================= + GEOMAlgo_WireEdgeSet& GEOMAlgo_WESCorrector::NewWES () +{ + return myNewWES; +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= + void GEOMAlgo_WESCorrector::Perform() +{ + myErrorStatus=0; + // + DoConnexityBlocks(); + DoCorrections(); +} +//======================================================================= +// function: DoConnexityBlocks +// purpose: +//======================================================================= + void GEOMAlgo_WESCorrector::DoConnexityBlocks() +{ + Standard_Boolean bRegular, bClosed; + Standard_Integer i, aNbV, j, aNbC, aNbVP, aNbVS; + TopTools_ListIteratorOfListOfShape aIt; + TopoDS_Iterator aItE; + TopoDS_Shape aER; + TopTools_IndexedMapOfShape aMER, aMEP, aMEC, aMVP; + TopTools_IndexedMapOfShape aMVS, aMVAdd; + TopTools_IndexedDataMapOfShapeListOfShape aMVE; + // + // 1. aMVE; + const TopTools_ListOfShape& aLSE=myWES->StartElements(); + aIt.Initialize(aLSE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (!aMEP.Contains(aE)) { + aMEP.Add(aE); + TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE); + } + else { + aMER.Add(aE); + } + } + // + // 2. + aNbV=aMVE.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMVE.FindKey(i); + // + aNbVS=aMVS.Extent(); + if (aNbVS==aNbV) { + break; + } + // + if (aMVS.Contains(aV)) { + continue; + } + aMVS.Add(aV); // aMVS - globally processed vertices + // + //------------------------------------- goal: aMEC + aMEC.Clear(); // aMEC - edges of CB + aMVP.Clear(); // aMVP - vertices to process right now + aMVAdd.Clear(); // aMVAdd vertices to process on next step of while(1) + // + aMVP.Add(aV); + // + while(1) { + aNbVP=aMVP.Extent(); + for (j=1; j<=aNbVP; ++j) { + const TopoDS_Shape& aVP=aMVP(j); + const TopTools_ListOfShape& aLE=aMVE.FindFromKey(aVP); + aIt.Initialize(aLE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + if (aMEC.Contains(aE)) { + continue; + } + aMEC.Add(aE); + // + aItE.Initialize(aE); + for (; aItE.More(); aItE.Next()) { + const TopoDS_Shape& aVE=aItE.Value(); + if (!aMVS.Contains(aVE)) { + aMVS.Add(aVE); + aMVAdd.Add(aVE); + } + } + } + }//for (j=1; j<=aNbVP; ++j) + // + aNbVP=aMVAdd.Extent(); + if (!aNbVP) { + break; // from while(1) + } + // + aMVP.Clear(); + for (j=1; j<=aNbVP; ++j) { + const TopoDS_Shape& aVE=aMVAdd(j); + aMVP.Add(aVE); + } + aMVAdd.Clear(); + }// while(1) { + //------------------------------------- + BOP_ConnexityBlock aCB; + TopTools_ListOfShape aLEC; + TopTools_IndexedDataMapOfShapeListOfShape aMVER; + // + bRegular=Standard_True; + + aNbC=aMEC.Extent(); + for (j=1; j<=aNbC; ++j) { + aER=aMEC(j); + // + if (aMER.Contains(aER)) { + aER.Orientation(TopAbs_FORWARD); + aLEC.Append(aER); + aER.Orientation(TopAbs_REVERSED); + aLEC.Append(aER); + // + bRegular=Standard_False; + } + else { + aLEC.Append(aER); + } + // + if (bRegular) { + //modified by NIZNHY-PKV Wed Oct 20 14:45:52 2010f + const TopoDS_Edge& aEx=*((TopoDS_Edge*)&aER); + if (!BRep_Tool::Degenerated(aEx)) { + TopExp::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER); + } + // + //TopExp::MapShapesAndAncestors(aER, TopAbs_VERTEX, TopAbs_EDGE, aMVER); + //modified by NIZNHY-PKV Wed Oct 20 14:46:48 2010t + } + }//for (j=1; j<=aNbC; ++j) { + // + if (bRegular) { + Standard_Integer k, aNbVR, aNbER; + // + aNbVR=aMVER.Extent(); + for (k=1; k<=aNbVR; ++k) { + const TopTools_ListOfShape& aLER=aMVER(k); + aNbER=aLER.Extent(); + if (aNbER==1) { + const TopoDS_Edge& aEx=TopoDS::Edge(aER); + bClosed=BRep_Tool::IsClosed(aEx, myWES->Face()); + if (!bClosed) { + bRegular=!bRegular; + break; + } + } + if (aNbER>2) { + bRegular=!bRegular; + break; + } + } + } + // + aCB.SetShapes(aLEC); + aCB.SetRegularity(bRegular); + myConnexityBlocks.Append(aCB); + aMEC.Clear(); + }//for (i=1; i<=aNbV; ++i) { +} + +//======================================================================= +// function: DoCorrections +// purpose: +//======================================================================= + void GEOMAlgo_WESCorrector::DoCorrections() +{ + Standard_Boolean bIsRegular, bIsNothingToDo, bToScale; + Standard_Integer iErr; + Standard_Real aScale; + TopoDS_Wire aW; + BOP_ListIteratorOfListOfConnexityBlock aCBIt; + GEOMAlgo_WESScaler aWSC; + // + const TopoDS_Face& aF=myWES->Face(); + // + bToScale=IsToScale(aF, aScale); + // + myNewWES.SetFace(aF); + aCBIt.Initialize(myConnexityBlocks); + for (; aCBIt.More(); aCBIt.Next()) { + const BOP_ConnexityBlock& aCB=aCBIt.Value(); + const TopTools_ListOfShape& aLE=aCB.Shapes(); + // + bIsRegular=aCB.IsRegular(); + if (bIsRegular) { + MakeWire(aLE, aW); + myNewWES.AddShape (aW); + continue; + } + // + GEOMAlgo_WireSplitter aWS; + // + if(bToScale) { + TopoDS_Shape aE; + TopTools_ListIteratorOfListOfShape aIt; + BOPTColStd_ListIteratorOfListOfListOfShape aItLLSS; + // + aWSC.SetScale(aScale); + aWSC.SetFace(aF); + aWSC.SetEdges(aLE); + // + aWSC.Perform(); + iErr=aWSC.ErrorStatus(); + if (iErr) { + return; + } + // + const TopoDS_Face& aFS=aWSC.FaceScaled(); + const TopTools_ListOfShape& aLES=aWSC.EdgesScaled(); + // + aWS.SetFace(aFS); + aWS.SetEdges(aLES); + // + aWS.Perform(); + iErr=aWS.ErrorStatus(); + if (iErr) { + continue; + } + // + bIsNothingToDo=aWS.IsNothingToDo(); + if (bIsNothingToDo) { + MakeWire(aLE, aW); + myNewWES.AddShape (aW); + continue; + } + // + const BOPTColStd_ListOfListOfShape& aLLSS=aWS.Shapes(); + aItLLSS.Initialize(aLLSS); + for (; aItLLSS.More(); aItLLSS.Next()) { + TopTools_ListOfShape aLS; + // + const TopTools_ListOfShape& aLSS=aItLLSS.Value(); + aIt.Initialize(aLSS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aES=aIt.Value(); + aE=aWSC.Origin(aES); + aLS.Append(aE); + } + // + MakeWire(aLS, aW); + myNewWES.AddShape (aW); + } + }//if(bToScale) + // + else { + aWS.SetFace(aF); + aWS.SetEdges(aLE); + // + aWS.Perform(); + iErr=aWS.ErrorStatus(); + if (iErr) { + continue; + } + bIsNothingToDo=aWS.IsNothingToDo(); + if (bIsNothingToDo) { + MakeWire(aLE, aW); + myNewWES.AddShape (aW); + continue; + } + // + const BOPTColStd_ListOfListOfShape& aSSS=aWS.Shapes(); + + BOPTColStd_ListIteratorOfListOfListOfShape aWireIt(aSSS); + for (; aWireIt.More(); aWireIt.Next()) { + const TopTools_ListOfShape& aLEx=aWireIt.Value(); + // + MakeWire(aLEx, aW); + myNewWES.AddShape (aW); + } + }// else + } +} +//======================================================================= +// function: MakeWire +// purpose: +//======================================================================= + void MakeWire(const TopTools_ListOfShape& aLE, + TopoDS_Wire& newWire) +{ + BRep_Builder aBB; + aBB.MakeWire(newWire); + + TopTools_ListIteratorOfListOfShape anIt(aLE); + for (; anIt.More(); anIt.Next()){ + const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value()); + aBB.Add(newWire, aE); + } +} +// + + +//======================================================================= +//function : IsToScale +//purpose : +//======================================================================= +Standard_Boolean IsToScale(const TopoDS_Face& aF, + Standard_Real& aScale) +{ + Standard_Boolean bRet; + Standard_Real aV1, aV2, dV, aTr; + GeomAbs_SurfaceType aType; + BRepAdaptor_Surface aBAS; + // + bRet=Standard_False; + aScale=1.; + // + aBAS.Initialize(aF); + aType=aBAS.GetType(); + if (aType==GeomAbs_Cylinder) { + aTr=1.e5; + aV1=aBAS.FirstVParameter(); + aV2=aBAS.LastVParameter(); + dV=aV2-aV1; + if (dV>aTr) { + bRet=!bRet; + aScale=1./aTr; + } + } + return bRet; +} + diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WESCorrector.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_WESCorrector.hxx new file mode 100644 index 000000000..ac0cd72f7 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WESCorrector.hxx @@ -0,0 +1,87 @@ + +// 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: NMTAlgo_WESCorrector.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _GEOMAlgo_WESCorrector_HeaderFile +#define _GEOMAlgo_WESCorrector_HeaderFile + +#include +#include +#include +#include +#include +#include + + +//! The algorithm to change the Wire Edges Set (WES) contents.
+//! The NewWES will contain only wires instead of wires and edges.
+//======================================================================= +//class : GEOMAlgo_WESCorrector +//purpose : +//======================================================================= +class GEOMAlgo_WESCorrector : public GEOMAlgo_Algo +{ + public: + //! Empty constructor;
+ //!
+ Standard_EXPORT + GEOMAlgo_WESCorrector(); + + Standard_EXPORT + virtual ~GEOMAlgo_WESCorrector(); + + //! Modifier
+ Standard_EXPORT + void SetWES(const GEOMAlgo_WireEdgeSet& aWES) ; + + //! Performs the algorithm that consists of two steps
+ //! 1. Make conexity blocks ( DoConnexityBlocks() )
+ //! 2. Make corrections ( DoCorrections() )
+ Standard_EXPORT + virtual void Perform() ; + + //! Selector
+ Standard_EXPORT + GEOMAlgo_WireEdgeSet& WES() ; + + //! Selector
+ Standard_EXPORT + GEOMAlgo_WireEdgeSet& NewWES() ; + +protected: + Standard_EXPORT + void DoConnexityBlocks() ; + + Standard_EXPORT + void DoCorrections() ; + + + GEOMAlgo_PWireEdgeSet myWES; + GEOMAlgo_WireEdgeSet myNewWES; + BOP_ListOfConnexityBlock myConnexityBlocks; +}; + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WESScaler.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_WESScaler.cxx new file mode 100644 index 000000000..8f3cf2241 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WESScaler.cxx @@ -0,0 +1,267 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_WESScaler.cxx +// Created: +// Author: +// + + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include + + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_WESScaler::GEOMAlgo_WESScaler() +: + GEOMAlgo_Algo() +{ + myScale=1.; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + GEOMAlgo_WESScaler::~GEOMAlgo_WESScaler() +{ +} +//======================================================================= +// function: SetScale +// purpose: +//======================================================================= + void GEOMAlgo_WESScaler::SetScale (const Standard_Real aScale) +{ + myScale=aScale; +} +//======================================================================= +// function: Scale +// purpose: +//======================================================================= + Standard_Real GEOMAlgo_WESScaler::Scale()const +{ + return myScale; +} +//======================================================================= +// function: SetFace +// purpose: +//======================================================================= + void GEOMAlgo_WESScaler::SetFace(const TopoDS_Face& aF) +{ + myFace=aF; +} +//======================================================================= +// function: Face +// purpose: +//======================================================================= + const TopoDS_Face& GEOMAlgo_WESScaler::Face()const +{ + return myFace; +} +//======================================================================= +// function: SetEdges +// purpose: +//======================================================================= + void GEOMAlgo_WESScaler::SetEdges(const TopTools_ListOfShape& aLE) +{ + myEdges=aLE; +} +//======================================================================= +// function: Edges +// purpose: +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_WESScaler::Edges()const +{ + return myEdges; +} +//======================================================================= +// function: FaceScaled +// purpose: +//======================================================================= + const TopoDS_Face& GEOMAlgo_WESScaler::FaceScaled()const +{ + return myFaceScaled; +} +//======================================================================= +// function: EdgesScaled +// purpose: +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_WESScaler::EdgesScaled()const +{ + return myEdgesScaled; +} +//======================================================================= +// function: Image +// purpose: +//======================================================================= + const TopoDS_Shape& GEOMAlgo_WESScaler::Image (const TopoDS_Shape& aS) const +{ + if (myImages.IsBound(aS)) { + return myImages.Find(aS); + } + return myShapeTmp; +} +//======================================================================= +// function: Origin +// purpose: +//======================================================================= + const TopoDS_Shape& GEOMAlgo_WESScaler::Origin (const TopoDS_Shape& aS) const +{ + if (myOrigins.IsBound(aS)) { + return myOrigins.Find(aS); + } + return myShapeTmp; +} +//======================================================================= +// function: Images +// purpose: +//======================================================================= + const GEOMAlgo_DataMapOfOrientedShapeShape& GEOMAlgo_WESScaler::Images () const +{ + return myImages; +} +//======================================================================= +// function: Origins +// purpose: +//======================================================================= + const GEOMAlgo_DataMapOfOrientedShapeShape& GEOMAlgo_WESScaler::Origins () const +{ + return myOrigins; +} +//======================================================================= +// function: CheckData +// purpose: +//======================================================================= + void GEOMAlgo_WESScaler::CheckData() +{ + myErrorStatus=0; + // + if(myFace.IsNull()) { + myErrorStatus=2; + return; + } + if(!myEdges.Extent()) { + myErrorStatus=3; + return; + } + if (myScale<=0.){ + myErrorStatus=4; + } +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= + void GEOMAlgo_WESScaler::Perform() +{ + Standard_Boolean bIsDone; + Standard_Integer i; + gp_Pnt aP; + gp_Trsf aTrsf; + TopAbs_Orientation aOr; + TopoDS_Shape aFC, aFR, aER; + TopoDS_Wire aWE; + TopoDS_Iterator aItS; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aIt; + // + // 0. CheckData + CheckData(); + if(myErrorStatus) { + return; + } + // + myImages.Clear(); + myOrigins.Clear(); + myEdgesScaled.Clear(); + // + // 1. aFC + aFC=myFace.EmptyCopied(); + // + aBB.MakeWire(aWE); + aIt.Initialize(myEdges); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + aBB.Add(aWE, aE); + } + aBB.Add(aFC, aWE); + // + aItS.Initialize(myFace); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aW=aItS.Value(); + aBB.Add(aFC, aW); + } + // + // 2. Scale aFC + aP.SetCoord(0.,0.,0.); + aTrsf.SetScale(aP, myScale); + // + BRepBuilderAPI_Transform aBT(aTrsf); + aBT.Perform(aFC); + bIsDone=aBT.IsDone(); + if (!bIsDone) { + myErrorStatus=10; + return; + } + // + const TopoDS_Shape& aSR=aBT.Shape(); + // + // Refined image face FR + aFR=aSR.EmptyCopied(); + aItS.Initialize(aSR); + for (i=0; aItS.More(); aItS.Next(),++i) { + const TopoDS_Shape& aWR=aItS.Value(); + if (i) { + aBB.Add(aFR, aWR); + } + } + myFaceScaled=*((TopoDS_Face*)&aFR); + // + // 3. Fill Images, Origins, EdgesScaled + aIt.Initialize(myEdges); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aE=aIt.Value(); + aOr=aE.Orientation(); + // + aER=aBT.ModifiedShape(aE); + if(aER.IsNull()) { + myErrorStatus=11; + return; + } + // + aER.Orientation(aOr); + myImages.Bind(aE, aER); + myOrigins.Bind(aER, aE); + // + myEdgesScaled.Append(aER); + } +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WESScaler.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_WESScaler.hxx new file mode 100644 index 000000000..4cb2050f3 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WESScaler.hxx @@ -0,0 +1,110 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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_WESScaler.hxx +// Created: +// Author: +// + +#ifndef _GEOMAlgo_WESScaler_HeaderFile +#define _GEOMAlgo_WESScaler_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_WESScaler +//purpose : +//======================================================================= +class GEOMAlgo_WESScaler : public GEOMAlgo_Algo +{ +public: + //! Empty constructor
+ Standard_EXPORT + GEOMAlgo_WESScaler(); + + Standard_EXPORT + virtual ~GEOMAlgo_WESScaler(); + + //! Modifier
+ Standard_EXPORT + void SetScale(const Standard_Real aWES) ; + + //! Selector
+ Standard_EXPORT + Standard_Real Scale() const; + + Standard_EXPORT + void SetFace(const TopoDS_Face& aF) ; + + Standard_EXPORT + const TopoDS_Face& Face() const; + + Standard_EXPORT + void SetEdges(const TopTools_ListOfShape& aLE) ; + + Standard_EXPORT + const TopTools_ListOfShape& Edges() const; + + //! Performs the algorithm
+ Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + const TopoDS_Face& FaceScaled() const; + + Standard_EXPORT + const TopTools_ListOfShape& EdgesScaled() const; + + Standard_EXPORT + const TopoDS_Shape& Image(const TopoDS_Shape& aS) const; + + Standard_EXPORT + const TopoDS_Shape& Origin(const TopoDS_Shape& aS) const; + + //! Selector
+ Standard_EXPORT + const GEOMAlgo_DataMapOfOrientedShapeShape& Images() const; + + //! Selector
+ Standard_EXPORT + const GEOMAlgo_DataMapOfOrientedShapeShape& Origins() const; + + protected: + + //! Performs the algorithm
+ Standard_EXPORT virtual void CheckData() ; + + + Standard_Real myScale; + TopoDS_Face myFace; + TopTools_ListOfShape myEdges; + TopoDS_Face myFaceScaled; + TopTools_ListOfShape myEdgesScaled; + GEOMAlgo_DataMapOfOrientedShapeShape myImages; + GEOMAlgo_DataMapOfOrientedShapeShape myOrigins; + TopoDS_Shape myShapeTmp; +}; + +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WireEdgeSet.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_WireEdgeSet.cxx new file mode 100644 index 000000000..bffb2e9f7 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WireEdgeSet.cxx @@ -0,0 +1,95 @@ +// 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_WireEdgeSet.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + GEOMAlgo_WireEdgeSet::GEOMAlgo_WireEdgeSet() +{ + Clear(); +} + +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void GEOMAlgo_WireEdgeSet::Clear() +{ + myStartShapes.Clear(); + myShapes.Clear(); +} +//======================================================================= +//function : SetFace +//purpose : +//======================================================================= + void GEOMAlgo_WireEdgeSet::SetFace(const TopoDS_Face& aF) +{ + myFace=aF; +} +//======================================================================= +//function : Face +//purpose : +//======================================================================= + const TopoDS_Face& GEOMAlgo_WireEdgeSet::Face()const +{ + return myFace; +} +//======================================================================= +//function : AddStartElement +//purpose : +//======================================================================= + void GEOMAlgo_WireEdgeSet::AddStartElement(const TopoDS_Shape& aE) +{ + myStartShapes.Append(aE); +} +//======================================================================= +//function : StartElements +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_WireEdgeSet::StartElements()const +{ + return myStartShapes; +} +//======================================================================= +//function : AddShape +//purpose : +//======================================================================= + void GEOMAlgo_WireEdgeSet::AddShape(const TopoDS_Shape& aW) +{ + myShapes.Append(aW); +} +//======================================================================= +//function : Shapes +//purpose : +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_WireEdgeSet::Shapes()const +{ + return myShapes; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WireEdgeSet.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_WireEdgeSet.hxx new file mode 100644 index 000000000..26dbe6724 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WireEdgeSet.hxx @@ -0,0 +1,73 @@ +// 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_WireEdgeSet.hxx +// Created: +// Author: Peter KURNEV +// +// + +#ifndef _GEOMAlgo_WireEdgeSet_HeaderFile +#define _GEOMAlgo_WireEdgeSet_HeaderFile + +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_WireEdgeSet +//purpose : +//======================================================================= +class GEOMAlgo_WireEdgeSet { + public: + Standard_EXPORT + GEOMAlgo_WireEdgeSet(); + + Standard_EXPORT + void Clear() ; + + Standard_EXPORT + void SetFace(const TopoDS_Face& aF) ; + + Standard_EXPORT + const TopoDS_Face& Face() const; + + Standard_EXPORT + void AddStartElement(const TopoDS_Shape& sS) ; + + Standard_EXPORT + const TopTools_ListOfShape& StartElements() const; + + Standard_EXPORT + void AddShape(const TopoDS_Shape& sS) ; + + Standard_EXPORT + const TopTools_ListOfShape& Shapes() const; + +protected: + TopoDS_Face myFace; + TopTools_ListOfShape myStartShapes; + TopTools_ListOfShape myShapes; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WireSolid.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_WireSolid.cxx new file mode 100644 index 000000000..1afe2ea8e --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WireSolid.cxx @@ -0,0 +1,173 @@ +// 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_WireSolid.cxx +// Created: Wed Jan 12 10:19:31 2005 +// Author: Peter KURNEV +// +// +#include + +#include + +#include + +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : GEOMAlgo_WireSolid +//purpose : +//======================================================================= +GEOMAlgo_WireSolid::GEOMAlgo_WireSolid() +: + GEOMAlgo_ShapeSolid() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +GEOMAlgo_WireSolid::~GEOMAlgo_WireSolid() +{ +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= +void GEOMAlgo_WireSolid::Perform() +{ + myErrorStatus=0; + // + try { + if (myDSFiller==NULL) { + myErrorStatus=10; + return; + } + if(!myDSFiller->IsDone()) { + myErrorStatus=11; + return; + } + // + Standard_Boolean bIsNewFiller; + // + bIsNewFiller=myDSFiller->IsNewFiller(); + + if (bIsNewFiller) { + Prepare(); + myDSFiller->SetNewFiller(!bIsNewFiller); + } + BuildResult(); + } + // + catch (Standard_Failure) { + myErrorStatus= 12; + } +} +//======================================================================= +// function: Prepare +// purpose: +//======================================================================= +void GEOMAlgo_WireSolid::Prepare() +{ + const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); + // + BOPTools_WireStateFiller aStateFiller(aPaveFiller); + aStateFiller.Do(); + // +} +//======================================================================= +// function: BuildResult +// purpose: +//======================================================================= +void GEOMAlgo_WireSolid::BuildResult() +{ + const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS(); + const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller(); + const BOPTools_SplitShapesPool& aSplitShapesPool=aPaveFiller.SplitShapesPool(); + // + Standard_Integer i, aNbPB, nSp, iBeg, iEnd; + TopAbs_ShapeEnum aType; + BooleanOperations_StateOfShape aState; + // + myLSIN.Clear(); + myLSOUT.Clear(); + myLSON.Clear(); + // + iBeg=1; + iEnd=aDS.NumberOfShapesOfTheObject(); + if (aDS.Tool().ShapeType()==TopAbs_WIRE) { + iBeg=iEnd+1; + iEnd=aDS.NumberOfSourceShapes(); + } + // + for (i=iBeg; i<=iEnd; ++i) { + aType=aDS.GetShapeType(i); + if (aType==TopAbs_EDGE) { + const TopoDS_Shape& aE=aDS.Shape(i); + const BOPTools_ListOfPaveBlock& aLPB=aSplitShapesPool(aDS.RefEdge(i)); + aNbPB=aLPB.Extent(); + // + if (!aNbPB) { + aState=aDS.GetState(i); + // + if (aState==BooleanOperations_IN) { + myLSIN.Append(aE); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aE); + } + else if (aState==BooleanOperations_ON) { + myLSON.Append(aE); + } + } + // + else if (aNbPB==1) { + const BOPTools_PaveBlock& aPB=aLPB.First(); + nSp=aPB.Edge(); + /*const TopoDS_Shape& aSp=*/aDS.Shape(nSp); + aState=aDS.GetState(nSp); + // + if (aState==BooleanOperations_IN) { + myLSIN.Append(aE); + } + else if (aState==BooleanOperations_OUT) { + myLSOUT.Append(aE); + } + else if (aState==BooleanOperations_ON) { + myLSON.Append(aE); + } + } + } + } +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WireSolid.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_WireSolid.hxx new file mode 100644 index 000000000..b2097ddab --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WireSolid.hxx @@ -0,0 +1,58 @@ +// 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_WireSolid.hxx +// Created: Wed Jan 12 10:19:31 2005 +// Author: Peter KURNEV +// + +#ifndef _GEOMAlgo_WireSolid_HeaderFile +#define _GEOMAlgo_WireSolid_HeaderFile + +#include +#include +#include + +//======================================================================= +//class : GEOMAlgo_WireSolid +//purpose : +//======================================================================= +class GEOMAlgo_WireSolid : public GEOMAlgo_ShapeSolid +{ + public: + Standard_EXPORT + GEOMAlgo_WireSolid(); + + Standard_EXPORT + virtual ~GEOMAlgo_WireSolid(); + + Standard_EXPORT + virtual void Perform() ; + + protected: + Standard_EXPORT + virtual void Prepare() ; + + Standard_EXPORT + virtual void BuildResult() ; +}; +#endif diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WireSplitter.cxx b/src/GEOMAlgo_NEW/GEOMAlgo_WireSplitter.cxx new file mode 100644 index 000000000..84bad20bc --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WireSplitter.cxx @@ -0,0 +1,876 @@ +// 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_WireSplitter.cxx +// 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 +#include +#include +#include + +static + void Path (const GeomAdaptor_Surface& aGAS, + const TopoDS_Face& myFace, + const TopoDS_Vertex& aVa, + const TopoDS_Edge& aEOuta, + BOP_EdgeInfo& anEdgeInfo, + TopTools_SequenceOfShape& aLS, + TopTools_SequenceOfShape& aVertVa, + TColgp_SequenceOfPnt2d& aCoordVa, + BOPTColStd_ListOfListOfShape& myShapes, + BOP_IndexedDataMapOfVertexListEdgeInfo& mySmartMap); + + +static + Standard_Real Angle (const gp_Dir2d& aDir2D); + + +static + void GetNextVertex(const TopoDS_Vertex& aV, + const TopoDS_Edge& aE, + TopoDS_Vertex& aV1); +static + Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, + const Standard_Real aAngleOut); + +static + Standard_Real AngleIn(const TopoDS_Edge& aEIn, + const BOP_ListOfEdgeInfo& aLEInfo); + +static + Standard_Real Angle2D (const TopoDS_Vertex& aV, + const TopoDS_Edge& anEdge, + const TopoDS_Face& myFace, + const GeomAdaptor_Surface& aGAS, + const Standard_Boolean aFlag); +static + gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1, + const TopoDS_Edge& aE1, + const TopoDS_Face& aF); +static + gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE, + const TopoDS_Face& aF); +static + Standard_Real Tolerance2D (const TopoDS_Vertex& aV, + const GeomAdaptor_Surface& aGAS); + +static + Standard_Integer NbWaysOut(const BOP_ListOfEdgeInfo& ); +// + +//======================================================================= +// function: +// purpose: +//======================================================================= + GEOMAlgo_WireSplitter::GEOMAlgo_WireSplitter() +: + GEOMAlgo_Algo(), + myNothingToDo(Standard_False) +{ +} +//======================================================================= +// function: ~ +// purpose: +//======================================================================= + GEOMAlgo_WireSplitter::~GEOMAlgo_WireSplitter() +{ +} +//======================================================================= +// function: SetFace +// purpose: +//======================================================================= + void GEOMAlgo_WireSplitter::SetFace(const TopoDS_Face& aFace) +{ + myFace=aFace; +} +//======================================================================= +// function: Face +// purpose: +//======================================================================= + const TopoDS_Face& GEOMAlgo_WireSplitter::Face()const +{ + return myFace; +} +//======================================================================= +// function: SetEdges +// purpose: +//======================================================================= + void GEOMAlgo_WireSplitter::SetEdges(const TopTools_ListOfShape& aLE) +{ + TopTools_ListIteratorOfListOfShape anIt; + // + myEdges.Clear(); + anIt.Initialize(aLE); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aE =anIt.Value(); + // + if (aE.Orientation()==TopAbs_INTERNAL){ + continue; + } + // + myEdges.Append(aE); + } +} +//======================================================================= +// function: Edges +// purpose: +//======================================================================= + const TopTools_ListOfShape& GEOMAlgo_WireSplitter::Edges()const +{ + return myEdges; +} +//======================================================================= +// function: IsNothingToDo +// purpose: +//======================================================================= + Standard_Boolean GEOMAlgo_WireSplitter::IsNothingToDo()const +{ + return myNothingToDo; +} +//======================================================================= +// function: Shapes +// purpose: +//======================================================================= + const BOPTColStd_ListOfListOfShape& GEOMAlgo_WireSplitter::Shapes()const +{ + return myShapes; +} +//======================================================================= +// function: Perform +// purpose: +//======================================================================= + void GEOMAlgo_WireSplitter::Perform() +{ + myErrorStatus=2; + myNothingToDo=Standard_True; + + Standard_Integer index, i, aNb, aCntIn, aCntOut; + Standard_Boolean anIsIn; + Standard_Real anAngle; + + BOP_ListOfEdgeInfo emptyInfo; + TopTools_ListIteratorOfListOfShape anItList; + // + // 1.Filling mySmartMap + mySmartMap.Clear(); + + anItList.Initialize(myEdges); + for (; anItList.More(); anItList.Next()) { + const TopoDS_Edge& anEdge = TopoDS::Edge(anItList.Value()); + // + if (!BOPTools_Tools2D::HasCurveOnSurface (anEdge, myFace)) { + continue; + } + // + TopExp_Explorer anExpVerts (anEdge, TopAbs_VERTEX); + for (; anExpVerts.More(); anExpVerts.Next()) { + const TopoDS_Shape& aVertex= anExpVerts.Current(); + + index = mySmartMap.FindIndex(aVertex); + if (!index) { + index=mySmartMap.Add(aVertex, emptyInfo); + } + + BOP_ListOfEdgeInfo& aListOfEInfo=mySmartMap(index); + + BOP_EdgeInfo aEInfo; + aEInfo.SetEdge(anEdge); + + TopAbs_Orientation anOr=aVertex.Orientation(); + + if (anOr==TopAbs_FORWARD) { + aEInfo.SetInFlag(Standard_False); + } + + else if (anOr==TopAbs_REVERSED) { + aEInfo.SetInFlag(Standard_True); + } + + aListOfEInfo.Append(aEInfo); + } + } + // + aNb=mySmartMap.Extent(); + // + // 2. myNothingToDo + myNothingToDo=Standard_True; + + for (i=1; i<=aNb; i++) { + aCntIn=0; + aCntOut=0; + const BOP_ListOfEdgeInfo& aLEInfo= mySmartMap(i); + BOP_ListIteratorOfListOfEdgeInfo anIt(aLEInfo); + for (; anIt.More(); anIt.Next()) { + const BOP_EdgeInfo& anEdgeInfo=anIt.Value(); + anIsIn=anEdgeInfo.IsIn(); + if (anIsIn) { + aCntIn++; + } + else { + aCntOut++; + } + } + if (aCntIn!=1 || aCntOut!=1) { + myNothingToDo=Standard_False; + break; + } + } + // + // Each vertex has one edge In and one - Out. Good. But it is not enought + // to consider that nothing to do with this. We must check edges on TShape + // coinsidence. If there are such edges there is something to do with. + // + if (myNothingToDo) { + Standard_Integer aNbE, aNbMapEE; + TopTools_IndexedDataMapOfShapeListOfShape aMapEE; + aNbE=myEdges.Extent(); + + anItList.Initialize(myEdges); + for (; anItList.More(); anItList.Next()) { + const TopoDS_Shape& aE = anItList.Value(); + + if (!aMapEE.Contains(aE)) { + TopTools_ListOfShape aLEx; + aLEx.Append(aE); + aMapEE.Add(aE, aLEx); + } + else { + TopTools_ListOfShape& aLEx=aMapEE.ChangeFromKey(aE); + aLEx.Append(aE); + } + } + + Standard_Boolean bFlag; + bFlag=Standard_True; + aNbMapEE=aMapEE.Extent(); + for (i=1; i<=aNbMapEE; i++) { + const TopTools_ListOfShape& aLEx=aMapEE(i); + aNbE=aLEx.Extent(); + if (aNbE==1) { + // usual case + continue; + } + else if (aNbE==2){ + const TopoDS_Shape& aE1=aLEx.First(); + const TopoDS_Shape& aE2=aLEx.Last(); + if (aE1.IsSame(aE2)) { + bFlag=Standard_False; + break; + } + } + else { + bFlag=Standard_False; + break; + } + } + myNothingToDo=myNothingToDo && bFlag; + } + // + // + if (myNothingToDo) { + myErrorStatus=0; + return; + } + // + // 3. Angles in mySmartMap + BRepAdaptor_Surface aBAS(myFace); + const GeomAdaptor_Surface& aGAS=aBAS.Surface(); + for (i=1; i<=aNb; i++) { + const TopoDS_Vertex& aV=TopoDS::Vertex (mySmartMap.FindKey(i)); + const BOP_ListOfEdgeInfo& aLEInfo= mySmartMap(i); + + BOP_ListIteratorOfListOfEdgeInfo anIt(aLEInfo); + for (; anIt.More(); anIt.Next()) { + BOP_EdgeInfo& anEdgeInfo=anIt.Value(); + const TopoDS_Edge& aE=anEdgeInfo.Edge(); + // + TopoDS_Vertex aVV=aV; + // + anIsIn=anEdgeInfo.IsIn(); + if (anIsIn) { + // + aVV.Orientation(TopAbs_REVERSED); + anAngle=Angle2D (aVV, aE, myFace, aGAS, Standard_True); + } + // + else { // OUT + // + aVV.Orientation(TopAbs_FORWARD); + anAngle=Angle2D (aVV, aE, myFace, aGAS, Standard_False); + } + anEdgeInfo.SetAngle(anAngle); + + } + } + // + // 4. Do + // + Standard_Boolean anIsOut, anIsNotPassed; + + TopTools_SequenceOfShape aLS, aVertVa; + TColgp_SequenceOfPnt2d aCoordVa; + + BOP_ListIteratorOfListOfEdgeInfo anIt; + + for (i=1; i<=aNb; i++) { + const TopoDS_Vertex aVa=TopoDS::Vertex (mySmartMap.FindKey(i)); + const BOP_ListOfEdgeInfo& aLEInfo=mySmartMap(i); + + anIt.Initialize(aLEInfo); + for (; anIt.More(); anIt.Next()) { + BOP_EdgeInfo& anEdgeInfo=anIt.Value(); + const TopoDS_Edge& aEOuta=anEdgeInfo.Edge(); + + anIsOut=!anEdgeInfo.IsIn(); + anIsNotPassed=!anEdgeInfo.Passed(); + + if (anIsOut && anIsNotPassed) { + // + aLS.Clear(); + aVertVa.Clear(); + aCoordVa.Clear(); + // + Path(aGAS, myFace, aVa, aEOuta, anEdgeInfo, aLS, + aVertVa, aCoordVa, myShapes, mySmartMap); + } + } + } + // + { + Standard_Integer aNbV, aNbE; + TopoDS_Vertex aV1, aV2; + BOPTColStd_ListOfListOfShape aShapes; + BOPTColStd_ListIteratorOfListOfListOfShape anItW(myShapes); + + for (; anItW.More(); anItW.Next()) { + TopTools_IndexedMapOfShape aMV, aME; + const TopTools_ListOfShape& aLE=anItW.Value(); + TopTools_ListIteratorOfListOfShape anItE(aLE); + for (; anItE.More(); anItE.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(anItE.Value()); + aME.Add(aE); + TopExp::Vertices(aE, aV1, aV2); + aMV.Add(aV1); + aMV.Add(aV2); + } + aNbV=aMV.Extent(); + aNbE=aME.Extent(); + if (aNbV<=aNbE) { + aShapes.Append(aLE); + } + } + // + myShapes.Clear(); + anItW.Initialize(aShapes); + for (; anItW.More(); anItW.Next()) { + const TopTools_ListOfShape& aLE=anItW.Value(); + myShapes.Append(aLE); + } + } + // + myErrorStatus=0; +} +//======================================================================= +// function: Path +// purpose: +//======================================================================= + void Path (const GeomAdaptor_Surface& aGAS, + const TopoDS_Face& myFace, + const TopoDS_Vertex& aVa, + const TopoDS_Edge& aEOuta, + BOP_EdgeInfo& anEdgeInfo, + TopTools_SequenceOfShape& aLS, + TopTools_SequenceOfShape& aVertVa, + TColgp_SequenceOfPnt2d& aCoordVa, + BOPTColStd_ListOfListOfShape& myShapes, + BOP_IndexedDataMapOfVertexListEdgeInfo& mySmartMap) + +{ + Standard_Integer i,j, aNb, aNbj; + Standard_Real aTol, anAngleIn, anAngleOut, anAngle, aMinAngle; + Standard_Real aTol2D, aTol2D2; + Standard_Real aTol2, aD2;//, aTolUVb, aTolVVb; + Standard_Boolean anIsSameV2d, anIsSameV, anIsFound, anIsOut, anIsNotPassed; + BOP_ListIteratorOfListOfEdgeInfo anIt; + TopoDS_Vertex aVb; + TopoDS_Edge aEOutb; + // + aTol=1.e-7; + // + // append block + // + // Do not escape through edge from which you enter + aNb=aLS.Length(); + if (aNb==1) { + const TopoDS_Shape& anEPrev=aLS(aNb); + if (anEPrev.IsSame(aEOuta)) { + return; + } + } + // + // + anEdgeInfo.SetPassed(Standard_True); + aLS.Append(aEOuta); + aVertVa.Append(aVa); + + TopoDS_Vertex pVa=aVa; + pVa.Orientation(TopAbs_FORWARD); + gp_Pnt2d aPa=Coord2d(pVa, aEOuta, myFace); + aCoordVa.Append(aPa); + + GetNextVertex (pVa, aEOuta, aVb); + + gp_Pnt2d aPb=Coord2d(aVb, aEOuta, myFace); + + //const BOP_ListOfEdgeInfo& aLEInfoVb=mySmartMap.FindFromKey(aVb); + // + aTol=2.*Tolerance2D(aVb, aGAS); + aTol2=10.*aTol*aTol; + // + aNb=aLS.Length(); + if (aNb>0) { + // + TopTools_ListOfShape aBuf; + // + for (i=aNb; i>0; i--) { + const TopoDS_Shape& aVPrev=aVertVa(i); + const gp_Pnt2d& aPaPrev=aCoordVa(i); + const TopoDS_Shape& aEPrev=aLS(i); + + aBuf.Append(aEPrev); + + anIsSameV=aVPrev.IsSame(aVb); + anIsSameV2d=Standard_False; + + if (anIsSameV) { + anIsSameV2d = Standard_True; + // + aD2=aPaPrev.SquareDistance(aPb); + anIsSameV2d =aD2 aTol2D2){ + continue; + } + // + // + anAngleOut=anEI.Angle(); + // + anAngle=ClockWiseAngle(anAngleIn, anAngleOut); + if (anAngle < aMinAngle) { + aMinAngle=anAngle; + pEdgeInfo=&anEI; + anIsFound=Standard_True; + } + } + } // for (; anIt.More(); anIt.Next()) + // + if (!anIsFound) { + // no way to go . (Error) + return; + } + + aEOutb=pEdgeInfo->Edge(); + // + Path (aGAS, myFace, aVb, aEOutb, *pEdgeInfo, aLS, + aVertVa, aCoordVa, myShapes, mySmartMap); +} +//======================================================================= +// function: Coord2dVf +// purpose: +//======================================================================= + gp_Pnt2d Coord2dVf (const TopoDS_Edge& aE, + const TopoDS_Face& aF) +{ + Standard_Real aCoord=99.; + gp_Pnt2d aP2D1(aCoord, aCoord); + TopoDS_Iterator aIt; + // + aIt.Initialize(aE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aVx=aIt.Value(); + if (aVx.Orientation()==TopAbs_FORWARD) { + const TopoDS_Vertex& aVxx=TopoDS::Vertex(aVx); + aP2D1=Coord2d(aVxx, aE, aF); + return aP2D1; + } + } + return aP2D1; +} +//======================================================================= +// function: Tolerance2D +// purpose: +//======================================================================= + Standard_Real Tolerance2D (const TopoDS_Vertex& aV, + const GeomAdaptor_Surface& aGAS) +{ + Standard_Real aTol2D, anUr, aVr, aTolV3D; + GeomAbs_SurfaceType aType; + // + aType=aGAS.GetType(); + aTolV3D=BRep_Tool::Tolerance(aV); + + anUr=aGAS.UResolution(aTolV3D); + aVr =aGAS.VResolution(aTolV3D); + aTol2D=(aVr>anUr) ? aVr : anUr; + // + if (aType==GeomAbs_BSplineSurface|| + aType==GeomAbs_Sphere|| + GeomAbs_SurfaceOfRevolution) { + if (aTol2D < aTolV3D) { + aTol2D=aTolV3D; + } + } + if (aType==GeomAbs_BSplineSurface) { + aTol2D=1.1*aTol2D; + } + // + return aTol2D; +} + +//======================================================================= +// function: Coord2d +// purpose: +//======================================================================= + gp_Pnt2d Coord2d (const TopoDS_Vertex& aV1, + const TopoDS_Edge& aE1, + const TopoDS_Face& aF) +{ + Standard_Real aT, aFirst, aLast; + Handle(Geom2d_Curve) aC2D; + gp_Pnt2d aP2D1; + // + aT=BRep_Tool::Parameter (aV1, aE1, aF); + aC2D=BRep_Tool::CurveOnSurface(aE1, aF, aFirst, aLast); + aC2D->D0 (aT, aP2D1); + // + return aP2D1; +} +//======================================================================= +// function: AngleIn +// purpose: +//======================================================================= + Standard_Real AngleIn(const TopoDS_Edge& aEIn, + const BOP_ListOfEdgeInfo& aLEInfo) +{ + Standard_Real anAngleIn; + Standard_Boolean anIsIn; + BOP_ListIteratorOfListOfEdgeInfo anIt; + + anIt.Initialize(aLEInfo); + for (; anIt.More(); anIt.Next()) { + BOP_EdgeInfo& anEdgeInfo=anIt.Value(); + const TopoDS_Edge& aE=anEdgeInfo.Edge(); + anIsIn=anEdgeInfo.IsIn(); + // + if (anIsIn && aE==aEIn) { + anAngleIn=anEdgeInfo.Angle(); + return anAngleIn; + } + } + anAngleIn=0.; + return anAngleIn; +} +//======================================================================= +// function: ClockWiseAngle +// purpose: +//======================================================================= + Standard_Real ClockWiseAngle(const Standard_Real aAngleIn, + const Standard_Real aAngleOut) +{ + Standard_Real aTwoPi = M_PI+M_PI; + Standard_Real dA, A1, A2, AIn, AOut ; + + AIn=aAngleIn; + AOut=aAngleOut; + if (AIn >= aTwoPi) { + AIn=AIn-aTwoPi; + } + + if (AOut >= aTwoPi) { + AOut=AOut-aTwoPi; + } + + A1 = AIn + M_PI; + + if (A1 >= aTwoPi) { + A1=A1-aTwoPi; + } + + A2=AOut; + + dA=A1-A2; + if (dA <= 0.) { + dA=aTwoPi+dA; + //modified by NIZNHY-PKV Thu Feb 17 08:26:39 2011f + if (dA <= 1.e-14) { + dA=aTwoPi; + } + //modified by NIZNHY-PKV Thu Feb 17 08:26:42 2011t + } + //xx + else if (dA <= 1.e-14) { + dA=aTwoPi; + } + return dA; +} +//======================================================================= +// function: GetNextVertex +// purpose: +//======================================================================= + void GetNextVertex(const TopoDS_Vertex& aV, + const TopoDS_Edge& aE, + TopoDS_Vertex& aV1) +{ + TopoDS_Iterator aIt; + // + aIt.Initialize(aE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aVx=aIt.Value(); + if (!aVx.IsEqual(aV)) { + aV1=TopoDS::Vertex(aVx); + return ; + } + } + aV1=aV; +} +//======================================================================= +// function: Angle2D +// purpose: +//======================================================================= + Standard_Real Angle2D (const TopoDS_Vertex& aV, + const TopoDS_Edge& anEdge, + const TopoDS_Face& myFace, + const GeomAdaptor_Surface& aGAS, + const Standard_Boolean aFlag) +{ + Standard_Real aFirst, aLast, aToler, dt, aTV, aTV1, anAngle, aTX; + gp_Pnt2d aPV, aPV1; + gp_Vec2d aV2D; + Handle(Geom2d_Curve) aC2D; + // + aTV=BRep_Tool::Parameter (aV, anEdge, myFace); + if (Precision::IsInfinite(aTV)) { + return 0.; + } + // + BOPTools_Tools2D::CurveOnSurface (anEdge, myFace, aC2D, + aFirst, aLast, aToler, Standard_True); + //dt=1.e-7; + dt=2.*Tolerance2D(aV, aGAS); + // + aTX=0.25*(aLast - aFirst); + if(dt > aTX) { + // to save direction of the curve as much as it possible + // in the case of big tolerances + dt = aTX; + } + // + if (fabs (aTV-aFirst) < fabs(aTV - aLast)) { + aTV1=aTV + dt; + } + else { + aTV1=aTV - dt; + } + // + aC2D->D0 (aTV, aPV); + aC2D->D0 (aTV1, aPV1); + // + if (aFlag) {//IN + gp_Vec2d aV2DIn(aPV1, aPV); + aV2D=aV2DIn; + } + else { + gp_Vec2d aV2DOut(aPV, aPV1); + aV2D=aV2DOut; + } + // + gp_Dir2d aDir2D(aV2D); + anAngle=Angle(aDir2D); + // + return anAngle; +} +//======================================================================= +// function: Angle +// purpose: +//======================================================================= +Standard_Real Angle (const gp_Dir2d& aDir2D) +{ + gp_Dir2d aRefDir(1., 0.); + Standard_Real anAngle = aRefDir.Angle(aDir2D); + + if (anAngle < 0.) + anAngle += M_PI + M_PI; + + return anAngle; +} +// +//======================================================================= +// function: NbWaysOut +// purpose: +//======================================================================= +Standard_Integer NbWaysOut(const BOP_ListOfEdgeInfo& aLEInfo) +{ + Standard_Boolean bIsOut, bIsNotPassed; + Standard_Integer iCnt=0; + BOP_ListIteratorOfListOfEdgeInfo anIt; + // + anIt.Initialize(aLEInfo); + for (; anIt.More(); anIt.Next()) { + BOP_EdgeInfo& anEI=anIt.Value(); + // + bIsOut=!anEI.IsIn(); + bIsNotPassed=!anEI.Passed(); + if (bIsOut && bIsNotPassed) { + iCnt++; + } + } + return iCnt; +} diff --git a/src/GEOMAlgo_NEW/GEOMAlgo_WireSplitter.hxx b/src/GEOMAlgo_NEW/GEOMAlgo_WireSplitter.hxx new file mode 100644 index 000000000..8108443a4 --- /dev/null +++ b/src/GEOMAlgo_NEW/GEOMAlgo_WireSplitter.hxx @@ -0,0 +1,83 @@ +// 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_WireSplitter.hxx +// Author: Peter KURNEV + +#ifndef _GEOMAlgo_WireSplitter_HeaderFile +#define _GEOMAlgo_WireSplitter_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + +//! the algorithm to split multiconnexed set of edges
+//! wires on a face onto simple connexed wires
+//! .
+//======================================================================= +//class : GEOMAlgo_WireSplitter +//purpose : +//======================================================================= +class GEOMAlgo_WireSplitter : public GEOMAlgo_Algo +{ +public: + Standard_EXPORT + GEOMAlgo_WireSplitter(); + + Standard_EXPORT + virtual ~GEOMAlgo_WireSplitter(); + + Standard_EXPORT + void SetFace(const TopoDS_Face& aF) ; + + Standard_EXPORT + void SetEdges(const TopTools_ListOfShape& aLE) ; + + Standard_EXPORT + const TopTools_ListOfShape& Edges() const; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + Standard_Boolean IsNothingToDo() const; + + Standard_EXPORT + const TopoDS_Face& Face() const; + + Standard_EXPORT + const BOPTColStd_ListOfListOfShape& Shapes() const; + +protected: + TopoDS_Face myFace; + Standard_Boolean myIsDone; + Standard_Boolean myNothingToDo; + BOPTColStd_ListOfListOfShape myShapes; + BOP_IndexedDataMapOfVertexListEdgeInfo mySmartMap; + TopTools_ListOfShape myEdges; +}; + +#endif diff --git a/src/GEOMAlgo_NEW/Handle_BlockFix_BlockFixAPI.hxx b/src/GEOMAlgo_NEW/Handle_BlockFix_BlockFixAPI.hxx new file mode 100644 index 000000000..bc7daabef --- /dev/null +++ b/src/GEOMAlgo_NEW/Handle_BlockFix_BlockFixAPI.hxx @@ -0,0 +1,92 @@ +// 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_BlockFix_BlockFixAPI_HeaderFile +#define _Handle_BlockFix_BlockFixAPI_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_MMgt_TShared_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(MMgt_TShared); +class BlockFix_BlockFixAPI; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_BlockFixAPI); + +class Handle(BlockFix_BlockFixAPI) : public Handle(MMgt_TShared) { + 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); + } + Handle(BlockFix_BlockFixAPI)():Handle(MMgt_TShared)() {} + Handle(BlockFix_BlockFixAPI)(const Handle(BlockFix_BlockFixAPI)& aHandle) : Handle(MMgt_TShared)(aHandle) + { + } + + Handle(BlockFix_BlockFixAPI)(const BlockFix_BlockFixAPI* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) + { + } + + Handle(BlockFix_BlockFixAPI)& operator=(const Handle(BlockFix_BlockFixAPI)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_BlockFixAPI)& operator=(const BlockFix_BlockFixAPI* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_BlockFixAPI* operator->() + { + return (BlockFix_BlockFixAPI *)ControlAccess(); + } + + BlockFix_BlockFixAPI* operator->() const + { + return (BlockFix_BlockFixAPI *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_BlockFixAPI)(); + + Standard_EXPORT static const Handle(BlockFix_BlockFixAPI) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo_NEW/Handle_BlockFix_PeriodicSurfaceModifier.hxx b/src/GEOMAlgo_NEW/Handle_BlockFix_PeriodicSurfaceModifier.hxx new file mode 100644 index 000000000..93fd00c01 --- /dev/null +++ b/src/GEOMAlgo_NEW/Handle_BlockFix_PeriodicSurfaceModifier.hxx @@ -0,0 +1,92 @@ +// 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_BlockFix_PeriodicSurfaceModifier_HeaderFile +#define _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_BRepTools_Modification_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(BRepTools_Modification); +class BlockFix_PeriodicSurfaceModifier; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_PeriodicSurfaceModifier); + +class Handle(BlockFix_PeriodicSurfaceModifier) : public Handle(BRepTools_Modification) { + 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); + } + Handle(BlockFix_PeriodicSurfaceModifier)():Handle(BRepTools_Modification)() {} + Handle(BlockFix_PeriodicSurfaceModifier)(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) + { + } + + Handle(BlockFix_PeriodicSurfaceModifier)(const BlockFix_PeriodicSurfaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) + { + } + + Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const Handle(BlockFix_PeriodicSurfaceModifier)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_PeriodicSurfaceModifier)& operator=(const BlockFix_PeriodicSurfaceModifier* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_PeriodicSurfaceModifier* operator->() + { + return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); + } + + BlockFix_PeriodicSurfaceModifier* operator->() const + { + return (BlockFix_PeriodicSurfaceModifier *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_PeriodicSurfaceModifier)(); + + Standard_EXPORT static const Handle(BlockFix_PeriodicSurfaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo_NEW/Handle_BlockFix_SphereSpaceModifier.hxx b/src/GEOMAlgo_NEW/Handle_BlockFix_SphereSpaceModifier.hxx new file mode 100644 index 000000000..29253a81a --- /dev/null +++ b/src/GEOMAlgo_NEW/Handle_BlockFix_SphereSpaceModifier.hxx @@ -0,0 +1,92 @@ +// 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_BlockFix_SphereSpaceModifier_HeaderFile +#define _Handle_BlockFix_SphereSpaceModifier_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_BRepTools_Modification_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(BRepTools_Modification); +class BlockFix_SphereSpaceModifier; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(BlockFix_SphereSpaceModifier); + +class Handle(BlockFix_SphereSpaceModifier) : public Handle(BRepTools_Modification) { + 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); + } + Handle(BlockFix_SphereSpaceModifier)():Handle(BRepTools_Modification)() {} + Handle(BlockFix_SphereSpaceModifier)(const Handle(BlockFix_SphereSpaceModifier)& aHandle) : Handle(BRepTools_Modification)(aHandle) + { + } + + Handle(BlockFix_SphereSpaceModifier)(const BlockFix_SphereSpaceModifier* anItem) : Handle(BRepTools_Modification)((BRepTools_Modification *)anItem) + { + } + + Handle(BlockFix_SphereSpaceModifier)& operator=(const Handle(BlockFix_SphereSpaceModifier)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(BlockFix_SphereSpaceModifier)& operator=(const BlockFix_SphereSpaceModifier* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + BlockFix_SphereSpaceModifier* operator->() + { + return (BlockFix_SphereSpaceModifier *)ControlAccess(); + } + + BlockFix_SphereSpaceModifier* operator->() const + { + return (BlockFix_SphereSpaceModifier *)ControlAccess(); + } + + Standard_EXPORT ~Handle(BlockFix_SphereSpaceModifier)(); + + Standard_EXPORT static const Handle(BlockFix_SphereSpaceModifier) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/GEOMAlgo_NEW/Makefile.am b/src/GEOMAlgo_NEW/Makefile.am new file mode 100644 index 000000000..ce5047db3 --- /dev/null +++ b/src/GEOMAlgo_NEW/Makefile.am @@ -0,0 +1,225 @@ +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 + +# 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 + +# Libraries targets +lib_LTLIBRARIES = libGEOMAlgo.la + +dist_libGEOMAlgo_la_SOURCES = \ + BlockFix_BlockFixAPI.cxx \ + BlockFix_CheckTool.cxx \ + BlockFix.cxx \ + BlockFix_PeriodicSurfaceModifier.cxx \ + BlockFix_SphereSpaceModifier.cxx \ + BlockFix_UnionEdges.cxx \ + BlockFix_UnionFaces.cxx \ + GEOMAlgo_Algo.cxx \ + GEOMAlgo_Builder_0.cxx \ + GEOMAlgo_Builder_1.cxx \ + GEOMAlgo_Builder_2.cxx \ + GEOMAlgo_Builder_3.cxx \ + GEOMAlgo_Builder_4.cxx \ + GEOMAlgo_BuilderArea.cxx \ + GEOMAlgo_Builder.cxx \ + GEOMAlgo_BuilderFace.cxx \ + GEOMAlgo_BuilderShape.cxx \ + GEOMAlgo_BuilderSolid.cxx \ + GEOMAlgo_BuilderTools.cxx \ + GEOMAlgo_ClsfBox.cxx \ + GEOMAlgo_Clsf.cxx \ + GEOMAlgo_ClsfSolid.cxx \ + GEOMAlgo_ClsfSurf.cxx \ + GEOMAlgo_CoupleOfShapes.cxx \ + GEOMAlgo_FinderShapeOn1.cxx \ + GEOMAlgo_FinderShapeOn2.cxx \ + GEOMAlgo_FinderShapeOn.cxx \ + GEOMAlgo_FinderShapeOnQuad.cxx \ + GEOMAlgo_GetInPlace_1.cxx \ + GEOMAlgo_GetInPlace_2.cxx \ + GEOMAlgo_GetInPlace_3.cxx \ + GEOMAlgo_GetInPlace.cxx \ + GEOMAlgo_GlueAnalyser.cxx \ + GEOMAlgo_GlueDetector.cxx \ + GEOMAlgo_Gluer2_1.cxx \ + GEOMAlgo_Gluer2_2.cxx \ + GEOMAlgo_Gluer2_3.cxx \ + GEOMAlgo_Gluer2.cxx \ + GEOMAlgo_GluerAlgo.cxx \ + GEOMAlgo_Gluer.cxx \ + GEOMAlgo_HAlgo.cxx \ + GEOMAlgo_PassKey.cxx \ + GEOMAlgo_PassKeyMapHasher.cxx \ + GEOMAlgo_PassKeyShape.cxx \ + GEOMAlgo_PassKeyShapeMapHasher.cxx \ + GEOMAlgo_ShapeAlgo.cxx \ + GEOMAlgo_ShapeInfo.cxx \ + GEOMAlgo_ShapeInfoFiller_1.cxx \ + GEOMAlgo_ShapeInfoFiller.cxx \ + GEOMAlgo_ShapeSet.cxx \ + GEOMAlgo_ShapeSolid.cxx \ + GEOMAlgo_ShellSolid.cxx \ + GEOMAlgo_SolidSolid.cxx \ + GEOMAlgo_Splitter.cxx \ + GEOMAlgo_StateCollector.cxx \ + GEOMAlgo_SurfaceTools.cxx \ + GEOMAlgo_Tools_1.cxx \ + GEOMAlgo_Tools3D.cxx \ + GEOMAlgo_Tools.cxx \ + GEOMAlgo_VertexSolid.cxx \ + GEOMAlgo_WESCorrector.cxx \ + GEOMAlgo_WESScaler.cxx \ + GEOMAlgo_WireEdgeSet.cxx \ + GEOMAlgo_WireSolid.cxx \ + GEOMAlgo_WireSplitter.cxx + +# header files +salomeinclude_HEADERS = \ + BlockFix.hxx \ + BlockFix.ixx \ + BlockFix.jxx \ + BlockFix_BlockFixAPI.hxx \ + BlockFix_BlockFixAPI.ixx \ + BlockFix_BlockFixAPI.jxx \ + BlockFix_BlockFixAPI.lxx \ + BlockFix_CheckTool.hxx \ + BlockFix_CheckTool.ixx \ + BlockFix_CheckTool.jxx \ + BlockFix_PeriodicSurfaceModifier.hxx \ + BlockFix_PeriodicSurfaceModifier.ixx \ + BlockFix_PeriodicSurfaceModifier.jxx \ + BlockFix_SphereSpaceModifier.hxx \ + BlockFix_SphereSpaceModifier.ixx \ + BlockFix_SphereSpaceModifier.jxx \ + BlockFix_UnionEdges.hxx \ + BlockFix_UnionEdges.ixx \ + BlockFix_UnionEdges.jxx \ + BlockFix_UnionFaces.hxx \ + BlockFix_UnionFaces.ixx \ + BlockFix_UnionFaces.jxx \ + Handle_BlockFix_BlockFixAPI.hxx \ + Handle_BlockFix_SphereSpaceModifier.hxx \ + Handle_BlockFix_PeriodicSurfaceModifier.hxx \ + GEOMAlgo_Algo.hxx \ + GEOMAlgo_BuilderArea.hxx \ + GEOMAlgo_BuilderFace.hxx \ + GEOMAlgo_Builder.hxx \ + GEOMAlgo_BuilderShape.hxx \ + GEOMAlgo_BuilderSolid.hxx \ + GEOMAlgo_BuilderTools.hxx \ + GEOMAlgo_ClsfBox.hxx \ + GEOMAlgo_Clsf.hxx \ + GEOMAlgo_ClsfSolid.hxx \ + GEOMAlgo_ClsfSurf.hxx \ + GEOMAlgo_CoupleOfShapes.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx \ + GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.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.hxx \ + GEOMAlgo_FinderShapeOn2.hxx \ + GEOMAlgo_FinderShapeOn.hxx \ + GEOMAlgo_FinderShapeOnQuad.hxx \ + GEOMAlgo_GetInPlace.hxx \ + GEOMAlgo_GlueAnalyser.hxx \ + GEOMAlgo_GlueDetector.hxx \ + GEOMAlgo_Gluer2.hxx \ + GEOMAlgo_GluerAlgo.hxx \ + GEOMAlgo_Gluer.hxx \ + GEOMAlgo_HAlgo.hxx \ + GEOMAlgo_IndexedDataMapOfIntegerShape.hxx \ + GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx \ + GEOMAlgo_IndexedDataMapOfShapeBox.hxx \ + GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx \ + GEOMAlgo_IndexedDataMapOfShapeState.hxx \ + GEOMAlgo_KindOfBounds.hxx \ + GEOMAlgo_KindOfClosed.hxx \ + GEOMAlgo_KindOfName.hxx \ + GEOMAlgo_KindOfShape.hxx \ + GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx \ + GEOMAlgo_ListIteratorOfListOfPnt.hxx \ + GEOMAlgo_ListOfCoupleOfShapes.hxx \ + GEOMAlgo_ListOfPnt.hxx \ + GEOMAlgo_PassKey.hxx \ + GEOMAlgo_PassKeyMapHasher.hxx \ + GEOMAlgo_PassKeyShape.hxx \ + GEOMAlgo_PassKeyShapeMapHasher.hxx \ + GEOMAlgo_PWireEdgeSet.hxx \ + GEOMAlgo_ShapeAlgo.hxx \ + GEOMAlgo_ShapeInfo.hxx \ + GEOMAlgo_ShapeInfoFiller.hxx \ + GEOMAlgo_ShapeSet.hxx \ + GEOMAlgo_ShapeSolid.hxx \ + GEOMAlgo_ShellSolid.hxx \ + GEOMAlgo_SolidSolid.hxx \ + GEOMAlgo_Splitter.hxx \ + GEOMAlgo_StateCollector.hxx \ + GEOMAlgo_State.hxx \ + GEOMAlgo_SurfaceTools.hxx \ + GEOMAlgo_Tools3D.hxx \ + GEOMAlgo_Tools.hxx \ + GEOMAlgo_VertexSolid.hxx \ + GEOMAlgo_WESCorrector.hxx \ + GEOMAlgo_WESScaler.hxx \ + GEOMAlgo_WireEdgeSet.hxx \ + GEOMAlgo_WireSolid.hxx \ + GEOMAlgo_WireSplitter.hxx + +libGEOMAlgo_la_CPPFLAGS = \ + $(CAS_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) \ + -I$(srcdir)/../$(NMTDS_VAR) \ + -I$(srcdir)/../$(NMTTools_VAR) + +libGEOMAlgo_la_LDFLAGS = \ + ../$(NMTTools_VAR)/libNMTTools.la \ + $(STDLIB) \ + $(CAS_LDPATH) -lTKBO -lTKShHealing -lTKBool -lTKMesh \ + $(KERNEL_LDFLAGS) -lSALOMELocalTrace + +# extra distributed files +CDL_FILES = \ + BlockFix.cdl \ + BlockFix_BlockFixAPI.cdl \ + BlockFix_CheckTool.cdl \ + BlockFix_PeriodicSurfaceModifier.cdl \ + BlockFix_SphereSpaceModifier.cdl \ + BlockFix_UnionEdges.cdl \ + BlockFix_UnionFaces.cdl \ + GEOMAlgo.cdl + +EXTRA_DIST += \ + $(CDL_FILES) \ + FILES diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index 1e3e4e8ee..c77071890 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -21,12 +21,10 @@ # Author : Damien COQUERET (OCC) # Modified by : Alexander BORODIN (OCN) - autotools usage # Module : GEOM -# $Header: include $(top_srcdir)/adm_local/unix/make_common_starter.am # Libraries targets - lib_LTLIBRARIES = libGEOMimpl.la # header files @@ -241,17 +239,17 @@ libGEOMimpl_la_CPPFLAGS = \ $(BOOST_CPPFLAGS) \ $(PYTHON_INCLUDES) \ -I$(srcdir)/../ShHealOper \ - -I$(srcdir)/../NMTDS \ - -I$(srcdir)/../NMTTools \ + -I$(srcdir)/../$(NMTDS_VAR) \ + -I$(srcdir)/../$(NMTTools_VAR) \ -I$(srcdir)/../GEOM \ - -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../$(GEOMAlgo_VAR) \ -I$(srcdir)/../SKETCHER \ -I$(srcdir)/../ARCHIMEDE \ -I$(top_builddir)/idl libGEOMimpl_la_LDFLAGS = \ ../GEOM/libGEOMbasic.la \ - ../GEOMAlgo/libGEOMAlgo.la \ + ../$(GEOMAlgo_VAR)/libGEOMAlgo.la \ ../ShHealOper/libShHealOper.la \ ../ARCHIMEDE/libGEOMArchimede.la \ ../SKETCHER/libGEOMSketcher.la \ diff --git a/src/GEOM_I/Makefile.am b/src/GEOM_I/Makefile.am index a0c8d2c04..62337f46a 100644 --- a/src/GEOM_I/Makefile.am +++ b/src/GEOM_I/Makefile.am @@ -78,7 +78,7 @@ libGEOMEngine_la_CPPFLAGS = \ -I$(srcdir)/../SKETCHER \ -I$(srcdir)/../ARCHIMEDE \ -I$(srcdir)/../GEOMImpl \ - -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../$(GEOMAlgo_VAR) \ -I$(srcdir)/../GEOM \ -I$(top_builddir)/idl diff --git a/src/GEOM_I_Superv/Makefile.am b/src/GEOM_I_Superv/Makefile.am index b9829b1cd..1bee76813 100644 --- a/src/GEOM_I_Superv/Makefile.am +++ b/src/GEOM_I_Superv/Makefile.am @@ -54,7 +54,7 @@ libGEOM_SupervEngine_la_CPPFLAGS = \ -I$(srcdir)/../GEOMImpl \ -I$(srcdir)/../GEOM \ -I$(srcdir)/../GEOM_I \ - -I$(srcdir)/../GEOMAlgo \ + -I$(srcdir)/../$(GEOMAlgo_VAR) \ -I$(top_builddir)/idl libGEOM_SupervEngine_la_LDFLAGS = \ diff --git a/src/Makefile.am b/src/Makefile.am index 7b2f4f374..7464d1502 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,18 +15,27 @@ # 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 : Makefile.am # Author : Alexander BORODIN, Open CASCADE S.A.S. (alexander.borodin@opencascade.com) # Package : src (source files directory) -# -SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER OCC2VTK GEOM \ +SUBDIRS = ARCHIMEDE $(NMTDS_VAR) $(NMTTools_VAR) $(GEOMAlgo_VAR) SKETCHER OCC2VTK GEOM \ BREPExport BREPImport IGESExport IGESImport STEPExport \ STEPImport STLExport VTKExport ShHealOper GEOMImpl GEOM_I \ GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY +#if PARTITION_OLD_PACKAGING +# SUBDIRS += NMTDS NMTTools GEOMAlgo +#else +# SUBDIRS += NMTDS_NEW NMTTools_NEW GEOMAlgo_NEW +#endif +# +# SUBDIRS += SKETCHER OCC2VTK GEOM \ +# BREPExport BREPImport IGESExport IGESImport STEPExport \ +# STEPImport STLExport VTKExport ShHealOper GEOMImpl GEOM_I \ +# GEOMClient GEOM_I_Superv GEOM_SWIG GEOM_PY + if WITH_OPENCV SUBDIRS += ShapeRecognition endif @@ -38,7 +47,8 @@ if GEOM_ENABLE_GUI GroupGUI BlocksGUI AdvancedGUI GEOM_SWIG_WITHIHM endif -DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo SKETCHER OCC2VTK GEOM BREPExport\ +DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo NMTDS_NEW NMTTools_NEW GEOMAlgo_NEW \ + SKETCHER OCC2VTK GEOM BREPExport\ BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \ VTKExport ShHealOper GEOMImpl GEOM_I GEOMClient GEOM_I_Superv \ GEOM_SWIG OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI GEOMBase \ diff --git a/src/NMTDS_NEW/FILES b/src/NMTDS_NEW/FILES new file mode 100644 index 000000000..e60c1fcdc --- /dev/null +++ b/src/NMTDS_NEW/FILES @@ -0,0 +1,66 @@ +Basics_OCCTVersion.hxx + +NMTDS_BoxBndTree.cxx +NMTDS_BoxBndTree.hxx +NMTDS_BndSphereTree.cxx +NMTDS_BndSphereTree.hxx +NMTDS_BndSphere.hxx +NMTDS_BndSphere.cxx +NMTDS_BndSphere.lxx +NMTDS_IndexRange.hxx +NMTDS_IndexRange.cxx +NMTDS_InterfPool.hxx +NMTDS_InterfPool.cxx +NMTDS_Iterator.hxx +NMTDS_Iterator.cxx +NMTDS_IteratorCheckerSI.hxx +NMTDS_IteratorCheckerSI.cxx +NMTDS_Pair.hxx +NMTDS_Pair.cxx +NMTDS_PairBoolean.hxx +NMTDS_PairBoolean.cxx +NMTDS_PairMapHasher.hxx +NMTDS_PairMapHasher.cxx +NMTDS_PassKey.hxx +NMTDS_PassKey.cxx +NMTDS_PassKeyBoolean.hxx +NMTDS_PassKeyBoolean.cxx +NMTDS_PassKeyMapHasher.hxx +NMTDS_PassKeyMapHasher.cxx +NMTDS_PassKeyShape.hxx +NMTDS_PassKeyShape.cxx +NMTDS_PassKeyShapeMapHasher.hxx +NMTDS_PassKeyShapeMapHasher.cxx +NMTDS_Tools.hxx +NMTDS_Tools.cxx +NMTDS_ShapesDataStructure.hxx +NMTDS_ShapesDataStructure.cxx +NMTDS_InterfType.hxx +NMTDS_PInterfPool.hxx +NMTDS_PIterator.hxx +NMTDS_PShapesDataStructure.hxx + +NMTDS_ListOfPassKey.hxx +NMTDS_ListIteratorOfListOfPassKey.hxx +NMTDS_ListOfPassKeyBoolean.hxx +NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx +NMTDS_ListOfPair.hxx +NMTDS_ListIteratorOfListOfPair.hxx +NMTDS_ListOfPairBoolean.hxx +NMTDS_ListIteratorOfListOfPairBoolean.hxx +NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx +NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx +NMTDS_MapOfPassKey.hxx +NMTDS_MapIteratorOfMapOfPassKey.hxx +NMTDS_MapOfPassKeyBoolean.hxx +NMTDS_MapIteratorOfMapOfPassKeyBoolean.hxx +NMTDS_MapOfPairBoolean.hxx +NMTDS_MapIteratorOfMapOfPairBoolean.hxx +NMTDS_IndexedDataMapOfShapeBox.hxx +NMTDS_IndexedDataMapOfIntegerShape.hxx +NMTDS_IndexedDataMapOfShapeBndSphere.hxx +NMTDS_DataMapOfIntegerMapOfInteger.hxx +NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx + +NMTDS_CArray1OfIndexRange.hxx +NMTDS_CArray1OfIndexRange.cxx diff --git a/src/NMTDS_NEW/Makefile.am b/src/NMTDS_NEW/Makefile.am new file mode 100644 index 000000000..a8a43b8dd --- /dev/null +++ b/src/NMTDS_NEW/Makefile.am @@ -0,0 +1,112 @@ + +# +# 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 + +# GEOM NMTAlgo : partition algorithm +# File : Makefile.in +# Author : Julia DOROVSKIKH +# Modified by : Alexander BORODIN (OCN) - autotools usage +# Module : GEOM + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# header files +salomeinclude_HEADERS = \ + NMTDS_BndSphere.hxx \ + NMTDS_BndSphere.lxx \ + NMTDS_BndSphereTree.hxx \ + NMTDS_BoxBndTree.hxx \ + NMTDS_CArray1OfIndexRange.hxx \ + NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx \ + NMTDS_DataMapOfIntegerMapOfInteger.hxx \ + NMTDS_IndexedDataMapOfIntegerShape.hxx \ + NMTDS_IndexedDataMapOfShapeBndSphere.hxx \ + NMTDS_IndexedDataMapOfShapeBox.hxx \ + NMTDS_IndexRange.hxx \ + NMTDS_InterfPool.hxx \ + NMTDS_InterfType.hxx \ + NMTDS_IteratorCheckerSI.hxx \ + NMTDS_Iterator.hxx \ + NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx \ + NMTDS_ListIteratorOfListOfPairBoolean.hxx \ + NMTDS_ListIteratorOfListOfPair.hxx \ + NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx \ + NMTDS_ListIteratorOfListOfPassKey.hxx \ + NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx \ + NMTDS_ListOfPairBoolean.hxx \ + NMTDS_ListOfPair.hxx \ + NMTDS_ListOfPassKeyBoolean.hxx \ + NMTDS_ListOfPassKey.hxx \ + NMTDS_MapIteratorOfMapOfPairBoolean.hxx \ + NMTDS_MapIteratorOfMapOfPassKeyBoolean.hxx \ + NMTDS_MapIteratorOfMapOfPassKey.hxx \ + NMTDS_MapOfPairBoolean.hxx \ + NMTDS_MapOfPassKeyBoolean.hxx \ + NMTDS_MapOfPassKey.hxx \ + NMTDS_PairBoolean.hxx \ + NMTDS_Pair.hxx \ + NMTDS_PairMapHasher.hxx \ + NMTDS_PassKeyBoolean.hxx \ + NMTDS_PassKey.hxx \ + NMTDS_PassKeyMapHasher.hxx \ + NMTDS_PassKeyShape.hxx \ + NMTDS_PassKeyShapeMapHasher.hxx \ + NMTDS_PInterfPool.hxx \ + NMTDS_PIterator.hxx \ + NMTDS_PShapesDataStructure.hxx \ + NMTDS_ShapesDataStructure.hxx \ + NMTDS_Tools.hxx + +# Libraries targets +lib_LTLIBRARIES = libNMTDS.la + +dist_libNMTDS_la_SOURCES = \ + NMTDS_BndSphere.cxx \ + NMTDS_BndSphereTree.cxx \ + NMTDS_BoxBndTree.cxx \ + NMTDS_CArray1OfIndexRange.cxx \ + NMTDS_IndexRange.cxx \ + NMTDS_InterfPool.cxx \ + NMTDS_IteratorCheckerSI.cxx \ + NMTDS_Iterator.cxx \ + NMTDS_PairBoolean.cxx \ + NMTDS_Pair.cxx \ + NMTDS_PairMapHasher.cxx \ + NMTDS_PassKeyBoolean.cxx \ + NMTDS_PassKey.cxx \ + NMTDS_PassKeyMapHasher.cxx \ + NMTDS_PassKeyShape.cxx \ + NMTDS_PassKeyShapeMapHasher.cxx \ + NMTDS_ShapesDataStructure.cxx \ + NMTDS_Tools.cxx + +# additional information to compile and link file + +libNMTDS_la_CPPFLAGS = \ + $(CAS_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) + +libNMTDS_la_LDFLAGS = \ + $(STDLIB) \ + $(CAS_LDPATH) -lTKBool -lTKBO + +# extra dist files +CDL_FILES = NMTDS.cdl + +EXTRA_DIST += \ + $(CDL_FILES) \ + FILES diff --git a/src/NMTDS_NEW/NMTDS.cdl b/src/NMTDS_NEW/NMTDS.cdl new file mode 100644 index 000000000..39ee4546f --- /dev/null +++ b/src/NMTDS_NEW/NMTDS.cdl @@ -0,0 +1,94 @@ +-- 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: NMTDS.cdl +-- Created: Fri Nov 28 10:13:19 2003 +-- Author: Peter KURNEV +-- +package NMTDS + + ---Purpose: + +--uses + --TCollection, + --TColStd, + --gp, + --Bnd, + --TopoDS, + --TopAbs, + --TopTools, + --BooleanOperations, + --BOPTools, + --BOPTColStd + +is + imported InterfType from NMTDS; + imported BndSphere from NMTDS; + imported IndexRange from NMTDS; + imported InterfPool from NMTDS; + imported Iterator from NMTDS; + imported IteratorCheckerSI from NMTDS; + imported Pair from NMTDS; + imported PairBoolean from NMTDS; + imported PairMapHasher from NMTDS; + imported PassKey from NMTDS; + imported PassKeyBoolean from NMTDS; + imported PassKeyMapHasher from NMTDS; + imported PassKeyShape from NMTDS; + imported PassKeyShapeMapHasher from NMTDS; + imported Tools from NMTDS; + imported ShapesDataStructure from NMTDS; + imported PShapesDataStructure from NMTDS; + imported PIterator from NMTDS; + imported PInterfPool from NMTDS; + -- + imported ListOfPassKey from NMTDS; + imported ListIteratorOfListOfPassKey from NMTDS; + + imported ListOfPassKeyBoolean from NMTDS; + imported ListIteratorOfListOfPassKeyBoolean from NMTDS; + + imported ListOfPair from NMTDS; + imported ListIteratorOfListOfPair from NMTDS; + + imported ListOfPairBoolean from NMTDS; + imported ListIteratorOfListOfPairBoolean from NMTDS; + + imported ListOfIndexedDataMapOfShapeAncestorsSuccessors from NMTDS; + imported ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors from NMTDS; + + imported MapOfPassKey from NMTDS; + imported MapIteratorOfMapOfPassKey from NMTDS; + + imported MapOfPairBoolean from NMTDS; + imported MapIteratorOfMapOfPairBoolean from NMTDS; + + imported IndexedDataMapOfShapeBox from NMTDS; + imported IndexedDataMapOfIntegerShape from NMTDS; + imported IndexedDataMapOfShapeBndSphere from NMTDS; + + imported DataMapOfIntegerMapOfInteger from NMTDS; + imported DataMapIteratorOfDataMapOfIntegerMapOfInteger from NMTDS; + + imported CArray1OfIndexRange from NMTDS; + +end NMTDS; diff --git a/src/NMTDS_NEW/NMTDS_BndSphere.cxx b/src/NMTDS_NEW/NMTDS_BndSphere.cxx new file mode 100644 index 000000000..0c5d7e5a7 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_BndSphere.cxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_BndSphere.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_BndSphere::NMTDS_BndSphere() +{ + myCenter.SetCoord(0., 0., 0.); + myRadius=0.; + myGap=0.; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + NMTDS_BndSphere::~NMTDS_BndSphere() +{ +} +//======================================================================= +//function : IsOut +//purpose : +//======================================================================= + Standard_Boolean NMTDS_BndSphere::IsOut(const NMTDS_BndSphere& theOther)const +{ + Standard_Real aD2, aT2; + // + aD2=myCenter.SquareDistance(theOther.myCenter); + aT2=myRadius+myGap+theOther.myRadius+theOther.myGap; + aT2=aT2*aT2; + // + return aD2>aT2; +} diff --git a/src/NMTDS_NEW/NMTDS_BndSphere.hxx b/src/NMTDS_NEW/NMTDS_BndSphere.hxx new file mode 100644 index 000000000..8cd676219 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_BndSphere.hxx @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_BndSphere.hxx +// Created: +// Author: Peter KURNEV +// + +#ifndef _NMTDS_BndSphere_HeaderFile +#define _NMTDS_BndSphere_HeaderFile + +#include +#include +#include +#include +#include + +//======================================================================= +//class : NMTDS_BndSphere +//purpose : +//======================================================================= +class NMTDS_BndSphere { + public: + Standard_EXPORT + NMTDS_BndSphere(); + + Standard_EXPORT + virtual ~NMTDS_BndSphere(); + + void SetCenter(const gp_Pnt& theP) ; + + const gp_Pnt& Center() const; + + void SetRadius(const Standard_Real theR) ; + + Standard_Real Radius() const; + + void SetGap(const Standard_Real theGap) ; + + Standard_Real Gap() const; + + void Add(const NMTDS_BndSphere& theOther) ; + + Standard_EXPORT + Standard_Boolean IsOut(const NMTDS_BndSphere& theOther) const; + + Standard_Real SquareExtent() const; + + protected: + gp_Pnt myCenter; + Standard_Real myRadius; + Standard_Real myGap; +}; + +#include + +#endif diff --git a/src/NMTDS_NEW/NMTDS_BndSphere.lxx b/src/NMTDS_NEW/NMTDS_BndSphere.lxx new file mode 100644 index 000000000..582e8d290 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_BndSphere.lxx @@ -0,0 +1,108 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_BndSphere.lxx +// Created: +// Author: Peter KURNEV +// +//======================================================================= +//function : SetCenter +//purpose : +//======================================================================= + inline void NMTDS_BndSphere::SetCenter(const gp_Pnt& theP) +// +{ + myCenter=theP; +} +//======================================================================= +//function : Center +//purpose : +//======================================================================= + inline const gp_Pnt& NMTDS_BndSphere::Center()const +{ + return myCenter; +} +//======================================================================= +//function : SetRadius +//purpose : +//======================================================================= + inline void NMTDS_BndSphere::SetRadius(const Standard_Real theR) +{ + myRadius=theR; +} +//======================================================================= +//function : Radius +//purpose : +//======================================================================= + inline Standard_Real NMTDS_BndSphere::Radius()const +{ + return myRadius; +} +//======================================================================= +//function : SetGap +//purpose : +//======================================================================= + inline void NMTDS_BndSphere::SetGap(const Standard_Real theGap) +{ + myGap=theGap; +} +//======================================================================= +//function : Gap +//purpose : +//======================================================================= + inline Standard_Real NMTDS_BndSphere::Gap()const +{ + return myGap; +} +//======================================================================= +//function : Add +//purpose : +//======================================================================= + inline void NMTDS_BndSphere::Add(const NMTDS_BndSphere& theOther) +{ + Standard_Real aTmax, aR, aT, aTOther; + gp_Pnt aPc; + // + aPc.SetXYZ(0.5*(myCenter.XYZ()+theOther.myCenter.XYZ())); + // + aR=aPc.Distance(myCenter); + // + aT=myRadius+myGap; + aTOther=theOther.myRadius+theOther.myGap; + aTmax=(aT>aTOther) ? aT: aTOther; + // + aR=aR+aTmax; + // + myCenter=aPc; + myRadius=aR; +} +//======================================================================= +//function : SquareExtent +//purpose : +//======================================================================= + inline Standard_Real NMTDS_BndSphere::SquareExtent()const +{ + Standard_Real aD; + // + aD=myRadius+myGap; + aD=aD+aD; + aD=aD*aD; + // + return aD; +} diff --git a/src/NMTDS_NEW/NMTDS_BndSphereTree.cxx b/src/NMTDS_NEW/NMTDS_BndSphereTree.cxx new file mode 100644 index 000000000..f5f810fc4 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_BndSphereTree.cxx @@ -0,0 +1,89 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_BndSphereTree.cxx +// Created: +// Author: Peter KURNEV +// +// +#include +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_BndSphereTreeSelector::NMTDS_BndSphereTreeSelector() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + NMTDS_BndSphereTreeSelector::~NMTDS_BndSphereTreeSelector() +{ +} +//======================================================================= +//function : Reject +//purpose : +//======================================================================= + Standard_Boolean NMTDS_BndSphereTreeSelector::Reject (const NMTDS_BndSphere& aBox) const +{ + Standard_Boolean bRet; + // + bRet=myBox.IsOut(aBox); + return bRet; +} +//======================================================================= +//function : Accept +//purpose : +//======================================================================= + Standard_Boolean NMTDS_BndSphereTreeSelector::Accept (const Standard_Integer& aIndex) +{ + Standard_Boolean bRet=Standard_False; + // + if (myFence.Add(aIndex)) { + myIndices.Append(aIndex); + bRet=!bRet; + } + return bRet; +} +//======================================================================= +//function : SetBox +//purpose : +//======================================================================= + void NMTDS_BndSphereTreeSelector::SetBox(const NMTDS_BndSphere& aBox) +{ + myBox=aBox; +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void NMTDS_BndSphereTreeSelector::Clear() +{ + myFence.Clear(); + myIndices.Clear(); +} +//======================================================================= +//function : Indices +//purpose : +//======================================================================= + const TColStd_ListOfInteger& NMTDS_BndSphereTreeSelector::Indices() const +{ + return myIndices; +} diff --git a/src/NMTDS_NEW/NMTDS_BndSphereTree.hxx b/src/NMTDS_NEW/NMTDS_BndSphereTree.hxx new file mode 100644 index 000000000..518745cf7 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_BndSphereTree.hxx @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_BndSphereTree.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef NMTDS_BndSphereTree_HeaderFile +#define NMTDS_BndSphereTree_HeaderFile + +#include +#include +#include +#include + +typedef NCollection_UBTree NMTDS_BndSphereTree; + + class NMTDS_BndSphereTreeSelector : public NMTDS_BndSphereTree::Selector { + public: + Standard_EXPORT NMTDS_BndSphereTreeSelector(); + Standard_EXPORT virtual Standard_Boolean Reject(const NMTDS_BndSphere&) const; + Standard_EXPORT virtual Standard_Boolean Accept(const Standard_Integer &); + Standard_EXPORT virtual ~NMTDS_BndSphereTreeSelector(); + + Standard_EXPORT void Clear(); + Standard_EXPORT void SetBox(const NMTDS_BndSphere&); + Standard_EXPORT const TColStd_ListOfInteger& Indices() const; + + protected: + NMTDS_BndSphere myBox; + TColStd_MapOfInteger myFence; + TColStd_ListOfInteger myIndices; + + }; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_BoxBndTree.cxx b/src/NMTDS_NEW/NMTDS_BoxBndTree.cxx new file mode 100644 index 000000000..100d9857c --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_BoxBndTree.cxx @@ -0,0 +1,92 @@ +// 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: NMTDS_BoxBndTree.cxx +// Created: Tue Oct 17 13:04:11 2006 +// Author: Peter KURNEV +// +// +#include +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_BoxBndTreeSelector::NMTDS_BoxBndTreeSelector() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + NMTDS_BoxBndTreeSelector::~NMTDS_BoxBndTreeSelector() +{ +} +//======================================================================= +//function : Reject +//purpose : +//======================================================================= + Standard_Boolean NMTDS_BoxBndTreeSelector::Reject (const Bnd_Box& aBox) const +{ + Standard_Boolean bRet; + // + bRet=myBox.IsOut(aBox); + return bRet; +} +//======================================================================= +//function : Accept +//purpose : +//======================================================================= + Standard_Boolean NMTDS_BoxBndTreeSelector::Accept (const Standard_Integer& aIndex) +{ + Standard_Boolean bRet=Standard_False; + // + if (myFence.Add(aIndex)) { + myIndices.Append(aIndex); + bRet=!bRet; + } + return bRet; +} +//======================================================================= +//function : SetBox +//purpose : +//======================================================================= + void NMTDS_BoxBndTreeSelector::SetBox(const Bnd_Box& aBox) +{ + myBox=aBox; +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void NMTDS_BoxBndTreeSelector::Clear() +{ + myFence.Clear(); + myIndices.Clear(); +} +//======================================================================= +//function : Indices +//purpose : +//======================================================================= + const TColStd_ListOfInteger& NMTDS_BoxBndTreeSelector::Indices() const +{ + return myIndices; +} diff --git a/src/NMTDS_NEW/NMTDS_BoxBndTree.hxx b/src/NMTDS_NEW/NMTDS_BoxBndTree.hxx new file mode 100644 index 000000000..171da43ae --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_BoxBndTree.hxx @@ -0,0 +1,56 @@ +// 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: NMTDS_BoxBndTree.hxx +// Created: Tue Oct 17 12:50:31 2006 +// Author: Peter KURNEV +// +// +#ifndef NMTDS_BoxBndTree_HeaderFile +#define NMTDS_BoxBndTree_HeaderFile + +#include +#include +#include +#include + +typedef NCollection_UBTree NMTDS_BoxBndTree; + + class NMTDS_BoxBndTreeSelector : public NMTDS_BoxBndTree::Selector { + public: + Standard_EXPORT NMTDS_BoxBndTreeSelector(); + Standard_EXPORT virtual Standard_Boolean Reject(const Bnd_Box&) const; + Standard_EXPORT virtual Standard_Boolean Accept(const Standard_Integer &); + Standard_EXPORT virtual ~NMTDS_BoxBndTreeSelector(); + + Standard_EXPORT void Clear(); + Standard_EXPORT void SetBox(const Bnd_Box&); + Standard_EXPORT const TColStd_ListOfInteger& Indices() const; + + protected: + Bnd_Box myBox; + TColStd_MapOfInteger myFence; + TColStd_ListOfInteger myIndices; + + }; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_CArray1OfIndexRange.cxx b/src/NMTDS_NEW/NMTDS_CArray1OfIndexRange.cxx new file mode 100644 index 000000000..d7dbed2c1 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_CArray1OfIndexRange.cxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_CArray1OfIndexRange.hxx +// Created: +// Author: Peter KURNEV +// + +#include + +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_OutOfMemory_HeaderFile +#include +#endif + + +#define Array1Item NMTDS_IndexRange +#define Array1Item_hxx +#define BOPTColStd_CArray1 NMTDS_CArray1OfIndexRange +#define BOPTColStd_CArray1_hxx +#include + diff --git a/src/NMTDS_NEW/NMTDS_CArray1OfIndexRange.hxx b/src/NMTDS_NEW/NMTDS_CArray1OfIndexRange.hxx new file mode 100644 index 000000000..1ded0aff1 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_CArray1OfIndexRange.hxx @@ -0,0 +1,121 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_BndSphere.hxx +// Created: +// Author: Peter KURNEV +// + +#ifndef _NMTDS_CArray1OfIndexRange_HeaderFile +#define _NMTDS_CArray1OfIndexRange_HeaderFile + +#include +#include +#include +#include +#include +#include + +class Standard_OutOfRange; +class Standard_OutOfMemory; + + + +//======================================================================= +//function : NMTDS_CArray1OfIndexRange +//purpose : +//======================================================================= +class NMTDS_CArray1OfIndexRange { + public: + + Standard_EXPORT + NMTDS_CArray1OfIndexRange(const Standard_Integer Length = 0, + const Standard_Integer BlockLength = 5); + + Standard_EXPORT + void Resize(const Standard_Integer theNewLength) ; + + Standard_EXPORT + void Destroy() ; + + ~NMTDS_CArray1OfIndexRange() { + Destroy(); + } + + Standard_EXPORT + Standard_Integer Length() const; + + Standard_EXPORT + Standard_Integer Extent() const; + + Standard_EXPORT + Standard_Integer FactLength() const; + + Standard_EXPORT + Standard_Integer Append(const NMTDS_IndexRange& Value) ; + + Standard_EXPORT + void Remove(const Standard_Integer Index) ; + + Standard_EXPORT + const NMTDS_IndexRange& Value(const Standard_Integer Index) const; + + const NMTDS_IndexRange& operator ()(const Standard_Integer Index) const { + return Value(Index); + } + + Standard_EXPORT + NMTDS_IndexRange& ChangeValue(const Standard_Integer Index) ; + + NMTDS_IndexRange& operator ()(const Standard_Integer Index) { + return ChangeValue(Index); + } + + Standard_EXPORT + void SetBlockLength(const Standard_Integer aBL) ; + + Standard_EXPORT + Standard_Integer BlockLength() const; + + Standard_EXPORT + void Purge() ; + + private: + Standard_EXPORT + NMTDS_CArray1OfIndexRange(const NMTDS_CArray1OfIndexRange& AnArray); + + Standard_EXPORT + NMTDS_CArray1OfIndexRange& Assign(const NMTDS_CArray1OfIndexRange& Other) ; + + NMTDS_CArray1OfIndexRange& operator =(const NMTDS_CArray1OfIndexRange& Other) { + return Assign(Other); + } + + Standard_EXPORT + Standard_Boolean IsInvalidIndex(const Standard_Integer Index) const; + + + Standard_Address myStart; + Standard_Integer myLength; + Standard_Integer myFactLength; + Standard_Integer myBlockLength; + Standard_Boolean myIsAllocated; +}; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx b/src/NMTDS_NEW/NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx new file mode 100644 index 000000000..5b2509a7e --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx +// Created: Mon Feb 20 09:31:43 2012 +// Author: +// + + +#ifndef NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger_HeaderFile +#define NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger_HeaderFile + +#ifndef NMTDS_DataMapOfIntegerMapOfInteger_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_DataMapOfIntegerMapOfInteger.hxx b/src/NMTDS_NEW/NMTDS_DataMapOfIntegerMapOfInteger.hxx new file mode 100644 index 000000000..1c413e03b --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_DataMapOfIntegerMapOfInteger.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_DataMapOfIntegerMapOfInteger.hxx +// Created: Mon Feb 20 09:27:40 2012 +// Author: +// + + +#ifndef NMTDS_DataMapOfIntegerMapOfInteger_HeaderFile +#define NMTDS_DataMapOfIntegerMapOfInteger_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_DataMap NMTDS_DataMapOfIntegerMapOfInteger; +typedef NMTDS_DataMapOfIntegerMapOfInteger::Iterator NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/NMTDS_NEW/NMTDS_IndexRange.cxx b/src/NMTDS_NEW/NMTDS_IndexRange.cxx new file mode 100644 index 000000000..2dd892c48 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_IndexRange.cxx @@ -0,0 +1,79 @@ +// 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: NMTDS_IndexRange.cxx +// Created: Fri Nov 28 10:34:59 2003 +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function :NMTDS_IndexRange::NMTDS_IndexRange +//purpose : +//======================================================================= + NMTDS_IndexRange::NMTDS_IndexRange() +: + myFirst(0), + myLast(0) +{ +} +//======================================================================= +//function :SetFirst +//purpose : +//======================================================================= + void NMTDS_IndexRange::SetFirst(const Standard_Integer aFirst) +{ + myFirst=aFirst; +} +//======================================================================= +//function :First +//purpose : +//======================================================================= + Standard_Integer NMTDS_IndexRange::First()const +{ + return myFirst; +} +//======================================================================= +//function :SetLast +//purpose : +//======================================================================= + void NMTDS_IndexRange::SetLast(const Standard_Integer aLast) +{ + myLast=aLast; +} +//======================================================================= +//function :Last +//purpose : +//======================================================================= + Standard_Integer NMTDS_IndexRange::Last()const +{ + return myLast; +} +//======================================================================= +//function :IsInRange +//purpose : +//======================================================================= + Standard_Boolean NMTDS_IndexRange::IsInRange(const Standard_Integer aIndex)const +{ + return (Standard_Boolean)(aIndex>=myFirst && aIndex<=myLast); +} diff --git a/src/NMTDS_NEW/NMTDS_IndexRange.hxx b/src/NMTDS_NEW/NMTDS_IndexRange.hxx new file mode 100644 index 000000000..c0ec21787 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_IndexRange.hxx @@ -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 +// + +// File: NMTDS_IndexRange.hxx +// Created: +// Author: Peter KURNEV +// +// + +#ifndef _NMTDS_IndexRange_HeaderFile +#define _NMTDS_IndexRange_HeaderFile + +#include +#include +#include +#include + +//======================================================================= +//class : NMTDS_IndexRange +//purpose : +//======================================================================= +class NMTDS_IndexRange { + public: + + Standard_EXPORT + NMTDS_IndexRange(); + + Standard_EXPORT void SetFirst(const Standard_Integer aFirst) ; + + Standard_EXPORT void SetLast(const Standard_Integer aLast) ; + + Standard_EXPORT Standard_Integer First() const; + + Standard_EXPORT Standard_Integer Last() const; + + Standard_EXPORT Standard_Boolean IsInRange(const Standard_Integer aIndex) const; + +protected: + Standard_Integer myFirst; + Standard_Integer myLast; +}; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_IndexedDataMapOfIntegerShape.hxx b/src/NMTDS_NEW/NMTDS_IndexedDataMapOfIntegerShape.hxx new file mode 100644 index 000000000..a3e494189 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_IndexedDataMapOfIntegerShape.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_IndexedDataMapOfIntegerShape.hxx +// Created: Mon Feb 20 09:20:07 2012 +// Author: +// + + +#ifndef NMTDS_IndexedDataMapOfIntegerShape_HeaderFile +#define NMTDS_IndexedDataMapOfIntegerShape_HeaderFile + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_IndexedDataMap NMTDS_IndexedDataMapOfIntegerShape; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/NMTDS_NEW/NMTDS_IndexedDataMapOfShapeBndSphere.hxx b/src/NMTDS_NEW/NMTDS_IndexedDataMapOfShapeBndSphere.hxx new file mode 100644 index 000000000..259b5258a --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_IndexedDataMapOfShapeBndSphere.hxx @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_IndexedDataMapOfShapeBndSphere.hxx +// Created: Mon Feb 20 09:17:01 2012 +// Author: +// + + +#ifndef NMTDS_IndexedDataMapOfShapeBndSphere_HeaderFile +#define NMTDS_IndexedDataMapOfShapeBndSphere_HeaderFile + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + + +typedef NCollection_IndexedDataMap NMTDS_IndexedDataMapOfShapeBndSphere; + +#undef _NCollection_MapHasher + + + + +#endif diff --git a/src/NMTDS_NEW/NMTDS_IndexedDataMapOfShapeBox.hxx b/src/NMTDS_NEW/NMTDS_IndexedDataMapOfShapeBox.hxx new file mode 100644 index 000000000..c659212fa --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_IndexedDataMapOfShapeBox.hxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_IndexedDataMapOfShapeBox.hxx +// Created: Mon Feb 20 09:17:01 2012 +// Author: +// + + +#ifndef NMTDS_IndexedDataMapOfShapeBox_HeaderFile +#define NMTDS_IndexedDataMapOfShapeBox_HeaderFile + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_IndexedDataMap NMTDS_IndexedDataMapOfShapeBox; + +#undef _NCollection_MapHasher + + + + +#endif diff --git a/src/NMTDS_NEW/NMTDS_InterfPool.cxx b/src/NMTDS_NEW/NMTDS_InterfPool.cxx new file mode 100644 index 000000000..ac930365c --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_InterfPool.cxx @@ -0,0 +1,301 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_InterfPool.cxx +// Author: Peter KURNEV + +#include + +#include +#include +#include +#include + +#include + +static + Standard_Integer TypeToInteger(const NMTDS_InterfType aType); + +//======================================================================= +//function : +//purpose : +//======================================================================= +NMTDS_InterfPool::NMTDS_InterfPool() +{ + myMaxInd=6; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + NMTDS_InterfPool::~NMTDS_InterfPool() +{ +} +//======================================================================= +//function : Add +//purpose : +//======================================================================= +Standard_Boolean NMTDS_InterfPool::Add (const NMTDS_PairBoolean& aPKB, + const NMTDS_InterfType aType) +{ + Standard_Boolean bRet; + Standard_Integer iType; + // + bRet=Standard_False; + // + iType=TypeToInteger(aType); + if (iType>-1 && iTypeClear(); + // + for (i=0; iAppend(aPKB); + } + } + return myList; +} +//======================================================================= +//function : Get +//purpose : +//======================================================================= +const NMTDS_ListOfPairBoolean& NMTDS_InterfPool::Get + (const Standard_Integer aInd)const +{ + Standard_Integer i, n1, n2; + NMTDS_ListOfPairBoolean* pL; + // + pL=(NMTDS_ListOfPairBoolean*)&myList; + pL->Clear(); + // + for (i=0; iAppend(aPKB); + } + } + } + return myList; +} +//======================================================================= +//function : Get +//purpose : +//======================================================================= +const NMTDS_ListOfPairBoolean& NMTDS_InterfPool::Get + (const NMTDS_InterfType aType)const +{ + Standard_Integer iType; + NMTDS_ListOfPairBoolean* pL; + // + pL=(NMTDS_ListOfPairBoolean*)&myList; + pL->Clear(); + // + iType=TypeToInteger(aType); + if (iType>-1 && iTypeAppend(aPKB); + } + } + return myList; +} +//======================================================================= +//function : Get +//purpose : +//======================================================================= +const NMTDS_ListOfPairBoolean& NMTDS_InterfPool::Get + (const Standard_Integer aInd, + const NMTDS_InterfType aType)const +{ + Standard_Integer n1, n2; + NMTDS_ListOfPairBoolean *pL, aLPKB; + NMTDS_ListIteratorOfListOfPairBoolean aIt; + // + aLPKB=Get(aType); + // + pL=(NMTDS_ListOfPairBoolean*)&myList; + pL->Clear(); + // + aIt.Initialize (aLPKB); + for (; aIt.More(); aIt.Next()) { + const NMTDS_PairBoolean& aPKB=aIt.Value(); + aPKB.Ids(n1, n2); + if(n1==aInd || n2==aInd) { + pL->Append(aPKB); + } + } + return myList; +} +//////////////////// +//=========================================================================== +//function : SSInterferences +//purpose : +//=========================================================================== +BOPTools_CArray1OfSSInterference& NMTDS_InterfPool::SSInterferences() +{ + return mySSInterferences; +} +//=========================================================================== +//function : ESInterferences +//purpose : +//=========================================================================== +BOPTools_CArray1OfESInterference& NMTDS_InterfPool::ESInterferences() +{ + return myESInterferences; +} +//=========================================================================== +//function : VSInterferences +//purpose : +//=========================================================================== +BOPTools_CArray1OfVSInterference& NMTDS_InterfPool::VSInterferences() +{ + return myVSInterferences; +} +//=========================================================================== +//function : EEInterferences +//purpose : +//=========================================================================== +BOPTools_CArray1OfEEInterference& NMTDS_InterfPool::EEInterferences() +{ + return myEEInterferences; +} +//=========================================================================== +//function : VEInterferences +//purpose : +//=========================================================================== +BOPTools_CArray1OfVEInterference& NMTDS_InterfPool::VEInterferences() +{ + return myVEInterferences; +} +//=========================================================================== +//function : VVInterferences +//purpose : +//=========================================================================== +BOPTools_CArray1OfVVInterference& NMTDS_InterfPool::VVInterferences() +{ + return myVVInterferences; +} + +//modified by NIZNHY-PKV Mon Dec 12 09:07:54 2011f +//======================================================================= +//function : Purge +//purpose : +//======================================================================= +void NMTDS_InterfPool::Purge() +{ +#if OCC_VERSION_LARGE > 0x06050200 + myVVInterferences.Purge(); + myVEInterferences.Purge(); + myEEInterferences.Purge(); + myVSInterferences.Purge(); + myESInterferences.Purge(); + mySSInterferences.Purge(); +#endif +} +//modified by NIZNHY-PKV Mon Dec 12 09:07:58 2011t + +//======================================================================= +//function : TypeToInteger +//purpose : +//======================================================================= +Standard_Integer TypeToInteger(const NMTDS_InterfType aType) +{ + return (Standard_Integer)aType; +} diff --git a/src/NMTDS_NEW/NMTDS_InterfPool.hxx b/src/NMTDS_NEW/NMTDS_InterfPool.hxx new file mode 100644 index 000000000..8e0ad399e --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_InterfPool.hxx @@ -0,0 +1,120 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_InterfPool.hxx +// +// Author: Peter KURNEV + +#ifndef _NMTDS_InterfPool_HeaderFile +#define _NMTDS_InterfPool_HeaderFile + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : NMTDS_InterfPool +//purpose : +//======================================================================= +class NMTDS_InterfPool { + public: + Standard_EXPORT + NMTDS_InterfPool(); + Standard_EXPORT + virtual ~NMTDS_InterfPool(); + + Standard_EXPORT + Standard_Boolean Add(const NMTDS_PairBoolean& aPKB, + const NMTDS_InterfType aType) ; + + Standard_EXPORT + Standard_Boolean Add(const Standard_Integer aInd1, + const Standard_Integer aInd2, + const NMTDS_InterfType aType) ; + + Standard_EXPORT + Standard_Boolean Add(const Standard_Integer aInd1, + const Standard_Integer aInd2, + const Standard_Boolean bFlag, + const NMTDS_InterfType aType) ; + + Standard_EXPORT + Standard_Boolean Contains(const NMTDS_PairBoolean& aPKB) const; + + Standard_EXPORT + Standard_Boolean Contains(const Standard_Integer aInd1, + const Standard_Integer aInd2) const; + + Standard_EXPORT + const NMTDS_ListOfPairBoolean& Get() const; + + Standard_EXPORT + const NMTDS_ListOfPairBoolean& Get(const NMTDS_InterfType aType) const; + + Standard_EXPORT + const NMTDS_ListOfPairBoolean& Get(const Standard_Integer aInd) const; + + Standard_EXPORT + const NMTDS_ListOfPairBoolean& Get(const Standard_Integer aInd, + const NMTDS_InterfType aType) const; + + //! Returns the reference to array Of F/F interferences
+ Standard_EXPORT BOPTools_CArray1OfSSInterference& SSInterferences() ; + + //! Returns the reference to array Of E/F interferences
+ Standard_EXPORT BOPTools_CArray1OfESInterference& ESInterferences() ; + + //! Returns the reference to array Of V/F interferences
+ Standard_EXPORT BOPTools_CArray1OfVSInterference& VSInterferences() ; + + //! Returns the reference to arrray Of E/E interferences
+ Standard_EXPORT BOPTools_CArray1OfEEInterference& EEInterferences() ; + + //! Returns the reference to arrray Of V/E interferences
+ Standard_EXPORT BOPTools_CArray1OfVEInterference& VEInterferences() ; + + //! Returns the reference to arrray Of V/V interferences
+ Standard_EXPORT BOPTools_CArray1OfVVInterference& VVInterferences() ; + + Standard_EXPORT void Purge() ; + +protected: + NMTDS_MapOfPairBoolean myTable[6]; + NMTDS_ListOfPairBoolean myList; + Standard_Integer myMaxInd; + BOPTools_CArray1OfSSInterference mySSInterferences; + BOPTools_CArray1OfESInterference myESInterferences; + BOPTools_CArray1OfVSInterference myVSInterferences; + BOPTools_CArray1OfEEInterference myEEInterferences; + BOPTools_CArray1OfVEInterference myVEInterferences; + BOPTools_CArray1OfVVInterference myVVInterferences; + +private: +}; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_InterfType.hxx b/src/NMTDS_NEW/NMTDS_InterfType.hxx new file mode 100644 index 000000000..7f35b579f --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_InterfType.hxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_InterfType.hxx +// Created: +// Author: Peter KURNEV +// + + +#ifndef _NMTDS_InterfType_HeaderFile +#define _NMTDS_InterfType_HeaderFile + + +enum NMTDS_InterfType { +NMTDS_TI_VV, +NMTDS_TI_VE, +NMTDS_TI_VF, +NMTDS_TI_EE, +NMTDS_TI_EF, +NMTDS_TI_FF, +NMTDS_TI_UNKNOWN +}; + +#ifndef _Standard_PrimitiveTypes_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_Iterator.cxx b/src/NMTDS_NEW/NMTDS_Iterator.cxx new file mode 100644 index 000000000..44f452d82 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_Iterator.cxx @@ -0,0 +1,467 @@ +// 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: NMTDS_Iterator.cxx +// 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 + +//======================================================================= +//function : NMTDS_Iterator +//purpose : +//======================================================================= +NMTDS_Iterator::NMTDS_Iterator() +{ + myDS=NULL; + myLength=0; +} +//======================================================================= +//function : ~NMTDS_Iterator +//purpose : +//======================================================================= +NMTDS_Iterator::~NMTDS_Iterator() +{ +} +//======================================================================= +// function: SetDS +// purpose: +//======================================================================= +void NMTDS_Iterator::SetDS(const NMTDS_PShapesDataStructure& aDS) +{ + myDS=aDS; +} +//======================================================================= +// function: DS +// purpose: +//======================================================================= +const NMTDS_ShapesDataStructure& NMTDS_Iterator::DS()const +{ + return *myDS; +} +//======================================================================= +// function: ExpectedLength +// purpose: +//======================================================================= +Standard_Integer NMTDS_Iterator::ExpectedLength() const +{ + return myLength; +} +//======================================================================= +// function: BlockLength +// purpose: +//======================================================================= +Standard_Integer NMTDS_Iterator::BlockLength() const +{ + Standard_Integer aNbIIs, iTresh; + Standard_Real aCfPredict=.5; + + aNbIIs=ExpectedLength(); + + if (aNbIIs<=1) { + return 1; + } + //modified by NIZNHY-PKV Mon Dec 12 08:50:50 2011f + iTresh=1000; + if (aNbIIs>iTresh) { + aNbIIs=iTresh; + return aNbIIs; + } + //modified by NIZNHY-PKV Mon Dec 12 08:50:54 2011t + // + aNbIIs=(Standard_Integer) (aCfPredict*(Standard_Real)aNbIIs); + return aNbIIs; +} +//======================================================================= +// function: Initialize +// purpose: +//======================================================================= +void NMTDS_Iterator::Initialize(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + Standard_Integer iX; + // + iX=NMTDS_Tools::TypeToInteger(aType1, aType2); + if (iX>=0) { + myIterator.Initialize(myLists[iX]); + myLength=myLists[iX].Extent(); + } + else { + myIterator.Initialize(myEmptyList); + myLength=0; + } +} +//======================================================================= +// function: More +// purpose: +//======================================================================= +Standard_Boolean NMTDS_Iterator::More()const +{ + return myIterator.More(); +} +//======================================================================= +// function: Next +// purpose: +//======================================================================= +void NMTDS_Iterator::Next() +{ + myIterator.Next(); +} +//======================================================================= +// function: Current +// purpose: +//======================================================================= +void NMTDS_Iterator::Current(Standard_Integer& aIndex1, + Standard_Integer& aIndex2, + Standard_Boolean& aWithSubShape) const +{ + const NMTDS_PairBoolean& aPKB=myIterator.Value(); + aPKB.Ids(aIndex1, aIndex2); + aWithSubShape=aPKB.Flag(); +} +//======================================================================= +// function: SDVertices +// purpose: +//======================================================================= +const TColStd_DataMapOfIntegerListOfInteger& NMTDS_Iterator::SDVertices()const +{ + return myMVSD; +} +//======================================================================= +// function: Prepare +// purpose: +//======================================================================= +void NMTDS_Iterator::Prepare() +{ + Standard_Integer i; + // + myLength=0; + for (i=0; i<6; ++i) { + myLists[i].Clear(); + } + myMVSD.Clear(); + // + if (myDS==NULL){ + return; + } + Intersect(); +} +//======================================================================= +// function: Intersect +// purpose: +//======================================================================= +void NMTDS_Iterator::Intersect() +{ + Standard_Boolean bFlag; + Standard_Integer aNb, i, aNbB, aNbR, iFlag; + Standard_Integer i1, i2, aNbSD, iX, j, iDS, jB, iR, k, aNbLV, aNbLV1; + TColStd_ListIteratorOfListOfInteger aIt; + TColStd_DataMapOfIntegerInteger aMII; + TColStd_DataMapOfIntegerListOfInteger aMVSD; + TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD; + TopTools_DataMapOfShapeInteger aMSI; + TopAbs_ShapeEnum aTi, aTj; + NMTDS_PairBoolean aPKXB; + NMTDS_MapOfPairBoolean aMPKXB; + NMTDS_IndexedDataMapOfShapeBox aMSB; + // + NMTDS_BoxBndTreeSelector aSelector; + NMTDS_BoxBndTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + const NMTDS_CArray1OfIndexRange& aRanges=myDS->Ranges(); + aNbR=aRanges.Extent(); + // + aNb=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=myDS->Shape(i); + aTi=aS.ShapeType(); + if (NMTDS_Tools::HasBRep(aTi)) { + Bnd_Box aBoxEx; + // + myDS->ComputeBoxEx(i, aBoxEx); + aMSI.Bind(aS, i); + aMSB.Add(aS, aBoxEx); + } + } + // + aNbB=aMSB.Extent(); + // + for (i=1; i<=aNbB; ++i) { + const TopoDS_Shape& aS=aMSB.FindKey(i); + const Bnd_Box& aBoxEx=aMSB(i); + // + aTreeFiller.Add(i, aBoxEx); + // + iDS=aMSI.Find(aS); + aMII.Bind(i, iDS); + } + // + aTreeFiller.Fill(); + // + for (iR=1; iRShape(i); + aTi=aSi.ShapeType(); + if (!NMTDS_Tools::HasBRep(aTi)){ + continue; + } + const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi); + aSelector.Clear(); + aSelector.SetBox(aBoxEx); + // + aNbSD=aBBTree.Select(aSelector); + // + if (!aNbSD){ + continue; + } + // + const TColStd_ListOfInteger& aLI=aSelector.Indices(); + // + k=0; + TColStd_ListOfInteger aLV; + // + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + jB=aIt.Value(); // box index in MII + j=aMII.Find(jB); // DS index + if (j>=i1 && j<=i2) { + continue;// same range + } + // + aPKXB.SetIds(i, j); + // + if (aMPKXB.Add(aPKXB)) { + bFlag=Standard_False;// Bounding boxes are intersected + const Bnd_Box& aBoxi=myDS->GetBoundingBox(i); + const Bnd_Box& aBoxj=myDS->GetBoundingBox(j); + if (aBoxi.IsOut(aBoxj)) { + bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected + } + const TopoDS_Shape& aSj=myDS->Shape(j); + aTj=aSj.ShapeType(); + iX=NMTDS_Tools::TypeToInteger(aTi, aTj); + //bFlag=(iStatus==2); + aPKXB.SetFlag(bFlag); + myLists[iX].Append(aPKXB); + // + // VSD prepare + if (iX==5) { //VV + aLV.Append(j); + } + }// if (aMPKXB.Add(aPKXB)) { + }// for (; aIt.More(); aIt.Next()) { + // + // VSD treatment + aNbLV=aLV.Extent(); + if (aNbLV) { + TColStd_ListOfInteger aLV1; + // + const TopoDS_Vertex& aVi=TopoDS::Vertex(aSi); + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + j=aIt.Value(); + const TopoDS_Shape& aSj=myDS->Shape(j); + const TopoDS_Vertex& aVj=TopoDS::Vertex(aSj); + iFlag=NMTDS_Tools::ComputeVV(aVi, aVj); + if (!iFlag) { + aLV1.Append(j); + } + else { + aPKXB.SetIds(i, j); + aMPKXB.Remove(aPKXB); + } + } + // + aNbLV1=aLV1.Extent(); + if (aNbLV1) { + aMVSD.Bind(i, aLV1); + } + } + }//for (i=i1; i<=i2; ++i) { + }//for (iR=1; iR +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : NMTDS_Iterator +//purpose : +//======================================================================= +class NMTDS_Iterator { + public: + Standard_EXPORT + NMTDS_Iterator(); + + Standard_EXPORT + virtual ~NMTDS_Iterator(); + + Standard_EXPORT + void SetDS(const NMTDS_PShapesDataStructure& pDS) ; + + Standard_EXPORT + const NMTDS_ShapesDataStructure& DS() const; + + Standard_EXPORT + void Initialize(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) ; + + Standard_EXPORT + Standard_Boolean More() const; + + Standard_EXPORT + void Next() ; + + Standard_EXPORT + void Current(Standard_Integer& aIndex1, + Standard_Integer& aIndex2, + Standard_Boolean& aWithSubShape) const; + + Standard_EXPORT + virtual void Prepare() ; + + Standard_EXPORT + Standard_Integer ExpectedLength() const; + + Standard_EXPORT + Standard_Integer BlockLength() const; + + Standard_EXPORT + const TColStd_DataMapOfIntegerListOfInteger& SDVertices() const; + + Standard_EXPORT + static void FillMVSD(const TColStd_DataMapOfIntegerListOfInteger& aMVSD1, + TColStd_DataMapOfIntegerListOfInteger& aMVSD2) ; + +protected: + Standard_EXPORT + virtual void Intersect() ; + // + + NMTDS_PShapesDataStructure myDS; + NMTDS_ListOfPairBoolean myLists[6]; + NMTDS_ListIteratorOfListOfPairBoolean myIterator; + NMTDS_ListOfPairBoolean myEmptyList; + Standard_Integer myLength; + TColStd_DataMapOfIntegerListOfInteger myMVSD; +}; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_IteratorCheckerSI.cxx b/src/NMTDS_NEW/NMTDS_IteratorCheckerSI.cxx new file mode 100644 index 000000000..345f6194f --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_IteratorCheckerSI.cxx @@ -0,0 +1,223 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_IteratorChecker.hxx +// 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 + +//======================================================================= +//function : +//purpose : +//======================================================================= +NMTDS_IteratorCheckerSI::NMTDS_IteratorCheckerSI() +: + NMTDS_Iterator() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +NMTDS_IteratorCheckerSI::~NMTDS_IteratorCheckerSI() +{ +} +//======================================================================= +// function: Intersect +// purpose: +//======================================================================= +void NMTDS_IteratorCheckerSI::Intersect() +{ + Standard_Boolean bFlag; + Standard_Integer aNbS, i, aNbA, aNbB, iFlag; + Standard_Integer aNbSD, iX, j, iDS, jB, k, aNbLV; + TColStd_ListIteratorOfListOfInteger aIt; + TColStd_DataMapOfIntegerInteger aMII; + TColStd_DataMapOfIntegerListOfInteger aMVSD; + TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD; + TopTools_DataMapOfShapeInteger aMSI; + TopAbs_ShapeEnum aTi, aTj; + NMTDS_PairBoolean aPKXB; + NMTDS_MapOfPairBoolean aMPKXB; + NMTDS_IndexedDataMapOfShapeBox aMSB; + NMTDS_MapOfPairBoolean aMPA;//myPairsAvoid + // + NMTDS_BoxBndTreeSelector aSelector; + NMTDS_BoxBndTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + aNbS=myDS->NumberOfShapesOfTheObject(); + // + // myPairsAvoid, aMSI, aMSB + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aSi=myDS->Shape(i); + aTi=aSi.ShapeType(); + if (NMTDS_Tools::HasBRep(aTi)) { + if (aTi!=TopAbs_VERTEX) { + TColStd_IndexedMapOfInteger aMA; + // + myDS->GetAllSuccessors(i, aMA); + // + aNbA=aMA.Extent(); + for (j=1; j<=aNbA; ++j) { + iX=aMA(j); + aPKXB.Clear(); + aPKXB.SetIds(i, iX); + aMPA.Add(aPKXB); + } + } + else { + aPKXB.Clear(); + aPKXB.SetIds(i, i); + aMPA.Add(aPKXB); + } + // + Bnd_Box aBoxEx; + // + myDS->ComputeBoxEx(i, aBoxEx); + aMSI.Bind(aSi, i); + aMSB.Add(aSi, aBoxEx); + } + } + // + // aMII + aNbB=aMSB.Extent(); + for (i=1; i<=aNbB; ++i) { + const TopoDS_Shape& aS=aMSB.FindKey(i); + const Bnd_Box& aBoxEx=aMSB(i); + // + aTreeFiller.Add(i, aBoxEx); + // + iDS=aMSI.Find(aS); + aMII.Bind(i, iDS); + } + // + aTreeFiller.Fill(); + // + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aSi=myDS->Shape(i); + aTi=aSi.ShapeType(); + if (!NMTDS_Tools::HasBRep(aTi)){ + continue; + } + const Bnd_Box& aBoxEx=aMSB.FindFromKey(aSi); + aSelector.Clear(); + aSelector.SetBox(aBoxEx); + // + aNbSD=aBBTree.Select(aSelector); + if (!aNbSD){ + continue; + } + // + const TColStd_ListOfInteger& aLI=aSelector.Indices(); + // + k=0; + TColStd_ListOfInteger aLV; + // + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + jB=aIt.Value(); // box index in MII + j=aMII.Find(jB); // DS index + // + aPKXB.SetIds(i, j); + if (aMPA.Contains(aPKXB)) { + continue; + } + // + if (aMPKXB.Add(aPKXB)) { + bFlag=Standard_False;// Bounding boxes are intersected + const Bnd_Box& aBoxi=myDS->GetBoundingBox(i); + const Bnd_Box& aBoxj=myDS->GetBoundingBox(j); + if (aBoxi.IsOut(aBoxj)) { + bFlag=!bFlag; //Bounding boxes of Sub-shapes are intersected + } + const TopoDS_Shape& aSj=myDS->Shape(j); + aTj=aSj.ShapeType(); + iX=NMTDS_Tools::TypeToInteger(aTi, aTj); + //bFlag=(iStatus==2); + aPKXB.SetFlag(bFlag); + myLists[iX].Append(aPKXB); + // + // VSD prepare + if (iX==5) { //VV + aLV.Append(j); + } + }// if (aMPKXB.Add(aPKXB)) { + }// for (; aIt.More(); aIt.Next()) { + // + // VSD treatment + aNbLV=aLV.Extent(); + if (aNbLV) { + TColStd_ListOfInteger aLV1; + // + const TopoDS_Vertex& aVi=TopoDS::Vertex(aSi); + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + j=aIt.Value(); + const TopoDS_Shape& aSj=myDS->Shape(j); + const TopoDS_Vertex& aVj=TopoDS::Vertex(aSj); + iFlag=NMTDS_Tools::ComputeVV(aVi, aVj); + if (!iFlag) { + aLV1.Append(j); + } + else { + aPKXB.SetIds(i, j); + aMPKXB.Remove(aPKXB); + } + } + aMVSD.Bind(i, aLV1); + } + }//for (i=1; i<=aNbS; ++i) { + // + // + // 2. Chains + //================= + myMVSD.Clear(); + NMTDS_Iterator::FillMVSD(aMVSD, myMVSD); +} + diff --git a/src/NMTDS_NEW/NMTDS_IteratorCheckerSI.hxx b/src/NMTDS_NEW/NMTDS_IteratorCheckerSI.hxx new file mode 100644 index 000000000..090e18bef --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_IteratorCheckerSI.hxx @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_IteratorChecker.cxx +// Author: Peter KURNEV + +#ifndef _NMTDS_IteratorCheckerSI_HeaderFile +#define _NMTDS_IteratorCheckerSI_HeaderFile + +#include +#include +#include + +//======================================================================= +//class : NMTDS_IteratorCheckerSI +//purpose : +//======================================================================= +class NMTDS_IteratorCheckerSI : public NMTDS_Iterator { + public: + + Standard_EXPORT + NMTDS_IteratorCheckerSI(); + Standard_EXPORT + virtual ~NMTDS_IteratorCheckerSI(); + +protected: + Standard_EXPORT + virtual void Intersect() ; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx new file mode 100644 index 000000000..183f0b5ea --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#define NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile + +#ifndef NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPair.hxx b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPair.hxx new file mode 100644 index 000000000..589ffc38a --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPair.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListIteratorOfListOfPair.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListIteratorOfListOfPair_HeaderFile +#define NMTDS_ListIteratorOfListOfPair_HeaderFile + +#ifndef NMTDS_ListOfPair_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPairBoolean.hxx b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPairBoolean.hxx new file mode 100644 index 000000000..d0b777299 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPairBoolean.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListIteratorOfListOfPairBoolean.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListIteratorOfListOfPairBoolean_HeaderFile +#define NMTDS_ListIteratorOfListOfPairBoolean_HeaderFile + +#ifndef NMTDS_ListOfPairBoolean_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPassKey.hxx b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPassKey.hxx new file mode 100644 index 000000000..c84cf2a14 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPassKey.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListIteratorOfListOfPassKey.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListIteratorOfListOfPassKey_HeaderFile +#define NMTDS_ListIteratorOfListOfPassKey_HeaderFile + +#ifndef NMTDS_ListOfPassKey_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx new file mode 100644 index 000000000..88785d58a --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListIteratorOfListOfPassKeyBoolean_HeaderFile +#define NMTDS_ListIteratorOfListOfPassKeyBoolean_HeaderFile + +#ifndef NMTDS_ListOfPassKeyBoolean_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx b/src/NMTDS_NEW/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx new file mode 100644 index 000000000..06af1646a --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx @@ -0,0 +1,34 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile +#define NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile + +#include +#include + +typedef NCollection_List NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors; +typedef NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors::Iterator NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListOfPair.hxx b/src/NMTDS_NEW/NMTDS_ListOfPair.hxx new file mode 100644 index 000000000..8eb271057 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListOfPair.hxx @@ -0,0 +1,34 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListOfPair.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListOfPair_HeaderFile +#define NMTDS_ListOfPair_HeaderFile + +#include +#include + +typedef NCollection_List NMTDS_ListOfPair; +typedef NMTDS_ListOfPair::Iterator NMTDS_ListIteratorOfListOfPair; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListOfPairBoolean.hxx b/src/NMTDS_NEW/NMTDS_ListOfPairBoolean.hxx new file mode 100644 index 000000000..30e021078 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListOfPairBoolean.hxx @@ -0,0 +1,34 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListOfPairBoolean.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListOfPairBoolean_HeaderFile +#define NMTDS_ListOfPairBoolean_HeaderFile + +#include +#include + +typedef NCollection_List NMTDS_ListOfPairBoolean; +typedef NMTDS_ListOfPairBoolean::Iterator NMTDS_ListIteratorOfListOfPairBoolean; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListOfPassKey.hxx b/src/NMTDS_NEW/NMTDS_ListOfPassKey.hxx new file mode 100644 index 000000000..ceb30e996 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListOfPassKey.hxx @@ -0,0 +1,34 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListOfPassKey.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListOfPassKey_HeaderFile +#define NMTDS_ListOfPassKey_HeaderFile + +#include +#include + +typedef NCollection_List NMTDS_ListOfPassKey; +typedef NMTDS_ListOfPassKey::Iterator NMTDS_ListIteratorOfListOfPassKey; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_ListOfPassKeyBoolean.hxx b/src/NMTDS_NEW/NMTDS_ListOfPassKeyBoolean.hxx new file mode 100644 index 000000000..369db2149 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ListOfPassKeyBoolean.hxx @@ -0,0 +1,34 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListOfPassKeyBoolean.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + + +#ifndef NMTDS_ListOfPassKeyBoolean_HeaderFile +#define NMTDS_ListOfPassKeyBoolean_HeaderFile + +#include +#include + +typedef NCollection_List NMTDS_ListOfPassKeyBoolean; +typedef NMTDS_ListOfPassKeyBoolean::Iterator NMTDS_ListIteratorOfListOfPassKeyBoolean; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPairBoolean.hxx b/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPairBoolean.hxx new file mode 100644 index 000000000..45c6df295 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPairBoolean.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_MapIteratorOfMapOfPairBoolean.hxx +// Created: Mon Feb 20 08:22:39 2012 +// Author: +// + + +#ifndef NMTDS_MapIteratorOfMapOfPairBoolean_HeaderFile +#define NMTDS_MapIteratorOfMapOfPairBoolean_HeaderFile + +#ifndef NMTDS_MapOfPairBoolean_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPassKey.hxx b/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPassKey.hxx new file mode 100644 index 000000000..cb2ec9454 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPassKey.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMRCol_MapIteratorOfMapOfPassKey.hxx +// Created: Mon Feb 20 08:22:39 2012 +// Author: +// + + +#ifndef NMRCol_MapIteratorOfMapOfPassKey_HeaderFile +#define NMRCol_MapIteratorOfMapOfPassKey_HeaderFile + +#ifndef NMTDS_MapOfPassKey_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPassKeyBoolean.hxx b/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPassKeyBoolean.hxx new file mode 100644 index 000000000..8fc515ce6 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_MapIteratorOfMapOfPassKeyBoolean.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMRCol_MapIteratorOfMapOfPassKeyBoolean.hxx +// Created: Mon Feb 20 08:22:39 2012 +// Author: +// + + +#ifndef NMRCol_MapIteratorOfMapOfPassKeyBoolean_HeaderFile +#define NMRCol_MapIteratorOfMapOfPassKeyBoolean_HeaderFile + +#ifndef NMTDS_MapOfPassKeyBoolean_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTDS_NEW/NMTDS_MapOfPairBoolean.hxx b/src/NMTDS_NEW/NMTDS_MapOfPairBoolean.hxx new file mode 100644 index 000000000..af42e830c --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_MapOfPairBoolean.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_MapOfPairBoolean.hxx +// Created: Mon Feb 20 08:19:07 2012 +// Author: +// + + +#ifndef NMTDS_MapOfPairBoolean_HeaderFile +#define NMTDS_MapOfPairBoolean_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_Map NMTDS_MapOfPairBoolean; +typedef NMTDS_MapOfPairBoolean::Iterator NMTDS_MapIteratorOfMapOfPairBoolean; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/NMTDS_NEW/NMTDS_MapOfPassKey.hxx b/src/NMTDS_NEW/NMTDS_MapOfPassKey.hxx new file mode 100644 index 000000000..831568394 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_MapOfPassKey.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_MapOfPassKey.hxx +// Created: Mon Feb 20 08:19:07 2012 +// Author: +// + + +#ifndef NMTDS_MapOfPassKey_HeaderFile +#define NMTDS_MapOfPassKey_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_Map NMTDS_MapOfPassKey; +typedef NMTDS_MapOfPassKey::Iterator NMTDS_MapIteratorOfMapOfPassKey; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/NMTDS_NEW/NMTDS_MapOfPassKeyBoolean.hxx b/src/NMTDS_NEW/NMTDS_MapOfPassKeyBoolean.hxx new file mode 100644 index 000000000..b07f2416e --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_MapOfPassKeyBoolean.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_MapOfPassKeyBoolean.hxx +// Created: Mon Feb 20 08:19:07 2012 +// Author: +// + + +#ifndef NMTDS_MapOfPassKeyBoolean_HeaderFile +#define NMTDS_MapOfPassKeyBoolean_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_Map NMTDS_MapOfPassKeyBoolean; +typedef NMTDS_MapOfPassKeyBoolean::Iterator NMTDS_MapIteratorOfMapOfPassKeyBoolean; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/NMTDS_NEW/NMTDS_PInterfPool.hxx b/src/NMTDS_NEW/NMTDS_PInterfPool.hxx new file mode 100644 index 000000000..c9973ce47 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PInterfPool.hxx @@ -0,0 +1,32 @@ +// 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: NMTDS_PInterfPool.hxx +// Author: Peter KURNEV + +#ifndef _NMTDS_PInterfPool_HeaderFile +#define _NMTDS_PInterfPool_HeaderFile + +class NMTDS_InterfPool; + +typedef NMTDS_InterfPool* NMTDS_PInterfPool; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_PIterator.hxx b/src/NMTDS_NEW/NMTDS_PIterator.hxx new file mode 100644 index 000000000..007ce188d --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PIterator.hxx @@ -0,0 +1,32 @@ +// 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: NMTDS_PIterator.hxx +// Author: Peter KURNEV + +#ifndef _NMTDS_PIterator_HeaderFile +#define _NMTDS_PIterator_HeaderFile + +class NMTDS_Iterator; + +typedef NMTDS_Iterator* NMTDS_PIterator; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_PShapesDataStructure.hxx b/src/NMTDS_NEW/NMTDS_PShapesDataStructure.hxx new file mode 100644 index 000000000..d38652121 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PShapesDataStructure.hxx @@ -0,0 +1,32 @@ +// 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: NMTDS_PShapesDataStructure.hxx +// Author: Peter KURNEV + +#ifndef _NMTDS_PShapesDataStructure_HeaderFile +#define _NMTDS_PShapesDataStructure_HeaderFile + +class NMTDS_ShapesDataStructure; + +typedef NMTDS_ShapesDataStructure* NMTDS_PShapesDataStructure; + +#endif diff --git a/src/NMTDS_NEW/NMTDS_Pair.cxx b/src/NMTDS_NEW/NMTDS_Pair.cxx new file mode 100644 index 000000000..682bf1587 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_Pair.cxx @@ -0,0 +1,149 @@ +// 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: NMTDS_Pair.cxx +// Author: Peter KURNEV + +#include + +#include +#include +#include +#include + +#ifdef WNT +#pragma warning( disable : 4101) +#endif + +static + Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv); + +//======================================================================= +//function : +//purpose : +//======================================================================= +NMTDS_Pair::NMTDS_Pair() +{ + Clear(); +} +//======================================================================= +//function : +//purpose : +//======================================================================= +NMTDS_Pair::NMTDS_Pair(const NMTDS_Pair& aOther) +{ + myId1=aOther.myId1; + myId2=aOther.myId2; +} +//======================================================================= +//function :operator = +//purpose : +//======================================================================= + NMTDS_Pair& NMTDS_Pair::operator =(const NMTDS_Pair& aOther) +{ + myId1=aOther.myId1; + myId2=aOther.myId2; + return *this; +} +//======================================================================= +//function :~ +//purpose : +//======================================================================= + NMTDS_Pair::~NMTDS_Pair() +{ +} +//======================================================================= +//function :Clear +//purpose : +//======================================================================= + void NMTDS_Pair::Clear() +{ + myId1=0; + myId2=0; +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void NMTDS_Pair::SetIds(const Standard_Integer aId1, + const Standard_Integer aId2) +{ + Clear(); + myId1=aId1; + myId2=aId2; + if (aId1>aId2) { + myId1=aId2; + myId2=aId1; + } +} +//======================================================================= +//function :Ids +//purpose : +//======================================================================= + void NMTDS_Pair::Ids(Standard_Integer& aId1, + Standard_Integer& aId2) const +{ + aId1=myId1; + aId2=myId2; +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean NMTDS_Pair::IsEqual(const NMTDS_Pair& aOther) const +{ + + Standard_Boolean bRet; + // + bRet=(myId1==aOther.myId1 && myId2==aOther.myId2);//ZZ + return bRet; +} +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer NMTDS_Pair::HashCode(const Standard_Integer aUpper) const +{ + Standard_Integer aSum; + // + aSum=0; + aSum+=NormalizedId(myId1, 2); + aSum+=NormalizedId(myId2, 2); + return ::HashCode(aSum, aUpper); +} +//======================================================================= +// function: NormalizedId +// purpose : +//======================================================================= +Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv) +{ + Standard_Integer aMax, aTresh, aIdRet; + // + aIdRet=aId; + aMax=::IntegerLast(); + aTresh=aMax/aDiv; + if (aId>aTresh) { + aIdRet=aId%aTresh; + } + return aIdRet; +} diff --git a/src/NMTDS_NEW/NMTDS_Pair.hxx b/src/NMTDS_NEW/NMTDS_Pair.hxx new file mode 100644 index 000000000..4d64b1e48 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_Pair.hxx @@ -0,0 +1,72 @@ +// 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: NMTDS_Pair.hxx +// Author: Peter KURNEV + +#ifndef _NMTDS_Pair_HeaderFile +#define _NMTDS_Pair_HeaderFile + +#include +#include +#include +#include + +//======================================================================= +//function : NMTDS_Pair +//purpose : +//======================================================================= +class NMTDS_Pair { + public: + Standard_EXPORT + NMTDS_Pair(); + + Standard_EXPORT + virtual ~NMTDS_Pair(); + + Standard_EXPORT + NMTDS_Pair(const NMTDS_Pair& Other); + + Standard_EXPORT + NMTDS_Pair& operator =(const NMTDS_Pair& Other); + + Standard_EXPORT + void Clear() ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1, + const Standard_Integer aI2) ; + + Standard_EXPORT + void Ids(Standard_Integer& aI1, + Standard_Integer& aI2) const; + + Standard_EXPORT + Standard_Boolean IsEqual(const NMTDS_Pair& aOther) const; + + Standard_EXPORT + Standard_Integer HashCode(const Standard_Integer Upper) const; + +protected: +Standard_Integer myId1; +Standard_Integer myId2; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_PairBoolean.cxx b/src/NMTDS_NEW/NMTDS_PairBoolean.cxx new file mode 100644 index 000000000..4a7a38f8c --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PairBoolean.cxx @@ -0,0 +1,69 @@ +// 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: NMTDS_PairBoolean.cxx +// Author: Peter KURNEV + +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_PairBoolean::NMTDS_PairBoolean() +: + myFlag(Standard_False), + NMTDS_Pair() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + NMTDS_PairBoolean::~NMTDS_PairBoolean() +{ +} +//======================================================================= +//function :operator = +//purpose : +//======================================================================= + NMTDS_PairBoolean& NMTDS_PairBoolean::operator =(const NMTDS_PairBoolean& anOther) +{ + myFlag=anOther.myFlag; + NMTDS_Pair::operator =(anOther); + return *this; +} +//======================================================================= +//function :SetFlag +//purpose : +//======================================================================= + void NMTDS_PairBoolean::SetFlag(const Standard_Boolean aFlag) +{ + myFlag=aFlag; +} +//======================================================================= +//function :Flag +//purpose : +//======================================================================= + Standard_Boolean NMTDS_PairBoolean::Flag()const +{ + return myFlag; +} diff --git a/src/NMTDS_NEW/NMTDS_PairBoolean.hxx b/src/NMTDS_NEW/NMTDS_PairBoolean.hxx new file mode 100644 index 000000000..a469b923e --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PairBoolean.hxx @@ -0,0 +1,57 @@ +// 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: NMTDS_PairBoolean.hxx +// Author: Peter KURNEV + +#ifndef _NMTDS_PairBoolean_HeaderFile +#define _NMTDS_PairBoolean_HeaderFile + +#include +#include +#include +#include + +//======================================================================= +//class : NMTDS_PairBoolean +//purpose : +//======================================================================= +class NMTDS_PairBoolean : public NMTDS_Pair { + public: + Standard_EXPORT + NMTDS_PairBoolean(); + + Standard_EXPORT + virtual ~NMTDS_PairBoolean(); + + Standard_EXPORT + void SetFlag(const Standard_Boolean aFlag) ; + + Standard_EXPORT + NMTDS_PairBoolean& operator =(const NMTDS_PairBoolean& Other); + + Standard_EXPORT + Standard_Boolean Flag() const; + +protected: + Standard_Boolean myFlag; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_PairMapHasher.cxx b/src/NMTDS_NEW/NMTDS_PairMapHasher.cxx new file mode 100644 index 000000000..b07202822 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PairMapHasher.cxx @@ -0,0 +1,44 @@ +// 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: NMTDS_PairMapHasher.cxx +// Author: Peter KURNEV + +#include + +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= +Standard_Integer NMTDS_PairMapHasher::HashCode(const NMTDS_Pair& aPK, + const Standard_Integer Upper) +{ + return aPK.HashCode(Upper); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= +Standard_Boolean NMTDS_PairMapHasher::IsEqual(const NMTDS_Pair& aPK1, + const NMTDS_Pair& aPK2) +{ + return aPK1.IsEqual(aPK2); +} diff --git a/src/NMTDS_NEW/NMTDS_PairMapHasher.hxx b/src/NMTDS_NEW/NMTDS_PairMapHasher.hxx new file mode 100644 index 000000000..65c8796f6 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PairMapHasher.hxx @@ -0,0 +1,48 @@ +// 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: NMTDS_PairMapHasher.cxx +// Author: Peter KURNEV + +#ifndef _NMTDS_PairMapHasher_HeaderFile +#define _NMTDS_PairMapHasher_HeaderFile + +#include +#include +#include +#include +#include + +//======================================================================= +//class : NMTDS_PairMapHasher +//purpose : +//======================================================================= +class NMTDS_PairMapHasher { + public: + Standard_EXPORT + static Standard_Integer HashCode(const NMTDS_Pair& aPKey, + const Standard_Integer Upper) ; + + Standard_EXPORT + static Standard_Boolean IsEqual(const NMTDS_Pair& aPKey1, + const NMTDS_Pair& aPKey2) ; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_PassKey.cxx b/src/NMTDS_NEW/NMTDS_PassKey.cxx new file mode 100644 index 000000000..9f7663696 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKey.cxx @@ -0,0 +1,362 @@ +// 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: NMTDS_PassKey.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include +#include + +#ifdef WNT +#pragma warning( disable : 4101) +#endif + +static + Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv); + +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_PassKey::NMTDS_PassKey() +{ + Clear(); +} +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_PassKey::NMTDS_PassKey(const NMTDS_PassKey& aOther) +{ + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; +} +//======================================================================= +//function :operator = +//purpose : +//======================================================================= + NMTDS_PassKey& NMTDS_PassKey::operator =(const NMTDS_PassKey& aOther) +{ + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; + return *this; +} +//======================================================================= +//function :~ +//purpose : +//======================================================================= + NMTDS_PassKey::~NMTDS_PassKey() +{ +} +//======================================================================= +//function :Clear +//purpose : +//======================================================================= + void NMTDS_PassKey::Clear() +{ + myNbIds=0; + mySum=0; + myMap.Clear(); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void NMTDS_PassKey::SetIds(const Standard_Integer aId1) + +{ + Clear(); + myNbIds=1; + myMap.Add(aId1); + mySum=NormalizedId(aId1, myNbIds); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void NMTDS_PassKey::SetIds(const Standard_Integer aId1, + const Standard_Integer aId2) +{ + TColStd_ListOfInteger aLI; + // + aLI.Append(aId1); + aLI.Append(aId2); + SetIds(aLI); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void NMTDS_PassKey::SetIds(const Standard_Integer aId1, + const Standard_Integer aId2, + const Standard_Integer aId3) +{ + TColStd_ListOfInteger aLI; + // + aLI.Append(aId1); + aLI.Append(aId2); + aLI.Append(aId3); + SetIds(aLI); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void NMTDS_PassKey::SetIds(const Standard_Integer aId1, + const Standard_Integer aId2, + const Standard_Integer aId3, + const Standard_Integer aId4) +{ + TColStd_ListOfInteger aLI; + // + aLI.Append(aId1); + aLI.Append(aId2); + aLI.Append(aId3); + aLI.Append(aId4); + SetIds(aLI); +} +//======================================================================= +//function :SetIds +//purpose : +//======================================================================= + void NMTDS_PassKey::SetIds(const TColStd_ListOfInteger& aLI) +{ + Standard_Integer i, aId, aIdN; + TColStd_ListIteratorOfListOfInteger aIt; + // + Clear(); + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + aId=aIt.Value(); + myMap.Add(aId); + } + myNbIds=myMap.Extent(); + for(i=1; i<=myNbIds; ++i) { + aId=myMap(i); + aIdN=NormalizedId(aId, myNbIds); + mySum+=aIdN; + } +} + +//======================================================================= +//function :NbIds +//purpose : +//======================================================================= + Standard_Integer NMTDS_PassKey::NbIds()const +{ + return myNbIds; +} +//======================================================================= +//function :Id +//purpose : +//======================================================================= + Standard_Integer NMTDS_PassKey::Id(const Standard_Integer aIndex) const +{ + if (aIndex<1 || aIndex>myNbIds) { + return -1; + } + return myMap(aIndex); +} +//======================================================================= +//function :Ids +//purpose : +//======================================================================= + void NMTDS_PassKey::Ids(Standard_Integer& aId1, + Standard_Integer& aId2) const +{ + aId1=0; + aId2=0; + if (myNbIds>1) { + aId1=myMap(1); + aId2=myMap(2); + } +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean NMTDS_PassKey::IsEqual(const NMTDS_PassKey& aOther) const +{ + Standard_Boolean bRet; + Standard_Integer i, aId; + // + bRet=Standard_False; + // + if (myNbIds!=aOther.myNbIds) { + return bRet; + } + for (i=1; i<=myNbIds; ++i) { + aId=myMap(i); + if (!aOther.myMap.Contains(aId)) { + return bRet; + } + } + return !bRet; +} +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer NMTDS_PassKey::HashCode(const Standard_Integer aUpper) const +{ + return ::HashCode(mySum, aUpper); +} +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void NMTDS_PassKey::Dump(const Standard_Integer )const +{ +} + +//======================================================================= +// function: NormalizedId +// purpose : +//======================================================================= +Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv) +{ + Standard_Integer aMax, aTresh, aIdRet; + // + aIdRet=aId; + aMax=::IntegerLast(); + aTresh=aMax/aDiv; + if (aId>aTresh) { + aIdRet=aId%aTresh; + } + return aIdRet; +} +/* +//========= +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + Standard_Boolean NMTDS_PassKey::Contains(const Standard_Integer aId) const +{ + return myMap.Contains(aId); +} +//======================================================================= +//function :Contains +//purpose : +//======================================================================= + Standard_Boolean NMTDS_PassKey::Contains(const NMTDS_PassKey& aOther) const +{ + Standard_Boolean bRet; + Standard_Integer i, aId; + // + bRet=Standard_False; + // + if (myNbIds +// +#ifndef _NMTDS_PassKey_HeaderFile +#define _NMTDS_PassKey_HeaderFile + +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : NMTDS_PassKey +//purpose : +//======================================================================= +class NMTDS_PassKey { + public: + Standard_EXPORT + NMTDS_PassKey(); + + Standard_EXPORT + virtual ~NMTDS_PassKey(); + + Standard_EXPORT + NMTDS_PassKey(const NMTDS_PassKey& Other); + + Standard_EXPORT + NMTDS_PassKey& operator =(const NMTDS_PassKey& Other); + + Standard_EXPORT + void Clear() ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1) ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1, + const Standard_Integer aI2) ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1, + const Standard_Integer aI2, + const Standard_Integer aI3) ; + + Standard_EXPORT + void SetIds(const Standard_Integer aI1, + const Standard_Integer aI2, + const Standard_Integer aI3, + const Standard_Integer aI4) ; + + Standard_EXPORT + void SetIds(const TColStd_ListOfInteger& aLS) ; + + Standard_EXPORT + Standard_Integer NbIds() const; + + Standard_EXPORT + Standard_Boolean IsEqual(const NMTDS_PassKey& aOther) const; + + Standard_EXPORT + Standard_Integer HashCode(const Standard_Integer Upper) const; + + Standard_EXPORT + Standard_Integer Id(const Standard_Integer aIndex) const; + + Standard_EXPORT + void Ids(Standard_Integer& aI1,Standard_Integer& aI2) const; + + Standard_EXPORT + void Dump(const Standard_Integer aHex = 0) const; + +protected: + Standard_Integer myNbIds; + Standard_Integer mySum; + TColStd_IndexedMapOfInteger myMap; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_PassKeyBoolean.cxx b/src/NMTDS_NEW/NMTDS_PassKeyBoolean.cxx new file mode 100644 index 000000000..af9ae8c5e --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKeyBoolean.cxx @@ -0,0 +1,72 @@ +// 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: NMTDS_PassKeyBoolean.cxx +// Created: Mon May 15 14:31:05 2006 +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_PassKeyBoolean::NMTDS_PassKeyBoolean() +: + myFlag(Standard_False), + NMTDS_PassKey() +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + NMTDS_PassKeyBoolean::~NMTDS_PassKeyBoolean() +{ +} +//======================================================================= +//function :operator = +//purpose : +//======================================================================= + NMTDS_PassKeyBoolean& NMTDS_PassKeyBoolean::operator =(const NMTDS_PassKeyBoolean& anOther) +{ + myFlag=anOther.myFlag; + NMTDS_PassKey::operator =(anOther); + return *this; +} +//======================================================================= +//function :SetFlag +//purpose : +//======================================================================= + void NMTDS_PassKeyBoolean::SetFlag(const Standard_Boolean aFlag) +{ + myFlag=aFlag; +} +//======================================================================= +//function :Flag +//purpose : +//======================================================================= + Standard_Boolean NMTDS_PassKeyBoolean::Flag()const +{ + return myFlag; +} diff --git a/src/NMTDS_NEW/NMTDS_PassKeyBoolean.hxx b/src/NMTDS_NEW/NMTDS_PassKeyBoolean.hxx new file mode 100644 index 000000000..1e46bf20f --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKeyBoolean.hxx @@ -0,0 +1,60 @@ +// 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: NMTDS_PassKeyBoolean.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _NMTDS_PassKeyBoolean_HeaderFile +#define _NMTDS_PassKeyBoolean_HeaderFile + +#include +#include +#include +#include + +//======================================================================= +//class : NMTDS_PassKeyBoolean +//purpose : +//======================================================================= +class NMTDS_PassKeyBoolean : public NMTDS_PassKey { + public: + Standard_EXPORT + NMTDS_PassKeyBoolean(); + + Standard_EXPORT + virtual ~NMTDS_PassKeyBoolean(); + + Standard_EXPORT + void SetFlag(const Standard_Boolean aFlag) ; + + Standard_EXPORT + NMTDS_PassKeyBoolean& operator =(const NMTDS_PassKeyBoolean& Other); + + Standard_EXPORT + Standard_Boolean Flag() const; + + protected: + Standard_Boolean myFlag; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_PassKeyMapHasher.cxx b/src/NMTDS_NEW/NMTDS_PassKeyMapHasher.cxx new file mode 100644 index 000000000..a77d8fa34 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKeyMapHasher.cxx @@ -0,0 +1,47 @@ +// 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: NMTDS_PassKeyMapHasher.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer NMTDS_PassKeyMapHasher::HashCode(const NMTDS_PassKey& aPK, + const Standard_Integer Upper) +{ + return aPK.HashCode(Upper); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean NMTDS_PassKeyMapHasher::IsEqual(const NMTDS_PassKey& aPK1, + const NMTDS_PassKey& aPK2) +{ + return aPK1.IsEqual(aPK2); +} diff --git a/src/NMTDS_NEW/NMTDS_PassKeyMapHasher.hxx b/src/NMTDS_NEW/NMTDS_PassKeyMapHasher.hxx new file mode 100644 index 000000000..f26688d1a --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKeyMapHasher.hxx @@ -0,0 +1,52 @@ +// 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: NMTDS_PassKeyMapHasher.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _NMTDS_PassKeyMapHasher_HeaderFile +#define _NMTDS_PassKeyMapHasher_HeaderFile + +#include +#include +#include +#include +#include + + +//======================================================================= +//function : NMTDS_PassKeyMapHasher +//purpose : +//======================================================================= +class NMTDS_PassKeyMapHasher { + public: + Standard_EXPORT + static Standard_Integer HashCode(const NMTDS_PassKey& aPKey, + const Standard_Integer Upper) ; + + Standard_EXPORT + static Standard_Boolean IsEqual(const NMTDS_PassKey& aPKey1, + const NMTDS_PassKey& aPKey2) ; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_PassKeyShape.cxx b/src/NMTDS_NEW/NMTDS_PassKeyShape.cxx new file mode 100644 index 000000000..87ae5d764 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKeyShape.cxx @@ -0,0 +1,227 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_PassKeyShape.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include + + +static + Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv); +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_PassKeyShape::NMTDS_PassKeyShape() +{ + myUpper=432123; +} +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTDS_PassKeyShape::NMTDS_PassKeyShape(const NMTDS_PassKeyShape& aOther) +{ + myUpper=432123; + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; +} +//======================================================================= +//function :~ +//purpose : +//======================================================================= + NMTDS_PassKeyShape::~NMTDS_PassKeyShape() +{ +} +//======================================================================= +//function :Assign +//purpose : +//======================================================================= + NMTDS_PassKeyShape& NMTDS_PassKeyShape::Assign(const NMTDS_PassKeyShape& aOther) +{ + myUpper=432123; + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; + return *this; +} +//======================================================================= +//function :Clear +//purpose : +//======================================================================= + void NMTDS_PassKeyShape::Clear() +{ + myNbIds=0; + mySum=0; + myMap.Clear(); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1) + +{ + Standard_Integer aHC; + // + Clear(); + myNbIds=1; + myMap.Add(aS1); + aHC=aS1.HashCode(myUpper); + mySum=NormalizedId(aHC, myNbIds); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) +{ + TopTools_ListOfShape aLS; + // + aLS.Append(aS1); + aLS.Append(aS2); + SetShapes(aLS); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3) +{ + TopTools_ListOfShape aLS; + // + aLS.Append(aS1); + aLS.Append(aS2); + aLS.Append(aS3); + SetShapes(aLS); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3, + const TopoDS_Shape& aS4) +{ + TopTools_ListOfShape aLS; + // + aLS.Append(aS1); + aLS.Append(aS2); + aLS.Append(aS3); + aLS.Append(aS4); + SetShapes(aLS); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void NMTDS_PassKeyShape::SetShapes(const TopTools_ListOfShape& aLS) +{ + Standard_Integer i, aId, aIdN; + TopTools_ListIteratorOfListOfShape aIt; + // + Clear(); + aIt.Initialize(aLS); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aS=aIt.Value(); + myMap.Add(aS); + } + myNbIds=myMap.Extent(); + for(i=1; i<=myNbIds; ++i) { + const TopoDS_Shape& aS=myMap(i); + aId=aS.HashCode(myUpper); + aIdN=NormalizedId(aId, myNbIds); + mySum+=aIdN; + } +} +//======================================================================= +//function :NbIds +//purpose : +//======================================================================= + Standard_Integer NMTDS_PassKeyShape::NbIds()const +{ + return myNbIds; +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean NMTDS_PassKeyShape::IsEqual(const NMTDS_PassKeyShape& aOther) const +{ + Standard_Boolean bRet; + Standard_Integer i; + // + bRet=Standard_False; + // + if (myNbIds!=aOther.myNbIds) { + return bRet; + } + for (i=1; i<=myNbIds; ++i) { + const TopoDS_Shape& aS=myMap(i); + if (!aOther.myMap.Contains(aS)) { + return bRet; + } + } + return !bRet; +} +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer NMTDS_PassKeyShape::HashCode(const Standard_Integer aUpper) const +{ + return ::HashCode(mySum, aUpper); +} +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void NMTDS_PassKeyShape::Dump(const Standard_Integer)const +{ +} +//======================================================================= +// function: NormalizedId +// purpose : +//======================================================================= +Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv) +{ + Standard_Integer aMax, aTresh, aIdRet; + // + aIdRet=aId; + aMax=::IntegerLast(); + aTresh=aMax/aDiv; + if (aId>aTresh) { + aIdRet=aId%aTresh; + } + return aIdRet; +} diff --git a/src/NMTDS_NEW/NMTDS_PassKeyShape.hxx b/src/NMTDS_NEW/NMTDS_PassKeyShape.hxx new file mode 100644 index 000000000..e77c56656 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKeyShape.hxx @@ -0,0 +1,100 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_PassKeyShape.hxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _NMTDS_PassKeyShape_HeaderFile +#define _NMTDS_PassKeyShape_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : NMTDS_PassKeyShape +//purpose : +//======================================================================= +class NMTDS_PassKeyShape { + public: + Standard_EXPORT + NMTDS_PassKeyShape(); + + Standard_EXPORT + virtual ~NMTDS_PassKeyShape(); + + Standard_EXPORT + NMTDS_PassKeyShape(const NMTDS_PassKeyShape& Other); + + Standard_EXPORT + NMTDS_PassKeyShape& Assign(const NMTDS_PassKeyShape& Other) ; + + NMTDS_PassKeyShape& operator =(const NMTDS_PassKeyShape& Other) { + return Assign(Other); + } + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) ; + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3) ; + + Standard_EXPORT + void SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3, + const TopoDS_Shape& aS4) ; + + Standard_EXPORT + void SetShapes(const TopTools_ListOfShape& aLS) ; + + Standard_EXPORT + void Clear() ; + + Standard_EXPORT + Standard_Integer NbIds() const; + + Standard_EXPORT + Standard_Boolean IsEqual(const NMTDS_PassKeyShape& aOther) const; + + Standard_EXPORT + Standard_Integer HashCode(const Standard_Integer Upper) const; + + Standard_EXPORT + void Dump(const Standard_Integer aHex = 0) const; + + protected: + Standard_Integer myNbIds; + Standard_Integer mySum; + Standard_Integer myUpper; + TopTools_IndexedMapOfShape myMap; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_PassKeyShapeMapHasher.cxx b/src/NMTDS_NEW/NMTDS_PassKeyShapeMapHasher.cxx new file mode 100644 index 000000000..7f43ed16a --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKeyShapeMapHasher.cxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_PassKeyMapHasher.cxx +// Created: +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer NMTDS_PassKeyShapeMapHasher::HashCode(const NMTDS_PassKeyShape& aPK, + const Standard_Integer Upper) +{ + return aPK.HashCode(Upper); +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean NMTDS_PassKeyShapeMapHasher::IsEqual(const NMTDS_PassKeyShape& aPK1, + const NMTDS_PassKeyShape& aPK2) +{ + return aPK1.IsEqual(aPK2); +} diff --git a/src/NMTDS_NEW/NMTDS_PassKeyShapeMapHasher.hxx b/src/NMTDS_NEW/NMTDS_PassKeyShapeMapHasher.hxx new file mode 100644 index 000000000..e4b600e78 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_PassKeyShapeMapHasher.hxx @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_PassKeyMapHasher.cxx +// Created: +// Author: Peter KURNEV +// +// +#ifndef _NMTDS_PassKeyShapeMapHasher_HeaderFile +#define _NMTDS_PassKeyShapeMapHasher_HeaderFile + +#include +#include +#include +#include +#include + +//======================================================================= +//function : NMTDS_PassKeyShapeMapHasher +//purpose : +//======================================================================= +class NMTDS_PassKeyShapeMapHasher { + public: + Standard_EXPORT + static Standard_Integer HashCode(const NMTDS_PassKeyShape& aPKey, + const Standard_Integer Upper) ; + + Standard_EXPORT + static Standard_Boolean IsEqual(const NMTDS_PassKeyShape& aPKey1, + const NMTDS_PassKeyShape& aPKey2) ; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_ShapesDataStructure.cxx b/src/NMTDS_NEW/NMTDS_ShapesDataStructure.cxx new file mode 100644 index 000000000..c6e9d4ece --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ShapesDataStructure.cxx @@ -0,0 +1,389 @@ +// 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: NMTDS_ShapesDataStructure.cxx +// Author: Peter KURNEV + +#include +#include +#include +#include +#include +#include +#include +#include +// +#include +#include +#include +#include + + +static + void ComputeBoxExS(const Standard_Integer aIx, + const NMTDS_ShapesDataStructure* pDS, + Bnd_Box& aBoxEx); +static + void GetAllSuccessorsS(const Standard_Integer nS, + const NMTDS_ShapesDataStructure* myDS, + TColStd_IndexedMapOfInteger& aMA); + +//=========================================================================== +//function : NMTDS_ShapesDataStructure::NMTDS_ShapesDataStructure +//purpose : +//=========================================================================== +NMTDS_ShapesDataStructure::NMTDS_ShapesDataStructure() +: + BooleanOperations_ShapesDataStructure() +{} +//=========================================================================== +//function : SetCompositeShape +//purpose : +//=========================================================================== +void NMTDS_ShapesDataStructure::SetCompositeShape(const TopoDS_Shape& aS) +{ + myCompositeShape=aS; +} +//=========================================================================== +//function : CompositeShape +//purpose : +//=========================================================================== +const TopoDS_Shape& NMTDS_ShapesDataStructure::CompositeShape()const +{ + return myCompositeShape; +} +//=========================================================================== +//function : Ranges +//purpose : +//=========================================================================== +const NMTDS_CArray1OfIndexRange& NMTDS_ShapesDataStructure::Ranges()const +{ + return myRanges; +} +//=========================================================================== +//function : FillMap +//purpose : +//=========================================================================== +void NMTDS_ShapesDataStructure::FillMap + (const TopoDS_Shape& aS, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSA, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMS) const +{ + Standard_Integer iX, i, j, aIndex, aNbSc, aNbS; + BooleanOperations_AncestorsSeqAndSuccessorsSeq aAS; + // + aMSA.Add(aS, aAS); + aMS.Add(aS, aAS); + FillSubshapes(aS, aMSA, aMS); + // + aNbS=aMS.Extent(); + for(i=1; i<=aNbS; ++i) { + TColStd_MapOfInteger aMFence; + // + const TopoDS_Shape& aSX=aMS.FindKey(i); + iX=aMSA.FindIndex(aSX); + const BooleanOperations_AncestorsSeqAndSuccessorsSeq& aAS1=aMSA(iX); + // + aNbSc=aAS1.NumberOfSuccessors(); + for(j=1; j<=aNbSc; ++j) { + aIndex=aAS1.GetSuccessor(j); + if(aMFence.Add(aIndex)) { + BooleanOperations_AncestorsSeqAndSuccessorsSeq& aAS2=aMSA.ChangeFromIndex(aIndex); + aAS2.SetNewAncestor(iX); + } + } + } +} +//=========================================================================== +//function : FillSubshapes +//purpose : +//=========================================================================== +void NMTDS_ShapesDataStructure::FillSubshapes + (const TopoDS_Shape& aS, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSA, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMS) const +{ + Standard_Boolean bIsNewSubShape; + Standard_Integer aIndexSubShape, aIndex; + BooleanOperations_AncestorsSeqAndSuccessorsSeq aASx; + // + aIndex=aMSA.FindIndex(aS); + BooleanOperations_AncestorsSeqAndSuccessorsSeq& aAS=aMSA.ChangeFromIndex(aIndex); + // + TopoDS_Iterator anIt(aS, Standard_True); + for(; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aSubShape = anIt.Value(); + bIsNewSubShape = Standard_False; + if(!aMSA.Contains(aSubShape)) { + bIsNewSubShape=!bIsNewSubShape; + aIndexSubShape=aMSA.Add(aSubShape, aASx); + aMS.Add(aSubShape, aASx); + } + else { + aIndexSubShape=aMSA.FindIndex(aSubShape); + } + aAS.SetNewSuccessor(aIndexSubShape); + aAS.SetNewOrientation(aSubShape.Orientation()); + // + if(bIsNewSubShape && (aSubShape.ShapeType() != TopAbs_VERTEX)) { + FillSubshapes(aSubShape, aMSA, aMS); + } + } +} +//=========================================================================== +//function : Init +//purpose : +//=========================================================================== +void NMTDS_ShapesDataStructure::Init() +{ + Standard_Integer i, j, aNbSx, aNbS, aShift, aNbRanges; + Standard_Integer iFirst, iLast; + NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors aLx; + NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors aLit; + TopoDS_Iterator anIt; + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aMSA; + // + anIt.Initialize(myCompositeShape); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aSx=anIt.Value(); + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors aMS; + // + if (!aMSA.Contains(aSx)) { + FillMap(aSx, aMSA, aMS); + aLx.Append(aMS); + } + } + aNbS=aMSA.Extent(); + // + // Fill myRanges + i=aLx.Extent(); + myRanges.Resize(i); + aLit.Initialize(aLx); + for (i=1; aLit.More(); aLit.Next(), ++i) { + const BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSx=aLit.Value(); + aNbSx=aMSx.Extent(); + if (i==1) { + iFirst=1; + iLast=aNbSx; + myRanges(i).SetFirst(iFirst); + myRanges(i).SetLast(iLast); + continue; + } + iFirst=myRanges(i-1).Last()+1; + iLast=iFirst+aNbSx-1; + myRanges(i).SetFirst(iFirst); + myRanges(i).SetLast(iLast); + } + // + myNumberOfShapesOfTheObject=aNbS; + myNumberOfShapesOfTheTool=0; + myLength=2*aNbS; + // + // Allocate the whole Table + myListOfShapeAndInterferences = (BooleanOperations_PShapeAndInterferences) + Standard::Allocate(myLength*sizeof(BooleanOperations_ShapeAndInterferences)); + // + // Fill the table + + aShift=0; + for (j=1; j<=aNbS; ++j) { + const TopoDS_Shape& aSx=aMSA.FindKey(j); + const BooleanOperations_AncestorsSeqAndSuccessorsSeq& aASx=aMSA.FindFromIndex(j); + InsertShapeAndAncestorsSuccessors(aSx, aASx, aShift); + } + // myShapeIndexMap + myShapeIndexMap.Clear(); + // + //modified by NIZNHY-PKV Mon Dec 12 09:01:53 2011f + aNbRanges=myRanges.Extent(); + for (i=1; i<=aNbRanges; ++i){ + const NMTDS_IndexRange& aR=myRanges(i); + iFirst=aR.First(); + iLast =aR.Last(); + for (j=iFirst; j<=iLast; ++j) { + const TopoDS_Shape& aS=Shape(j); + myShapeIndexMap.Bind(aS, j); + } + } + //modified by NIZNHY-PKV Mon Dec 12 09:02:00 2011t + // + // myRefEdges + iLast=myNumberOfShapesOfTheObject+myNumberOfShapesOfTheTool; + myRefEdges.Resize(iLast); + + for (i=1; i<=iLast; ++i) { + const TopoDS_Shape& aS=Shape(i); + myRefEdges(i)=0; + if (aS.ShapeType()==TopAbs_EDGE) { + myNbEdges++; + myRefEdges(i)=myNbEdges; + } + } +} +//=========================================================================== +//function : ShapeRangeIndex +//purpose : +//=========================================================================== +Standard_Integer NMTDS_ShapesDataStructure::ShapeRangeIndex + (const Standard_Integer aId)const +{ + Standard_Boolean bFound; + Standard_Integer i, aNbR, aIdx, aNbS, aZero=0; + // + aNbS=myNumberOfShapesOfTheObject+myNumberOfShapesOfTheTool; + + aIdx=aId; + if (aIdx > aNbS || aIdx < 1){ + return aZero; + } + // + if (aIdx > myNumberOfShapesOfTheObject) { + aIdx-=myNumberOfShapesOfTheObject; + } + // + aNbR=myRanges.Extent(); + for (i=1; i<=aNbR; ++i) { + const NMTDS_IndexRange& aRange=myRanges(i); + bFound=aRange.IsInRange(aIdx); + if (bFound) { + return i; + } + } + return aZero; +} +//=========================================================================== +//function : Rank +//purpose : +//=========================================================================== +Standard_Integer NMTDS_ShapesDataStructure::Rank + (const Standard_Integer aId)const +{ + Standard_Boolean bFound; + Standard_Integer i, aNbR, aNbS, aZero=0; + // + aNbS=myNumberOfShapesOfTheObject; + + if (aId > aNbS || aId < 1){ + return aZero; + } + // + aNbR=myRanges.Extent(); + for (i=1; i<=aNbR; ++i) { + const NMTDS_IndexRange& aRange=myRanges(i); + bFound=aRange.IsInRange(aId); + if (bFound) { + return i; + } + } + return aZero; +} +//=========================================================================== +//function : ShapeIndex +//purpose : +//=========================================================================== +Standard_Integer NMTDS_ShapesDataStructure::ShapeIndex + (const TopoDS_Shape& aS, + const Standard_Integer aRank)const +{ + Standard_Address pIndex; + Standard_Integer aIndex; + // + aIndex=0; + // + //modified by NIZNHY-PKV Mon Dec 12 09:02:48 2011f + pIndex=myShapeIndexMap.Find1(aS); + if (pIndex) { + aIndex=*((Standard_Integer*)pIndex); + } + //modified by NIZNHY-PKV Mon Dec 12 09:02:54 2011t + return aIndex; +} + +//======================================================================= +//function : ComputeBoxEx +//purpose : +//======================================================================= +void NMTDS_ShapesDataStructure::ComputeBoxEx + (const Standard_Integer aIx, + Bnd_Box& aBoxEx)const +{ + ComputeBoxExS(aIx, this, aBoxEx); +} +//======================================================================= +//function : GetAllSuccessors +//purpose : +//======================================================================= +void NMTDS_ShapesDataStructure::GetAllSuccessors + (const Standard_Integer nS, + TColStd_IndexedMapOfInteger& aMA)const +{ + GetAllSuccessorsS(nS, this, aMA); +} +//======================================================================= +//function : GetAllSuccessorsS +//purpose : +//======================================================================= +void GetAllSuccessorsS(const Standard_Integer nS, + const NMTDS_ShapesDataStructure* myDS, + TColStd_IndexedMapOfInteger& aMA) +{ + TopAbs_ShapeEnum aT; + Standard_Integer i, nSx, aNbSuccessors, *pSuccessors; + Standard_Address xSuccessors; + // + const TopoDS_Shape& aS=myDS->Shape(nS); + aT=aS.ShapeType(); + if(NMTDS_Tools::HasBRep(aT)) { + aMA.Add(nS); + // + if (aT==TopAbs_VERTEX) { + return; + } + } + // + myDS->GetSuccessors(nS, xSuccessors, aNbSuccessors); + pSuccessors=(Standard_Integer*)xSuccessors; + for (i=0; iGetBoundingBox(aIx); + aBoxEx.Add(aBox); + // + aNbS=pDS->NumberOfSuccessors(aIx); + for (i=1; i<=aNbS; ++i) { + Bnd_Box aBoxS; + iS=pDS->GetSuccessor(aIx, i); + ComputeBoxExS(iS, pDS, aBoxS); + aBoxEx.Add(aBoxS); + } +} diff --git a/src/NMTDS_NEW/NMTDS_ShapesDataStructure.hxx b/src/NMTDS_NEW/NMTDS_ShapesDataStructure.hxx new file mode 100644 index 000000000..82a88824d --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_ShapesDataStructure.hxx @@ -0,0 +1,74 @@ + +#ifndef _NMTDS_ShapesDataStructure_HeaderFile +#define _NMTDS_ShapesDataStructure_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : NMTDS_ShapesDataStructure +//purpose : +//======================================================================= +class NMTDS_ShapesDataStructure : public BooleanOperations_ShapesDataStructure +{ + public: + Standard_EXPORT + NMTDS_ShapesDataStructure(); + + Standard_EXPORT + void SetCompositeShape(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void Init() ; + + Standard_EXPORT + const NMTDS_CArray1OfIndexRange& Ranges() const; + + Standard_EXPORT + const TopoDS_Shape& CompositeShape() const; + + Standard_EXPORT + Standard_Integer ShapeRangeIndex(const Standard_Integer aId) const; + + Standard_EXPORT + virtual Standard_Integer Rank(const Standard_Integer anIndex) const; + + Standard_EXPORT + virtual Standard_Integer ShapeIndex(const TopoDS_Shape& aS, + const Standard_Integer iRank) const; + + Standard_EXPORT + void FillMap(const TopoDS_Shape& aS, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSA, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMS) const; + + Standard_EXPORT + void FillSubshapes(const TopoDS_Shape& aS, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSA, + BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMS) const; + + Standard_EXPORT + void GetAllSuccessors(const Standard_Integer anIndex, + TColStd_IndexedMapOfInteger& aScrs) const; + + Standard_EXPORT + void ComputeBoxEx(const Standard_Integer anIndex, + Bnd_Box& aBox) const; + + + protected: + TopoDS_Shape myCompositeShape; + NMTDS_CArray1OfIndexRange myRanges; + TopTools_DataMapOfShapeInteger myShapeIndexMap; +}; +#endif diff --git a/src/NMTDS_NEW/NMTDS_Tools.cxx b/src/NMTDS_NEW/NMTDS_Tools.cxx new file mode 100644 index 000000000..c1bcec502 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_Tools.cxx @@ -0,0 +1,180 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_Tools.cxx +// Created: Tue Feb 20 14:57:28 2007 +// Author: Peter KURNEV + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void CopySource(const TopoDS_Shape& aS, + TopTools_IndexedDataMapOfShapeShape& aMapSS, + TopoDS_Shape& aSC); + +//======================================================================= +//function : CopyShape +//purpose : +//======================================================================= + void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS, + TopoDS_Shape& aSC) +{ + TopTools_IndexedDataMapOfShapeShape aMapSS; + // + CopySource(aS, aMapSS, aSC); +} +//======================================================================= +//function : CopyShape +//purpose : +//======================================================================= + void NMTDS_Tools::CopyShape(const TopoDS_Shape& aS, + TopoDS_Shape& aSC, + TopTools_IndexedDataMapOfShapeShape& aMapSS) +{ + CopySource(aS, aMapSS, aSC); +} +//======================================================================= +//function : CopySource +//purpose : +//======================================================================= +void CopySource(const TopoDS_Shape& aS, + TopTools_IndexedDataMapOfShapeShape& aMapSS, + TopoDS_Shape& aSC) +{ + Standard_Boolean bFree; + TopAbs_ShapeEnum aT; + TopoDS_Iterator aIt; + TopoDS_Shape aSF; + BRep_Builder BB; + // + aT=aS.ShapeType(); + // + if (aMapSS.Contains(aS)) { + aSC=aMapSS.ChangeFromKey(aS); + aSC.Orientation(aS.Orientation()); + return; + } + else { + aSC=aS.EmptyCopied(); + aMapSS.Add(aS, aSC); + } + // + bFree=aSC.Free(); + aSC.Free(Standard_True); + aSF=aS; + if (aT==TopAbs_EDGE){ + TopAbs_Orientation aOr; + // + aOr=aS.Orientation(); + if(aOr==TopAbs_INTERNAL) { + aSF.Orientation(TopAbs_FORWARD); + } + } + aIt.Initialize(aSF); + for (; aIt.More(); aIt.Next()) { + TopoDS_Shape aSCx; + // + const TopoDS_Shape& aSx=aIt.Value(); + // + CopySource (aSx, aMapSS, aSCx); + // + aSCx.Orientation(aSx.Orientation()); + BB.Add(aSC, aSCx); + } + aSC.Free(bFree); +} +//======================================================================= +// function: ComputeVV +// purpose: +//======================================================================= + Standard_Integer NMTDS_Tools::ComputeVV(const TopoDS_Vertex& aV1, + const TopoDS_Vertex& aV2) +{ + Standard_Real aTolV1, aTolV2, aTolSum, aTolSum2, aD2; + gp_Pnt aP1, aP2; + // + aTolV1=BRep_Tool::Tolerance(aV1); + aTolV2=BRep_Tool::Tolerance(aV2); + aTolSum=aTolV1+aTolV2; + aTolSum2=aTolSum*aTolSum; + // + aP1=BRep_Tool::Pnt(aV1); + aP2=BRep_Tool::Pnt(aV2); + // + aD2=aP1.SquareDistance(aP2); + if (aD2>aTolSum2) { + return -1; + } + return 0; +} +//======================================================================= +// function: HasBRep +// purpose: +//======================================================================= + Standard_Boolean NMTDS_Tools::HasBRep(const TopAbs_ShapeEnum aTi) +{ + return (aTi==TopAbs_VERTEX || aTi==TopAbs_EDGE || aTi==TopAbs_FACE); +} +//======================================================================= +//function : TypeToInteger +//purpose : +//======================================================================= + Standard_Integer NMTDS_Tools::TypeToInteger(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + Standard_Integer iRet, iT1, iT2, iX; + // + iRet=-1; + iT1=(Standard_Integer)aType1; + iT2=(Standard_Integer)aType2; + // + iX=iT2*10+iT1; + switch (iX) { + case 77: + iRet=5; // VV + break; + case 76: + case 67: + iRet=4; // VE + break; + case 74: + case 47: + iRet=2; // VF + break; + case 66: + iRet=3; // EE + break; + case 64: + case 46: + iRet=1; // EF + break; + case 44: + iRet=0; // FF + break; + default: + break; + } + return iRet; +} diff --git a/src/NMTDS_NEW/NMTDS_Tools.hxx b/src/NMTDS_NEW/NMTDS_Tools.hxx new file mode 100644 index 000000000..39bda9460 --- /dev/null +++ b/src/NMTDS_NEW/NMTDS_Tools.hxx @@ -0,0 +1,62 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_Tools.hxx +// Created: +// Author: Peter KURNEV + +#ifndef _NMTDS_Tools_HeaderFile +#define _NMTDS_Tools_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : NMTDS_Tools +//purpose : +//======================================================================= +class NMTDS_Tools +{ + public: + Standard_EXPORT + static Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aT1, + const TopAbs_ShapeEnum aT2) ; + + Standard_EXPORT + static Standard_Boolean HasBRep(const TopAbs_ShapeEnum aT) ; + + Standard_EXPORT + static Standard_Integer ComputeVV(const TopoDS_Vertex& aV1, + const TopoDS_Vertex& aV2) ; + + Standard_EXPORT + static void CopyShape(const TopoDS_Shape& aS, + TopoDS_Shape& aSC) ; + + Standard_EXPORT + static void CopyShape(const TopoDS_Shape& aS, + TopoDS_Shape& aSC, + TopTools_IndexedDataMapOfShapeShape& aMSS) ; +}; +#endif diff --git a/src/NMTTools_NEW/FILES b/src/NMTTools_NEW/FILES new file mode 100644 index 000000000..63a775bc7 --- /dev/null +++ b/src/NMTTools_NEW/FILES @@ -0,0 +1,52 @@ +NMTTools_PaveFiller_0.cxx +NMTTools_PaveFiller_1.cxx +NMTTools_PaveFiller_2.cxx +NMTTools_PaveFiller_3.cxx +NMTTools_PaveFiller_4.cxx +NMTTools_PaveFiller_5.cxx +NMTTools_PaveFiller_6.cxx +NMTTools_PaveFiller_7.cxx +NMTTools_PaveFiller_8.cxx +NMTTools_PaveFiller_9.cxx + + +NMTTools_CoupleOfShape.hxx +NMTTools_CoupleOfShape.cxx +NMTTools_CommonBlock.hxx +NMTTools_CommonBlock.cxx +NMTTools_CommonBlockAPI.hxx +NMTTools_CommonBlockAPI.cxx +NMTTools_FaceInfo.hxx +NMTTools_FaceInfo.cxx +NMTTools_FaceInfo.lxx +NMTTools_Tools.hxx +NMTTools_Tools.cxx +NMTTools_PaveFiller.hxx +NMTTools_PaveFiller.cxx +NMTTools_PPaveFiller.hxx +NMTTools_DEProcessor.hxx +NMTTools_DEProcessor.cxx +NMTTools_CheckerSI.hxx +NMTTools_CheckerSI.cxx +NMTTools_CheckerSI_1.cxx + +NMTTools_ListOfCommonBlock.hxx +NMTTools_ListIteratorOfListOfCommonBlock.hxx +NMTTools_ListOfCoupleOfShape.hxx +NMTTools_ListIteratorOfListOfCoupleOfShape.hxx + +NMTTools_MapOfPaveBlock.hxx +NMTTools_MapIteratorOfMapOfPaveBlock.hxx + +NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx +NMTTools_IndexedDataMapOfShapePaveBlock.hxx +NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx + +NMTTools_DataMapOfIntegerListOfPaveBlock.hxx +NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx + +NMTTools_DataMapOfIntegerFaceInfo.hxx +NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx + +NMTTools_CommonBlockPool.hxx +NMTTools_CommonBlockPool.cxx diff --git a/src/NMTTools_NEW/Makefile.am b/src/NMTTools_NEW/Makefile.am new file mode 100644 index 000000000..221c2c9bf --- /dev/null +++ b/src/NMTTools_NEW/Makefile.am @@ -0,0 +1,97 @@ +# Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 + +# GEOM NMTTools : partition algorithm +# File : Makefile.in +# Author : Julia DOROVSKIKH +# Modified by : Alexander BORODIN (OCN) - autotools usage +# Module : GEOM + +include $(top_srcdir)/adm_local/unix/make_common_starter.am + +# header files +salomeinclude_HEADERS = \ + NMTTools_CheckerSI.hxx \ + NMTTools_CommonBlockAPI.hxx \ + NMTTools_CommonBlock.hxx \ + NMTTools_CommonBlockPool.hxx \ + NMTTools_CoupleOfShape.hxx \ + NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx \ + NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx \ + NMTTools_DataMapOfIntegerFaceInfo.hxx \ + NMTTools_DataMapOfIntegerListOfPaveBlock.hxx \ + NMTTools_DEProcessor.hxx \ + NMTTools_FaceInfo.hxx \ + NMTTools_FaceInfo.lxx \ + NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx \ + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx \ + NMTTools_IndexedDataMapOfShapePaveBlock.hxx \ + NMTTools_ListIteratorOfListOfCommonBlock.hxx \ + NMTTools_ListIteratorOfListOfCoupleOfShape.hxx \ + NMTTools_ListOfCommonBlock.hxx \ + NMTTools_ListOfCoupleOfShape.hxx \ + NMTTools_MapIteratorOfMapOfPaveBlock.hxx \ + NMTTools_MapOfPaveBlock.hxx \ + NMTTools_PaveFiller.hxx \ + NMTTools_PPaveFiller.hxx \ + NMTTools_Tools.hxx + +# Libraries targets +lib_LTLIBRARIES = libNMTTools.la + +dist_libNMTTools_la_SOURCES = \ + NMTTools_CheckerSI.cxx \ + NMTTools_CheckerSI_1.cxx \ + NMTTools_CommonBlockAPI.cxx \ + NMTTools_CommonBlock.cxx \ + NMTTools_CommonBlockPool.cxx \ + NMTTools_CoupleOfShape.cxx \ + NMTTools_DEProcessor.cxx \ + NMTTools_FaceInfo.cxx \ + NMTTools_PaveFiller_0.cxx \ + NMTTools_PaveFiller_1.cxx \ + NMTTools_PaveFiller_2.cxx \ + NMTTools_PaveFiller_3.cxx \ + NMTTools_PaveFiller_4.cxx \ + NMTTools_PaveFiller_5.cxx \ + NMTTools_PaveFiller_6.cxx \ + NMTTools_PaveFiller_7.cxx \ + NMTTools_PaveFiller_8.cxx \ + NMTTools_PaveFiller_9.cxx \ + NMTTools_PaveFiller.cxx \ + NMTTools_Tools.cxx + +# additional information to compile and link file + +libNMTTools_la_CPPFLAGS = \ + $(CAS_CPPFLAGS) \ + $(KERNEL_CXXFLAGS) \ + -I$(srcdir)/../$(NMTDS_VAR) + +libNMTTools_la_LDFLAGS = \ + ../$(NMTDS_VAR)/libNMTDS.la \ + $(STDLIB) \ + $(CAS_LDPATH) -lTKBool -lTKBO \ + $(KERNEL_LDFLAGS) + +CDL_FILES = \ + NMTTools.cdl + +EXTRA_DIST += \ + $(CDL_FILES) \ + FILES diff --git a/src/NMTTools_NEW/NMTTools.cdl b/src/NMTTools_NEW/NMTTools.cdl new file mode 100644 index 000000000..82a03105b --- /dev/null +++ b/src/NMTTools_NEW/NMTTools.cdl @@ -0,0 +1,129 @@ +-- 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: NMTTools.cdl +-- Created: Thu Dec 4 16:55:49 2003 +-- Author: Peter KURNEV +-- +-- +package NMTTools + + ---Purpose: + +uses + + TCollection, + TColStd, + gp, + TopAbs, + TopoDS, + TopTools, + Geom2d, + BooleanOperations, + BOPTColStd, + IntTools, + BOPTools, + NMTDS + +is + imported CoupleOfShape from NMTTools; + imported CommonBlock from NMTTools; + imported CommonBlockAPI from NMTTools; + imported FaceInfo from NMTTools; + imported Tools from NMTTools; + imported PaveFiller from NMTTools; + imported PPaveFiller from NMTTools; + imported DEProcessor from NMTTools; + imported CheckerSI from NMTTools; + -- + imported ListOfCommonBlock from NMTTools; + imported ListIteratorOfListOfCommonBlock from NMTTools; + + imported ListOfCoupleOfShape from NMTTools; + imported ListIteratorOfListOfCoupleOfShape from NMTTools; + + imported MapOfPaveBlock from NMTTools; + imported MapIteratorOfMapOfPaveBlock from NMTTools; + + imported IndexedDataMapOfIndexedMapOfInteger from NMTTools; + imported IndexedDataMapOfShapePaveBlock from NMTTools; + imported IndexedDataMapOfShapeIndexedMapOfShape from NMTTools; + + imported DataMapOfIntegerListOfPaveBlock from NMTTools; + imported DataMapIteratorOfDataMapOfIntegerListOfPaveBlock from NMTTools; + + imported DataMapOfIntegerFaceInfo from NMTTools; + imported DataMapIteratorOfDataMapOfIntegerFaceInfo from NMTTools; + + imported CommonBlockPool from NMTTools; + + -- + --class PaveFiller; + --class Tools; + --class CommonBlock; + --class CommonBlockAPI; + --class FaceInfo; + --class CoupleOfShape; + --class CheckerSI; + --class DEProcessor; + --pointer PPaveFiller to PaveFiller from NMTTools; + -- + --class ListOfCommonBlock instantiates + -- List from TCollection(CommonBlock from NMTTools); + + --class ListOfCoupleOfShape instantiates + -- List from TCollection(CoupleOfShape from NMTTools); +-- + --class MapOfPaveBlock instantiates + -- Map from TCollection (PaveBlock from BOPTools, + -- PaveBlockMapHasher from BOPTools); +-- + --class IndexedDataMapOfIndexedMapOfInteger instantiates + -- IndexedDataMap from TCollection (Integer from Standard, + -- IndexedMapOfInteger from TColStd, + -- MapIntegerHasher from TColStd); + + --class IndexedDataMapOfShapePaveBlock instantiates + -- IndexedDataMap from TCollection (Shape from TopoDS, + -- PaveBlock from BOPTools, + -- ShapeMapHasher from TopTools); + + --class IndexedDataMapOfShapeIndexedMapOfShape instantiates + -- IndexedDataMap from TCollection (Shape from TopoDS, + -- IndexedMapOfShape from TopTools, + -- ShapeMapHasher from TopTools); + +-- + --class DataMapOfIntegerListOfPaveBlock instantiates + -- DataMap from TCollection(Integer from Standard, + -- ListOfPaveBlock from BOPTools, + -- MapIntegerHasher from TColStd); + + --class DataMapOfIntegerFaceInfo instantiates + -- DataMap from TCollection(Integer from Standard, + -- FaceInfo from NMTTools, + -- MapIntegerHasher from TColStd); +-- + --class CommonBlockPool instantiates + -- CArray1 from BOPTColStd (ListOfCommonBlock from NMTTools); +-- +end NMTTools; diff --git a/src/NMTTools_NEW/NMTTools_CheckerSI.cxx b/src/NMTTools_NEW/NMTTools_CheckerSI.cxx new file mode 100644 index 000000000..037445e16 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CheckerSI.cxx @@ -0,0 +1,180 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_CheckerSI.cxx +// Created: Mon Feb 19 11:32:08 2007 +// Author: Peter KURNEV +// +#include + +#include +#include +#include +#include +#include + +//======================================================================= +//function : +//purpose : +//======================================================================= + NMTTools_CheckerSI::NMTTools_CheckerSI() +: + NMTTools_PaveFiller() +{ + myStopStatus=0; +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= + NMTTools_CheckerSI::~NMTTools_CheckerSI() +{ +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= + void NMTTools_CheckerSI::Clear() +{ + NMTTools_PaveFiller::Clear(); +} +//======================================================================= +//function : StopStatus +//purpose : +//======================================================================= + Standard_Integer NMTTools_CheckerSI::StopStatus()const +{ + return myStopStatus; +} +//======================================================================= +//function : Init +//purpose : +//======================================================================= + void NMTTools_CheckerSI::Init() +{ + myIsDone=Standard_False; + if (myCompositeShape.IsNull()) { + return; + } + // + Clear(); + // 1. + myDS=new NMTDS_ShapesDataStructure; + myDS->SetCompositeShape(myCompositeShape); + myDS->Init(); + // + // 2. + myDSIt=new NMTDS_IteratorCheckerSI; + myDSIt->SetDS(myDS); + myDSIt->Prepare(); + // + // 3. + myNbSources=myDS->NumberOfShapesOfTheObject()+ + myDS->NumberOfShapesOfTheTool(); + myNbEdges=myDS->NbEdges(); + // 4 + myIP=new NMTDS_InterfPool; + // + // 5 + myContext=new IntTools_Context; +} +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + void NMTTools_CheckerSI::Perform() +{ + myIsDone=Standard_False; + myStopStatus=0; + // + Init(); + //1.VV + // + PerformVV(); + // + // 2.VE + myPavePool.Resize (myNbEdges); + + PrepareEdges(); + // + PerformVE(); + // + // 3.VF + PerformVF(); + // + // 4.EE + myCommonBlockPool.Resize (myNbEdges); + mySplitShapesPool.Resize (myNbEdges); + myPavePoolNew .Resize (myNbEdges); + // + PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); + if (myStopStatus) { + return; + } + PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); + if (myStopStatus) { + return; + } + // + PerformEE(); + // + RefinePavePool (); + if (myStopStatus) { + return; + } + // + myPavePoolNew.Destroy(); + myPavePoolNew.Resize (myNbEdges); + // + // 5.EF + PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE); + if (myStopStatus) { + return; + } + // + PerformEF(); + // + RefinePavePool(); + if (myStopStatus) { + return; + } + // + myPavePoolNew.Destroy(); + // + MakeSplitEdges(); + // + UpdateCommonBlocks(); + // + // 6. FF + PerformFF (); + // + MakeBlocks(); + // + MakePCurves(); + // + // 7. Postprocessing + UpdatePaveBlocks(); + // + NMTTools_DEProcessor aDEP(*this); + aDEP.Do(); + // + MakeAloneVertices(); + // + myIsDone=Standard_True; +} diff --git a/src/NMTTools_NEW/NMTTools_CheckerSI.hxx b/src/NMTTools_NEW/NMTTools_CheckerSI.hxx new file mode 100644 index 000000000..27ec729d4 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CheckerSI.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_CheckerSI.hxx +// Created: Mon Feb 19 11:32:08 2007 +// Author: Peter KURNEV +// +#ifndef _NMTTools_CheckerSI_HeaderFile +#define _NMTTools_CheckerSI_HeaderFile + +#include +#include +#include +#include +#include + +//======================================================================= +//class : NMTTools_CheckerSI +//purpose : +//======================================================================= +class NMTTools_CheckerSI : public NMTTools_PaveFiller +{ + public: + Standard_EXPORT + NMTTools_CheckerSI(); + + Standard_EXPORT + virtual ~NMTTools_CheckerSI(); + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + Standard_Integer StopStatus() const; + + protected: + Standard_EXPORT + virtual void Init() ; + + Standard_EXPORT + virtual void Clear() ; + + Standard_EXPORT + virtual void PreparePaveBlocks(const Standard_Integer nE) ; + + Standard_EXPORT + virtual void PreparePaveBlocks(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) ; + + + Standard_Integer myStopStatus; +}; +#endif diff --git a/src/NMTTools_NEW/NMTTools_CheckerSI_1.cxx b/src/NMTTools_NEW/NMTTools_CheckerSI_1.cxx new file mode 100644 index 000000000..6cc796ac9 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CheckerSI_1.cxx @@ -0,0 +1,159 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_CheckerSI.cxx +// Created: Mon Feb 19 11:32:08 2007 +// Author: Peter KURNEV +// +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +static + Standard_Boolean IsValid(const TopoDS_Edge& aE, + const TopoDS_Vertex& aV, + const Standard_Real aTV1, + const Standard_Real aTV2); + +//======================================================================= +// function: PreparePaveBlocks +// purpose: +//======================================================================= + void NMTTools_CheckerSI::PreparePaveBlocks(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + NMTTools_PaveFiller::PreparePaveBlocks(aType1, aType2); +} +//======================================================================= +// function: PreparePaveBlocks +// purpose: +//======================================================================= + void NMTTools_CheckerSI::PreparePaveBlocks(const Standard_Integer nE) +{ + myIsDone=Standard_False; + // + // char buf[32]={"SR"}; + Standard_Boolean bIsValid; + Standard_Integer nV1, nV2, iErr; + Standard_Real aT1, aT2; + TopoDS_Edge aE; + TopoDS_Vertex aV1, aV2; + // + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + // Edge + aE=TopoDS::Edge(myDS->Shape(nE)); + if (BRep_Tool::Degenerated(aE)) { + myIsDone=Standard_True; + return; + } + // + BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE)); + + BOPTools_PaveBlockIterator aPBIt(nE, aPS); + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + const IntTools_Range& aRange=aPB.Range(); + // + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + aV1=TopoDS::Vertex(myDS->Shape(nV1)); + aT1=aPave1.Param(); + // + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + aV2=TopoDS::Vertex(myDS->Shape(nV2)); + aT2=aPave2.Param(); + // + bIsValid=Standard_True; + if (nV1==nV2) { + bIsValid=IsValid(aE, aV1, aT1, aT2); + if (!bIsValid) { + //printf(" pb SR: nV nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2); + myStopStatus=1; + } + } + // + IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext); + iErr=aSR.ErrorStatus(); + if (!aSR.IsDone()) { + //printf(" pb SR: Done nE: %d nV1:( %d %15.10lf ) nV2:( %d %15.10lf )\n", nE, nV1, aT1, nV2, aT2); + aSR.SetShrunkRange(aRange); + //throw BOPTColStd_Failure(buf) ; + } + else if (iErr!=6) { + CorrectShrunkRanges (0, aPave1, aSR); + CorrectShrunkRanges (1, aPave2, aSR); + } + aPB.SetShrunkRange(aSR); + aLPB.Append(aPB); + } //for (; aPBIt.More(); aPBIt.Next()) + myIsDone=Standard_True; +} + +//======================================================================= +//function : IsValid +//purpose : +//======================================================================= +Standard_Boolean IsValid(const TopoDS_Edge& aE, + const TopoDS_Vertex& aV, + const Standard_Real aTV1, + const Standard_Real aTV2) +{ + Standard_Boolean bRet; + Standard_Integer i, aNbP, aNbP1; + Standard_Real aTolV2, aTC1, aTC2, dT, aTC, aD2; + Handle(Geom_Curve) aC; + gp_Pnt aPV, aPC; + // + bRet=Standard_False; + aTolV2=BRep_Tool::Tolerance(aV); + aTolV2=aTolV2*aTolV2; + aPV=BRep_Tool::Pnt(aV); + aC=BRep_Tool::Curve(aE, aTC1, aTC2); + aNbP=7; + aNbP1=aNbP-1; + dT=(aTV2-aTV1)/aNbP1; + // + for (i=1; iD0(aTC, aPC); + aD2=aPV.SquareDistance(aPC); + bRet=aD2>aTolV2; + } + return bRet; +} diff --git a/src/NMTTools_NEW/NMTTools_CommonBlock.cxx b/src/NMTTools_NEW/NMTTools_CommonBlock.cxx new file mode 100644 index 000000000..6324342d9 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CommonBlock.cxx @@ -0,0 +1,248 @@ +// 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: NMTTools_CommonBlock.cxx +// Created: Tue Dec 9 12:23:29 2003 +// Author: Peter KURNEV +// +// +#include + +#include +#include + +//======================================================================= +// function: NMTTools_CommonBlock::NMTTools_CommonBlock() +// purpose: +//======================================================================= + NMTTools_CommonBlock::NMTTools_CommonBlock() +{ +} +//======================================================================= +// function: AddPaveBlock +// purpose: +//======================================================================= + void NMTTools_CommonBlock::AddPaveBlock(const BOPTools_PaveBlock& aPB) +{ + myPaveBlocks.Append(aPB); +} +//======================================================================= +// function: AddFace +// purpose: +//======================================================================= + void NMTTools_CommonBlock::AddFace(const Standard_Integer aF) +{ + myFaces.Append(aF); +} +//======================================================================= +// function: AddFaces +// purpose: +//======================================================================= + void NMTTools_CommonBlock::AddFaces(const TColStd_ListOfInteger& aLF) +{ + TColStd_ListIteratorOfListOfInteger aIt(aLF); + // + for (; aIt.More(); aIt.Next()) { + myFaces.Append(aIt.Value()); + } +} +//======================================================================= +// function: PaveBlocks +// purpose: +//======================================================================= + const BOPTools_ListOfPaveBlock& NMTTools_CommonBlock::PaveBlocks()const +{ + return myPaveBlocks; +} +//======================================================================= +// function: Faces +// purpose: +//======================================================================= + const TColStd_ListOfInteger& NMTTools_CommonBlock::Faces()const +{ + return myFaces; +} +//======================================================================= +// function: PaveBlock1 +// purpose: +//======================================================================= + const BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlock1()const +{ + return myPaveBlocks.First(); +} +//======================================================================= +// function: PaveBlock1 +// purpose: +//======================================================================= + BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlock1(const Standard_Integer aIx) +{ + return PaveBlockOnEdge(aIx); +} +//======================================================================= +// function: PaveBlockOnEdge +// purpose: +//======================================================================= + BOPTools_PaveBlock& NMTTools_CommonBlock::PaveBlockOnEdge(const Standard_Integer aIx) +{ + static BOPTools_PaveBlock aPBs; + Standard_Integer aIOr; + BOPTools_ListIteratorOfListOfPaveBlock anIt(myPaveBlocks); + // + for (; anIt.More(); anIt.Next()) { + BOPTools_PaveBlock& aPB=anIt.Value(); + aIOr=aPB.OriginalEdge(); + if (aIOr==aIx){ + return aPB; + } + } + return aPBs; +} +//======================================================================= +// function: IsPaveBlockOnFace +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlock::IsPaveBlockOnFace(const Standard_Integer aIx)const +{ + Standard_Boolean bFound=Standard_False; + Standard_Integer nF; + TColStd_ListIteratorOfListOfInteger anIt(myFaces); + // + for (; anIt.More(); anIt.Next()) { + nF=anIt.Value(); + if (nF==aIx){ + return !bFound; + } + } + return bFound; +} +//======================================================================= +// function: IsPaveBlockOnEdge +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlock::IsPaveBlockOnEdge(const Standard_Integer aIx)const +{ + Standard_Boolean bFound=Standard_False; + Standard_Integer aIOr; + BOPTools_ListIteratorOfListOfPaveBlock anIt(myPaveBlocks); + // + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + aIOr=aPB.OriginalEdge(); + if (aIOr==aIx){ + return !bFound; + } + } + return bFound; +} +//======================================================================= +// function: IsEqual +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlock::IsEqual(const NMTTools_CommonBlock& aOther)const +{ + Standard_Boolean bFound=Standard_True; + Standard_Integer aNb1, aNb2; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + aNb1=myPaveBlocks.Extent(); + aNb2=aOther.myPaveBlocks.Extent(); + // + if (!aNb1 && !aNb2) { + return bFound; + } + if (!aNb1) { + return !bFound; + } + if (!aNb2) { + return !bFound; + } + // + const BOPTools_PaveBlock& aPB=PaveBlock1(); + // + anIt.Initialize(aOther.myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBOther=anIt.Value(); + if (aPB.IsEqual(aPBOther)){ + return bFound; + } + } + return !bFound; +} +//======================================================================= +// function: Contains +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlock::Contains(const BOPTools_PaveBlock& aPBx)const +{ + Standard_Boolean bFound=Standard_False; + Standard_Integer aNb1; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + aNb1=myPaveBlocks.Extent(); + // + if (!aNb1) { + return bFound; + } + // + anIt.Initialize(myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + if (aPB.IsEqual(aPBx)) { + return !bFound; + } + } + return bFound; +} +/* +//======================================================================= +// function: SetEdge +// purpose: +//======================================================================= + void NMTTools_CommonBlock::SetEdge(const Standard_Integer anEdge) +{ + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + anIt.Initialize(myPaveBlocks); + for (; anIt.More(); anIt.Next()) { + BOPTools_PaveBlock& aPB=anIt.Value(); + aPB.SetEdge(anEdge); + } +} +//======================================================================= +// function: Edge +// purpose: +//======================================================================= + Standard_Integer NMTTools_CommonBlock::Edge()const +{ + Standard_Integer aNb; + // + aNb=myPaveBlocks.Extent(); + // + if (!aNb) { + return aNb; + } + // + const BOPTools_PaveBlock& aPB=PaveBlock1(); + aNb=aPB.Edge(); + return aNb; +} +*/ diff --git a/src/NMTTools_NEW/NMTTools_CommonBlock.hxx b/src/NMTTools_NEW/NMTTools_CommonBlock.hxx new file mode 100644 index 000000000..8fabb1143 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CommonBlock.hxx @@ -0,0 +1,91 @@ +// 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: NMTTools_CommonBlock.hxx +// Created: Tue Dec 9 12:23:29 2003 +// Author: Peter KURNEV +// +// + +#ifndef _NMTTools_CommonBlock_HeaderFile +#define _NMTTools_CommonBlock_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + + +//======================================================================= +//function : NMTTools_CommonBlock +//purpose : +//======================================================================= +class NMTTools_CommonBlock { + public: + Standard_EXPORT + NMTTools_CommonBlock(); + + Standard_EXPORT + void AddPaveBlock(const BOPTools_PaveBlock& aPB) ; + + Standard_EXPORT + void AddFace(const Standard_Integer aF) ; + + Standard_EXPORT + void AddFaces(const TColStd_ListOfInteger& aLF) ; + + Standard_EXPORT + const BOPTools_ListOfPaveBlock& PaveBlocks() const; + + Standard_EXPORT + const TColStd_ListOfInteger& Faces() const; + + Standard_EXPORT + const BOPTools_PaveBlock& PaveBlock1() const; + + Standard_EXPORT + BOPTools_PaveBlock& PaveBlock1(const Standard_Integer anIx) ; + + Standard_EXPORT + BOPTools_PaveBlock& PaveBlockOnEdge(const Standard_Integer anIndex) ; + + Standard_EXPORT + Standard_Boolean IsPaveBlockOnFace(const Standard_Integer anIndex) const; + + Standard_EXPORT + Standard_Boolean IsPaveBlockOnEdge(const Standard_Integer anIndex) const; + + Standard_EXPORT + Standard_Boolean IsEqual(const NMTTools_CommonBlock& aCB) const; + + Standard_EXPORT + Standard_Boolean Contains(const BOPTools_PaveBlock& aPB) const; + + protected: + BOPTools_ListOfPaveBlock myPaveBlocks; + TColStd_ListOfInteger myFaces; +}; + +#endif diff --git a/src/NMTTools_NEW/NMTTools_CommonBlockAPI.cxx b/src/NMTTools_NEW/NMTTools_CommonBlockAPI.cxx new file mode 100644 index 000000000..daaa5795e --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CommonBlockAPI.cxx @@ -0,0 +1,135 @@ +// 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: NMTTools_CommonBlockAPI.cxx +// Created: Mon Dec 15 11:38:04 2003 +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include + +#include +#include +#include + +//======================================================================= +// function: NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI +// purpose: +//======================================================================= + NMTTools_CommonBlockAPI::NMTTools_CommonBlockAPI (const NMTTools_ListOfCommonBlock& aLCB) +{ + myListOfCommonBlock=(void *)&aLCB; +} +//======================================================================= +// function: List +// purpose: +//======================================================================= + const NMTTools_ListOfCommonBlock& NMTTools_CommonBlockAPI::List () const +{ + NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock; + return *pListOfCommonBlock; +} +//======================================================================= +// function: CommonPaveBlocks +// purpose: get all CommonPaveBlocks +//======================================================================= + const BOPTools_ListOfPaveBlock& NMTTools_CommonBlockAPI::CommonPaveBlocks(const Standard_Integer anE) const +{ + Standard_Integer anECurrent; + BOPTools_ListIteratorOfListOfPaveBlock anItPB; + // + BOPTools_ListOfPaveBlock* pmyListOfPaveBlock=(BOPTools_ListOfPaveBlock*) &myListOfPaveBlock; + pmyListOfPaveBlock->Clear(); + + NMTTools_ListOfCommonBlock* pListOfCommonBlock=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock; + + NMTTools_ListIteratorOfListOfCommonBlock anIt(*pListOfCommonBlock); + for (; anIt.More(); anIt.Next()) { + const NMTTools_CommonBlock& aCB=anIt.Value(); + // + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + anItPB.Initialize(aLPB); + for (; anItPB.More(); anItPB.Next()) { + const BOPTools_PaveBlock& aPB=anItPB.Value(); + anECurrent=aPB.OriginalEdge(); + if (anECurrent==anE) { + pmyListOfPaveBlock->Append(aPB); + break; + } + } + } + return myListOfPaveBlock; +} +//======================================================================= +// function: IsCommonBlock +// purpose: +//======================================================================= + Standard_Boolean NMTTools_CommonBlockAPI::IsCommonBlock(const BOPTools_PaveBlock& aPB) const +{ + Standard_Integer anE; + // + anE=aPB.OriginalEdge(); + // + CommonPaveBlocks(anE); + // + BOPTools_ListIteratorOfListOfPaveBlock anIt(myListOfPaveBlock); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB1=anIt.Value(); + if (aPB1.IsEqual(aPB)) { + return Standard_True; + } + } + return Standard_False; +} + +//======================================================================= +// function: CommonBlock +// purpose: +//======================================================================= + NMTTools_CommonBlock& NMTTools_CommonBlockAPI::CommonBlock(const BOPTools_PaveBlock& aPB)const +{ + static NMTTools_CommonBlock aCBTMP; + // + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + BOPTools_ListIteratorOfListOfPaveBlock anItPB; + // + NMTTools_ListOfCommonBlock* pLCB=(NMTTools_ListOfCommonBlock*)myListOfCommonBlock; + // + anItCB.Initialize(*pLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.ChangeValue(); + // + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + anItPB.Initialize(aLPB); + for (; anItPB.More(); anItPB.Next()) { + const BOPTools_PaveBlock& aPBx=anItPB.Value(); + if (aPBx.IsEqual(aPB)) { + return aCB; + } + } + } + return aCBTMP; +} diff --git a/src/NMTTools_NEW/NMTTools_CommonBlockAPI.hxx b/src/NMTTools_NEW/NMTTools_CommonBlockAPI.hxx new file mode 100644 index 000000000..def2c49e9 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CommonBlockAPI.hxx @@ -0,0 +1,74 @@ +// 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: NMTTools_CommonBlockAPI.hxx +// Created: Mon Dec 15 11:38:04 2003 +// Author: Peter KURNEV +// +// +#ifndef _NMTTools_CommonBlockAPI_HeaderFile +#define _NMTTools_CommonBlockAPI_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : NMTTools_CommonBlockAPI +//purpose : +//======================================================================= +class NMTTools_CommonBlockAPI +{ + public: + Standard_EXPORT + NMTTools_CommonBlockAPI(const NMTTools_ListOfCommonBlock& aList); + +//! Selector
+ Standard_EXPORT + const NMTTools_ListOfCommonBlock& List() const; + +//! Returns all PaveBlock-s (from the list) that are
+//! common for the given edge with DS-index
+ Standard_EXPORT + const BOPTools_ListOfPaveBlock& CommonPaveBlocks(const Standard_Integer anE) const; + +//! Returns TRUE if given PaveBlock is
+//! common for the Blocks from the list
+ Standard_EXPORT + Standard_Boolean IsCommonBlock(const BOPTools_PaveBlock& aPB) const; + + Standard_EXPORT + NMTTools_CommonBlock& CommonBlock(const BOPTools_PaveBlock& aPB) const; +protected: +//private: + +Standard_Address myListOfCommonBlock; +BOPTools_ListOfPaveBlock myListOfPaveBlock; +}; +#endif diff --git a/src/NMTTools_NEW/NMTTools_CommonBlockPool.cxx b/src/NMTTools_NEW/NMTTools_CommonBlockPool.cxx new file mode 100644 index 000000000..654852c7f --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CommonBlockPool.cxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_CommonBlockPool.cxx +// Created: +// Author: Peter KURNEV +// +// + + +#include + +#ifndef _Standard_OutOfRange_HeaderFile +#include +#endif +#ifndef _Standard_OutOfMemory_HeaderFile +#include +#endif + + +#define Array1Item NMTTools_ListOfCommonBlock +#define Array1Item_hxx +#define BOPTColStd_CArray1 NMTTools_CommonBlockPool +#define BOPTColStd_CArray1_hxx +#include + diff --git a/src/NMTTools_NEW/NMTTools_CommonBlockPool.hxx b/src/NMTTools_NEW/NMTTools_CommonBlockPool.hxx new file mode 100644 index 000000000..f50c4471d --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CommonBlockPool.hxx @@ -0,0 +1,122 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_CommonBlockPool.hxx +// Created: +// Author: Peter KURNEV +// +// + +#ifndef _NMTTools_CommonBlockPool_HeaderFile +#define _NMTTools_CommonBlockPool_HeaderFile + +#include +#include +#include +#include +#include +#include + +class Standard_OutOfRange; +class Standard_OutOfMemory; + + + +//======================================================================= +//class : NMTTools_CommonBlockPool +//purpose : +//======================================================================= +class NMTTools_CommonBlockPool +{ + public: + Standard_EXPORT + NMTTools_CommonBlockPool(const Standard_Integer Length = 0,const Standard_Integer BlockLength = 5); + + Standard_EXPORT + void Resize(const Standard_Integer theNewLength) ; + + Standard_EXPORT + void Destroy() ; + + ~NMTTools_CommonBlockPool() { + Destroy(); + } + + Standard_EXPORT + Standard_Integer Length() const; + + Standard_EXPORT + Standard_Integer Extent() const; + + Standard_EXPORT + Standard_Integer FactLength() const; + + Standard_EXPORT + Standard_Integer Append(const NMTTools_ListOfCommonBlock& Value) ; + + Standard_EXPORT + void Remove(const Standard_Integer Index) ; + + Standard_EXPORT + const NMTTools_ListOfCommonBlock& Value(const Standard_Integer Index) const; + + const NMTTools_ListOfCommonBlock& operator ()(const Standard_Integer Index) const { + return Value(Index); + } + + Standard_EXPORT + NMTTools_ListOfCommonBlock& ChangeValue(const Standard_Integer Index) ; + + NMTTools_ListOfCommonBlock& operator ()(const Standard_Integer Index) { + return ChangeValue(Index); + } + + Standard_EXPORT + void SetBlockLength(const Standard_Integer aBL) ; + + Standard_EXPORT + Standard_Integer BlockLength() const; + + Standard_EXPORT + void Purge() ; + +protected: + +private: + Standard_EXPORT + NMTTools_CommonBlockPool(const NMTTools_CommonBlockPool& AnArray); + + Standard_EXPORT + NMTTools_CommonBlockPool& Assign(const NMTTools_CommonBlockPool& Other) ; + + NMTTools_CommonBlockPool& operator =(const NMTTools_CommonBlockPool& Other) { + return Assign(Other); + } + + Standard_EXPORT + Standard_Boolean IsInvalidIndex(const Standard_Integer Index) const; + + + Standard_Address myStart; + Standard_Integer myLength; + Standard_Integer myFactLength; + Standard_Integer myBlockLength; + Standard_Boolean myIsAllocated; +}; +#endif diff --git a/src/NMTTools_NEW/NMTTools_CoupleOfShape.cxx b/src/NMTTools_NEW/NMTTools_CoupleOfShape.cxx new file mode 100644 index 000000000..958b953e1 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CoupleOfShape.cxx @@ -0,0 +1,67 @@ +// 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: NMTTools_CoupleOfShape.cxx +// Created: Wed Jan 28 15:06:11 2004 +// Author: Peter KURNEV +// +// +#include + +//======================================================================= +// function: NMTTools_CoupleOfShape::NMTTools_CoupleOfShape +// purpose: +//======================================================================= + NMTTools_CoupleOfShape::NMTTools_CoupleOfShape() +{} +//======================================================================= +// function: SetShape1 +// purpose: +//======================================================================= + void NMTTools_CoupleOfShape::SetShape1(const TopoDS_Shape& aS) +{ + myShape1=aS; +} +//======================================================================= +// function: SetShape2 +// purpose: +//======================================================================= + void NMTTools_CoupleOfShape::SetShape2(const TopoDS_Shape& aS) +{ + myShape2=aS; +} +//======================================================================= +// function: Shape1 +// purpose: +//======================================================================= + const TopoDS_Shape& NMTTools_CoupleOfShape::Shape1()const +{ + return myShape1; +} +//======================================================================= +// function: Shape2 +// purpose: +//======================================================================= + const TopoDS_Shape& NMTTools_CoupleOfShape::Shape2()const +{ + return myShape2; +} diff --git a/src/NMTTools_NEW/NMTTools_CoupleOfShape.hxx b/src/NMTTools_NEW/NMTTools_CoupleOfShape.hxx new file mode 100644 index 000000000..6129512b4 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_CoupleOfShape.hxx @@ -0,0 +1,61 @@ +// 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: NMTTools_CoupleOfShape.hxx +// Created: Wed Jan 28 15:06:11 2004 +// Author: Peter KURNEV +// +// +#ifndef _NMTTools_CoupleOfShape_HeaderFile +#define _NMTTools_CoupleOfShape_HeaderFile + +#include +#include +#include + +//======================================================================= +//class : NMTTools_CoupleOfShape +//purpose : +//======================================================================= +class NMTTools_CoupleOfShape +{ + public: + Standard_EXPORT + NMTTools_CoupleOfShape(); + + Standard_EXPORT + void SetShape1(const TopoDS_Shape& aS) ; + + Standard_EXPORT + void SetShape2(const TopoDS_Shape& aS) ; + + Standard_EXPORT + const TopoDS_Shape& Shape1() const; + + Standard_EXPORT + const TopoDS_Shape& Shape2() const; + + protected: + TopoDS_Shape myShape1; + TopoDS_Shape myShape2; +}; +#endif diff --git a/src/NMTTools_NEW/NMTTools_DEProcessor.cxx b/src/NMTTools_NEW/NMTTools_DEProcessor.cxx new file mode 100644 index 000000000..2b701f0c2 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_DEProcessor.cxx @@ -0,0 +1,568 @@ +// 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: NMTTools_DEProcessor.cxx +// Created: Wed Sep 12 12:10:52 2001 +// 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +//======================================================================= +// function: +// purpose: +//======================================================================= + NMTTools_DEProcessor::NMTTools_DEProcessor(NMTTools_PaveFiller& aPaveFiller) +: + myIsDone(Standard_False) +{ + myFiller=(NMTTools_PaveFiller*) &aPaveFiller; + myDS=myFiller->DS(); +} +//======================================================================= +// function: IsDone +// purpose: +//======================================================================= + Standard_Boolean NMTTools_DEProcessor::IsDone() const +{ + return myIsDone; +} +//======================================================================= +// function: Do +// purpose: +//======================================================================= + void NMTTools_DEProcessor::Do() +{ + Standard_Integer aNbE; + // + myIsDone=Standard_False; + // + FindDegeneratedEdges(); + // + aNbE=myDEMap.Extent(); + if (!aNbE) { + myIsDone=!myIsDone; + return; + } + // + DoPaves(); +} +//======================================================================= +// function: FindDegeneratedEdges +// purpose: +//======================================================================= + void NMTTools_DEProcessor::FindDegeneratedEdges() +{ + Standard_Integer i, aNb, nV, nF, nVx, ip, iRankE; + TopoDS_Vertex aV; + TopTools_IndexedDataMapOfShapeListOfShape aMEF; + // + aNb=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape aF=myDS->Shape(i); + if (aF.ShapeType()==TopAbs_FACE) { + TopExp::MapShapesAndAncestors (aF, TopAbs_EDGE, TopAbs_FACE, aMEF); + } + } + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape aS=myDS->Shape(i); + if (aS.ShapeType()==TopAbs_EDGE) { + const TopoDS_Edge& aE=TopoDS::Edge(aS); + + if (BRep_Tool::Degenerated(aE)) { + iRankE=myDS->Rank(i); + aV=TopExp::FirstVertex(aE); + nVx=myDS->ShapeIndex(aV, iRankE); + // + nV=nVx; + ip=myFiller->FindSDVertex(nV); + if (ip) { + nV=ip; + } + // + TColStd_ListOfInteger aLFn; + const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE); + TopTools_ListIteratorOfListOfShape anIt(aLF); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Shape& aF=anIt.Value(); + nF=myDS->ShapeIndex(aF, iRankE); + aLFn.Append(nF); + } + BOPTools_DEInfo aDEInfo; + aDEInfo.SetVertex(nV); + aDEInfo.SetFaces(aLFn); + + myDEMap.Add (i, aDEInfo); + } + } + } +} +//======================================================================= +// function: DoPaves +// purpose: +//======================================================================= + void NMTTools_DEProcessor::DoPaves() +{ + + Standard_Integer i, aNbE, nED, nVD, aNbLPB, nFD; + // + nFD=0; + aNbE=myDEMap.Extent(); + for (i=1; i<=aNbE; ++i) { + nED=myDEMap.FindKey(i); + // + const BOPTools_DEInfo& aDEInfo=myDEMap(i); + nVD=aDEInfo.Vertex(); + // + // Fill PaveSet for the edge nED + const TColStd_ListOfInteger& nLF=aDEInfo.Faces(); + TColStd_ListIteratorOfListOfInteger anIt(nLF); + for (; anIt.More(); anIt.Next()) { + nFD=anIt.Value(); + + BOPTools_ListOfPaveBlock aLPB; + FindPaveBlocks(nED, nVD, nFD, aLPB); + // + aNbLPB=aLPB.Extent(); + if (!aNbLPB) { + continue; + } + // + FillPaveSet (nED, nVD, nFD, aLPB); + } + // + // Fill aSplitEdges for the edge nED + FillSplitEdgesPool(nED); + // + // MakeSplitEdges + MakeSplitEdges(nED, nFD); + // + }// next nED +} +//======================================================================= +// function: FindPaveBlocks +// purpose: +//======================================================================= + void NMTTools_DEProcessor::FindPaveBlocks(const Standard_Integer , + const Standard_Integer nVD, + const Standard_Integer nFD, + BOPTools_ListOfPaveBlock& aLPBOut) +{ + BOPTools_ListIteratorOfListOfPaveBlock anIt; + Standard_Integer i, aNb, nF2, nV; + // + BOPTools_CArray1OfSSInterference& aFFs=(myFiller->IP())->SSInterferences(); + // + aNb=aFFs.Extent(); + for (i=1; i<=aNb; ++i) { + BOPTools_SSInterference& aFF=aFFs(i); + // + nF2=aFF.OppositeIndex(nFD); + if (!nF2) { + continue; + } + // + // Split Parts + const BOPTools_ListOfPaveBlock& aLPBSplits=aFF.PaveBlocks(); + anIt.Initialize(aLPBSplits); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBSp=anIt.Value(); + // + const BOPTools_Pave& aPave1=aPBSp.Pave1(); + nV=aPave1.Index(); + if (nV==nVD) { + aLPBOut.Append(aPBSp); + continue; + } + // + const BOPTools_Pave& aPave2=aPBSp.Pave2(); + nV=aPave2.Index(); + if (nV==nVD) { + aLPBOut.Append(aPBSp); + continue; + } + } + // + // Section Parts + Standard_Integer j, aNbCurves; + // + BOPTools_SequenceOfCurves& aSC=aFF.Curves(); + aNbCurves=aSC.Length(); + for (j=1; j<=aNbCurves; ++j) { + const BOPTools_Curve& aBC=aSC(j); + const BOPTools_ListOfPaveBlock& aLPBSe=aBC.NewPaveBlocks(); + // + anIt.Initialize(aLPBSe); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBSe=anIt.Value(); + // + const BOPTools_Pave& aPv1=aPBSe.Pave1(); + nV=aPv1.Index(); + if (nV==nVD) { + aLPBOut.Append(aPBSe); + continue; + } + // + const BOPTools_Pave& aPv2=aPBSe.Pave2(); + nV=aPv2.Index(); + if (nV==nVD) { + aLPBOut.Append(aPBSe); + continue; + } + } + } + } +} +//======================================================================= +// function: FillPaveSet +// purpose: +//======================================================================= + void NMTTools_DEProcessor::FillPaveSet (const Standard_Integer nED, + const Standard_Integer nVD, + const Standard_Integer nFD, + const BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Boolean bIsDone, bXDir, bRejectFlag; + Standard_Integer nE, aNbPoints, j; + Standard_Real aTD1, aTD2, aT1, aT2, aTolInter, aX, aDT, aXx; + gp_Pnt2d aP2d1, aP2d2, aP2D; + gp_Lin2d aLDE; + // + aDT=Precision::PConfusion(); + // + BOPTools_PaveSet& aPaveSet= + (myFiller->ChangePavePool()).ChangeValue(myDS->RefEdge(nED)); + // + // Clear aPaveSet, aSplitEdges + aPaveSet.ChangeSet().Clear(); + // + const TopoDS_Edge aDE=TopoDS::Edge(myDS->Shape(nED)); + const TopoDS_Face aDF=TopoDS::Face(myDS->Shape(nFD)); + // + // 2D Curve of degenerated edge on the face aDF + Handle(Geom2d_Curve) aC2DDE1=BRep_Tool::CurveOnSurface(aDE, aDF, aTD1, aTD2); + Handle(Geom2d_TrimmedCurve)aC2DDE=new Geom2d_TrimmedCurve(aC2DDE1, aTD1, aTD2); + // + // Choose direction for degenerated edge + aC2DDE->D0(aTD1, aP2d1); + aC2DDE->D0(aTD2, aP2d2); + + bXDir=Standard_False; + if (fabs(aP2d1.Y()-aP2d2.Y()) < aDT){ + bXDir=!bXDir; + } + // + // Prepare bounding Paves + BOPTools_Pave aPave1 (nVD, aTD1, BooleanOperations_UnknownInterference); + aPaveSet.Append(aPave1); + BOPTools_Pave aPave2 (nVD, aTD2, BooleanOperations_UnknownInterference); + aPaveSet.Append(aPave2); + // + // Fill other paves + BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + nE=aPB.Edge(); + const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE)); + + Handle(Geom2d_Curve) aC2D=BRep_Tool::CurveOnSurface(aE, aDF, aT1, aT2); + // + // Intersection + Geom2dAdaptor_Curve aGAC1, aGAC2; + // + aGAC1.Load(aC2DDE, aTD1, aTD2); + Handle(Geom2d_Line) aL2D= Handle(Geom2d_Line)::DownCast(aC2D); + if (!aL2D.IsNull()) { + aGAC2.Load(aC2D); + } + else { + aGAC2.Load(aC2D, aT1, aT2); + } + // + aTolInter=0.001; + Geom2dInt_GInter aGInter(aGAC1, aGAC2, aTolInter, aTolInter); + bIsDone=aGInter.IsDone(); + if(bIsDone) { + aNbPoints=aGInter.NbPoints(); + if (aNbPoints) { + for (j=1; j<=aNbPoints; ++j) { + aP2D=aGInter.Point(j).Value(); + Handle(Geom2d_Line) aCLDE; + // + //modified by NIZNHY-PKV Thu Mar 20 17:37:32 2008f + Handle(Geom2d_TrimmedCurve) aCLDET1= + Handle(Geom2d_TrimmedCurve)::DownCast(aC2DDE1); + if (aCLDET1.IsNull()) { + aCLDE=Handle(Geom2d_Line)::DownCast(aC2DDE1); + } + else { + Handle(Geom2d_Curve) aBasisCurve=aCLDET1->BasisCurve(); + aCLDE=Handle(Geom2d_Line)::DownCast(aBasisCurve); + } + //aCLDE=Handle(Geom2d_Line)::DownCast(aC2DDE1); + //modified by NIZNHY-PKV Thu Mar 20 17:37:37 2008t + + if (aCLDE.IsNull()) { + continue; + } + + aLDE=aCLDE->Lin2d(); + aX=ElCLib::Parameter(aLDE, aP2D); + // + if (fabs (aX-aTD1) < aDT || fabs (aX-aTD2) < aDT) { + continue; + } + if (aX < aTD1 || aX > aTD2) { + continue; + } + // + bRejectFlag=Standard_False; + const BOPTools_ListOfPave& aListOfPave=aPaveSet.Set(); + BOPTools_ListIteratorOfListOfPave aPaveIt(aListOfPave); + for (; aPaveIt.More(); aPaveIt.Next()) { + const BOPTools_Pave& aPavex=aPaveIt.Value(); + aXx=aPavex.Param(); + if (fabs (aX-aXx) < aDT) { + bRejectFlag=Standard_True; + break; + } + } + if (bRejectFlag) { + continue; + } + // + BOPTools_Pave aPave(nVD, aX, BooleanOperations_UnknownInterference); + aPaveSet.Append(aPave); + } + } + } + } +} +//======================================================================= +// function: FillSplitEdgesPool +// purpose: +//======================================================================= + void NMTTools_DEProcessor::FillSplitEdgesPool (const Standard_Integer nED) +{ + BOPTools_SplitShapesPool& aSplitShapesPool= + myFiller->ChangeSplitShapesPool(); + BOPTools_ListOfPaveBlock& aSplitEdges= + aSplitShapesPool.ChangeValue(myDS->RefEdge(nED)); + // + aSplitEdges.Clear(); + // + const BOPTools_PavePool& aPavePool=myFiller->PavePool(); + BOPTools_PavePool* pPavePool=(BOPTools_PavePool*) &aPavePool; + BOPTools_PaveSet& aPaveSet= pPavePool->ChangeValue(myDS->RefEdge(nED)); + + BOPTools_PaveBlockIterator aPBIt(nED, aPaveSet); + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + aSplitEdges.Append(aPB); + } +} +//======================================================================= +// function: MakeSplitEdges +// purpose: +//======================================================================= + void NMTTools_DEProcessor::MakeSplitEdges (const Standard_Integer nED, + const Standard_Integer nFD) +{ + const BOPTools_SplitShapesPool& aSplitShapesPool=myFiller->SplitShapesPool(); + const BOPTools_ListOfPaveBlock& aSplitEdges=aSplitShapesPool(myDS->RefEdge(nED)); + + Standard_Integer nV1, nV2, aNbPB, aNewShapeIndex; + Standard_Real t1, t2; + TopoDS_Edge aE, aESplit; + TopoDS_Vertex aV1, aV2; + BOPTools_ListIteratorOfListOfPaveBlock aPBIt; + // + const TopoDS_Edge aDE=TopoDS::Edge(myDS->Shape(nED)); + const TopoDS_Face aDF=TopoDS::Face(myDS->Shape(nFD)); + // + //modified by NIZNHY-PKV Wed Oct 20 13:20:37 2010f + aNbPB=aSplitEdges.Extent(); + if (aNbPB==1) { + Standard_Real aT1, aT2, dT1, dT2, aDT; + Handle(Geom2d_Curve) aC2D; + // + BOPTools_PaveBlock& aPB=aSplitEdges.First(); + // + const BOPTools_Pave& aPave1=aPB.Pave1(); + t1=aPave1.Param(); + const BOPTools_Pave& aPave2=aPB.Pave2(); + t2=aPave2.Param(); + //// + nV1=aPave1.Index(); + aV1=*((TopoDS_Vertex*)&myDS->GetShape(nV1)); + // + aV2=TopExp::FirstVertex(aDE); + if (aV2.IsSame(aV1)) { + aC2D=BRep_Tool::CurveOnSurface(aDE, aDF, aT1, aT2); + dT1=aT1-t1; + if (dT1<0.) { + dT1=-dT1; + } + // + dT2=aT2-t2; + if (dT2<0.) { + dT2=-dT2; + } + aDT=Precision::PConfusion(); + if(dT1Clear(); + return; + } + } + } + //modified by NIZNHY-PKV Wed Oct 20 13:20:39 2010t + // + aPBIt.Initialize(aSplitEdges); + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + t1=aPave1.Param(); + aV1=TopoDS::Vertex(myDS->GetShape(nV1)); + aV1.Orientation(TopAbs_FORWARD); + + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + t2=aPave2.Param(); + aV2=TopoDS::Vertex(myDS->GetShape(nV2)); + aV2.Orientation(TopAbs_REVERSED); + + MakeSplitEdge(aDE, aDF, aV1, t1, aV2, t2, aESplit); + // + // Add Split Part of the Original Edge to the DS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); + + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + + myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq); + aNewShapeIndex=myDS->NumberOfInsertedShapes(); + myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN); + // + // Fill Split Set for the Original Edge + aPB.SetEdge(aNewShapeIndex); + // + } +} +//======================================================================= +// function: MakeSplitEdge +// purpose: +//======================================================================= + void NMTTools_DEProcessor::MakeSplitEdge (const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const TopoDS_Vertex& aV1, + const Standard_Real aP1, + const TopoDS_Vertex& aV2, + const Standard_Real aP2, + TopoDS_Edge& aNewEdge) +{ + Standard_Real aTol=1.e-7; + + TopoDS_Edge E=aE; + + E.EmptyCopy(); + BRep_Builder BB; + BB.Add (E, aV1); + BB.Add (E, aV2); + + BB.Range(E, aF, aP1, aP2); + + BB.Degenerated(E, Standard_True); + + BB.UpdateEdge(E, aTol); + aNewEdge=E; +} + diff --git a/src/NMTTools_NEW/NMTTools_DEProcessor.hxx b/src/NMTTools_NEW/NMTTools_DEProcessor.hxx new file mode 100644 index 000000000..147792f59 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_DEProcessor.hxx @@ -0,0 +1,117 @@ +// 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: NMTTools_DEProcessor.hxx +// Created: Wed Sep 12 12:10:52 2001 +// Author: Peter KURNEV +// + +#ifndef _NMTTools_DEProcessor_HeaderFile +#define _NMTTools_DEProcessor_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//!
+//! The Algorithm to compute and store in interferences' pool
+//! and in the Data Structure the following values
+//! for degenerated edges
+//! 1. Paves/Pave set(s)
+//! 2. Split parts
+//! 3. States (3D) for split parts
+//!
+//======================================================================= +//class : NMTTools_DEProcessor +//purpose : +//======================================================================= +class NMTTools_DEProcessor { +public: + + + +//! Constructor
+//!
+//! Constructor
+//!
+ Standard_EXPORT + NMTTools_DEProcessor(NMTTools_PaveFiller& aFiller); + +//! Launches the processor
+ Standard_EXPORT + void Do() ; + +//! Returns TRUE if it is Ok
+ Standard_EXPORT + Standard_Boolean IsDone() const; + + + +protected: + Standard_EXPORT + void FindDegeneratedEdges() ; + + Standard_EXPORT + void DoPaves() ; + + Standard_EXPORT + void FindPaveBlocks(const Standard_Integer nED, + const Standard_Integer nVD, + const Standard_Integer nFD, + BOPTools_ListOfPaveBlock& aLPB) ; + + Standard_EXPORT + void FillPaveSet(const Standard_Integer nED, + const Standard_Integer nVD, + const Standard_Integer nFD, + const BOPTools_ListOfPaveBlock& aLPB) ; + + Standard_EXPORT + void FillSplitEdgesPool(const Standard_Integer nED) ; + + Standard_EXPORT + void MakeSplitEdges(const Standard_Integer nED, + const Standard_Integer nFD) ; + + Standard_EXPORT + void MakeSplitEdge(const TopoDS_Edge& aS1, + const TopoDS_Face& aF, + const TopoDS_Vertex& aV1, + const Standard_Real aP1, + const TopoDS_Vertex& aV2, + const Standard_Real aP2, + TopoDS_Edge& aNewEdge) ; + + + NMTTools_PPaveFiller myFiller; + NMTDS_PShapesDataStructure myDS; + Standard_Boolean myIsDone; + BOPTools_IndexedDataMapOfIntegerDEInfo myDEMap; +}; +#endif diff --git a/src/NMTTools_NEW/NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx b/src/NMTTools_NEW/NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx new file mode 100644 index 000000000..8e071554d --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx +// Created: Mon Feb 20 12:24:47 2012 +// Author: +// + + +#ifndef NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo_HeaderFile +#define NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo_HeaderFile + +#ifndef NMTTools_DataMapOfIntegerFaceInfo_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTTools_NEW/NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx b/src/NMTTools_NEW/NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx new file mode 100644 index 000000000..82fa67266 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx @@ -0,0 +1,14 @@ +// File: NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx +// Created: Mon Feb 20 12:04:52 2012 +// Author: +// + + +#ifndef NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock_HeaderFile +#define NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock_HeaderFile + +#ifndef NMTTools_DataMapOfIntegerListOfPaveBlock_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTTools_NEW/NMTTools_DataMapOfIntegerFaceInfo.hxx b/src/NMTTools_NEW/NMTTools_DataMapOfIntegerFaceInfo.hxx new file mode 100644 index 000000000..99efe576c --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_DataMapOfIntegerFaceInfo.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_DataMapOfIntegerFaceInfo.hxx +// Created: Mon Feb 20 12:21:55 2012 +// Author: +// + + +#ifndef NMTTools_DataMapOfIntegerFaceInfo_HeaderFile +#define NMTTools_DataMapOfIntegerFaceInfo_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_DataMap NMTTools_DataMapOfIntegerFaceInfo; +typedef NMTTools_DataMapOfIntegerFaceInfo::Iterator NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/NMTTools_NEW/NMTTools_DataMapOfIntegerListOfPaveBlock.hxx b/src/NMTTools_NEW/NMTTools_DataMapOfIntegerListOfPaveBlock.hxx new file mode 100644 index 000000000..7a3e80549 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_DataMapOfIntegerListOfPaveBlock.hxx @@ -0,0 +1,41 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_DataMapOfIntegerListOfPaveBlock.hxx +// Created: Mon Feb 20 09:27:40 2012 +// Author: +// + + +#ifndef NMTTools_DataMapOfIntegerListOfPaveBlock_HeaderFile +#define NMTTools_DataMapOfIntegerListOfPaveBlock_HeaderFile + + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_DataMap NMTTools_DataMapOfIntegerListOfPaveBlock; +typedef NMTTools_DataMapOfIntegerListOfPaveBlock::Iterator NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/NMTTools_NEW/NMTTools_FaceInfo.cxx b/src/NMTTools_NEW/NMTTools_FaceInfo.cxx new file mode 100644 index 000000000..6cd717aa1 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_FaceInfo.cxx @@ -0,0 +1,28 @@ +// 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: NMTTools_FaceInfo.cxx +// Created: Tue Dec 9 12:23:29 2003 +// Author: Peter KURNEV +// +// +#include diff --git a/src/NMTTools_NEW/NMTTools_FaceInfo.hxx b/src/NMTTools_NEW/NMTTools_FaceInfo.hxx new file mode 100644 index 000000000..3d6218ae2 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_FaceInfo.hxx @@ -0,0 +1,124 @@ +// 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: NMTTools_FaceInfo.hxx +// Created: Tue Dec 9 12:23:29 2003 +// Author: Peter KURNEV +// +// +#ifndef _NMTTools_FaceInfo_HeaderFile +#define _NMTTools_FaceInfo_HeaderFile + +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//class : NMTTools_FaceInfo +//purpose : +//======================================================================= +class NMTTools_FaceInfo { + public: + + //! Empty contructor
+ //!
+ NMTTools_FaceInfo(); + + virtual ~NMTTools_FaceInfo(); + + //! Clears the contents
+ Standard_EXPORT void Clear() ; + + //! Modifier
+ //! Sets the index of the face
+ void SetIndex(const Standard_Integer theI) ; + + //! Selector
+ //! Returns the index of the face
+ //!
+ //! In
+ //!
+ Standard_Integer Index() const; + + //! Selector
+ //! Returns the pave blocks of the face
+ //! that have state In
+ const NMTTools_MapOfPaveBlock& PaveBlocksIn() const; + +//! Selector/Modifier
+ //! Returns the pave blocks
+ //! of the face
+ //! that have state In
+ NMTTools_MapOfPaveBlock& ChangePaveBlocksIn() ; + + //! Selector
+ //! Returns the list of indices for vertices
+ //! of the face
+ //! that have state In
+ const TColStd_MapOfInteger& VerticesIn() const; + + //! Selector/Modifier
+ //! Returns the list of indices for vertices
+ //! of the face
+ //! that have state In
+ //!
+ //! On
+ //!
+ TColStd_MapOfInteger& ChangeVerticesIn() ; + + //! Selector
+ //! Returns the pave blocks of the face
+ //! that have state On
+ const NMTTools_MapOfPaveBlock& PaveBlocksOn() const; + + //! Selector/Modifier
+ //! Returns the pave blocks
+ //! of the face
+ //! that have state On
+ NMTTools_MapOfPaveBlock& ChangePaveBlocksOn() ; + + //! Selector
+ //! Returns the list of indices for vertices
+ //! of the face
+ //! that have state On
+ const TColStd_MapOfInteger& VerticesOn() const; + + //! Selector/Modifier
+ //! Returns the list of indices for vertices
+ //! of the face
+ //! that have state On
+ TColStd_MapOfInteger& ChangeVerticesOn() ; + + protected: + Standard_Integer myIndex; + NMTTools_MapOfPaveBlock myPaveBlocksIn; + TColStd_MapOfInteger myVerticesIn; + NMTTools_MapOfPaveBlock myPaveBlocksOn; + TColStd_MapOfInteger myVerticesOn; +}; + +#include +#endif diff --git a/src/NMTTools_NEW/NMTTools_FaceInfo.lxx b/src/NMTTools_NEW/NMTTools_FaceInfo.lxx new file mode 100644 index 000000000..b92bca7b1 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_FaceInfo.lxx @@ -0,0 +1,136 @@ +// 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: NMTTools_FaceInfo.lxx +// Created: Tue Dec 9 12:23:29 2003 +// Author: Peter KURNEV +// +// + +//======================================================================= +//function : +//purpose : +//======================================================================= +inline NMTTools_FaceInfo::NMTTools_FaceInfo() +: + myIndex(-1) +{ +} +//======================================================================= +//function : ~ +//purpose : +//======================================================================= +inline NMTTools_FaceInfo::~NMTTools_FaceInfo() +{ + Clear(); +} +//======================================================================= +//function : Clear +//purpose : +//======================================================================= +inline void NMTTools_FaceInfo::Clear() +{ + myIndex=-1; + myPaveBlocksIn.Clear(); + myVerticesIn.Clear(); + myPaveBlocksOn.Clear(); + myVerticesOn.Clear(); +} +//======================================================================= +//function : SetIndex +//purpose : +//======================================================================= + inline void NMTTools_FaceInfo::SetIndex(const Standard_Integer theI) +{ + myIndex=theI; +} +//======================================================================= +//function : Index +//purpose : +//======================================================================= + inline Standard_Integer NMTTools_FaceInfo::Index()const +{ + return myIndex; +} +//======================================================================= +//function : PaveBlockIn +//purpose : +//======================================================================= + inline const NMTTools_MapOfPaveBlock& NMTTools_FaceInfo::PaveBlocksIn()const +{ + return myPaveBlocksIn; +} +//======================================================================= +//function : ChangePaveBlocksIn +//purpose : +//======================================================================= + inline NMTTools_MapOfPaveBlock& NMTTools_FaceInfo::ChangePaveBlocksIn() +{ + return myPaveBlocksIn; +} +//======================================================================= +//function : VerticesIn +//purpose : +//======================================================================= + inline const TColStd_MapOfInteger& NMTTools_FaceInfo::VerticesIn()const +{ + return myVerticesIn; +} +//======================================================================= +//function : ChangeVerticesIn +//purpose : +//======================================================================= + inline TColStd_MapOfInteger& NMTTools_FaceInfo::ChangeVerticesIn() +{ + return myVerticesIn; +} +//======================================================================= +//function : PaveBlockOn +//purpose : +//======================================================================= + inline const NMTTools_MapOfPaveBlock& NMTTools_FaceInfo::PaveBlocksOn()const +{ + return myPaveBlocksOn; +} +//======================================================================= +//function : ChangePaveBlocksOn +//purpose : +//======================================================================= + inline NMTTools_MapOfPaveBlock& NMTTools_FaceInfo::ChangePaveBlocksOn() +{ + return myPaveBlocksOn; +} +//======================================================================= +//function : VerticesOn +//purpose : +//======================================================================= + inline const TColStd_MapOfInteger& NMTTools_FaceInfo::VerticesOn()const +{ + return myVerticesOn; +} +//======================================================================= +//function : ChangeVerticesOn +//purpose : +//======================================================================= + inline TColStd_MapOfInteger& NMTTools_FaceInfo::ChangeVerticesOn() +{ + return myVerticesOn; +} diff --git a/src/NMTTools_NEW/NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx b/src/NMTTools_NEW/NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx new file mode 100644 index 000000000..7d3822488 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx +// Created: Mon Feb 20 09:20:07 2012 +// Author: +// + + +#ifndef NMTTools_IndexedDataMapOfIndexedMapOfInteger_HeaderFile +#define NMTTools_IndexedDataMapOfIndexedMapOfInteger_HeaderFile + + +#include +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_IndexedDataMap NMTTools_IndexedDataMapOfIndexedMapOfInteger; + +#undef _NCollection_MapHasher + + + +#endif diff --git a/src/NMTTools_NEW/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx b/src/NMTTools_NEW/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx new file mode 100644 index 000000000..ef50fa54d --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx +// Created: Mon Feb 20 09:20:07 2012 +// Author: +// +// File: NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx +// Created: Mon Feb 20 11:59:23 2012 +// Author: +// + + +#ifndef NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_HeaderFile +#define NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_HeaderFile + + +#include +#include +#include + +#define _NCollection_MapHasher +#include + + +typedef NCollection_IndexedDataMap NMTTools_IndexedDataMapOfShapeIndexedMapOfShape; + +#undef _NCollection_MapHasher + + +#endif + diff --git a/src/NMTTools_NEW/NMTTools_IndexedDataMapOfShapePaveBlock.hxx b/src/NMTTools_NEW/NMTTools_IndexedDataMapOfShapePaveBlock.hxx new file mode 100644 index 000000000..1e96e62bd --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_IndexedDataMapOfShapePaveBlock.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_IndexedDataMapOfShapePaveBlock.hxx +// Created: Mon Feb 20 11:55:34 2012 +// Author: +// + + +#ifndef NMTTools_IndexedDataMapOfShapePaveBlock_HeaderFile +#define NMTTools_IndexedDataMapOfShapePaveBlock_HeaderFile + +#include +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_IndexedDataMap NMTTools_IndexedDataMapOfShapePaveBlock; + +#undef _NCollection_MapHasher + + +#endif diff --git a/src/NMTTools_NEW/NMTTools_ListIteratorOfListOfCommonBlock.hxx b/src/NMTTools_NEW/NMTTools_ListIteratorOfListOfCommonBlock.hxx new file mode 100644 index 000000000..de43fb7e3 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_ListIteratorOfListOfCommonBlock.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListIteratorOfListOfCommonBlock.hxx +// Created: Mon Feb 20 11:25:23 2012 +// Author: +// + +#ifndef NMTDS_ListIteratorOfListOfCommonBlock_HeaderFile +#define NMTDS_ListIteratorOfListOfCommonBlock_HeaderFile + +#ifndef NMTTools_ListOfCommonBlock_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTTools_NEW/NMTTools_ListIteratorOfListOfCoupleOfShape.hxx b/src/NMTTools_NEW/NMTTools_ListIteratorOfListOfCoupleOfShape.hxx new file mode 100644 index 000000000..61dc585b7 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_ListIteratorOfListOfCoupleOfShape.hxx @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTDS_ListIteratorOfListOfCoupleOfShape.hxx +// Created: Mon Feb 20 11:25:23 2012 +// Author: +// + +#ifndef NMTDS_ListIteratorOfListOfCoupleOfShape_HeaderFile +#define NMTDS_ListIteratorOfListOfCoupleOfShape_HeaderFile + +#ifndef NMTTools_ListOfCoupleOfShape_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTTools_NEW/NMTTools_ListOfCommonBlock.hxx b/src/NMTTools_NEW/NMTTools_ListOfCommonBlock.hxx new file mode 100644 index 000000000..02654de6b --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_ListOfCommonBlock.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_ListOfCommonBlock.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + +#ifndef NMTTools_ListOfCommonBlock_HeaderFile +#define NMTTools_ListOfCommonBlock_HeaderFile + +#include +#include + +typedef NCollection_List NMTTools_ListOfCommonBlock; +typedef NMTTools_ListOfCommonBlock::Iterator NMTTools_ListIteratorOfListOfCommonBlock; + +#endif diff --git a/src/NMTTools_NEW/NMTTools_ListOfCoupleOfShape.hxx b/src/NMTTools_NEW/NMTTools_ListOfCoupleOfShape.hxx new file mode 100644 index 000000000..f3e6ae3fb --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_ListOfCoupleOfShape.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_ListOfCoupleOfShape.hxx +// Created: Mon Feb 20 07:27:34 2012 +// Author: +// + +#ifndef NMTTools_ListOfCoupleOfShape_HeaderFile +#define NMTTools_ListOfCoupleOfShape_HeaderFile + +#include +#include + +typedef NCollection_List NMTTools_ListOfCoupleOfShape; +typedef NMTTools_ListOfCoupleOfShape::Iterator NMTTools_ListIteratorOfListOfCoupleOfShape; + +#endif diff --git a/src/NMTTools_NEW/NMTTools_MapIteratorOfMapOfPaveBlock.hxx b/src/NMTTools_NEW/NMTTools_MapIteratorOfMapOfPaveBlock.hxx new file mode 100644 index 000000000..6d62fd75a --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_MapIteratorOfMapOfPaveBlock.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_MapIteratorOfMapOfPaveBlock.hxx +// Created: Mon Feb 20 11:47:30 2012 +// Author: +// + + +#ifndef NMTTools_MapIteratorOfMapOfPaveBlock_HeaderFile +#define NMTTools_MapIteratorOfMapOfPaveBlock_HeaderFile + +#ifndef NMTTools_MapOfPaveBlock_HeaderFile +#include +#endif + +#endif diff --git a/src/NMTTools_NEW/NMTTools_MapOfPaveBlock.hxx b/src/NMTTools_NEW/NMTTools_MapOfPaveBlock.hxx new file mode 100644 index 000000000..7f97d9942 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_MapOfPaveBlock.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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: NMTTools_MapOfPaveBlock.hxx +// Created: Mon Feb 20 08:19:07 2012 +// Author: +// + + +#ifndef NMTTools_MapOfPaveBlock_HeaderFile +#define NMTTools_MapOfPaveBlock_HeaderFile + +#include +#include + +#define _NCollection_MapHasher +#include + +typedef NCollection_Map NMTTools_MapOfPaveBlock; +typedef NMTTools_MapOfPaveBlock::Iterator NMTTools_MapIteratorOfMapOfPaveBlock; + +#undef _NCollection_MapHasher + +#endif diff --git a/src/NMTTools_NEW/NMTTools_PPaveFiller.hxx b/src/NMTTools_NEW/NMTTools_PPaveFiller.hxx new file mode 100644 index 000000000..f1b7cc0b7 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PPaveFiller.hxx @@ -0,0 +1,35 @@ +// 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: NMTTools_PPaveFiller.hxx +// Created: Tue Dec 9 12:23:29 2003 +// Author: Peter KURNEV +// +// +#ifndef _NMTTools_PPaveFiller_HeaderFile +#define _NMTTools_PPaveFiller_HeaderFile + +class NMTTools_PaveFiller; + +typedef NMTTools_PaveFiller* NMTTools_PPaveFiller; + +#endif diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller.cxx new file mode 100644 index 000000000..3a9155b10 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller.cxx @@ -0,0 +1,303 @@ +// 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: NMTTools_PaveFiller.cxx +// Created: Fri Dec 5 14:58:54 2003 +// Author: Peter KURNEV +// +// +#include +// +#include +#include +#include +#include +#include +#include + +//======================================================================= +// function: NMTTools_PaveFiller::NMTTools_PaveFiller +// purpose: +//======================================================================= + NMTTools_PaveFiller::NMTTools_PaveFiller() +{ + myDS=NULL; + myDSIt=NULL; + myIsDone=Standard_False; + myNbSources=0; + myNbEdges=0; + myIP=NULL; +} +//======================================================================= +// function: ~ +// purpose: +//======================================================================= + NMTTools_PaveFiller::~NMTTools_PaveFiller() +{ + Clear(); +} +//======================================================================= +// function: Clear +// purpose: +//======================================================================= + void NMTTools_PaveFiller::Clear() +{ + if (myDSIt) { + delete myDSIt; + } + if (myDS) { + delete myDS; + } + myDSIt=NULL; + myDS=NULL; + + if (myIP) { + delete myIP; + } + myIP=NULL; +} +//======================================================================= +// function: SetCompositeShape +// purpose: +//======================================================================= + void NMTTools_PaveFiller::SetCompositeShape(const TopoDS_Shape& aS) +{ + myCompositeShape=aS; +} +//======================================================================= +// function: CompositeShape +// purpose: +//======================================================================= + const TopoDS_Shape& NMTTools_PaveFiller::CompositeShape()const +{ + return myCompositeShape; +} +//======================================================================= +// function: DS +// purpose: +//======================================================================= + NMTDS_PShapesDataStructure NMTTools_PaveFiller::DS() +{ + return myDS; +} +//======================================================================= +// function: DSIt +// purpose: +//======================================================================= + NMTDS_PIterator NMTTools_PaveFiller::DSIt() +{ + return myDSIt; +} +//======================================================================= +// function: IP +// purpose: +//======================================================================= + NMTDS_PInterfPool NMTTools_PaveFiller::IP() +{ + return myIP; +} +//======================================================================= +// function:IsDone +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PaveFiller::IsDone() const +{ + return myIsDone; +} +//======================================================================= +// function: Context +// purpose: +//======================================================================= + const Handle(IntTools_Context)& NMTTools_PaveFiller::Context() const +{ + return myContext; +} +//======================================================================= +// function: PavePool +// purpose: +//======================================================================= + const BOPTools_PavePool& NMTTools_PaveFiller::PavePool() const +{ + return myPavePool; +} +//======================================================================= +// function: ChangePavePool +// purpose: +//======================================================================= + BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePool() +{ + return myPavePool; +} +//======================================================================= +// function: ChangePavePoolNew +// purpose: +//======================================================================= + BOPTools_PavePool& NMTTools_PaveFiller::ChangePavePoolNew() +{ + return myPavePoolNew; +} +//======================================================================= +// function: CommonBlockPool +// purpose: +//======================================================================= + const NMTTools_CommonBlockPool& NMTTools_PaveFiller::CommonBlockPool() const +{ + return myCommonBlockPool; +} +//======================================================================= +// function: ChangeCommonBlockPool +// purpose: +//======================================================================= + NMTTools_CommonBlockPool& NMTTools_PaveFiller::ChangeCommonBlockPool() +{ + return myCommonBlockPool; +} +//======================================================================= +// function: SplitShapesPool +// purpose: +//======================================================================= + const BOPTools_SplitShapesPool& NMTTools_PaveFiller::SplitShapesPool() const +{ + return mySplitShapesPool; +} +//======================================================================= +// function: ChangeSplitShapesPool +// purpose: +//======================================================================= + BOPTools_SplitShapesPool& NMTTools_PaveFiller::ChangeSplitShapesPool() +{ + return mySplitShapesPool; +} +//======================================================================= +// function: Init +// purpose: +//======================================================================= + void NMTTools_PaveFiller::Init() +{ + myIsDone=Standard_False; + if (myCompositeShape.IsNull()) { + return; + } + // + Clear(); + // 1. + myDS=new NMTDS_ShapesDataStructure; + myDS->SetCompositeShape(myCompositeShape); + myDS->Init(); + // + // 2. + myDSIt=new NMTDS_Iterator; + myDSIt->SetDS(myDS); + myDSIt->Prepare(); + // + // 3. + myNbSources=myDS->NumberOfShapesOfTheObject()+ + myDS->NumberOfShapesOfTheTool(); + myNbEdges=myDS->NbEdges(); + // + // 4 + myIP=new NMTDS_InterfPool; + // + // 5 + myContext=new IntTools_Context; +} + +//======================================================================= +// function: Perform +// purpose: +//======================================================================= + void NMTTools_PaveFiller::Perform() +{ + myIsDone=Standard_False; + // + //---------------- + try { + // 0. + Init(); + //1.VV + // + PerformVV(); + // + // 2.VE + myPavePool.Resize (myNbEdges); + + PrepareEdges(); + + PerformVE(); + // + // 3.VF + PerformVF(); + // + // 4.EE + myCommonBlockPool.Resize (myNbEdges); + mySplitShapesPool.Resize (myNbEdges); + myPavePoolNew .Resize (myNbEdges); + + PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); + PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); + // + PerformEE(); + // + RefinePavePool (); + // + myPavePoolNew.Destroy(); + myPavePoolNew.Resize (myNbEdges); + // + //modified by NIZNHY-PKV Mon Dec 12 09:13:53 2011f + UpdateCommonBlocks(0); + //modified by NIZNHY-PKV Mon Dec 12 09:13:56 2011t + // + // 5.EF + PreparePaveBlocks(TopAbs_EDGE, TopAbs_FACE); + PerformEF(); + // + RefinePavePool(); + // + myPavePoolNew.Destroy(); + + MakeSplitEdges(); + + UpdateCommonBlocks(); + // + // 6. FF + PerformFF (); + // + MakeBlocks(); + // + MakePCurves(); + // + // 7.Postprocessing + UpdatePaveBlocks(); + // + NMTTools_DEProcessor aDEP(*this); + aDEP.Do(); + // + MakeAloneVertices(); + // + //modified by NIZNHY-PKV Mon Dec 12 09:14:23 2011f + myIP->Purge(); + //modified by NIZNHY-PKV Mon Dec 12 09:14:27 2011t + myIsDone=Standard_True; + } + catch (BOPTColStd_Failure& ) { + } +} diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller.hxx b/src/NMTTools_NEW/NMTTools_PaveFiller.hxx new file mode 100644 index 000000000..34ce90f9c --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller.hxx @@ -0,0 +1,500 @@ +// 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: NMTTools_PaveFiller.hxx +// Created: Fri Dec 5 14:58:54 2003 +// Author: Peter KURNEV +// +// +#ifndef _NMTTools_PaveFiller_HeaderFile +#define _NMTTools_PaveFiller_HeaderFile + +#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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* +class TopoDS_Shape; +class BOPTools_Pave; +class IntTools_ShrunkRange; +class BOPTools_PavePool; +class NMTTools_CommonBlockPool; +class BOPTools_SplitShapesPool; +class BOPTools_PaveBlock; +class TopoDS_Vertex; +class NMTTools_ListOfCommonBlock; +class BOPTools_IDMapOfPaveBlockIMapOfPaveBlock; +class BOPTools_IDMapOfPaveBlockIMapOfInteger; +class BooleanOperations_IndexedDataMapOfShapeInteger; +class TColStd_ListOfInteger; +class BOPTools_ListOfPaveBlock; +class TopoDS_Face; +class BOPTools_PaveSet; +class BOPTools_Curve; +class BOPTools_SSInterference; +class gp_Pnt; +class NMTTools_IndexedDataMapOfIndexedMapOfInteger; +class TopTools_ListOfShape; +class TopoDS_Edge; +class TopTools_DataMapOfShapeShape; +class TCoLSTD_MapOfInteger; +*/ + + +//======================================================================= +//function : NMTTools_PaveFiller +//purpose : +//======================================================================= +class NMTTools_PaveFiller { + public: + Standard_EXPORT + NMTTools_PaveFiller(); + + Standard_EXPORT + virtual ~NMTTools_PaveFiller(); + + Standard_EXPORT + void SetCompositeShape(const TopoDS_Shape& aS) ; + + Standard_EXPORT + const TopoDS_Shape& CompositeShape() const; + + Standard_EXPORT + NMTDS_PShapesDataStructure DS() ; + + Standard_EXPORT + NMTDS_PIterator DSIt() ; + + Standard_EXPORT + NMTDS_PInterfPool IP() ; + + Standard_EXPORT + virtual void Perform() ; + + Standard_EXPORT + Standard_Boolean IsDone() const; + + Standard_EXPORT + const Handle_IntTools_Context& Context() const; + + Standard_EXPORT + const BOPTools_PavePool& PavePool() const; + + Standard_EXPORT + BOPTools_PavePool& ChangePavePool() ; + + Standard_EXPORT + const NMTTools_CommonBlockPool& CommonBlockPool() const; + + Standard_EXPORT + NMTTools_CommonBlockPool& ChangeCommonBlockPool() ; + + Standard_EXPORT + const BOPTools_SplitShapesPool& SplitShapesPool() const; + + Standard_EXPORT + BOPTools_SplitShapesPool& ChangeSplitShapesPool() ; + + Standard_EXPORT + Standard_Integer FindSDVertex(const Standard_Integer nV) const; + + Standard_EXPORT + Standard_Integer SplitsInFace(const Standard_Integer aBid, + const Standard_Integer nF1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + TColStd_ListOfInteger& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsOnFace(const Standard_Integer aBid, + const Standard_Integer nF1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsInFace(const Standard_Integer aBid, + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsOnFace(const Standard_Integer aBid, + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsFace(const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + Standard_Integer SplitsFace(const Standard_Integer nF2, + TColStd_ListOfInteger& aLs) ; + + Standard_EXPORT + Standard_Integer CommonBlocksFace(const Standard_Integer nF, + NMTTools_ListOfCommonBlock& aLCB) ; + + Standard_EXPORT + void PrepareFace(const Standard_Integer nF, + TopoDS_Face& aF) ; + + Standard_EXPORT + const BOPTools_PaveBlock& RealPaveBlock(const BOPTools_PaveBlock& aPB) ; + + Standard_EXPORT + const BOPTools_PaveBlock& RealPaveBlock(const BOPTools_PaveBlock& aPB, + TColStd_ListOfInteger& aLB, + Standard_Integer& aIsCommonBlock) ; + + Standard_EXPORT + void RealSplitsFace(const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + Standard_Boolean HasRealSplitsInOnFace(const Standard_Integer nF1, + const Standard_Integer nF2) ; + + Standard_EXPORT + void RealSplitsInFace(const Standard_Integer aBid, + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + void RealSplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + void RealSplitsInFace(const Standard_Integer nF1, + BOPTools_ListOfPaveBlock& aLPB) ; + + Standard_EXPORT + void RealSplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + void RealSplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + void RealSplitsOnFace(const Standard_Integer aBid, + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLs) ; + + Standard_EXPORT + void PrepareSetForFace(const Standard_Integer nF1, + const Standard_Integer nF2, + const BOPTools_ListOfPaveBlock& aLPB, + BOPTools_PaveSet& aPSF) ; + + Standard_EXPORT + void PutPaveOnCurve(const BOPTools_PaveSet& aPSF, + const Standard_Real aTol, + BOPTools_Curve& aBC) ; + + Standard_EXPORT + void PutBoundPaveOnCurve(BOPTools_Curve& aBC, + BOPTools_SSInterference& aFF) ; + + Standard_EXPORT + void PutBoundPaveOnCurve(const gp_Pnt& aP, + const Standard_Real aT, + BOPTools_Curve& aBC, + BOPTools_SSInterference& aFF) ; + + Standard_EXPORT + Standard_Boolean FindPave(const gp_Pnt& aP, + const Standard_Real aTpV, + const BOPTools_PaveSet& aPS, + BOPTools_Pave& aPV) ; + + Standard_EXPORT + Standard_Integer CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, + const BOPTools_PaveBlock& aPBR, + const Standard_Real aTol) ; + + Standard_EXPORT + Standard_Boolean IsExistingPaveBlock(const BOPTools_PaveBlock& aPB, + const BOPTools_ListOfPaveBlock& aLPB, + const Standard_Real aTol) ; + + Standard_EXPORT + void MakePCurves() ; + + Standard_EXPORT + const NMTTools_IndexedDataMapOfIndexedMapOfInteger& AloneVertices() const; + + Standard_EXPORT + Standard_Boolean IsExistingPaveBlock(const BOPTools_PaveBlock& aPB, + const TopTools_ListOfShape& aLPB, + const Standard_Real aTol) ; + + Standard_EXPORT + Standard_Boolean CheckCoincidence(const BOPTools_PaveBlock& aPB, + const BOPTools_ListOfPaveBlock& aLPB) ; + + Standard_EXPORT + Standard_Integer CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, + const TopoDS_Edge& aE, + const Standard_Real aTol) ; + + Standard_EXPORT + void SharedEdges(const Standard_Integer nF1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aLNE, + TopTools_ListOfShape& aLSE) ; + + Standard_EXPORT + void FuseVertices(const TopoDS_Shape& aC, + TopTools_DataMapOfShapeShape& aDMVV) const; + + Standard_EXPORT + void TreatPaveBlocks(NMTTools_ListOfCommonBlock& theLCB) ; + + Standard_EXPORT + BOPTools_PavePool& ChangePavePoolNew() ; + + Standard_EXPORT + Standard_Boolean CheckCoincidence(const BOPTools_PaveBlock& aPB1, + const BOPTools_PaveBlock& aPB2) ; + + Standard_EXPORT + void PutClosingPaveOnCurve(BOPTools_Curve& aBC, + BOPTools_SSInterference& aFF) ; + + protected: + Standard_EXPORT + virtual void Init() ; + + Standard_EXPORT + virtual void Clear() ; + + Standard_EXPORT + virtual void PerformVV() ; + + Standard_EXPORT + virtual void PerformVE() ; + + Standard_EXPORT + virtual void PerformVF() ; + + Standard_EXPORT + virtual void PerformEE() ; + + Standard_EXPORT + virtual void PerformEF() ; + + Standard_EXPORT + virtual void PerformFF() ; + + Standard_EXPORT + void MakeSplitEdges() ; + + Standard_EXPORT + virtual void PreparePaveBlocks(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) ; + + Standard_EXPORT + void CorrectShrunkRanges(const Standard_Integer aSide, + const BOPTools_Pave& aPave, + IntTools_ShrunkRange& aSR) ; + + Standard_EXPORT + virtual void PreparePaveBlocks(const Standard_Integer anE) ; + + Standard_EXPORT + virtual void PrepareEdges() ; + + Standard_EXPORT + Standard_Boolean IsSuccessorsComputed(const Standard_Integer iF1, + const Standard_Integer iF2) const; + + Standard_EXPORT + Standard_Boolean IsBlocksCoinside(const BOPTools_PaveBlock& aPB1, + const BOPTools_PaveBlock& aPB2) const; + + Standard_EXPORT + void RefinePavePool() ; + + Standard_EXPORT + Standard_Integer CheckFacePaves(const TopoDS_Vertex& aV, + const Standard_Integer nF) ; + + Standard_EXPORT + void ReplaceCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ; + + Standard_EXPORT + void RemoveCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ; + + Standard_EXPORT + void SplitCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ; + + Standard_EXPORT + void SplitCommonBlock(const NMTTools_CommonBlock& aCB,NMTTools_ListOfCommonBlock& aLCB) ; + + Standard_EXPORT + void EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aM) ; + + Standard_EXPORT + void EFCommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB) ; + + Standard_EXPORT + void EENewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ; + + Standard_EXPORT + void EENewVertices(const TopoDS_Vertex& aV, + const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ; + + Standard_EXPORT + void EFNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ; + + Standard_EXPORT + void EFNewVertices(const TopoDS_Vertex& aV, + const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ; + + Standard_EXPORT + void UpdateCommonBlocks() ; + + Standard_EXPORT + void UpdateCommonBlocks(const Standard_Integer aI) ; + + Standard_EXPORT + void UpdatePaveBlocks() ; + + Standard_EXPORT + Standard_Integer SplitIndex(const BOPTools_PaveBlock& aPB) const; + + Standard_EXPORT + void MakeBlocks() ; + + Standard_EXPORT + void PerformVF1() ; + + Standard_EXPORT + void MakeAloneVertices() ; + + Standard_EXPORT + void FillFaceInfo() ; + + Standard_EXPORT + void CorrectTolR3D(const BOPTools_SSInterference& aFF, + const TColStd_MapOfInteger& aMVStick, + Standard_Real& aTolR3D) ; + + + NMTDS_PShapesDataStructure myDS; + Standard_Boolean myIsDone; + Standard_Integer myNbSources; + Standard_Integer myNbEdges; + BOPTools_PavePool myPavePool; + BOPTools_PavePool myPavePoolNew; + NMTTools_CommonBlockPool myCommonBlockPool; + BOPTools_SplitShapesPool mySplitShapesPool; + Handle_IntTools_Context myContext; + BOPTools_SSIntersectionAttribute mySectionAttribute; + NMTTools_IndexedDataMapOfIndexedMapOfInteger myAloneVertices; + TColStd_DataMapOfIntegerInteger myVSD; + NMTDS_PIterator myDSIt; + TopoDS_Shape myCompositeShape; + NMTDS_PInterfPool myIP; + NMTTools_DataMapOfIntegerFaceInfo myFaceInfo; + + + // private: + +}; +#endif diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller_0.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller_0.cxx new file mode 100644 index 000000000..7d7834334 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller_0.cxx @@ -0,0 +1,128 @@ +// 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: NMTTools_PaveFiller_0.cxx +// Created: Mon Dec 8 11:45:51 2003 +// Author: Peter KURNEV +// +// +#include + +#include +#include + +#include +#include +#include + +//======================================================================= +// function:IsSuccesstorsComputed +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PaveFiller::IsSuccessorsComputed(const Standard_Integer aN1, + const Standard_Integer aN2)const +{ + Standard_Boolean bComputed; + Standard_Integer i, nSuc, n1, n2, ntmp, aNbS; + TopAbs_ShapeEnum aType; + TColStd_IndexedMapOfInteger aMSuc; + // + n1=aN1; + n2=aN2; + aType=myDS->GetShapeType(aN1); + if (aType!=TopAbs_VERTEX) { + ntmp=n1; + n1=n2; + n2=ntmp; + } + // + myDS->GetAllSuccessors(n2, aMSuc); + aNbS=aMSuc.Extent(); + for (i=1; i<=aNbS; ++i) { + nSuc=aMSuc(i); + bComputed=myIP->Contains(n1, nSuc); + if (bComputed) { + break; + } + } + return bComputed; +} +/* +//======================================================================= +// function: ExpectedPoolLength +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::ExpectedPoolLength()const +{ + Standard_Integer aNbIIs; + Standard_Real aCfPredict=.5; + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + //const BOPTools_ListOfCoupleOfInteger& aLC=myDSIt.ListOfCouple(); + //aNbIIs=aLC.Extent(); + aNbIIs=myDSIt->ExpectedLength(); + // Contribution of Samtech www.samcef.com END + // + if (aNbIIs==1) { + return aNbIIs; + } + // + aNbIIs=(Standard_Integer) (aCfPredict*(Standard_Real)aNbIIs); + + return aNbIIs; +} +*/ +/* +//======================================================================= +//function : SortTypes +//purpose : +//======================================================================= + void NMTTools_PaveFiller::SortTypes(Standard_Integer& theWhat, + Standard_Integer& theWith)const +{ + Standard_Integer aWhat, aWith; + Standard_Boolean aReverseFlag; + TopAbs_ShapeEnum aType1, aType2; + // + aType1= myDS->GetShapeType(theWhat), + aType2= myDS->GetShapeType(theWith); + // + if (aType1==aType2) { + return; + } + // + aReverseFlag=Standard_True; + if (aType1==TopAbs_EDGE && aType2==TopAbs_FACE) { + aReverseFlag=Standard_False; + } + if (aType1==TopAbs_VERTEX && + (aType2==TopAbs_FACE || aType2==TopAbs_EDGE)) { + aReverseFlag=Standard_False; + } + // + aWhat=(aReverseFlag) ? theWith : theWhat; + aWith=(aReverseFlag) ? theWhat : theWith; + // + theWhat=aWhat; + theWith=aWith; +} +*/ diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller_1.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller_1.cxx new file mode 100644 index 000000000..c0d015fc6 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller_1.cxx @@ -0,0 +1,163 @@ +// 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: NMTTools_PaveFiller_1.cxx +// Created: Mon Dec 8 11:47:55 2003 +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +//======================================================================= +// function: PerformVV +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformVV() +{ + myIsDone=Standard_False; + // + Standard_Integer aNbVVs, aBL, aNbVSD, nVnew, i, j, n1, n2; + TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aIt1; + TColStd_ListIteratorOfListOfInteger aItX, aItY; + TColStd_ListOfInteger aLIX; + TopTools_ListOfShape aLV; + TopoDS_Vertex aVnew; + // + myVSD.Clear(); + // + const TColStd_DataMapOfIntegerListOfInteger& aMVSD=myDSIt->SDVertices(); + aNbVSD=aMVSD.Extent(); + if (!aNbVSD) { + return; + } + // + BOPTools_CArray1OfVVInterference& aVVs=myIP->VVInterferences(); + // + // BlockLength correction + myDSIt->Initialize(TopAbs_VERTEX, TopAbs_VERTEX); + aNbVVs=myDSIt->BlockLength(); + aBL=aVVs.BlockLength(); + if (aNbVVs > aBL) { + aVVs.SetBlockLength(aNbVVs); + } + // + aIt1.Initialize(aMVSD); + for (; aIt1.More(); aIt1.Next()) { + aLV.Clear(); + // + n1=aIt1.Key(); + const TColStd_ListOfInteger& aLIV=aIt1.Value(); + // + // new vertex + const TopoDS_Shape& aS1=myDS->Shape(n1); + aLV.Append(aS1); + aItX.Initialize(aLIV); + for (; aItX.More(); aItX.Next()) { + n2=aItX.Value(); + const TopoDS_Shape& aS2=myDS->Shape(n2); + aLV.Append(aS2); + } + // + NMTTools_Tools::MakeNewVertex(aLV, aVnew); + // + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + myDS->InsertShapeAndAncestorsSuccessors(aVnew, anASSeq); + nVnew=myDS->NumberOfInsertedShapes(); + myDS->SetState (nVnew, BooleanOperations_ON); + // + // myVSD, aLIX + aLIX.Clear(); + aLIX.Append(n1); + myVSD.Bind(n1, nVnew); + // + aItX.Initialize(aLIV); + for (; aItX.More(); aItX.Next()) { + n2=aItX.Value(); + aLIX.Append(n2); + myVSD.Bind(n2, nVnew); + } + // + // interferences + aItX.Initialize(aLIX); + for (i=0; aItX.More(); aItX.Next(), ++i) { + aItY.Initialize(aLIX); + for (j=0; aItY.More(); aItY.Next(), ++j) { + if (j>i) { + n1=aItX.Value(); + n2=aItY.Value(); + myIP->Add(n1, n2, Standard_True, NMTDS_TI_VV); + // + BOPTools_VVInterference aVV(n1, n2); + aVV.SetNewShape(nVnew); + aVVs.Append(aVV); + } + } + } + }//for (; aIt1.More(); aIt1.Next()) { + myIsDone=Standard_True; +} +//======================================================================= +// function: FindSDVertex +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::FindSDVertex(const Standard_Integer nV)const +{ + Standard_Integer nVSD; + // + nVSD=0; + if (myVSD.IsBound(nV)) { + nVSD=myVSD.Find(nV); + } + return nVSD; +} +/* +//======================================================================= +// function: PerformNewVertices +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformNewVertices() +{ +} +*/ diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller_2.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller_2.cxx new file mode 100644 index 000000000..fb40db6a3 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller_2.cxx @@ -0,0 +1,275 @@ +// 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: NMTTools_PaveFiller_2.cxx +// Created: Mon Dec 8 12:02:56 2003 +// 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 + +static + Standard_Boolean Contains(const TopoDS_Edge& aE, + const TopoDS_Vertex& aV); + +//======================================================================= +// function: PerformVE +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PerformVE() +{ + myIsDone=Standard_False; + // + Standard_Boolean bJustAdd; + Standard_Integer n1, n2, anIndexIn, aFlag, aWhat; + Standard_Integer aWith, aNbVEs, aBlockLength, iSDV, nV1; + Standard_Real aT; +#if OCC_VERSION_LARGE > 0x06030008 + // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method + Standard_Boolean bToUpdateVertex; + Standard_Real aDist; +#endif + TopoDS_Vertex aV1; + TopoDS_Edge aE2; + BOPTools_IndexedMapOfCoupleOfInteger aSnareMap; + BOPTools_CoupleOfInteger aCouple; + // + BOPTools_CArray1OfVEInterference& aVEs=myIP->VEInterferences(); + // + myDSIt->Initialize (TopAbs_VERTEX, TopAbs_EDGE); + // + // BlockLength correction + aNbVEs=myDSIt->BlockLength(); + aBlockLength=aVEs.BlockLength(); + if (aNbVEs > aBlockLength) { + aVEs.SetBlockLength(aNbVEs); + } + // + for (; myDSIt->More(); myDSIt->Next()) { + myDSIt->Current(n1, n2, bJustAdd); + if (!IsSuccessorsComputed(n1, n2)) { + anIndexIn=0; + aWhat=n1; // Vertex + aWith=n2; // Edge + if (myDS->GetShapeType(n1)==TopAbs_EDGE) { + aWhat=n2; + aWith=n1; + } + // + if(bJustAdd) { + continue; + } + // Edge + aE2=TopoDS::Edge(myDS->Shape(aWith)); + if (BRep_Tool::Degenerated(aE2)){ + continue; + } + // Vertex + nV1=aWhat; + aV1=TopoDS::Vertex(myDS->Shape(aWhat)); + // + iSDV=FindSDVertex(aWhat); + if (iSDV) { + nV1=iSDV; + aV1=TopoDS::Vertex(myDS->Shape(nV1)); + // Modified to find same domain vertex Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + Standard_Integer nVE, iSDVE, iRet; + // + BooleanOperations_OnceExplorer aExp(*myDS); + iRet=0; + aExp.Init(aWith, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + nVE=aExp.Current(); + iSDVE=FindSDVertex(nVE); + if (iSDVE==iSDV) { + iRet=1; + break; + } + } + if (iRet) { + continue; + } + } + else { + if (Contains(aE2, aV1)) { + continue; + } + // Contribution of Samtech www.samcef.com END + } + // + //modified by NIZNHY-PKV Mon Dec 28 08:58:05 2009f +#if OCC_VERSION_LARGE > 0x06030008 + // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method + aFlag = myContext->ComputeVE (aV1, aE2, aT, bToUpdateVertex, aDist); +#else + aFlag = myContext->ComputeVE (aV1, aE2, aT); +#endif + //modified by NIZNHY-PKV Mon Dec 28 08:58:13 2009t + // + if (!aFlag) { + // Add Interference to the Pool + BOPTools_VEInterference anInterf (aWhat, aWith, aT); + anIndexIn=aVEs.Append(anInterf); + // + // Add Pave to the Edge's myPavePool + aCouple.SetCouple(nV1, aWith); + if (!aSnareMap.Contains(aCouple)){ + aSnareMap.Add(aCouple); + // + BOPTools_Pave aPave(nV1, aT, BooleanOperations_VertexEdge); + aPave.SetInterference(anIndexIn); + BOPTools_PaveSet& aPaveSet= myPavePool(myDS->RefEdge(aWith)); + aPaveSet.Append(aPave); + } + // + // State for the Vertex in DS; + myDS->SetState (aWhat, BooleanOperations_ON); + // Insert Vertex in Interference Object + BOPTools_VEInterference& aVE=aVEs(anIndexIn); + aVE.SetNewShape(aWhat); + // + myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VE); + // + //modified by NIZNHY-PKV Mon Dec 28 09:00:54 2009f +#if OCC_VERSION_LARGE > 0x06030008 + // In OCCT6.3.0sp9 is changed a signature of IntTools_Context::ComputeVE() method + if (bToUpdateVertex) { + BRep_Builder aBB; + // + aBB.UpdateVertex(aV1, aDist); + } +#endif + //modified by NIZNHY-PKV Mon Dec 28 09:00:57 2009t + // + } //if (!aFlag) { + } + } + myIsDone=Standard_True; +} + +//======================================================================= +// function: PrepareEdges +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PrepareEdges() +{ + Standard_Integer i, nV, ii, aNBSuc, ip, aNbShapesObject; + Standard_Real aT; + TopAbs_Orientation anOr; + TopoDS_Edge aE; + TopoDS_Vertex aV; + // + aNbShapesObject=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=myNbSources; ++i) { + if (myDS->GetShapeType(i)==TopAbs_EDGE) { + aE=TopoDS::Edge(myDS->Shape(i)); + // + if (BRep_Tool::Degenerated(aE)){ + continue; + } + // + BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(i)); + // + // A <- + aNBSuc=myDS->NumberOfSuccessors(i); + for (ii=1; ii <=aNBSuc; ii++) { + nV=myDS->GetSuccessor(i, ii); + anOr=myDS->GetOrientation(i, ii); + aV=TopoDS::Vertex(myDS->Shape(nV)); + aV.Orientation(anOr); + aT=BRep_Tool::Parameter(aV, aE); + // + ip=FindSDVertex(nV); + if (ip) { + aV=TopoDS::Vertex(myDS->Shape(ip)); + aV.Orientation(anOr);// XX ? if the edge is closed it'll be amazing result + nV=ip; + } + // + BOPTools_Pave aPave(nV, aT); + aPaveSet.Append (aPave); + } + } + } +} + +// Modified Thu Sep 14 14:35:18 2006 +// Contribution of Samtech www.samcef.com BEGIN +//======================================================================= +//function : Contains +//purpose : +//======================================================================= +Standard_Boolean Contains(const TopoDS_Edge& aE, + const TopoDS_Vertex& aV) +{ + Standard_Boolean bRet; + TopoDS_Iterator aIt; + // + bRet=Standard_False; + aIt.Initialize(aE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Shape& aVE=aIt.Value(); + if (aVE.IsSame(aV)) { + bRet=!bRet; + break; + } + } + return bRet; +} +// Contribution of Samtech www.samcef.com END diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller_3.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller_3.cxx new file mode 100644 index 000000000..460f72442 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller_3.cxx @@ -0,0 +1,155 @@ +// 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: NMTTools_PaveFiller_3.cxx +// Created: Mon Dec 8 16:06:56 2003 +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + + +static + Standard_Boolean Contains(const TopoDS_Face& aF, + const TopoDS_Vertex& aV); + +//======================================================================= +// function: PerformVF +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformVF() +{ + myIsDone=Standard_False; + // + Standard_Boolean aJustAdd; + Standard_Integer n1, n2, anIndexIn, aFlag, aWhat, aWith, aNbVSs, aBlockLength, iSDV; + Standard_Real aU, aV; + TopoDS_Vertex aV1; + TopoDS_Face aF2; + // + BOPTools_CArray1OfVSInterference& aVSs=myIP->VSInterferences(); + // + // V/E Interferences + myDSIt->Initialize(TopAbs_VERTEX, TopAbs_FACE); + // + // BlockLength correction + aNbVSs=myDSIt->BlockLength(); + aBlockLength=aVSs.BlockLength(); + if (aNbVSs > aBlockLength) { + aVSs.SetBlockLength(aNbVSs); + } + // + for (; myDSIt->More(); myDSIt->Next()) { + myDSIt->Current(n1, n2, aJustAdd); + if (! IsSuccessorsComputed(n1, n2)) { + anIndexIn=0; + aWhat=n1; // Vertex + aWith=n2; // Face + if (myDS->GetShapeType(n1)==TopAbs_FACE) { + aWhat=n2; + aWith=n1; + } + // + iSDV=FindSDVertex(aWhat); + // + if(aJustAdd) { + //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn); + continue; + } + // + aV1=TopoDS::Vertex(myDS->Shape(aWhat)); + if (iSDV) { + aV1=TopoDS::Vertex(myDS->Shape(iSDV)); + } + // + aF2=TopoDS::Face(myDS->Shape(aWith)); + // + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + if (Contains(aF2, aV1)) { + continue; + } + // Contribution of Samtech www.samcef.com END + // + aFlag=myContext->ComputeVS (aV1, aF2, aU, aV); + // + if (!aFlag) { + // + // Add Interference to the Pool + BOPTools_VSInterference anInterf (aWhat, aWith, aU, aV); + anIndexIn=aVSs.Append(anInterf); + // + // SetState for Vertex in DS; + myDS->SetState (aWhat, BooleanOperations_ON); + // Insert Vertex in Interference Object + BOPTools_VSInterference& aVS=aVSs(anIndexIn); + aVS.SetNewShape(aWhat); + // qqf + { + myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_VF); + } + // qqt + } + //myIntrPool->AddInterference(aWhat, aWith, BooleanOperations_VertexSurface, anIndexIn); + } + } + myIsDone=Standard_True; +} +// Modified Thu Sep 14 14:35:18 2006 +// Contribution of Samtech www.samcef.com BEGIN +//======================================================================= +//function : Contains +//purpose : +//======================================================================= +Standard_Boolean Contains(const TopoDS_Face& aF, + const TopoDS_Vertex& aV) +{ + Standard_Boolean bRet; + TopExp_Explorer aExp; + // + bRet=Standard_False; + aExp.Init(aF, TopAbs_VERTEX); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Shape& aVF=aExp.Current(); + if (aVF.IsSame(aV)) { + bRet=!bRet; + break; + } + } + return bRet; +} +// Contribution of Samtech www.samcef.com END diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller_4.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller_4.cxx new file mode 100644 index 000000000..acfc6efb2 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller_4.cxx @@ -0,0 +1,1613 @@ +// 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: NMTTools_PaveFiller_4.cxx +// Created: Mon Dec 8 17:08:58 2003 +// 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 +#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 +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +static + void TreatNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI, + TopTools_DataMapOfShapeListOfShape& myImages, + TopTools_DataMapOfShapeShape& myOrigins); + +static + void MakeNewVertex(const TopTools_ListOfShape& aLV, + TopoDS_Vertex& aNewVertex); + +static + void VertexParameters(const IntTools_CommonPrt& aCPart, + Standard_Real& aT1, + Standard_Real& aT2); + +static + Standard_Boolean IsOnPave(const Standard_Real& aT1, + const IntTools_Range& aRange, + const Standard_Real& aTolerance); + +// static +// void EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB); + +static + void ProcessBlock(const BOPTools_PaveBlock& aPB, + const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB, + BOPTools_IMapOfPaveBlock& aProcessedBlocks, + BOPTools_IMapOfPaveBlock& aChain); + +static + void FindChains(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB, + NMTTools_ListOfCommonBlock& aLCB); + +//======================================================================= +// function: PerformEE +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PerformEE() +{ + myIsDone=Standard_False; + // + Standard_Boolean bJustAdd; + Standard_Integer n1, n2, anIndexIn, nE1, nE2, aNbVEs, aBlockLength; + Standard_Integer aTmp, aWhat, aWith, i, aNbCPrts, aDiscretize=30; + Standard_Integer aNbLPB1, aNbLPB2; + Standard_Real aTolE1, aTolE2, aDeflection=0.01; + BOPTools_ListIteratorOfListOfPaveBlock anIt1, anIt2; + TopoDS_Edge aEWhat, aEWith; + TopoDS_Vertex aNewVertex; + BooleanOperations_IndexedDataMapOfShapeInteger aMapVI; + BOPTools_IDMapOfPaveBlockIMapOfPaveBlock aMapCB; + // + BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences(); + // + myDSIt->Initialize(TopAbs_EDGE, TopAbs_EDGE); + // + // BlockLength correction + aNbVEs=myDSIt->BlockLength(); + aBlockLength=aEEs.BlockLength(); + if (aNbVEs > aBlockLength) { + aEEs.SetBlockLength(aNbVEs); + } + // + for (; myDSIt->More(); myDSIt->Next()) { + myDSIt->Current(n1, n2, bJustAdd); + anIndexIn = 0; + nE1=n1; + nE2=n2; + // + if(bJustAdd) { + continue; + } + // + const TopoDS_Edge aE1=TopoDS::Edge(myDS->Shape(nE1));//mpv + const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv + // + if (BRep_Tool::Degenerated(aE1) || BRep_Tool::Degenerated(aE2)){ + continue; + } + // + aTolE1=BRep_Tool::Tolerance(aE1); + aTolE2=BRep_Tool::Tolerance(aE2); + // + BOPTools_ListOfPaveBlock& aLPB1=mySplitShapesPool(myDS->RefEdge(nE1)); + BOPTools_ListOfPaveBlock& aLPB2=mySplitShapesPool(myDS->RefEdge(nE2)); + // + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + aNbLPB1=aLPB1.Extent(); + aNbLPB2=aLPB2.Extent(); + // + //if (aE1.IsSame(aE2) && aNbLPB1==1 && aNbLPB2==1) { + // continue; + //} + // Contribution of Samtech www.samcef.com END + // + for (anIt1.Initialize(aLPB1); anIt1.More(); anIt1.Next()) { + BOPTools_PaveBlock& aPB1=anIt1.Value(); + const IntTools_ShrunkRange& aShrunkRange1=aPB1.ShrunkRange(); + // + const IntTools_Range& aSR1=aShrunkRange1.ShrunkRange(); + const Bnd_Box& aBB1=aShrunkRange1.BndBox(); + // + for (anIt2.Initialize(aLPB2); anIt2.More(); anIt2.Next()) { + BOPTools_PaveBlock& aPB2=anIt2.Value(); + const IntTools_ShrunkRange& aShrunkRange2=aPB2.ShrunkRange(); + // + const IntTools_Range& aSR2=aShrunkRange2.ShrunkRange(); + const Bnd_Box& aBB2=aShrunkRange2.BndBox(); + // + if (aBB1.IsOut (aBB2)) { + continue; + } + // + // EE + IntTools_EdgeEdge aEE; + aEE.SetEdge1 (aE1); + aEE.SetEdge2 (aE2); + aEE.SetTolerance1 (aTolE1); + aEE.SetTolerance2 (aTolE2); + aEE.SetDiscretize (aDiscretize); + aEE.SetDeflection (aDeflection); + // + IntTools_Range anewSR1 = aSR1; + IntTools_Range anewSR2 = aSR2; + // + BOPTools_Tools::CorrectRange (aE1, aE2, aSR1, anewSR1); + BOPTools_Tools::CorrectRange (aE2, aE1, aSR2, anewSR2); + // + aEE.SetRange1(anewSR1); + aEE.SetRange2(anewSR2); + // + aEE.Perform(); + // + anIndexIn=0; + // + if (aEE.IsDone()) { + // reverse order if it is necessary + aEWhat=aE1; + aEWith=aE2; + aWhat=nE1; + aWith=nE2; + if (aEE.Order()) { + aTmp=aWhat; + aWhat=aWith; + aWith=aTmp; + aEWhat=aE2; + aEWith=aE1; + } + // + const IntTools_SequenceOfCommonPrts& aCPrts=aEE.CommonParts(); + aNbCPrts=aCPrts.Length(); + for (i=1; i<=aNbCPrts; i++) { + const IntTools_CommonPrt& aCPart=aCPrts(i); + const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); + // + anIndexIn=0; + // + TopAbs_ShapeEnum aType=aCPart.Type(); + switch (aType) { + case TopAbs_VERTEX: { + Standard_Real aT1, aT2, aTol=Precision::PConfusion(); + Standard_Boolean bIsOnPave1, bIsOnPave2; + IntTools_Range aR1, aR2; + // + VertexParameters(aCPart, aT1, aT2); + // + //decide to keep the pave or not + aR1 = (aEE.Order()) ? anewSR2 : anewSR1; + aR2 = (aEE.Order()) ? anewSR1 : anewSR2; + // + aTol=0.8*aTol; + bIsOnPave1=IsOnPave(aT1, aR1, aTol); + bIsOnPave2=IsOnPave(aT2, aR2, aTol); + // + if(bIsOnPave1 || bIsOnPave2) { + continue; + } + // + BOPTools_Tools::MakeNewVertex(aEWhat, aT1, aEWith, aT2, aNewVertex); + // + { + Standard_Integer nV11, nV12, nV21, nV22, nVS[2], k, j, iFound; + Standard_Real aTolVx, aTolVnew, aD2, aDT2; + TColStd_MapOfInteger aMV; + gp_Pnt aPnew, aPx; + // + iFound=0; + j=-1; + nV11=aPB1.Pave1().Index(); + nV12=aPB1.Pave2().Index(); + nV21=aPB2.Pave1().Index(); + nV22=aPB2.Pave2().Index(); + aMV.Add(nV11); + aMV.Add(nV12); + // + if (aMV.Contains(nV21)) { + ++j; + nVS[j]=nV21; + } + if (aMV.Contains(nV22)) { + ++j; + nVS[j]=nV22; + } + // + aTolVnew=BRep_Tool::Tolerance(aNewVertex); + aPnew=BRep_Tool::Pnt(aNewVertex); + // + for (k=0; k<=j; ++k) { + const TopoDS_Vertex& aVx=TopoDS::Vertex(myDS->Shape(nVS[k])); + aTolVx=BRep_Tool::Tolerance(aVx); + aPx=BRep_Tool::Pnt(aVx); + aD2=aPnew.SquareDistance(aPx); + // + aDT2=100.*(aTolVnew+aTolVx)*(aTolVnew+aTolVx); + // + if (aD2Add(aWhat, aWith, Standard_True, NMTDS_TI_EE); + } + // qqt + // + // Collect + aMapVI.Add(aNewVertex, anIndexIn); + } + break; + + case TopAbs_EDGE: { + Standard_Integer aNbComPrt2; + Standard_Boolean aCoinsideFlag; + // + aNbComPrt2=aRanges2.Length(); + aCoinsideFlag=IsBlocksCoinside(aPB1, aPB2); + // + if (aNbComPrt2>1 || !aCoinsideFlag) { + break; + } + // + // Fill aMapCB + if (aMapCB.Contains(aPB1)) { + BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.ChangeFromKey(aPB1); + aMapPB.Add(aPB1); + aMapPB.Add(aPB2); + } + else { + BOPTools_IMapOfPaveBlock aMapPB; + aMapPB.Add(aPB1); + aMapPB.Add(aPB2); + aMapCB.Add(aPB1, aMapPB); + } + // + if (aMapCB.Contains(aPB2)) { + BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.ChangeFromKey(aPB2); + aMapPB.Add(aPB1); + aMapPB.Add(aPB2); + } + else { + BOPTools_IMapOfPaveBlock aMapPB; + aMapPB.Add(aPB1); + aMapPB.Add(aPB2); + aMapCB.Add(aPB2, aMapPB); + } + // qqf + { + myIP->Add(aWhat, aWith, Standard_True, NMTDS_TI_EE); + } + // qqt + } + break; + default: + break; + } // switch (aType) + } // for (i=1; i<=aNbCPrts; i++) + }// if (aEE.IsDone()) + } // for (; anIt2.More(); anIt2.Next()) + } // for (; anIt1.More(); anIt1.Next()) + }// for (; myDSIt.More(); myDSIt.Next()) + // + { + NMTTools_ListOfCommonBlock aLCB; + // + FindChains(aMapCB, aLCB); + EENewVertices (aMapVI); + //TreatPaveBlocks(*this, aLCB); + TreatPaveBlocks(aLCB); + ReplaceCommonBlocks(aLCB); + } + // + PerformVF1(); + // + myIsDone=Standard_True; +} + +//======================================================================= +// function:TreatPaveBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::TreatPaveBlocks (NMTTools_ListOfCommonBlock& theLCB) +{ + Standard_Boolean bFound; + Standard_Integer nE, nV, nVp, iFlag; + Standard_Real aT; + TColStd_MapOfInteger aMI; + TColStd_MapIteratorOfMapOfInteger aItMI; + NMTTools_ListIteratorOfListOfCommonBlock aItLCB; + BOPTools_ListIteratorOfListOfPaveBlock aItLPB; + BOPTools_ListIteratorOfListOfPave aItLP; + // + aItLCB.Initialize(theLCB); + for (; aItLCB.More(); aItLCB.Next()) { + const NMTTools_CommonBlock& aCB=aItLCB.Value(); + // + aMI.Clear(); + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + // + // 1 -> aMI + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const BOPTools_PaveBlock& aPB=aItLPB.Value(); + nE=aPB.OriginalEdge(); + BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); + BOPTools_ListOfPave& aLP=aPaveSet.ChangeSet(); + // + aItLP.Initialize(aLP); + for (; aItLP.More(); aItLP.Next()) { + const BOPTools_Pave& aPave=aItLP.Value(); + nV=aPave.Index(); + aMI.Add(nV); + } + }//for (; anItLPB.More(); anItLPB.Next()) { + // + // 2 + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const BOPTools_PaveBlock& aPB=aItLPB.Value(); + nE=aPB.OriginalEdge(); + BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); + BOPTools_ListOfPave& aLP=aPaveSet.ChangeSet(); + // + aItMI.Initialize(aMI); + for (; aItMI.More(); aItMI.Next()) { + nV=aItMI.Key(); + bFound=Standard_False; + aItLP.Initialize(aLP); + for (; aItLP.More(); aItLP.Next()) { + const BOPTools_Pave& aPave=aItLP.Value(); + nVp=aPave.Index(); + if (nVp==nV) { + bFound=!bFound; + break; + } + } + // + if (!bFound) { + // Append Pave of nV to rhe edge nE + const TopoDS_Edge& aE=*(TopoDS_Edge*)(&myDS->Shape(nE)); + const TopoDS_Vertex& aV= *(TopoDS_Vertex*)(&myDS->Shape(nV)); + iFlag=myContext->ComputeVE (aV, aE, aT); + if (!iFlag) { + BOPTools_Pave aPave; + // + aPave.SetInterference(-1); + aPave.SetType (BooleanOperations_EdgeEdge); + aPave.SetIndex(nV); + aPave.SetParam(aT); + aPaveSet.Append(aPave); + } + } + }//for (; aItMI.More(); aItMI.Next()) { + }//for (; anItLPB.More(); anItLPB.Next()) { + } +} + +//======================================================================= +// function:EECommonBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB) +{ + NMTTools_ListOfCommonBlock aLCB; + // + FindChains(aMapCB, aLCB); + ReplaceCommonBlocks(aLCB); +} + +//======================================================================= +// function:EENewVertices +// purpose: +//======================================================================= +void NMTTools_PaveFiller::EENewVertices (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) +{ + Standard_Integer aNb, aNbVSD, nVnew, nIEE, nE[2], j, iFlag; + Standard_Real aT; + TopoDS_Edge aE; + TopTools_DataMapOfShapeListOfShape myImages; + TopTools_DataMapOfShapeShape myOrigins; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + TopTools_ListIteratorOfListOfShape aIt; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + TColStd_MapOfInteger aMFence; + BOPTools_Pave aPave; + // + BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences(); + // + aNb=aMapVI.Extent(); + if (!aNb) { // no new vertices, no new problems + return; + } + // + // 0. + if (aNb==1) { + TopoDS_Vertex aV1=TopoDS::Vertex(aMapVI.FindKey(1)); + EENewVertices(aV1, aMapVI); + return; + } + // + // 1. + TreatNewVertices(aMapVI, myImages, myOrigins); + // + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Vertex& aVnew=TopoDS::Vertex(aItIm.Key()); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + // + aNbVSD=aLVSD.Extent(); + if (aNbVSD==1) {// simple case aVnew=aVold + EENewVertices(aVnew, aMapVI); + continue; + } + // + // aNbVSD>1 + myDS->InsertShapeAndAncestorsSuccessors(aVnew, anASSeq); + nVnew=myDS->NumberOfInsertedShapes(); + myDS->SetState(nVnew, BooleanOperations_ON); + // + aMFence.Clear(); + aIt.Initialize(aLVSD); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Vertex& aVold=TopoDS::Vertex(aIt.Value()); + nIEE=aMapVI.FindFromKey(aVold); + BOPTools_EEInterference& aEE=aEEs(nIEE); + aEE.Indices(nE[0], nE[1]); + aEE.SetNewShape(nVnew); + // + for (j=0; j<2; ++j) { + if (aMFence.Add(nE[j])) { + aE=TopoDS::Edge(myDS->Shape(nE[j])); + iFlag=myContext->ComputeVE (aVnew, aE, aT); + if (!iFlag) { + aPave.SetInterference(-1); + aPave.SetType (BooleanOperations_EdgeEdge); + aPave.SetIndex(nVnew); + aPave.SetParam(aT); + // + BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE[j])); + aPaveSet.Append(aPave); + } + }// if (aMFence.Add(nE[j])) { + }// for (j=0; j<2; ++j) { + }//for (; aIt.More(); aIt.Next()) { + }// for (; aItIm.More(); aItIm.Next()) +} +// +// case: use_02 +// completely rewritten +//======================================================================= +//function : TreatNewVertices +//purpose : +//======================================================================= +void TreatNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI, + TopTools_DataMapOfShapeListOfShape& myImages, + TopTools_DataMapOfShapeShape& myOrigins) +{ + Standard_Integer j, i, aNbV, aNbVSD; + Standard_Real aTol; + TColStd_ListIteratorOfListOfInteger aIt; + TopoDS_Shape aSTmp, aVF; + TopoDS_Vertex aVnew; + TopTools_IndexedMapOfShape aMV, aMVProcessed; + TopTools_ListIteratorOfListOfShape aItS; + TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItIm; + TopTools_DataMapOfShapeListOfShape aMVV; + NMTDS_IndexedDataMapOfIntegerShape aMIS; + NMTDS_IndexedDataMapOfShapeBox aMSB; + // + NMTDS_BoxBndTreeSelector aSelector; + NMTDS_BoxBndTree aBBTree; + NCollection_UBTreeFiller aTreeFiller(aBBTree); + // + myImages.Clear(); + myOrigins.Clear(); + // + aNbV=aMapVI.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMapVI.FindKey(i); + aMV.Add(aV); + } + // + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + Bnd_Box aBox; + // + aTol=BRep_Tool::Tolerance(TopoDS::Vertex(aV)); + aBox.SetGap(aTol); + BRepBndLib::Add(aV, aBox); + // + aTreeFiller.Add(i, aBox); + // + aMIS.Add(i, aV); + aMSB.Add(aV, aBox); + } + // + aTreeFiller.Fill(); + // + // Chains + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + // + if (aMVProcessed.Contains(aV)) { + continue; + } + // + Standard_Integer aNbIP, aIP, aNbIP1, aIP1; + TopTools_ListOfShape aLVSD; + TColStd_MapOfInteger aMIP, aMIP1, aMIPC; + TColStd_MapIteratorOfMapOfInteger aIt1; + // + aMIP.Add(i); + while(1) { + aNbIP=aMIP.Extent(); + aIt1.Initialize(aMIP); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + if (aMIPC.Contains(aIP)) { + continue; + } + // + const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); + const Bnd_Box& aBoxVP=aMSB.FindFromKey(aVP); + // + aSelector.Clear(); + aSelector.SetBox(aBoxVP); + // + aNbVSD=aBBTree.Select(aSelector); + if (!aNbVSD) { + continue; // it must not be + } + // + const TColStd_ListOfInteger& aLI=aSelector.Indices(); + aIt.Initialize(aLI); + for (; aIt.More(); aIt.Next()) { + aIP1=aIt.Value(); + if (aMIP.Contains(aIP1)) { + continue; + } + aMIP1.Add(aIP1); + } //for (; aIt.More(); aIt.Next()) { + }//for(; aIt1.More(); aIt1.Next()) { + // + aNbIP1=aMIP1.Extent(); + if (!aNbIP1) { + break; // from while(1) + } + // + aIt1.Initialize(aMIP); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + aMIPC.Add(aIP); + } + // + aMIP.Clear(); + aIt1.Initialize(aMIP1); + for(; aIt1.More(); aIt1.Next()) { + aIP=aIt1.Key(); + aMIP.Add(aIP); + } + aMIP1.Clear(); + }// while(1) + //... + aNbIP=aMIPC.Extent(); + if (!aNbIP) { + aMIPC.Add(i); + } + // + aIt1.Initialize(aMIPC); + for(j=0; aIt1.More(); aIt1.Next(), ++j) { + aIP=aIt1.Key(); + const TopoDS_Shape& aVP=aMIS.FindFromKey(aIP); + if (!j) { + aVF=aVP; + } + aLVSD.Append(aVP); + aMVProcessed.Add(aVP); + } + myImages.Bind(aVF, aLVSD); + }// for (i=1; i<=aNbV; ++i) { + //------------------------------ + // + // Make new vertices + aMV.Clear(); + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + aNbVSD=aLVSD.Extent(); + if (aNbVSD>1) { + aMV.Add(aV); + MakeNewVertex(aLVSD, aVnew); + aMVV.Bind(aVnew, aLVSD); + } + } + // + // UnBind old vertices + aNbV=aMV.Extent(); + for (i=1; i<=aNbV; ++i) { + const TopoDS_Shape& aV=aMV(i); + myImages.UnBind(aV); + } + // + // Bind new vertices + aItIm.Initialize(aMVV); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + myImages.Bind(aV, aLVSD); + } + // + // Origins + aItIm.Initialize(myImages); + for (; aItIm.More(); aItIm.Next()) { + const TopoDS_Shape& aV=aItIm.Key(); + const TopTools_ListOfShape& aLVSD=aItIm.Value(); + // + aItS.Initialize(aLVSD); + for (; aItS.More(); aItS.Next()) { + const TopoDS_Shape& aVSD=aItS.Value(); + if (!myOrigins.IsBound(aVSD)) { + myOrigins.Bind(aVSD, aV); + } + } + } +} + +//======================================================================= +//function : MakeNewVertex +//purpose : +//======================================================================= +void MakeNewVertex(const TopTools_ListOfShape& aLV, + TopoDS_Vertex& aNewVertex) +{ + Standard_Integer aNbV; + Standard_Real aTolV, aD, aDmax; + gp_XYZ aGC; + gp_Pnt aP3D, aPGC; + TopoDS_Vertex aVx; + BRep_Builder aBB; + TopTools_ListIteratorOfListOfShape aIt; + // + aNbV=aLV.Extent(); + if (!aNbV) { + return; + } + // + // center of gravity + aGC.SetCoord(0.,0.,0.); + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + aVx=TopoDS::Vertex(aIt.Value()); + aP3D=BRep_Tool::Pnt(aVx); + aGC+=aP3D.XYZ(); + } + aGC/=(Standard_Real)aNbV; + aPGC.SetXYZ(aGC); + // + // tolerance value + aDmax=-1.; + aIt.Initialize(aLV); + for (; aIt.More(); aIt.Next()) { + aVx=TopoDS::Vertex(aIt.Value()); + aP3D=BRep_Tool::Pnt(aVx); + aTolV=BRep_Tool::Tolerance(aVx); + aD=aPGC.Distance(aP3D)+aTolV; + if (aD>aDmax) { + aDmax=aD; + } + } + // + aBB.MakeVertex (aNewVertex, aPGC, aDmax); +} + +//======================================================================= +// function:EENewVertices +// purpose: +//======================================================================= +void NMTTools_PaveFiller::EENewVertices (const TopoDS_Vertex& aNewVertex, + const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) +{ + Standard_Integer i, aNewShape, nE1, nE2; + Standard_Real aT1, aT2; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + BOPTools_Pave aPave; + // + BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences(); + // + // one new vertex case is treated in usual way + // + // Insert New Vertex in DS; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + aNewShape=myDS->NumberOfInsertedShapes(); + myDS->SetState (aNewShape, BooleanOperations_ON); + // Insert New Vertex in EE Interference + i=aMapVI.FindFromKey(aNewVertex); + BOPTools_EEInterference& aEEInterf= aEEs(i); + aEEInterf.SetNewShape(aNewShape); + // Extact interference info + aEEInterf.Indices(nE1, nE2); + const IntTools_CommonPrt& aCPart=aEEInterf.CommonPrt(); + VertexParameters(aCPart, aT1, aT2); + // + // Add Paves to the myPavePoolNew + aPave.SetInterference(i); + aPave.SetType (BooleanOperations_EdgeEdge); + aPave.SetIndex(aNewShape); + // Pave for edge nE1 + aPave.SetParam(aT1); + BOPTools_PaveSet& aPaveSet1=myPavePoolNew(myDS->RefEdge(nE1)); + aPaveSet1.Append(aPave); + // Pave for edge nE2 + aPave.SetParam(aT2); + BOPTools_PaveSet& aPaveSet2=myPavePoolNew(myDS->RefEdge(nE2)); + aPaveSet2.Append(aPave); +} + +//======================================================================= +// function: RefinePavePool +// purpose: +//======================================================================= +void NMTTools_PaveFiller::RefinePavePool() +{ + Standard_Integer i, aNbNew; + + for (i=1; i<=myNbSources; i++) { + + if ((myDS->GetShape(i)).ShapeType()==TopAbs_EDGE) { + BOPTools_PaveSet& aPS= myPavePool(myDS->RefEdge(i)); + // + BOPTools_PaveSet& aNewPS= myPavePoolNew(myDS->RefEdge(i)); + BOPTools_ListOfPave& aNewLP=aNewPS.ChangeSet(); + // + aNbNew=aNewLP.Extent(); + if (aNbNew) { + BOPTools_ListIteratorOfListOfPave anIt(aNewLP); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPave=anIt.Value(); + aPS.Append(aPave); + } + // Clear the ListOfPaveBlock + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(i)); + aLPB.Clear(); + // Prepare the paveBlocks for that egde again + PreparePaveBlocks(i); + } + aNewLP.Clear(); + } + } +} + +//======================================================================= +// function: PreparePaveBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PreparePaveBlocks(const TopAbs_ShapeEnum aType1, + const TopAbs_ShapeEnum aType2) +{ + myIsDone=Standard_False; + // + Standard_Boolean bOk1, bOk2, bOk3, bFlag; + Standard_Integer i, aNb, nE[2], n1, n2, aNbSplits; + TColStd_MapOfInteger aMap; + // + bOk1= (aType1==TopAbs_VERTEX) && (aType2==TopAbs_EDGE) ; + bOk2= (aType1==TopAbs_EDGE) && (aType2==TopAbs_EDGE) ; + bOk3= (aType1==TopAbs_EDGE) && (aType2==TopAbs_FACE) ; + if (!bOk1 && !bOk2 && !bOk3) {// error: Type mismatch + return; + } + // + aNb=bOk2 ? 2 : 1; + // + myDSIt->Initialize(aType1, aType2); + for (; myDSIt->More(); myDSIt->Next()) { + myDSIt->Current(n1, n2, bFlag); + // + nE[0]=n1; + nE[1]=n2; + if (myDS->GetShapeType(n1)!=TopAbs_EDGE) { + nE[0]=n2; + nE[1]=n1; + } + // + for (i=0; iRefEdge(nE[i])); + aNbSplits=aLPB.Extent(); + if (!aNbSplits) { + if (aMap.Add(nE[i])) { + PreparePaveBlocks(nE[i]); + if (!myIsDone) { + return; + } + } + } + } + }// for (; myDSIt.More(); myDSIt.Next()) + myIsDone=Standard_True; +} + +//======================================================================= +// function: PreparePaveBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PreparePaveBlocks(const Standard_Integer nE) +{ + myIsDone=Standard_False; + // + char buf[512]; + Standard_Integer nV1, nV2, iErr; + TopoDS_Edge aE; + TopoDS_Vertex aV1, aV2; + // + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + // Edge + aE=TopoDS::Edge(myDS->Shape(nE)); + if (BRep_Tool::Degenerated(aE)) { + myIsDone=Standard_True; + return; + } + // + BOPTools_PaveSet& aPS=myPavePool(myDS->RefEdge(nE)); + // + BOPTools_PaveBlockIterator aPBIt(nE, aPS); + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + const IntTools_Range& aRange=aPB.Range(); + // + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + aV1=TopoDS::Vertex(myDS->GetShape(nV1)); + // + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + aV2=TopoDS::Vertex(myDS->GetShape(nV2)); + // + // ShrunkRange + IntTools_ShrunkRange aSR (aE, aV1, aV2, aRange, myContext); + iErr=aSR.ErrorStatus(); + if (!aSR.IsDone()) { + sprintf (buf, "Can not obtain ShrunkRange for Edge %d\n", nE); + BOPTColStd_Dump::PrintMessage(buf); + sprintf (buf, "Can not obtain ShrunkRange for Edge %d", nE); + throw + BOPTColStd_Failure(buf) ; + } + // + if (iErr==6) { + sprintf(buf, + "Warning: [PreparePaveBlocks()] Max.Dummy Shrunk Range for Edge %d\n", nE); + BOPTColStd_Dump::PrintMessage(buf); + } + else { + // Check left paves and correct ShrunkRange if it is necessary + CorrectShrunkRanges (0, aPave1, aSR); + CorrectShrunkRanges (1, aPave2, aSR); + } + // + aPB.SetShrunkRange(aSR); + aLPB.Append(aPB); + } //for (; aPBIt.More(); aPBIt.Next()) + myIsDone=Standard_True; +} + +//======================================================================= +// function: CorrectShrunkRanges +// purpose: +//======================================================================= +void NMTTools_PaveFiller::CorrectShrunkRanges(const Standard_Integer aSide, + const BOPTools_Pave& aPave, + IntTools_ShrunkRange& aShrunkRange) +{ + BooleanOperations_KindOfInterference aType; + Standard_Integer anIndexInterf ; + // + aType=aPave.Type(); + if (aType!=BooleanOperations_EdgeEdge) { + return; + } + // + anIndexInterf=aPave.Interference(); + if (anIndexInterf<0) { + // it can be EE interf between E and (e1,e2,..en) -> vertex + // so we can't decide which aEE.CommonPrt() we should take. + return; + } + + BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences(); + const BOPTools_EEInterference& aEE=aEEs(anIndexInterf); + const IntTools_CommonPrt& aCP=aEE.CommonPrt(); + const TopoDS_Edge& aE1=aCP.Edge1(); + const TopoDS_Edge& aE2=aCP.Edge2(); + + const IntTools_Range& aSR=aShrunkRange.ShrunkRange(); + const TopoDS_Edge& aE=aShrunkRange.Edge(); + + IntTools_Range aNewRange; + IntTools_Range aCPRange; + + if (aE1.IsSame(aE)) { + const IntTools_Range& aR1=aCP.Range1(); + aCPRange=aR1; + } + if (aE2.IsSame(aE)) { + const IntTools_SequenceOfRanges& aSeqR=aCP.Ranges2(); + const IntTools_Range& aR2=aSeqR(1); + aCPRange=aR2; + } + // + Standard_Real aCoeff=1.05, tV, tNV; + tV=aPave.Param(); + if (aSide==0) { // Left + if (aCPRange.Last() > aSR.First()) { + tNV=aCPRange.Last(); + tNV=tV+aCoeff*(tNV-tV); + aNewRange.SetFirst(tNV); + aNewRange.SetLast (aSR.Last()); + if(aNewRange.First() < aNewRange.Last()) { + aShrunkRange.SetShrunkRange(aNewRange); + } + } + } + else { // Right + if (aCPRange.First() < aSR.Last()) { + tNV=aCPRange.First(); + tNV=tV-aCoeff*(tV-tNV); + aNewRange.SetFirst(aSR.First()); + aNewRange.SetLast (tNV); + + if(aNewRange.First() < aNewRange.Last()) { + aShrunkRange.SetShrunkRange(aNewRange); + } + } + } +} + +//======================================================================= +// function: IsBlocksCoinside +// purpose: +//======================================================================= +Standard_Boolean NMTTools_PaveFiller::IsBlocksCoinside(const BOPTools_PaveBlock& aPB1, + const BOPTools_PaveBlock& aPB2) const +{ + Standard_Boolean bRetFlag=Standard_True; + Standard_Real aTolV11, aTolV12, aTolV21, aTolV22; + Standard_Real d1121, d1122, d1222, d1221, aTolSum, aCoeff=1.05; + gp_Pnt aP11, aP12, aP21, aP22; + + const TopoDS_Vertex aV11=TopoDS::Vertex(myDS->Shape(aPB1.Pave1().Index()));//mpv + const TopoDS_Vertex aV12=TopoDS::Vertex(myDS->Shape(aPB1.Pave2().Index()));//mpv + const TopoDS_Vertex aV21=TopoDS::Vertex(myDS->Shape(aPB2.Pave1().Index()));//mpv + const TopoDS_Vertex aV22=TopoDS::Vertex(myDS->Shape(aPB2.Pave2().Index()));//mpv + + aTolV11=BRep_Tool::Tolerance(aV11); + aTolV12=BRep_Tool::Tolerance(aV12); + aTolV21=BRep_Tool::Tolerance(aV21); + aTolV22=BRep_Tool::Tolerance(aV22); + + aP11=BRep_Tool::Pnt(aV11); + aP12=BRep_Tool::Pnt(aV12); + aP21=BRep_Tool::Pnt(aV21); + aP22=BRep_Tool::Pnt(aV22); + + d1121=aP11.Distance(aP21); + aTolSum=aCoeff*(aTolV11+aTolV21); + if (d1121RefEdge(nE)); + aLCBE.Append(aCBx); + } + } + } + // Modified to provide the order of edges + // in common block where the edge with max + // tolerance value will be the first + // Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + Standard_Integer i, iMax, aNb, aNbCB, nSp; + Standard_Real aTolSp, aTolMax; + BOPTools_ListOfPaveBlock *pLPBE; + // + aNb=myDS->NumberOfShapesOfTheObject(); + for (nE=1; nE<=aNb; ++nE) { + const TopoDS_Shape& aE=myDS->Shape(nE); + if (aE.ShapeType()!=TopAbs_EDGE) { + continue; + } + // + NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE)); + aNbCB=aLCBE.Extent(); + if (!aNbCB) { + continue; + } + // + anIt.Initialize(aLCBE); + for (; anIt.More(); anIt.Next()) { + NMTTools_CommonBlock& aCBE=anIt.ChangeValue(); + const BOPTools_ListOfPaveBlock& aLPBE=aCBE.PaveBlocks(); + // + aTolMax=-1.; + anItLPE.Initialize(aLPBE); + for (i=0; anItLPE.More(); anItLPE.Next(), ++i) { + const BOPTools_PaveBlock& aPB=anItLPE.Value(); + nSp=aPB.OriginalEdge(); + const TopoDS_Edge& aSp=TopoDS::Edge(myDS->Shape(nSp)); + aTolSp=BRep_Tool::Tolerance(aSp); + if (aTolSp>aTolMax) { + iMax=i; + aTolSp=aTolMax; + } + } + // + BOPTools_ListOfPaveBlock aLPBx; + // + anItLPE.Initialize(aLPBE); + for (i=0; anItLPE.More(); anItLPE.Next(), ++i) { + const BOPTools_PaveBlock& aPB=anItLPE.Value(); + if (i==iMax) { + aLPBx.Prepend(aPB); + } + else { + aLPBx.Append(aPB); + } + } + // + pLPBE=(BOPTools_ListOfPaveBlock *)&aLPBE; + pLPBE->Clear(); + pLPBE->Append(aLPBx); + }//for (; anIt.More(); anIt.Next()) { + }//for (nE=1; nE<=aNb; ++nE) { + // Contribution of Samtech www.samcef.com END +} + +//======================================================================= +// function: RemoveCommonBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::RemoveCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) +{ + Standard_Integer nE; + NMTTools_ListOfCommonBlock aLCBx; + NMTTools_ListIteratorOfListOfCommonBlock anItCB, anItCBE; + BOPTools_ListIteratorOfListOfPaveBlock anItLPB; + // + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + const NMTTools_CommonBlock& aCB=anItCB.Value(); + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + // + // Remove aCB from each edge + anItLPB.Initialize(aLPB); + for (; anItLPB.More(); anItLPB.Next()) { + const BOPTools_PaveBlock& aPB=anItLPB.Value(); + nE=aPB.OriginalEdge(); + // + NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE)); + anItCBE.Initialize(aLCBE); + for (; anItCBE.More(); anItCBE.Next()) { + const NMTTools_CommonBlock& aCBE=anItCBE.Value(); + if (aCBE.IsEqual(aCB)) { + aLCBE.Remove(anItCBE); + break; + } + } + } + } +} + +//======================================================================= +// function: SplitCommonBlock +// purpose: +//======================================================================= +void NMTTools_PaveFiller::SplitCommonBlock(const NMTTools_CommonBlock& aCB, + NMTTools_ListOfCommonBlock& aLCBx) +{ + Standard_Boolean bIsCoincided; + Standard_Integer i, j,nE, aNbE, aNbSPBx, aNbPB, k; + BOPTools_SequenceOfPaveBlock aSPBx; + BOPTools_ListIteratorOfListOfPaveBlock anItLPB; + BOPTools_ListIteratorOfListOfPave anIt; + BOPTools_PaveBlockIterator anPBIt; + // + const BOPTools_ListOfPaveBlock& aLPB=aCB.PaveBlocks(); + aNbE=aLPB.Extent(); + // + // 1. Checking: Whether we realy need to split the common block ? + anItLPB.Initialize(aLPB); + for (; anItLPB.More(); anItLPB.Next()) { + const BOPTools_PaveBlock& aPB=anItLPB.Value(); + nE=aPB.OriginalEdge(); + BOPTools_PaveSet& aPSE=myPavePoolNew(myDS->RefEdge(nE)); + aPSE.SortSet(); + // + BOPTools_PaveSet aPSx; + // + const BOPTools_ListOfPave& aLPE=aPSE.Set(); + anIt.Initialize(aLPE); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPx=anIt.Value(); + if (aPB.IsInBlock(aPx)) { + aPSx.Append(aPx); + } + } + aNbPB=aPSx.Set().Extent(); + break; + } + // + if (!aNbPB) { + // we need not split it + aLCBx.Append(aCB); + return; + } + // + // 2. Get sequence of pave Blocks containing all new pave blocks + // for each edges's source pave Block + anItLPB.Initialize(aLPB); + for (; anItLPB.More(); anItLPB.Next()) { + const BOPTools_PaveBlock& aPB=anItLPB.Value(); + const BOPTools_Pave& aPave1=aPB.Pave1(); + const BOPTools_Pave& aPave2=aPB.Pave2(); + nE=aPB.OriginalEdge(); + // + BOPTools_PaveSet aPSx; + // + // the set aPsx will contain bounadry paves aPave1, aPave2 and + // all paves of the edge nE that are inside block aPB + aPSx.Append(aPave1); + aPSx.Append(aPave2); + // + BOPTools_PaveSet& aPSE=myPavePoolNew(myDS->RefEdge(nE)); + aPSE.SortSet(); + // + const BOPTools_ListOfPave& aLPE=aPSE.Set(); + anIt.Initialize(aLPE); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPx=anIt.Value(); + if (aPB.IsInBlock(aPx)) { + aPSx.Append(aPx); + } + } + // + // Form pave blocks from aPSx and collect them in aSPBx + anPBIt.Initialize(nE, aPSx); + for (; anPBIt.More(); anPBIt.Next()) { + const BOPTools_PaveBlock& aPBx=anPBIt.Value(); + aSPBx.Append(aPBx); + } + } + // + // 3. Do new common blocks + // + const TColStd_ListOfInteger& aLF=aCB.Faces(); + aNbSPBx=aSPBx.Length(); + aNbPB=aNbSPBx/aNbE; + // + Standard_Integer k1, k2, n11, n12, n21, n22; + // + for (i=1; i<=aNbPB; ++i) { + NMTTools_CommonBlock aCBx; + // + aCBx.AddFaces(aLF); + // + const BOPTools_PaveBlock& aPB1=aSPBx(i); + n11=aPB1.Pave1().Index(); + n12=aPB1.Pave2().Index(); + // + aCBx.AddPaveBlock(aPB1); + // + for (j=2; j<=aNbE; ++j) { + k1=(j-1)*aNbPB+1; + k2=k1+aNbPB-1; + for(k=k1; k<=k2; ++k) { + const BOPTools_PaveBlock& aPB2=aSPBx(k); + n21=aPB2.Pave1().Index(); + n22=aPB2.Pave2().Index(); + if ((n21==n11 && n22==n12) || (n21==n12 && n22==n11)) { + //modified by NIZNHY-PKV Thu Nov 11 08:13:24 2010f + bIsCoincided=CheckCoincidence(aPB2, aPB1); + if (bIsCoincided) { + aCBx.AddPaveBlock(aPB2); + break; + } + //aCBx.AddPaveBlock(aPB2); + //break; + //modified by NIZNHY-PKV Thu Nov 11 08:13:31 2010t + } + } + } + aLCBx.Append(aCBx); + } +} + +//======================================================================= +// function: VertexParameters +// purpose: +//======================================================================= +void VertexParameters(const IntTools_CommonPrt& aCPart, + Standard_Real& aT1, + Standard_Real& aT2) +{ + const IntTools_Range& aR1=aCPart.Range1(); + aT1=0.5*(aR1.First()+aR1.Last()); + // + if((aCPart.VertexParameter1() >= aR1.First()) && + (aCPart.VertexParameter1() <= aR1.Last())) { + aT1 = aCPart.VertexParameter1(); + } + // + const IntTools_SequenceOfRanges& aRanges2=aCPart.Ranges2(); + const IntTools_Range& aR2=aRanges2(1); + aT2=0.5*(aR2.First()+aR2.Last()); + // + if((aCPart.VertexParameter2() >= aR2.First()) && + (aCPart.VertexParameter2() <= aR2.Last())) { + aT2 = aCPart.VertexParameter2(); + } +} + +//======================================================================= +// function: KeepPave +// purpose: +//======================================================================= +Standard_Boolean IsOnPave(const Standard_Real& aT1, + const IntTools_Range& aRange, + const Standard_Real& aTolerance) +{ + Standard_Boolean firstisonpave1, firstisonpave2, bIsOnPave; + // + firstisonpave1 = (Abs(aRange.First() - aT1) < aTolerance); + firstisonpave2 = (Abs(aRange.Last() - aT1) < aTolerance); + bIsOnPave=(firstisonpave1 || firstisonpave2); + return bIsOnPave; +} + +//======================================================================= +// function:FindChains +// purpose: +//======================================================================= +void FindChains(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB, + NMTTools_ListOfCommonBlock& aLCB) +{ + Standard_Integer i, j, aNbCB, aNbPB; + BOPTools_IMapOfPaveBlock aProcessedBlocks, aChain; + // + aNbCB=aMapCB.Extent(); + for (i=1; i<=aNbCB; ++i) { + const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i); + if (aProcessedBlocks.Contains(aPB)) { + continue; + } + // + aProcessedBlocks.Add(aPB); + aChain.Add(aPB); + // + const BOPTools_IMapOfPaveBlock& aMapPB=aMapCB(i); + aNbPB=aMapPB.Extent(); + for (j=1; j<=aNbPB; ++j) { + const BOPTools_PaveBlock& aPBx=aMapPB(j); + ProcessBlock(aPBx, aMapCB, aProcessedBlocks, aChain); + } + // + NMTTools_CommonBlock aCB; + // + aNbPB=aChain.Extent(); + for (j=1; j<=aNbPB; ++j) { + const BOPTools_PaveBlock& aPBx=aChain(j); + aCB.AddPaveBlock(aPBx); + } + aLCB.Append(aCB); + aChain.Clear(); + } +} + +//======================================================================= +// function:ProcessBlock +// purpose: +//======================================================================= +void ProcessBlock(const BOPTools_PaveBlock& aPB, + const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aMapCB, + BOPTools_IMapOfPaveBlock& aProcessedBlocks, + BOPTools_IMapOfPaveBlock& aChain) +{ + Standard_Integer j, aNbPB; + // + if (aProcessedBlocks.Contains(aPB)) { + return; + } + aProcessedBlocks.Add(aPB); + aChain.Add(aPB); + // + const BOPTools_IMapOfPaveBlock& aMapPB=aMapCB.FindFromKey(aPB); + aNbPB=aMapPB.Extent(); + for (j=1; j<=aNbPB; ++j) { + const BOPTools_PaveBlock& aPBx=aMapPB(j); + ProcessBlock(aPBx, aMapCB, aProcessedBlocks, aChain); + } +} +// Modified to provide VS interference between +// vertex as result of EE and a Face of argument +// Thu Sep 14 14:35:18 2006 +// Contribution of Samtech www.samcef.com BEGIN +//======================================================================= +// function: PerformVF1 +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformVF1() +{ + Standard_Integer i, aNbEE, n1, n2, nNewShape, aNbS, nF; + Standard_Integer anIndexIn, aFlag; + Standard_Real aU, aV; + TColStd_ListOfInteger aLFI; + TColStd_ListIteratorOfListOfInteger aItLFI; + // + BOPTools_CArray1OfVSInterference& aVSs=myIP->VSInterferences(); + BOPTools_CArray1OfEEInterference& aEEs=myIP->EEInterferences(); + // + aNbS=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aF=myDS->Shape(i); + if (aF.ShapeType()==TopAbs_FACE) { + aLFI.Append(i); + } + } + if (!aLFI.Extent()) { + return; + } + // + aNbEE=aEEs.Extent(); + for (i=1; i<=aNbEE; ++i) { + BOPTools_EEInterference& aEE=aEEs(i); + aEE.Indices(n1, n2); + nNewShape=aEE.NewShape(); + if (!nNewShape) { + continue; + } + // + const TopoDS_Shape& aSnew=myDS->Shape(nNewShape); + if (aSnew.ShapeType()!=TopAbs_VERTEX) { + continue; + } + // + const TopoDS_Vertex& aVnew=TopoDS::Vertex(aSnew); + // + Bnd_Box aBV; + // + BRepBndLib::Add(aVnew, aBV); + // + aItLFI.Initialize(aLFI); + for (; aItLFI.More(); aItLFI.Next()) { + nF=aItLFI.Value(); + // + const TopoDS_Face& aF=TopoDS::Face(myDS->Shape(nF)); + const Bnd_Box& aBF=myDS->GetBoundingBox(nF); + if (aBF.IsOut(aBV)) { + continue; + } + // + anIndexIn=0; + aFlag=myContext->ComputeVS (aVnew, aF, aU, aV); + if (!aFlag) { + BOPTools_VSInterference anInterf (nNewShape, nF, aU, aV); + // + anIndexIn=aVSs.Append(anInterf); + BOPTools_VSInterference& aVS=aVSs(anIndexIn); + aVS.SetNewShape(nNewShape);//-> + } + } + } +} +// Contribution of Samtech www.samcef.com END +//modified by NIZNHY-PKV Thu Nov 11 08:13:48 2010f +//======================================================================= +// function: CheckCoincidence +// purpose: +//======================================================================= +Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPB1, + const BOPTools_PaveBlock& aPB2) +{ + Standard_Boolean bRet; + Standard_Integer nE1, nE2, aNbPoints; + Standard_Real aT11, aT12, aT21, aT22, aT1m, aD, aTol, aT2x; + gp_Pnt aP1m; + // + bRet=Standard_False; + // + aT11=aPB1.Pave1().Param(); + aT12=aPB1.Pave2().Param(); + aT1m=IntTools_Tools::IntermediatePoint (aT11, aT12); + nE1=aPB1.OriginalEdge(); + const TopoDS_Edge& aE1=(*(TopoDS_Edge*)(&myDS->Shape(nE1))); + BOPTools_Tools::PointOnEdge(aE1, aT1m, aP1m); + // + aT21=aPB2.Pave1().Param(); + aT22=aPB2.Pave2().Param(); + nE2=aPB2.OriginalEdge(); + const TopoDS_Edge& aE2=(*(TopoDS_Edge*)(&myDS->Shape(nE2))); + // + GeomAPI_ProjectPointOnCurve& aPPC=myContext->ProjPC(aE2); + aPPC.Perform(aP1m); + aNbPoints=aPPC.NbPoints(); + if (aNbPoints) { + aD=aPPC.LowerDistance(); + // + aTol=BRep_Tool::Tolerance(aE1); + aTol=aTol+BRep_Tool::Tolerance(aE2); + if (aDaT21 && aT2x +// +#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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + + +static + void VertexParameter(const IntTools_CommonPrt& aCPart, + Standard_Real& aT); +static + Standard_Boolean IsOnPave(const Standard_Real& aTR, + const IntTools_Range& aCPRange, + const Standard_Real& aTolerance); +// +//======================================================================= +// function: PerformEF +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformEF() +{ + Standard_Boolean bJustAdd; + Standard_Integer n1, n2, anIndexIn, nE, nF, aNbEFs, aBlockLength; + Standard_Integer aDiscretize; + Standard_Real aTolE, aTolF, aDeflection; + BooleanOperations_IndexedDataMapOfShapeInteger aMapVI; + BOPTools_IDMapOfPaveBlockIMapOfInteger aMapCB; + BOPTools_IMapOfPaveBlock aIMPBx; + // + myIsDone=Standard_False; + aDeflection=0.01; + aDiscretize=35; + // + BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences(); + // + myDSIt->Initialize(TopAbs_EDGE, TopAbs_FACE); + // + // BlockLength correction + aNbEFs=myDSIt->BlockLength(); + aBlockLength=aEFs.BlockLength(); + if (aNbEFs > aBlockLength) { + aEFs.SetBlockLength(aNbEFs); + } + // + for (; myDSIt->More(); myDSIt->Next()) { + myDSIt->Current(n1, n2, bJustAdd); + // + if(bJustAdd) { + continue; + } + // + anIndexIn = 0; + // + nE=n1; + nF=n2; + if (myDS->GetShapeType(n2)==TopAbs_EDGE) { + nE=n2; + nF=n1; + } + // + // all Common Blocks for face nF + NMTTools_ListOfCommonBlock aLCBF; + CommonBlocksFace(nF, aLCBF); + NMTTools_CommonBlockAPI aCBAPIF(aLCBF); + // + // Edge + const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE)); + if (BRep_Tool::Degenerated(aE)){ + continue; + } + // + // Face + const TopoDS_Face aF=TopoDS::Face(myDS->Shape(nF)); + // + TopTools_IndexedMapOfShape aME; + TopExp::MapShapes(aF, TopAbs_EDGE, aME); + if (aME.Contains(aE)) { + continue; + } + // + aTolF=BRep_Tool::Tolerance(aF); + aTolE=BRep_Tool::Tolerance(aE); + + const Bnd_Box& aBBF=myDS->GetBoundingBox(nF); + // + // Process each PaveBlock on edge nE + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + // + BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); + for (; anIt.More(); anIt.Next()) { + BOPTools_PaveBlock& aPB=anIt.Value(); + if (aCBAPIF.IsCommonBlock(aPB)) { + continue; + } + // + const IntTools_ShrunkRange& aShrunkRange=aPB.ShrunkRange(); + const IntTools_Range& aSR =aShrunkRange.ShrunkRange(); + const Bnd_Box& aBBE=aShrunkRange.BndBox(); + // + if (aBBF.IsOut (aBBE)) { + continue; + } + // + // EF + IntTools_EdgeFace aEF; + aEF.SetEdge (aE); + aEF.SetFace (aF); + aEF.SetTolE (aTolE); + aEF.SetTolF (aTolF); + aEF.SetDiscretize (aDiscretize); + aEF.SetDeflection (aDeflection); + // + aEF.SetContext(myContext); + // + IntTools_Range anewSR = aSR; + // + // Correction of the Shrunk Range + BOPTools_Tools::CorrectRange(aE, aF, aSR, anewSR); + aEF.SetRange (anewSR); + // + aEF.Perform(); + // + if (aEF.IsDone()) { + Standard_Boolean bCoinsideFlag; + Standard_Integer i, aNbCPrts; + TopAbs_ShapeEnum aType; + // + const IntTools_SequenceOfCommonPrts& aCPrts=aEF.CommonParts(); + // + aNbCPrts=aCPrts.Length(); + for (i=1; i<=aNbCPrts; ++i) { + anIndexIn=0; + // + const IntTools_CommonPrt& aCPart=aCPrts(i); + aType=aCPart.Type(); + // + switch (aType) { + // + case TopAbs_VERTEX: { + Standard_Boolean bIsOnPave1, bIsOnPave2; + Standard_Integer nVF; + Standard_Real aT, aTolToDecide; + TopoDS_Vertex aNewVertex; + // + const IntTools_Range& aR=aCPart.Range1(); + // + // New Vertex + VertexParameter(aCPart, aT); + BOPTools_Tools::MakeNewVertex(aE, aT, aF, aNewVertex); + // + //decide to add pave or not + aTolToDecide=5.e-8; + bIsOnPave1=IsOnPave(anewSR.First(), aR, aTolToDecide); + bIsOnPave2=IsOnPave(anewSR.Last() , aR, aTolToDecide); + // + if (!bIsOnPave1 && !bIsOnPave2) { + nVF=CheckFacePaves(aNewVertex, nF); + if (!nVF) { + // really new vertex + // Add Interference to the Pool + BOPTools_ESInterference anInterf (nE, nF, aCPart); + anIndexIn=aEFs.Append(anInterf); + anInterf.SetNewShape(0); + // + aMapVI.Add(aNewVertex, anIndexIn); + aIMPBx.Add(aPB); + // + myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF); + // + }// if (!nVF) + }// if (!bIsOnPave1 && !bIsOnPave2) + // + //modified by NIZNHY-PKV Fri Apr 18 10:55:38 2008f + else { + const BOPTools_Pave& aPave=(bIsOnPave1)? aPB.Pave1() : aPB.Pave2(); + nVF=aPave.Index(); + const TopoDS_Vertex& aVF=TopoDS::Vertex(myDS->Shape(nVF)); + BOPTools_Tools::UpdateVertex (aVF, aNewVertex); + } + //modified by NIZNHY-PKV Fri Apr 18 10:55:40 2008t + // + }// case TopAbs_VERTEX: + break; + // + case TopAbs_EDGE: { + bCoinsideFlag=BOPTools_Tools::IsBlockInOnFace(aPB, aF, myContext); + if (!bCoinsideFlag) { + break; + } + // + // Fill aMapCB + if (aMapCB.Contains(aPB)) { + TColStd_IndexedMapOfInteger& aMapF=aMapCB.ChangeFromKey(aPB); + aMapF.Add(nF); + } + else { + TColStd_IndexedMapOfInteger aMapF; + aMapF.Add(nF); + aMapCB.Add(aPB, aMapF); + } + // + aIMPBx.Add(aPB); + myIP->Add(nE, nF, Standard_True, NMTDS_TI_EF); + }// case TopAbs_EDGE: + break; + + default: + break; + } // switch (aType) + } // for (i=1; i<=aNbCPrts; i++) + } //if (aEF.IsDone()) + } // for (; anIt.More(); anIt.Next()) + }// for (; myDSIt.More(); myDSIt.Next()) + // + // Treat New vertices + EFNewVertices(aMapVI); + // + // Add draft Common Blocks of EF type + EFCommonBlocks(aMapCB); + // + // Collect all CB we suspected to split by new vertices + NMTTools_ListOfCommonBlock aLCBx; + { + Standard_Integer i, aNbPBx, nEx; + BOPTools_IMapOfPaveBlock aMx; + // + aNbPBx=aIMPBx.Extent(); + for (i=1; i<=aNbPBx; ++i) { + const BOPTools_PaveBlock& aPBx=aIMPBx(i); + nEx=aPBx.OriginalEdge(); + NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nEx)); + if (aLCB.Extent()) { + NMTTools_CommonBlockAPI aCBAPIx(aLCB); + if (aCBAPIx.IsCommonBlock(aPBx)) { + NMTTools_CommonBlock& aCBx=aCBAPIx.CommonBlock(aPBx); + const BOPTools_PaveBlock& aPB1=aCBx.PaveBlock1(); + if (!aMx.Contains(aPB1)){ + aMx.Add(aPB1); + aLCBx.Append(aCBx); + } + } + } + } + } + // + // Split the common blocks above + if (aLCBx.Extent()) { + ReplaceCommonBlocks(aLCBx); + } + // + myIsDone=Standard_True; +} +//======================================================================= +// function:EFCommonBlocks +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EFCommonBlocks + (const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB) +{ + Standard_Integer i, aNbPB, nE, j, aNbF, nF; + // + aNbPB=aMapCB.Extent(); + for (i=1; i<=aNbPB; ++i) { + const BOPTools_PaveBlock& aPB=aMapCB.FindKey(i); + const TColStd_IndexedMapOfInteger& aMapF=aMapCB.FindFromIndex(i); + aNbF=aMapF.Extent(); + // + nE=aPB.OriginalEdge(); + // + NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); + // + NMTTools_CommonBlockAPI aCBAPI(aLCB); + if (aCBAPI.IsCommonBlock(aPB)) { + NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); + for (j=1; j<=aNbF; ++j) { + nF=aMapF(j); + aCB.AddFace(nF); + } + } + else { + NMTTools_CommonBlock aCB; + // + aCB.AddPaveBlock(aPB); + for (j=1; j<=aNbF; ++j) { + nF=aMapF(j); + aCB.AddFace(nF); + } + aLCB.Append(aCB); + } + } +} +//======================================================================= +// function:EFNewVertices +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EFNewVertices + (const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) +{ + Standard_Integer i, j, aNb, aNewShape, aFlag, iX, aNbVV, aNbSimple; + Standard_Integer aWhat, aWith, nE, nF, nV, aNbIEF, aNbEdges, iTmp; + Standard_Real aT; + TopoDS_Compound aCompound; + TopoDS_Vertex aNewVertex; + BRep_Builder aBB; + BOPTools_Pave aPave; + NMTTools_IndexedDataMapOfIndexedMapOfInteger aMNVE, aMNVIEF; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + TopTools_IndexedMapOfShape aMNVComplex, aMNVSimple; + // + aNb=aMapVI.Extent(); + if (!aNb) { // no new vertices, no new problems + return; + } + // + BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences(); + // + // 0. + if (aNb==1) { + aNewVertex=TopoDS::Vertex(aMapVI.FindKey(1)); + EFNewVertices(aNewVertex, aMapVI); + return; + } + // + // 1. Make compound from new vertices + aBB.MakeCompound(aCompound); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aV=aMapVI.FindKey(i); + aBB.Add(aCompound, aV); + } + // + // 2. VV intersection between these vertices + // using the auxiliary Filler + NMTTools_PaveFiller tPF; + // + tPF.SetCompositeShape(aCompound); + // + tPF.Init(); + tPF.PerformVV(); + // + NMTDS_ShapesDataStructure& tDS=*(tPF.DS()); + NMTDS_InterfPool& tInterfPool=*(tPF.IP()); + BOPTools_CArray1OfVVInterference& aVVInterfs=tInterfPool.VVInterferences(); + // + // 3. Separate Comlex and Simple new vertices + aNbVV=aVVInterfs.Extent(); + for (i=1; i<=aNbVV; ++i) { + const BOPTools_VVInterference& aVV=aVVInterfs(i); + aVV.Indices(aWhat, aWith); + const TopoDS_Shape& aV1=tDS.Shape(aWhat); + const TopoDS_Shape& aV2=tDS.Shape(aWith); + aMNVComplex.Add(aV1); + aMNVComplex.Add(aV2); + } + // + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aV=aMapVI.FindKey(i); + if (!aMNVComplex.Contains(aV)) { + aMNVSimple.Add(aV); + } + } + // + // 4. Treat Simple new Vertices + aNbSimple=aMNVSimple.Extent(); + for (i=1; i<=aNbSimple; ++i) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aMNVSimple(i)); + EFNewVertices(aV, aMapVI); + } + // + // 3. Fill Maps : NewVertex-edges (aMNVE) + // NewVertex-interferences (aMNVIEE) + aNb=aVVInterfs.Extent(); + for (i=1; i<=aNb; ++i) { + const BOPTools_VVInterference& aVV=aVVInterfs(i); + aNewShape=aVV.NewShape(); + if (!aNewShape) { + continue; + } + // + if (!aMNVE.Contains(aNewShape)) { + TColStd_IndexedMapOfInteger aMx; + aMNVE.Add(aNewShape, aMx); + } + if (!aMNVIEF.Contains(aNewShape)) { + TColStd_IndexedMapOfInteger aMx; + aMNVIEF.Add(aNewShape, aMx); + } + // + TColStd_IndexedMapOfInteger& aME=aMNVE.ChangeFromKey(aNewShape); + TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.ChangeFromKey(aNewShape); + // + aVV.Indices(aWhat, aWith); + //aWhat + const TopoDS_Shape& aV1=tDS.Shape(aWhat); + iX=aMapVI.FindFromKey(aV1); + const BOPTools_ESInterference& aEF1=aEFs(iX); + aEF1.Indices(nE, nF); + // + if (myDS->GetShapeType(nF)==TopAbs_EDGE) { + iTmp=nE; + nE=nF; + nF=iTmp; + } + aME.Add(nE); + aMIEF.Add(iX); + //aWith + const TopoDS_Shape& aV2=tDS.Shape(aWith); + iX=aMapVI.FindFromKey(aV2); + const BOPTools_ESInterference& aEF2=aEFs(iX); + aEF2.Indices(nE, nF); + // + if (myDS->GetShapeType(nF)==TopAbs_EDGE) { + iTmp=nE; + nE=nF; + nF=iTmp; + } + aME.Add(nE); + aMIEF.Add(iX); + }// for (i=1; i<=aNb; ++i) { + // + // 4. Process new vertices + aNb=aMNVE.Extent(); + for (i=1; i<=aNb; ++i) { // xx + // + // new Vertex + nV=aMNVE.FindKey(i); + aNewVertex=TopoDS::Vertex(tDS.Shape(nV)); + // + // Insert New Vertex in DS; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + aNewShape=myDS->NumberOfInsertedShapes(); + myDS->SetState (aNewShape, BooleanOperations_ON); + // + // Update index of NewShape in EF interferences + const TColStd_IndexedMapOfInteger& aMIEF=aMNVIEF.FindFromKey(nV); + aNbIEF=aMIEF.Extent(); + for (j=1; j<=aNbIEF; ++j) { + iX=aMIEF(j); + BOPTools_ESInterference& aEF=aEFs(iX); + aEF.SetNewShape(aNewShape); + } + // + // Update Paves on all edges + const TColStd_IndexedMapOfInteger& aME=aMNVE(i); + aNbEdges=aME.Extent(); + for (j=1; j<=aNbEdges; ++j) { + nE=aME(j); + const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv + // + aFlag=myContext->ComputeVE (aNewVertex, aE, aT); + // + if (!aFlag) { + aPave.SetInterference(-1); + aPave.SetType (BooleanOperations_EdgeSurface); + aPave.SetIndex(aNewShape); + aPave.SetParam(aT); + // + BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); + aPaveSet.Append(aPave); + } + } + } +} +//======================================================================= +// function:EFNewVertices +// purpose: +//======================================================================= + void NMTTools_PaveFiller::EFNewVertices + (const TopoDS_Vertex& aNewVertex, + const BooleanOperations_IndexedDataMapOfShapeInteger& aMapVI) +{ + Standard_Integer i, aNewShape, nE, nF; + Standard_Real aT; + BOPTools_Pave aPave; + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences(); + // + // Insert New Vertex in DS; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + aNewShape=myDS->NumberOfInsertedShapes(); + myDS->SetState (aNewShape, BooleanOperations_ON); + // + // Insert New Vertex in EFInterference + i=aMapVI.FindFromKey(aNewVertex); + BOPTools_ESInterference& aEFInterf= aEFs(i); + aEFInterf.SetNewShape(aNewShape); + // Extract interference info + aEFInterf.Indices(nE, nF); + if (myDS->GetShapeType(nF)==TopAbs_EDGE) { + nE=nF; + } + const IntTools_CommonPrt& aCPart=aEFInterf.CommonPrt(); + VertexParameter(aCPart, aT); + // + // Pave for edge nE + aPave.SetInterference(i); + aPave.SetType (BooleanOperations_EdgeSurface); + aPave.SetIndex(aNewShape); + aPave.SetParam(aT); + // Append the Pave to the myPavePoolNew + BOPTools_PaveSet& aPaveSet=myPavePoolNew(myDS->RefEdge(nE)); + aPaveSet.Append(aPave); + // +} +//======================================================================= +// function: CheckFacePaves +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::CheckFacePaves + (const TopoDS_Vertex& aNewVertex, + const Standard_Integer nF) +{ + Standard_Integer nEF, nVF, iFlag, i, aNbV, iRet; + BOPTools_ListIteratorOfListOfPave anIt; + TColStd_IndexedMapOfInteger aMVF; + // + iRet=0; + // + BooleanOperations_OnceExplorer aExp(*myDS); + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nEF=aExp.Current(); + BOPTools_PaveSet& aPaveSet=myPavePool(myDS->RefEdge(nEF)); + const BOPTools_ListOfPave& aLP=aPaveSet.Set(); + anIt.Initialize(aLP); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPave=anIt.Value(); + nVF=aPave.Index(); + aMVF.Add(nVF); + } + } + // + aNbV=aMVF.Extent(); + for (i=1; i<=aNbV; ++i) { + nVF=aMVF(i); + const TopoDS_Vertex aVF=TopoDS::Vertex(myDS->Shape(nVF)); + iFlag=IntTools_Tools::ComputeVV(aNewVertex, aVF); + if (!iFlag) { + return nVF; + } + } + return iRet; +} +// +//======================================================================= +// function: VertexParameter +// purpose: +//======================================================================= +void VertexParameter(const IntTools_CommonPrt& aCPart, + Standard_Real& aT) +{ + const IntTools_Range& aR=aCPart.Range1(); + aT=0.5*(aR.First()+aR.Last()); + if((aCPart.VertexParameter1() >= aR.First()) && + (aCPart.VertexParameter1() <= aR.Last())) { + aT = aCPart.VertexParameter1(); + } +} +//======================================================================= +// function: IsOnPave +// purpose: +//======================================================================= +Standard_Boolean IsOnPave(const Standard_Real& aTR, + const IntTools_Range& aCPRange, + const Standard_Real& aTolerance) +{ + Standard_Boolean bIsOnPave; + Standard_Real aT1, aT2, dT1, dT2; + // + aT1=aCPRange.First(); + aT2=aCPRange.Last(); + bIsOnPave=(aTR>=aT1 && aTR<=aT1); + if (bIsOnPave) { + return bIsOnPave; + } + // + dT1=Abs(aTR-aT1); + dT2=Abs(aTR-aT2); + bIsOnPave=(dT1<=aTolerance || dT2<=aTolerance); + return bIsOnPave; +} diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller_6.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller_6.cxx new file mode 100644 index 000000000..96efa6914 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller_6.cxx @@ -0,0 +1,1605 @@ +// 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: NMTTools_PaveFiller_6.cxx +// Created: Fri Dec 19 10:27:31 2003 +// 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 +#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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static + Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, + const Handle(IntTools_Context)& aCtx); + +//======================================================================= +// function: PerformFF +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PerformFF() +{ + myIsDone=Standard_False; + // + Standard_Boolean bToApproxC3d, bToApproxC2dOnS1, bToApproxC2dOnS2, bIsDone; + Standard_Boolean bJustAdd, bToSplit; + Standard_Integer n1, n2, anIndexIn, nF1, nF2, aBlockLength, aNbFFs; + Standard_Integer aNbCurves, aNbPoints; + Standard_Real anApproxTol, aTolR3D, aTolR2D; + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMapWhat, aMapWith; + IntTools_SequenceOfPntOn2Faces aPnts; + IntTools_SequenceOfCurves aCvs; + // + BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); + // + // F/F Interferences [BooleanOperations_SurfaceSurface] + myDSIt->Initialize(TopAbs_FACE, TopAbs_FACE); + // + // BlockLength correction + aNbFFs=myDSIt->BlockLength(); + aBlockLength=aFFs.BlockLength(); + if (aNbFFs > aBlockLength) { + aFFs.SetBlockLength(aNbFFs); + } + // + //modified by NIZNHY-PKV Thu Sep 15 08:02:52 2011f + bToSplit=Standard_False; + //modified by NIZNHY-PKV Thu Sep 15 08:02:55 2011t + // + for (; myDSIt->More(); myDSIt->Next()) { + myDSIt->Current(n1, n2, bJustAdd); + // + nF1 = n2; + nF2 = n1; + if(n1 < n2) { + nF1 = n1; + nF2 = n2; + } + anIndexIn=0; + aPnts.Clear(); + aCvs.Clear(); + // + const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv + const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv + // + // FF + bToApproxC3d = mySectionAttribute.Approximation(); + bToApproxC2dOnS1 = mySectionAttribute.PCurveOnS1(); + bToApproxC2dOnS2 = mySectionAttribute.PCurveOnS2(); + // + anApproxTol=1.e-7; + // + IntTools_FaceFace aFF; + // + aFF.SetParameters (bToApproxC3d, bToApproxC2dOnS1, + bToApproxC2dOnS2, anApproxTol); + // + aFF.Perform(aF1, aF2); + // + bIsDone=aFF.IsDone(); + // + if (!bIsDone) { + BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); + anIndexIn=aFFs.Append(anInterf); + continue; + } + // + aTolR3D=aFF.TolReached3d(); + aTolR2D=aFF.TolReached2d(); + if (aTolR3D < 1.e-7){ + aTolR3D=1.e-7; + } + // + //modified by NIZNHY-PKV Thu Sep 15 08:03:02 2011f +#if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher + aFF.PrepareLines3D(bToSplit); +#else + aFF.PrepareLines3D(); +#endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher + //modified by NIZNHY-PKV Thu Sep 15 08:03:04 2011t + // + const IntTools_SequenceOfCurves& aCvsX=aFF.Lines(); + const IntTools_SequenceOfPntOn2Faces& aPntsX=aFF.Points(); + // + aNbCurves=aCvsX.Length(); + aNbPoints=aPntsX.Length(); + // + if (!aNbCurves && !aNbPoints) { + BOPTools_SSInterference anInterf (nF1, nF2, 1.e-07, 1.e-07, aCvs, aPnts); + anIndexIn=aFFs.Append(anInterf); + continue; + } + // + { + BOPTools_SSInterference anInterf (nF1, nF2, aTolR3D, aTolR2D, aCvsX, aPntsX); + anIndexIn=aFFs.Append(anInterf); + } + // + }// for (; myDSIt.More(); myDSIt.Next()) + // + myIsDone=Standard_True; +} + +//======================================================================= +// function: MakeBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::MakeBlocks() +{ + myIsDone=Standard_False; + // + Standard_Boolean bIsExistingPaveBlock, bIsValidIn2D, bIsCoincided; + Standard_Boolean bIsMicroEdge, bHasES; + Standard_Integer i, aNbFFs, nF1, nF2; + Standard_Integer nV1, nV2, j, aNbCurves; + Standard_Real aTolR3D, aTol2D, aT1, aT2, aTolPPC=Precision::PConfusion(); + TopoDS_Face aF1, aF2; + NMTTools_IndexedDataMapOfShapePaveBlock aMEPB; + BooleanOperations_IndexedDataMapOfShapeInteger aMapEI; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); + // + + // + // 1. Make Section Edges from intersection curves + // between each pair of faces + aNbFFs=aFFs.Extent(); + if (!aNbFFs) { + return; + } + // + FillFaceInfo(); + // + for (i=1; i<=aNbFFs; ++i) { + BOPTools_ListOfPaveBlock aLPB; + TColStd_MapOfInteger aMVStick; + TopTools_ListOfShape aLSE; + TColStd_ListOfInteger aLNE; + BOPTools_PaveSet aPSF; + NMTTools_MapOfPaveBlock aMPBX; + TColStd_MapIteratorOfMapOfInteger aItMI; + NMTTools_MapIteratorOfMapOfPaveBlock aItMPB; + // + BOPTools_SSInterference& aFFi=aFFs(i); + // + // Faces + aFFi.Indices(nF1, nF2); + aF1=*((TopoDS_Face*)(&myDS->Shape(nF1))); + aF2=*((TopoDS_Face*)(&myDS->Shape(nF2))); + // + SharedEdges(nF1, nF2, aLNE, aLSE); + aFFi.SetSharedEdges(aLNE); + // + // aMVStick + const NMTTools_FaceInfo& aFI1=myFaceInfo.Find(nF1); + const NMTTools_FaceInfo& aFI2=myFaceInfo.Find(nF2); + // + const TColStd_MapOfInteger& aMVOn1=aFI1.VerticesOn(); + const TColStd_MapOfInteger& aMVIn1=aFI1.VerticesIn(); + const TColStd_MapOfInteger& aMVOn2=aFI2.VerticesOn(); + const TColStd_MapOfInteger& aMVIn2=aFI2.VerticesIn(); + // + for (j=0; j<2; ++j) { + const TColStd_MapOfInteger& aMV1=(!j) ? aMVOn1 :aMVIn1; + aItMI.Initialize(aMV1); + for (; aItMI.More(); aItMI.Next()) { + nV1=aItMI.Key(); + if (aMVOn2.Contains(nV1) || aMVIn2.Contains(nV1)) { + aMVStick.Add(nV1); + } + } + } + // + // aLPB + const NMTTools_MapOfPaveBlock& aMPBIn1=aFI1.PaveBlocksIn(); + const NMTTools_MapOfPaveBlock& aMPBOn1=aFI1.PaveBlocksOn(); + const NMTTools_MapOfPaveBlock& aMPBIn2=aFI2.PaveBlocksIn(); + const NMTTools_MapOfPaveBlock& aMPBOn2=aFI2.PaveBlocksOn(); + // + aMPBX.Clear(); + for (j=0; j<4; ++j) { + NMTTools_MapOfPaveBlock *pMPB; + // + if (!j) { + pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn1); + } + else if (j==1) { + pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn1); + } + else if (j==2) { + pMPB=((NMTTools_MapOfPaveBlock*)&aMPBIn2); + } + else if (j==3) { + pMPB=((NMTTools_MapOfPaveBlock*)&aMPBOn2); + } + // + const NMTTools_MapOfPaveBlock& aMPB=*pMPB; + aItMPB.Initialize(aMPB); + for (; aItMPB.More(); aItMPB.Next()) { + const BOPTools_PaveBlock& aPB=aItMPB.Key(); + if (aMPBX.Add(aPB)) { + aLPB.Append(aPB); + } + // + else { + if (j>1) { + aFFi.AppendBlock(aPB); + } + } + // + } + } + // + BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); + aNbCurves=aSCvs.Length(); + if (!aNbCurves) { + continue; + } + // + aTolR3D=aFFi.TolR3D(); + aTol2D=(aTolR3D < 1.e-3) ? 1.e-3 : aTolR3D; + // + CorrectTolR3D(aFFi, aMVStick, aTolR3D); + // + PrepareSetForFace (nF1, nF2, aLPB, aPSF); + // + // Put Paves On Curves + for (j=1; j<=aNbCurves; ++j) { + BOPTools_Curve& aBC=aSCvs(j); + const IntTools_Curve& aC=aBC.Curve(); + // DEBUG f + Handle(Geom_Curve) aC3D = aC.Curve(); + // DEBUG t + PutPaveOnCurve (aPSF, aTolR3D, aBC); + } + // + // Put bounding paves on curves + for (j=1; j<=aNbCurves; ++j) { + BOPTools_Curve& aBC=aSCvs(j); + PutBoundPaveOnCurve (aBC, aFFi); + } + //modified by NIZNHY-PKV Wed Sep 14 13:12:14 2011f +#if OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher + // + // Put closing pave if needded + for (j=1; j<=aNbCurves; ++j) { + BOPTools_Curve& aBC=aSCvs(j); + PutClosingPaveOnCurve (aBC, aFFi); + } +#endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher + //modified by NIZNHY-PKV Wed Sep 14 13:12:17 2011t + // + // Pave Blocks on Curves + bHasES=Standard_False; + for (j=1; j<=aNbCurves; ++j) { + BOPTools_Curve& aBC=aSCvs(j); + const IntTools_Curve& aIC= aBC.Curve(); + BOPTools_PaveSet& aPaveSet=aBC.Set(); + // + BOPTools_PaveBlockIterator aPBIter(0, aPaveSet); + for (; aPBIter.More(); aPBIter.Next()) { + BOPTools_PaveBlock& aPBNew=aPBIter.Value(); + aPBNew.SetCurve(aIC); + aPBNew.SetFace1(nF1); + aPBNew.SetFace2(nF2); + // + nV1=aPBNew.Pave1().Index(); + nV2=aPBNew.Pave2().Index(); + aT1=aPBNew.Pave1().Param(); + aT2=aPBNew.Pave2().Param(); + // + if((nV1==nV2) && (Abs(aT2 - aT1) < aTolPPC)) { + continue;// mkk ft ??? + } + // + // 1 + bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLPB, aTolR3D); + if (bIsExistingPaveBlock) { + continue; + } + // + bIsCoincided=CheckCoincidence(aPBNew, aLPB); + if(bIsCoincided) { + continue; + } + // + // 2 + bIsExistingPaveBlock=IsExistingPaveBlock(aPBNew, aLSE, aTolR3D); + if (bIsExistingPaveBlock) { + continue; + } + // + // Checking of validity in 2D + // + bIsValidIn2D=myContext->IsValidBlockForFaces(aT1, aT2, aIC, aF1, aF2, aTol2D); + if (!bIsValidIn2D) { + continue; + } + // + // + // Make Section Edge + TopoDS_Edge aES; + // + const TopoDS_Vertex aV1=TopoDS::Vertex(myDS->Shape(nV1)); + const TopoDS_Vertex aV2=TopoDS::Vertex(myDS->Shape(nV2)); + // + { + Standard_Real aT; + // + myContext->IsVertexOnLine(aV1, aIC, aTolR3D, aT); + BOPTools_Tools::UpdateVertex (aIC, aT, aV1); + // + myContext->IsVertexOnLine(aV2, aIC, aTolR3D, aT); + BOPTools_Tools::UpdateVertex (aIC, aT, aV2); + } + // + BOPTools_Tools::MakeSectEdge (aIC, aV1, aT1, aV2, aT2, aES); + // + NMTTools_Tools::UpdateEdge (aES, aTolR3D); + bIsMicroEdge=IsMicroEdge(aES, myContext); + if (bIsMicroEdge) { + continue; + } + // + { + Handle(Geom2d_Curve) aC2D1, aC2D2; + // + aC2D1=aIC.FirstCurve2d(); + aC2D2=aIC.SecondCurve2d(); + // + NMTTools_Tools::MakePCurve(aES, aF1, aC2D1); + NMTTools_Tools::MakePCurve(aES, aF2, aC2D2); + } + // + aMEPB.Add(aES, aPBNew); + aMapEI.Add(aES, i); + // + bHasES=Standard_True; + }// for (; aPBIter.More(); aPBIter.Next()) + } // end of for (j=1; j<=aNbCurves; ++j) + // qqf + if (bHasES) { + myIP->Add(nF1, nF2, Standard_True, NMTDS_TI_FF); + } + // qqt + }// for (i=1; i<=aNbFFs; ++i) + //============================================================= + // + // II. Post treatment + // + // Input data: aMEPB, aMapEI + // Result : section edges in myDS + // + Standard_Integer aNbSE; + // + aNbSE=aMEPB.Extent(); + if (!aNbSE) { + // there is nothing to do here + return; + } + // + BRep_Builder aBB; + TopoDS_Compound aCompound; + // + // 1. Make compound from SE + aBB.MakeCompound(aCompound); + for (i=1; i<=aNbSE; ++i) { + const TopoDS_Shape& aSE=aMEPB.FindKey(i); + aBB.Add(aCompound, aSE); + } + // + // + // 2. Intersect SE using auxiliary Filler + NMTTools_PaveFiller tPF; + // + tPF.SetCompositeShape(aCompound); + // + // 2.1.VV + tPF.Init(); + tPF.PerformVV(); + // + // 2.2.VE + tPF.myPavePool.Resize (tPF.myNbEdges); + tPF.PrepareEdges(); + tPF.PerformVE(); + // + // 2.3.VF + tPF.PerformVF(); + // + // 2.4.EE + tPF.myCommonBlockPool.Resize (tPF.myNbEdges); + tPF.mySplitShapesPool.Resize (tPF.myNbEdges); + tPF.myPavePoolNew .Resize (tPF.myNbEdges); + + tPF.PreparePaveBlocks(TopAbs_VERTEX, TopAbs_EDGE); + tPF.PreparePaveBlocks(TopAbs_EDGE, TopAbs_EDGE); + // + tPF.PerformEE(); + // + tPF.RefinePavePool (); + // + tPF.myPavePoolNew.Destroy(); + // + tPF.MakeSplitEdges(); + tPF.UpdateCommonBlocks(); + // + // 3. Treatment of the result of intersection + // + Standard_Integer aNbOld, aNbLines, aNbPB, mV1, mV2, nE, mE, iFF; + TopAbs_ShapeEnum aType; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTColStd_IndexedDataMapOfIntegerInteger aMNewOld; + // + const NMTDS_ShapesDataStructure& tDS=*(tPF.DS()); + const BOPTools_SplitShapesPool& aSSP=tPF.mySplitShapesPool; + const NMTTools_CommonBlockPool& aCBP=tPF.myCommonBlockPool; + // + aNbLines=tDS.NumberOfInsertedShapes(); + aNbOld=tDS.NumberOfShapesOfTheObject(); + // + // 3.1 Links between indices in tDS and DS (kept in aMNewOld) + // + // 3.1.1.Old vertices [ links ] + for (i=1; i<=aNbOld; ++i) { + const TopoDS_Shape& aV=tDS.Shape(i); + aType=aV.ShapeType(); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + for (j=1; j<=aNbSE; ++j) { + const BOPTools_PaveBlock& aPBSE=aMEPB(j); + nV1=aPBSE.Pave1().Index(); + const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv + if (aV1.IsSame(aV)) { + aMNewOld.Add(i, nV1); + break; + } + nV2=aPBSE.Pave2().Index(); + const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv + if (aV2.IsSame(aV)) { + aMNewOld.Add(i, nV2); + break; + } + } + } + // + // 3.1.2. New vertices [ links ] + i=tDS.NumberOfSourceShapes()+1; + for (; i<=aNbLines; ++i) { + const TopoDS_Shape& aV=tDS.Shape(i); + aType=aV.ShapeType(); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + // Insert new vertex in myDS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq); + nV1=myDS->NumberOfInsertedShapes(); + // link + aMNewOld.Add(i, nV1); + } + // + // 3.2. Treatment of section edges (SE) + for (i=1; i<=aNbOld; ++i) { + const TopoDS_Shape& aE=tDS.Shape(i); + aType=aE.ShapeType(); + if (aType!=TopAbs_EDGE) { + continue; + } + // + // block of section edge that we already have for this SE + BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE); + // + // Corresponding FF-interference + iFF=aMapEI.FindFromKey(aE); + BOPTools_SSInterference& aFFi=aFFs(iFF); + BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); + // + BOPTools_Curve& aBC=aSCvs(1); + // + const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i)); + aNbPB=aLPB.Extent(); + // + if (!aNbPB) { + // no pave blocks -> use aPBSE and whole edge aE + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + nV1=aPBSE.Pave1().Index(); + const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv + nV2=aPBSE.Pave2().Index(); + const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv + // + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + // + myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq); + nE=myDS->NumberOfInsertedShapes(); + // + aPBSE.SetEdge(nE); + aBC.AppendNewBlock(aPBSE); + // + continue; + } + // + nF1=aPBSE.Face1(); + nF2=aPBSE.Face2(); + // + const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i)); + NMTTools_CommonBlockAPI aCBAPI(aLCB); + // + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + BOPTools_PaveBlock aPB=aIt.Value(); + // + const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1)); + const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2)); + // + if (aCBAPI.IsCommonBlock(aPB)) { + // it can be Common Block + Standard_Real aTolEx; + Handle(Geom2d_Curve) aC2D1, aC2D2; + TopoDS_Face aF1FWD, aF2FWD; + // + NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); + //const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); + // + aPB=aCB.PaveBlock1(); + mE=aPB.Edge(); // index of edge in tDS + const TopoDS_Edge& aEx=TopoDS::Edge(tDS.Shape(mE)); + aTolEx=BRep_Tool::Tolerance(aEx); + // + aF1FWD=aF1; + aF1FWD.Orientation(TopAbs_FORWARD); + aF2FWD=aF2; + aF2FWD.Orientation(TopAbs_FORWARD); + // + NMTTools_Tools::MakePCurve(aEx, aF1FWD, aC2D1); + NMTTools_Tools::MakePCurve(aEx, aF2FWD, aC2D2); + NMTTools_Tools::UpdateEdge (aEx, aTolEx); + } //if (aCBAPI.IsCommonBlock(aPB)) + // + // new SE + mE=aPB.Edge(); // index of edge in tDS + const TopoDS_Shape& aSp=tDS.Shape(mE); + // + const BOPTools_Pave& aPave1=aPB.Pave1(); + aT1=aPave1.Param(); + mV1=aPave1.Index(); // index in tDS + nV1=aMNewOld.FindFromKey(mV1); // index in myDS + const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv + // + const BOPTools_Pave& aPave2=aPB.Pave2(); + aT2=aPave2.Param(); + mV2=aPave2.Index(); + nV2=aMNewOld.FindFromKey(mV2); + const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv + // + if (!aMNewOld.Contains(mE)) { + // add new SE to the myDS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); + + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + + myDS->InsertShapeAndAncestorsSuccessors(aSp, anASSeq); + nE=myDS->NumberOfInsertedShapes(); + // + aMNewOld.Add(mE, nE); + } + else { + nE=aMNewOld.FindFromKey(mE); + } + // Form PaveBlock; + BOPTools_PaveBlock aPBx; + BOPTools_Pave aP1, aP2; + // + aPBx.SetFace1(nF1); + aPBx.SetFace1(nF2); + // + aP1.SetIndex(nV1); + aP1.SetParam(aT1); + // + aP2.SetIndex(nV2); + aP2.SetParam(aT2); + // + aPBx.SetPave1(aP1); + aPBx.SetPave2(aP2); + // + aPBx.SetEdge(nE); + // + aBC.AppendNewBlock(aPBx); + }// for (; aIt.More(); aIt.Next()) + }// for (i=1; i<=aNbOld; ++i) + // + myIsDone=Standard_True; +} + +//======================================================================= +// function: MakePCurves +// purpose: +//======================================================================= +void NMTTools_PaveFiller::MakePCurves() +{ + Standard_Integer i, aNb, nF1, nF2, nE; + Standard_Integer aNbCB, aNbF, nSp, nF; + TopAbs_ShapeEnum aType; + TopoDS_Face aF1FWD, aF2FWD; + TColStd_ListIteratorOfListOfInteger aItF; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + NMTTools_ListIteratorOfListOfCommonBlock aItCB; + // + BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); + // + aNb=aFFs.Extent(); + for (i=1; i<=aNb; i++) { + BOPTools_SSInterference& aFF=aFFs(i); + aFF.Indices(nF1, nF2); + // + const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv + const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv + // + aF1FWD=aF1; + aF1FWD.Orientation(TopAbs_FORWARD); + aF2FWD=aF2; + aF2FWD.Orientation(TopAbs_FORWARD); + // + // In, On parts processing + const BOPTools_ListOfPaveBlock& aLPBInOn=aFF.PaveBlocks(); + // + anIt.Initialize(aLPBInOn); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + nE=aPB.Edge(); + const TopoDS_Edge aE=TopoDS::Edge(myDS->Shape(nE));//mpv + + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF1FWD); + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aF2FWD); + } + } + // Check common blocks between edges and faces + // Build P-Curves if they were not built in previos block. + // The main case is :arguments for e.g aEdge, aFace -> no FFs, + // but p-curves are needed. + // + aNb=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=aNb; ++i) { + const TopoDS_Shape& aS=myDS->Shape(i); + aType=aS.ShapeType(); + // + if (aType!=TopAbs_EDGE) { + continue; + } + const TopoDS_Edge& aE=TopoDS::Edge(aS); + // + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i)); + aNbCB=aLCB.Extent(); + if (!aNbCB) { + continue; + } + // + aItCB.Initialize(aLCB); + for (; aItCB.More(); aItCB.Next()) { + const NMTTools_CommonBlock& aCB=aItCB.Value(); + const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1(); + // + const TColStd_ListOfInteger& aLF=aCB.Faces(); + aNbF=aLF.Extent(); + if (!aNbF) { + continue; + } + // + nSp=aPB1.Edge(); + const TopoDS_Edge aSp=TopoDS::Edge(myDS->Shape(nSp));//mpv + // + aItF.Initialize(aLF); + for (; aItF.More(); aItF.Next()) { + nF=aItF.Value(); + aF1FWD=TopoDS::Face(myDS->Shape(nF)); + aF1FWD.Orientation(TopAbs_FORWARD); + // + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aSp, aF1FWD); + } // for (; aItCB.More(); aItCB.Next()) { + }//if (aS.ShapeType()==TopAbs_EDGE) { + } +} + +//======================================================================= +// function: IsExistingPaveBlock +// purpose: +//======================================================================= +Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew, + const BOPTools_ListOfPaveBlock& aLPBR, + const Standard_Real aTolR3D) +{ + Standard_Boolean bFlag; + Standard_Integer nVNew1, nVNew2, nV1, nV2, iC; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + bFlag=Standard_False; + nVNew1=aPBNew.Pave1().Index(); + nVNew2=aPBNew.Pave2().Index(); + // + anIt.Initialize(aLPBR); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBR=anIt.Value(); + nV1=aPBR.Pave1().Index(); + nV2=aPBR.Pave2().Index(); + if (nVNew1==nV1 || nVNew1==nV2 || nVNew2==nV1 || nVNew2==nV2) { + // + iC=CheckIntermediatePoint(aPBNew, aPBR, aTolR3D); + if (!iC) { + return !bFlag; + } + } + } + return bFlag; +} + +//======================================================================= +// function: IsExistingPaveBlock +// purpose: +//======================================================================= +Standard_Boolean NMTTools_PaveFiller::IsExistingPaveBlock(const BOPTools_PaveBlock& aPBNew, + const TopTools_ListOfShape& aLSE, + const Standard_Real aTolR3D) +{ + Standard_Boolean bFlag; + Standard_Integer aNbSE, iC; + Standard_Real aTolE, aTol; + TopTools_ListIteratorOfListOfShape anIt; + // + bFlag=Standard_False; + // + aNbSE=aLSE.Extent(); + if (!aNbSE) { + return bFlag; + } + // + anIt.Initialize(aLSE); + for (; anIt.More(); anIt.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(anIt.Value()); + aTolE=BRep_Tool::Tolerance(aE); + aTol=aTolR3D; + if (aTolE>aTol) { + aTol=aTolE; + } + iC=CheckIntermediatePoint(aPBNew, aE, aTol); + if (!iC) { + return !bFlag; + } + } + return bFlag; +} + +//======================================================================= +// function: CheckIntermediatePoint +// purpose: +//======================================================================= +Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, + const BOPTools_PaveBlock& aPBR, + const Standard_Real aTolC) +{ + Standard_Integer iVM, nE2; + // + nE2=aPBR.Edge(); + const TopoDS_Edge aE2=TopoDS::Edge(myDS->Shape(nE2));//mpv + iVM=CheckIntermediatePoint(aPB, aE2, aTolC); + // + return iVM; +} + +//======================================================================= +// function: CheckIntermediatePoint +// purpose: +//======================================================================= +Standard_Integer NMTTools_PaveFiller::CheckIntermediatePoint(const BOPTools_PaveBlock& aPB, + const TopoDS_Edge& aE2, + const Standard_Real aTolC) +{ + Standard_Real aT11, aT12, aTM, aTmp; + Standard_Integer iVM; + gp_Pnt aPM; + BRep_Builder aBB; + TopoDS_Vertex aVM; + // + // Vertex + const BOPTools_Pave& aPave11=aPB.Pave1(); + aT11=aPave11.Param(); + // + const BOPTools_Pave& aPave12=aPB.Pave2(); + aT12=aPave12.Param(); + // + aTM=IntTools_Tools::IntermediatePoint (aT11, aT12); + // + const IntTools_Curve& aIC=aPB.Curve(); + aIC.D0(aTM, aPM); + // + aBB.MakeVertex (aVM, aPM, aTolC); + // + iVM=myContext->ComputeVE(aVM, aE2, aTmp); + // + return iVM; +} + +//======================================================================= +// function: PutBoundPaveOnCurve +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PutBoundPaveOnCurve(BOPTools_Curve& aBC, + BOPTools_SSInterference& aFFi) +{ + Standard_Boolean bHasBounds, bVF; + Standard_Integer nF1, nF2; + Standard_Real aT1, aT2, aTolR3D; + gp_Pnt aP1, aP2; + // + const IntTools_Curve& aIC=aBC.Curve(); + bHasBounds=aIC.HasBounds (); + if (!bHasBounds){ + return; + } + // + // Bounds + aIC.Bounds (aT1, aT2, aP1, aP2); + // + // Faces + aFFi.Indices(nF1, nF2); + aTolR3D=aFFi.TolR3D(); + // + const TopoDS_Face aF1=TopoDS::Face(myDS->GetShape(nF1));//mpv + const TopoDS_Face aF2=TopoDS::Face(myDS->GetShape(nF2));//mpv + // + bVF=myContext->IsValidPointForFaces (aP1, aF1, aF2, aTolR3D); + if (bVF) { + PutBoundPaveOnCurve (aP1, aT1, aBC, aFFi); + } + // + bVF=myContext->IsValidPointForFaces (aP2, aF1, aF2, aTolR3D); + if (bVF) { + PutBoundPaveOnCurve (aP2, aT2, aBC, aFFi); + } +} + +//======================================================================= +// function: PutBoundPaveOnCurve +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PutBoundPaveOnCurve(const gp_Pnt& aP, + const Standard_Real aT, + BOPTools_Curve& aBC, + BOPTools_SSInterference& aFFi) +{ + Standard_Boolean bFound1, bFound2; + Standard_Integer nV; + Standard_Real aTolV=aFFi.TolR3D(); + + BOPTools_Pave aPave1, aPave2, aPave; + BOPTools_PaveSet& aCPS=aBC.Set(); + BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet(); + const IntTools_Curve& aIC=aBC.Curve(); + // + bFound1=FindPave(aP, aTolV, aCPS , aPave1); + bFound2=FindPave(aP, aTolV, aFFiPS, aPave2); + // + if (!bFound1 && !bFound2) { + TopoDS_Vertex aNewVertex; + BOPTools_Tools::MakeNewVertex(aP, aTolV, aNewVertex); + // + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + myDS->InsertShapeAndAncestorsSuccessors(aNewVertex, anASSeq); + nV=myDS->NumberOfInsertedShapes(); + aPave.SetIndex(nV); + aPave.SetParam(aT); + + aCPS.Append(aPave); + aFFiPS.Append(aPave); + // + // Append Techno Vertex to the Curve + TColStd_ListOfInteger& aTVs=aBC.TechnoVertices(); + aTVs.Append(nV); + } + if (bFound1 && !bFound2) { + nV=aPave1.Index(); + aPave.SetIndex(nV); + aPave.SetParam(aT); + aFFiPS.Append(aPave); + // + const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv + BOPTools_Tools::UpdateVertex (aIC, aT, aV); + } + + if (!bFound1 && bFound2) { + nV=aPave2.Index(); + aPave.SetIndex(nV); + aPave.SetParam(aT); + aCPS.Append(aPave); + // + const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv + BOPTools_Tools::UpdateVertex (aIC, aT, aV); + } +} + +//======================================================================= +// function: FindPave +// purpose: +//======================================================================= +Standard_Boolean NMTTools_PaveFiller::FindPave(const gp_Pnt& aP, + const Standard_Real aTolPV, + const BOPTools_PaveSet& aPS, + BOPTools_Pave& aPave) +{ + Standard_Integer nV; + Standard_Boolean bIsVertex=Standard_False; + + const BOPTools_ListOfPave& aLP=aPS.Set(); + BOPTools_ListIteratorOfListOfPave anIt(aLP); + for (; anIt.More(); anIt.Next()) { + const BOPTools_Pave& aPC=anIt.Value(); + nV=aPC.Index(); + const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(nV));//mpv + bIsVertex=IntTools_Tools::IsVertex (aP, aTolPV, aV); + if (bIsVertex) { + aPave=aPC; + return bIsVertex; + } + } + return bIsVertex; +} + +//======================================================================= +// function: PrepareSetForFace +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PrepareSetForFace(const Standard_Integer ,//nF1, + const Standard_Integer ,//nF2, + const BOPTools_ListOfPaveBlock& aLPBC, + BOPTools_PaveSet& aPSF) +{ + Standard_Integer nV1, nV2; + TColStd_MapOfInteger aMap; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + anIt.Initialize(aLPBC); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + if (!aMap.Contains(nV1)) { + aMap.Add(nV1); + aPSF.Append(aPave1); + } + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + if (!aMap.Contains(nV2)) { + aMap.Add(nV2); + aPSF.Append(aPave2); + } + } +} + +//======================================================================= +// function: CheckCoincidence +// purpose: +//======================================================================= +Standard_Boolean NMTTools_PaveFiller::CheckCoincidence(const BOPTools_PaveBlock& aPBNew, + const BOPTools_ListOfPaveBlock& aLPBFF) +{ + Standard_Boolean bRet; + Standard_Real aTE; + Standard_Integer nV11, nV12, nV21, nV22, iVV, iVE, nE2; + Standard_Integer iV, iCount, iCountExt; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // V11 + const BOPTools_Pave& aPave11=aPBNew.Pave1(); + nV11=aPave11.Index(); + const TopoDS_Vertex& aV11=TopoDS::Vertex(myDS->Shape(nV11)); + + // V12 + const BOPTools_Pave& aPave12=aPBNew.Pave2(); + nV12=aPave12.Index(); + const TopoDS_Vertex& aV12=TopoDS::Vertex(myDS->Shape(nV12)); + // + iCountExt=1; + iCount=0; + anIt.Initialize(aLPBFF); + for (; anIt.More(); anIt.Next()) { + iCount=0; + // + const BOPTools_PaveBlock& aPBR=anIt.Value(); + // V21 + const BOPTools_Pave& aPave21=aPBR.Pave1(); + nV21=aPave21.Index(); + + // V22 + const BOPTools_Pave& aPave22=aPBR.Pave2(); + nV22=aPave22.Index(); + // + if (nV11==nV21 || nV11==nV22 || nV12==nV21 || nV12==nV22) { + continue; + } + // + // E2 + nE2=aPBR.Edge(); + // + const TopoDS_Vertex& aV21=TopoDS::Vertex(myDS->Shape(nV21)); + const TopoDS_Vertex& aV22=TopoDS::Vertex(myDS->Shape(nV22)); + const TopoDS_Edge& aE2=TopoDS::Edge(myDS->Shape(nE2)); + // + // VV + iV=0; + iVV=IntTools_Tools::ComputeVV (aV11, aV21); + if (!iVV) { + iCount++; + iV++; + if (iCount>iCountExt) { + break; + } + } + // + iVV=IntTools_Tools::ComputeVV (aV11, aV22); + if (!iVV) { + iCount++; + iV++; + if (iCount>iCountExt) { + break; + } + } + // VE + if (!iV) { + iVE=myContext->ComputeVE (aV11, aE2, aTE); + if (!iVE) { + iCount++; + if (iCount>iCountExt) { + break; + } + } + } + // VV + iV=0; + iVV=IntTools_Tools::ComputeVV (aV12, aV21); + if (!iVV) { + iCount++; + iV++; + if (iCount>iCountExt) { + break; + } + } + // + iVV=IntTools_Tools::ComputeVV (aV12, aV22); + if (!iVV) { + iCount++; + iV++; + if (iCount>iCountExt) { + break; + } + } + // VE + if (!iV) { + iVE=myContext->ComputeVE (aV12, aE2, aTE); + if (!iVE) { + iCount++; + if (iCount>iCountExt) { + break; + } + } + } + } // next aPBR + bRet=(Standard_Boolean)(iCount>iCountExt); + return bRet; +} + +//======================================================================= +//function : IsMicroEdge +//purpose : +//======================================================================= +Standard_Boolean IsMicroEdge(const TopoDS_Edge& aE, + const Handle(IntTools_Context)& aCtx) +{ + Standard_Boolean bRet; + Standard_Integer iErr; + Standard_Real aT1, aT2, aTmp; + Handle(Geom_Curve) aC3D; + TopoDS_Vertex aV1, aV2; + IntTools_Range aR; + // + bRet=(BRep_Tool::Degenerated(aE) || + !BRep_Tool::IsGeometric(aE)); + if (bRet) { + return bRet; + } + // + aC3D=BRep_Tool::Curve(aE, aT1, aT2); + TopExp::Vertices(aE, aV1, aV2); + aT1=BRep_Tool::Parameter(aV1, aE); + aT2=BRep_Tool::Parameter(aV2, aE); + if (aT2Shape(nV)); + // + Bnd_Box aBBV; + BRepBndLib::Add(aV, aBBV); + if (aBBC.IsOut(aBBV)){ + continue; + } + // + bIsVertexOnLine=myContext->IsVertexOnLine(aV, aC, aTolR3D, aT); + // + // + if (bIsVertexOnLine) { + BOPTools_Pave aPaveNew(nV, aT, BooleanOperations_SurfaceSurface); + BOPTools_PaveSet& aPS=aBC.Set(); + aPS.Append(aPaveNew); + //<-B + } + } +} +// +//======================================================================= +//function : FillFaceInfo +//purpose : +//======================================================================= +void NMTTools_PaveFiller::FillFaceInfo() +{ + Standard_Integer i, aNbS, aNbFFs, nF, aNbVFs, aNbEFs, j, n1, n2, nX, aNbF; + TopAbs_ShapeEnum aType; + TopoDS_Shape aS; + TColStd_ListIteratorOfListOfInteger aItF; + BOPTools_ListIteratorOfListOfPaveBlock anItPB; + NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo aItMFI; + NMTTools_ListIteratorOfListOfCommonBlock aItCB; + // + myFaceInfo.Clear(); + // + BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); + BOPTools_CArray1OfVSInterference& aVFs=myIP->VSInterferences(); + BOPTools_CArray1OfESInterference& aEFs=myIP->ESInterferences(); + // + aNbFFs=aFFs.Extent(); + if (!aNbFFs) { + return; + } + // + // 0. + for (i=1; i<=aNbFFs; ++i) { + NMTTools_FaceInfo aFI; + // + BOPTools_SSInterference& aFFi=aFFs(i); + aFFi.Indices(n1, n2); + myFaceInfo.Bind(n1, aFI); + myFaceInfo.Bind(n2, aFI); + } + // + // 1. + aNbS=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + aS=myDS->Shape(i); + aType=aS.ShapeType(); + if (aType==TopAbs_EDGE) { + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(i)); + aItCB.Initialize(aLCB); + for (; aItCB.More(); aItCB.Next()) { + const NMTTools_CommonBlock& aCB=aItCB.Value(); + const BOPTools_PaveBlock &aPB1=aCB.PaveBlock1(); + const TColStd_ListOfInteger& aLF=aCB.Faces(); + aNbF=aLF.Extent(); + if (!aNbF) { + continue; + } + // + aItF.Initialize(aLF); + for (; aItF.More(); aItF.Next()) { + nF=aItF.Value(); + if (!myFaceInfo.IsBound(nF)) { + continue; + } + // + NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF); + aFI.ChangePaveBlocksIn().Add(aPB1); + // + n1=aPB1.Pave1().Index(); + n2=aPB1.Pave2().Index(); + aFI.ChangeVerticesIn().Add(n1); + aFI.ChangeVerticesIn().Add(n2); + } + } + }// if (aType==TopAbs_EDGE) { + else if (aType==TopAbs_FACE) { + if (!myFaceInfo.IsBound(i)) { + continue; + } + // + BOPTools_ListOfPaveBlock aLPBOn; + // + nF=i; + NMTTools_FaceInfo& aFI=myFaceInfo.ChangeFind(nF); + // + RealSplitsFace(nF, aLPBOn); + // + anItPB.Initialize(aLPBOn); + for (; anItPB.More(); anItPB.Next()) { + const BOPTools_PaveBlock &aPB=anItPB.Value(); + aFI.ChangePaveBlocksOn().Add(aPB); + // + n1=aPB.Pave1().Index(); + n2=aPB.Pave2().Index(); + aFI.ChangeVerticesOn().Add(n1); + aFI.ChangeVerticesOn().Add(n2); + } + // + }// else if (aType==TopAbs_FACE) { + }// for (i=1; i<=aNbS; ++i) { + // + // 2. + aItMFI.Initialize(myFaceInfo); + for (; aItMFI.More(); aItMFI.Next()) { + nF=aItMFI.Key(); + NMTTools_FaceInfo& aFI=*((NMTTools_FaceInfo*)&aItMFI.Value()); + // + aFI.SetIndex(nF); + // + // + // 2.1 aVFs + aNbVFs=aVFs.Extent(); + for (j=1; j<=aNbVFs; ++j) { + BOPTools_VSInterference& aVFj=aVFs(j); + aVFj.Indices(n1, n2); + if (nF==n1) { + aFI.ChangeVerticesIn().Add(n2); + } + else if (nF==n2){ + aFI.ChangeVerticesIn().Add(n1); + } + }// for (j=1; j<=aNbVFs; ++j) { + // + // 2.2 aEFs + aNbEFs=aEFs.Extent(); + for (j=1; j<=aNbEFs; ++j) { + BOPTools_ESInterference& aEFj=aEFs(j); + aEFj.Indices(n1, n2); + if (!(nF==n1 || nF==n2)) { + continue; + } + // + nX=aEFj.NewShape(); + if (nX<1) { + continue; + } + // + aS=myDS->Shape(nX); + aType=aS.ShapeType(); + if (aType!=TopAbs_VERTEX) { + continue; + } + // + aFI.ChangeVerticesIn().Add(nX); + }// for (j=1; j<=aNbEFs; ++j) { + }// for (; aItMFI.More(); aItMFI.Next()) { +} + + +#include +#include +#include +#include +//======================================================================= +//function : CorrectTolR3D +//purpose : Attempt to correct the value of tolerance aTolR3D for +// the intersection curve in order to +// compel it to pass through the sticks. +// Prerequisites: +// 2. The are based on B-Spline surfaces; +// 1. There is at least the one intersection curve; +// 2. The faces have stick vertices to catch the curve; +// 3. The intersection angle is rather small (0.7-7 deg) +// +//======================================================================= +void NMTTools_PaveFiller::CorrectTolR3D(const BOPTools_SSInterference& aFF, + const TColStd_MapOfInteger& aMVStick, + Standard_Real& aTolR3D) + +{ + Standard_Boolean bHasBounds; + Standard_Integer i, nF[2], nV, aNbCurves; + Standard_Real aT1, aT2, aU, aV, aT, aA, aTolV, aTolVmax; + Standard_Real aTolR, aTolTresh, aAmin, aAmax; + TColStd_MapIteratorOfMapOfInteger aIt; + gp_Pnt aP, aP1, aP2; + gp_Dir aDN[2]; + gp_Vec aVT; + Handle(Geom_Surface) aS[2]; + Handle(Geom_Curve) aC3D; + GeomAdaptor_Surface aGAS; + GeomAbs_SurfaceType aType; + TopoDS_Face aF[2]; + // + aTolTresh=0.0005; + aAmin=0.012;// 0.7-7 deg + aAmax=0.12; + // + if (!aMVStick.Extent()) { + return; + } + // + BOPTools_SSInterference& aFFi=*((BOPTools_SSInterference*)&aFF); + BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves(); + aNbCurves=aSCvs.Length(); + if (aNbCurves!=1){ + return; + } + // + aFFi.Indices(nF[0], nF[1]); + for (i=0; i<2; ++i) { + aF[i]=*((TopoDS_Face*)(&myDS->Shape(nF[i]))); + aS[i]=BRep_Tool::Surface(aF[i]); + aGAS.Load(aS[i]); + aType=aGAS.GetType(); + if (aType!=GeomAbs_BSplineSurface) { + return; + } + } + // + BOPTools_Curve& aBC=aSCvs(1); + const IntTools_Curve& aIC=aBC.Curve(); + bHasBounds=aIC.HasBounds(); + if (!bHasBounds){ + return; + } + // + aIC.Bounds (aT1, aT2, aP1, aP2); + aT=IntTools_Tools::IntermediatePoint(aT1, aT2); + aC3D=aIC.Curve(); + aC3D->D0(aT, aP); + // + for (i=0; i<2; ++i) { + GeomAPI_ProjectPointOnSurf& aPPS=myContext->ProjPS(aF[i]); + aPPS.Perform(aP); + aPPS.LowerDistanceParameters(aU, aV); + BOPTools_Tools3D::GetNormalToSurface(aS[i], aU, aV, aDN[i]); + } + // + aA=aDN[0].Angle(aDN[1]); + aA=fabs(aA); + if (aA > 0.5*M_PI) { + aA = M_PI - aA; + } + // + if (aAaAmax) { + return; + } + // + aTolVmax=-1.; + aIt.Initialize(aMVStick); + for (; aIt.More(); aIt.Next()) { + nV=aIt.Key(); + const TopoDS_Vertex& aV=*((TopoDS_Vertex*)(&myDS->Shape(nV))); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolV>aTolVmax) { + aTolVmax=aTolV; + } + } + // + + aTolR=aTolVmax/aA; + if (aTolR 0x06050100 // For OCCT6.5.2 and higher +//======================================================================= +// function: PutClosingPaveOnCurve +// purpose: +//======================================================================= +void NMTTools_PaveFiller::PutClosingPaveOnCurve(BOPTools_Curve& aBC, + BOPTools_SSInterference& aFFi) +{ + Standard_Boolean bIsClosed, bHasBounds, bAdded; + Standard_Integer nVC, j; + Standard_Real aT[2], aTolR3D, aTC, dT, aTx; + gp_Pnt aP[2] ; + BOPTools_Pave aPVx; + BOPTools_ListIteratorOfListOfPave aItLP; + // + const IntTools_Curve& aIC=aBC.Curve(); + const Handle (Geom_Curve)& aC3D=aIC.Curve(); + if(aC3D.IsNull()) { + return; + } + // + bIsClosed=IntTools_Tools::IsClosed(aC3D); + if (!bIsClosed) { + return; + } + // + bHasBounds=aIC.HasBounds (); + if (!bHasBounds){ + return; + } + // + bAdded=Standard_False; + dT=Precision::PConfusion(); + aTolR3D=aFFi.TolR3D(); + aIC.Bounds (aT[0], aT[1], aP[0], aP[1]); + // + BOPTools_PaveSet& aFFiPS=aFFi.NewPaveSet(); + BOPTools_PaveSet& aCPS=aBC.Set(); + // + const BOPTools_ListOfPave& aLP=aCPS.Set(); + aItLP.Initialize(aLP); + for (; aItLP.More() && !bAdded; aItLP.Next()) { + const BOPTools_Pave& aPC=aItLP.Value(); + nVC=aPC.Index(); + const TopoDS_Vertex aVC=TopoDS::Vertex(myDS->Shape(nVC)); + aTC=aPC.Param(); + // + for (j=0; j<2; ++j) { + if (fabs(aTC-aT[j]) < dT) { + aTx=(!j) ? aT[1] : aT[0]; + aPVx.SetIndex(nVC); + aPVx.SetParam(aTx); + // + aCPS.Append(aPVx); + aFFiPS.Append(aPVx); + // + bAdded=Standard_True; + break; + } + } + } +} +#endif // OCC_VERSION_LARGE > 0x06050100 // For OCCT6.5.2 and higher +//modified by NIZNHY-PKV Wed Sep 14 13:21:17 2011t diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller_7.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller_7.cxx new file mode 100644 index 000000000..8386a9fd6 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller_7.cxx @@ -0,0 +1,817 @@ +// 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: NMTTools_PaveFiller_7.cxx +// 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 +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + + +//======================================================================= +// function: MakeSplitEdges +// purpose: +//======================================================================= +void NMTTools_PaveFiller::MakeSplitEdges() +{ + myIsDone=Standard_False; + // + Standard_Boolean bIsNewVertex1, bIsNewVertex2; + Standard_Integer i, aNbS, nV1, nV2, aNbPaveBlocks, aNewShapeIndex; + Standard_Real t1, t2; + TopAbs_Orientation anOri; + TopoDS_Edge aE, aESplit; + TopoDS_Vertex aV1, aV2; + // + aNbS=myDS->NumberOfShapesOfTheObject(); + for (i=1; i<=aNbS; ++i) { + if (myDS->GetShapeType(i) != TopAbs_EDGE) + continue; + // + // Original Edge + aE=TopoDS::Edge(myDS->Shape(i)); + if (BRep_Tool::Degenerated(aE)){ + continue; + } + // + anOri=aE.Orientation(); + aE.Orientation(TopAbs_FORWARD); + // + // Making Split Edges + // + // Split Set for the Original Edge i + BOPTools_ListOfPaveBlock& aSplitEdges=mySplitShapesPool(myDS->RefEdge(i)); + BOPTools_ListIteratorOfListOfPaveBlock aPBIt(aSplitEdges); + // + aNbPaveBlocks=aSplitEdges.Extent(); + + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPB=aPBIt.Value(); + // aPave1 + const BOPTools_Pave& aPave1=aPB.Pave1(); + nV1=aPave1.Index(); + t1=aPave1.Param(); + aV1=TopoDS::Vertex(myDS->GetShape(nV1)); + aV1.Orientation(TopAbs_FORWARD); + // aPave2 + const BOPTools_Pave& aPave2=aPB.Pave2(); + nV2=aPave2.Index(); + t2=aPave2.Param(); + aV2=TopoDS::Vertex(myDS->GetShape(nV2)); + aV2.Orientation(TopAbs_REVERSED); + //xx + if (aNbPaveBlocks==1) { + bIsNewVertex1=myDS->IsNewShape (nV1); + bIsNewVertex2=myDS->IsNewShape (nV2); + if (!bIsNewVertex1 && !bIsNewVertex2) { + aPB.SetEdge(i); + continue; + } + } + //xx + BOPTools_Tools::MakeSplitEdge(aE, aV1, t1, aV2, t2, aESplit); + // + // Add Split Part of the Original Edge to the DS + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + + anASSeq.SetNewSuccessor(nV1); + anASSeq.SetNewOrientation(aV1.Orientation()); + + anASSeq.SetNewSuccessor(nV2); + anASSeq.SetNewOrientation(aV2.Orientation()); + // + if (anOri==TopAbs_INTERNAL) { + anASSeq.SetNewAncestor(i); + aESplit.Orientation(anOri); + } + // + myDS->InsertShapeAndAncestorsSuccessors(aESplit, anASSeq); + aNewShapeIndex=myDS->NumberOfInsertedShapes(); + myDS->SetState(aNewShapeIndex, BooleanOperations_UNKNOWN); + // + // Fill Split Set for the Original Edge + aPB.SetEdge(aNewShapeIndex); + // + } + } + myIsDone=Standard_True; +} +//======================================================================= +// function: UpdateCommonBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::UpdateCommonBlocks(const Standard_Integer) +{ + Standard_Integer nE, aNbS, nEx, nEMax, j, aNbPoints, aNbLCB, nF; + Standard_Real aTolEx, aTolExMax, aTSRMax[2], aTx[2], aTmp; + TColStd_ListIteratorOfListOfInteger aItLI; + gp_Pnt aPMax[2]; + TopoDS_Edge aEMax; + BOPTools_ListIteratorOfListOfPaveBlock aItLPB, aItLPBS; + NMTTools_ListIteratorOfListOfCommonBlock aItLCB; + NMTTools_MapOfPaveBlock aMPB; + // + myIsDone=Standard_False; + // + aNbS=myDS->NumberOfShapesOfTheObject(); + for (nE=1; nE<=aNbS; ++nE) { + if (myDS->GetShapeType(nE)!=TopAbs_EDGE){ + continue; + } + // + const TopoDS_Edge& aE=*((TopoDS_Edge*)&myDS->Shape(nE)); + if (BRep_Tool::Degenerated(aE)){ + continue; + } + // + NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); + //modified by NIZNHY-PKV Thu Jan 19 09:03:19 2012f + aNbLCB=aLCB.Extent(); + if (!aNbLCB) { + continue; + } + // 0 + NMTTools_ListOfCommonBlock aLCBx; + // + aItLCB.Initialize(aLCB); + for (; aItLCB.More(); aItLCB.Next()) { + NMTTools_CommonBlock aCBx; + // + NMTTools_CommonBlock& aCB=aItLCB.ChangeValue(); + const BOPTools_ListOfPaveBlock &aLPB=aCB.PaveBlocks(); + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const BOPTools_PaveBlock& aPBx=aItLPB.Value(); + nEx=aPBx.OriginalEdge(); + BOPTools_ListOfPaveBlock& aLPBS=mySplitShapesPool(myDS->RefEdge(nEx)); + aItLPBS.Initialize(aLPBS); + for (; aItLPBS.More(); aItLPBS.Next()) { + const BOPTools_PaveBlock& aPBSx=aItLPBS.Value(); + if (aPBSx.IsEqual(aPBx)) { + aCBx.AddPaveBlock(aPBSx); + break; + } + }// for (; aItLPBS.More(); aItLPBS.Next()) { + }// for (; aItLPB.More(); aItLPB.Next()) { + // + const TColStd_ListOfInteger& aLI=aCB.Faces(); + aItLI.Initialize(aLI); + for (; aItLI.More(); aItLI.Next()) { + nF=aItLI.Value(); + aCBx.AddFace(nF); + } + // + aLCBx.Append(aCBx); + }//for (; aItLCB.More(); aItLCB.Next()) { + // + aLCB.Clear(); + // + aItLCB.Initialize(aLCBx); + for (; aItLCB.More(); aItLCB.Next()) { + NMTTools_CommonBlock& aCBx=aItLCB.ChangeValue(); + aLCB.Append(aCBx); + } + //modified by NIZNHY-PKV Thu Jan 19 09:03:30 2012t + // 1 + aItLCB.Initialize(aLCB); + for (; aItLCB.More(); aItLCB.Next()) { + NMTTools_CommonBlock& aCB=aItLCB.ChangeValue(); + // + BOPTools_PaveBlock aPBMax; + aTolExMax=-1.; + const BOPTools_ListOfPaveBlock &aLPB=aCB.PaveBlocks(); + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const BOPTools_PaveBlock& aPBx=aItLPB.Value(); + nEx=aPBx.OriginalEdge(); + const TopoDS_Edge& aEx=*((TopoDS_Edge*)&myDS->Shape(nEx)); + aTolEx=BRep_Tool::Tolerance(aEx); + if (aTolEx>aTolExMax) { + aTolExMax=aTolEx; + aEMax=aEx; + aPBMax=aPBx; + } + } + // + // 2 + if (aMPB.Contains(aPBMax)) { + continue; + } + aMPB.Add(aPBMax); + // + nEMax=aPBMax.OriginalEdge(); + const IntTools_ShrunkRange& aISRMax=aPBMax.ShrunkRange(); + const IntTools_Range& aSRMax=aISRMax.ShrunkRange(); + const Bnd_Box& aBoxMax=aISRMax.BndBox(); + aSRMax.Range(aTSRMax[0], aTSRMax[1]); + for (j=0; j<2; ++j) { + BOPTools_Tools::PointOnEdge(aEMax, aTSRMax[j], aPMax[j]); + } + // + // 3 + aItLPB.Initialize(aLPB); + for (; aItLPB.More(); aItLPB.Next()) { + const BOPTools_PaveBlock& aPBx=aItLPB.Value(); + nEx=aPBx.OriginalEdge(); + if (nEx==nEMax) { + continue; + } + // + const TopoDS_Edge& aEx=*((TopoDS_Edge*)&myDS->Shape(nEx)); + GeomAPI_ProjectPointOnCurve& aPPCx=myContext->ProjPC(aEx); + // + for (j=0; j<2; ++j) { + aPPCx.Perform(aPMax[j]); + aNbPoints=aPPCx.NbPoints(); + if (!aNbPoints) { + break; + } + aTx[j]=aPPCx.LowerDistanceParameter(); + } + if (!aNbPoints) { + // correction the range is impossible due to + // a projection problem + continue; + } + // + if (aTx[0]>aTx[1]){ + aTmp=aTx[0]; + aTx[0]=aTx[1]; + aTx[1]=aTmp; + } + // + // 4 Correction + // 4.1 aPBx + { + const IntTools_ShrunkRange& aISRx=aPBx.ShrunkRange(); + IntTools_Range *pSRx=(IntTools_Range *)(&aISRx.ShrunkRange()); + Bnd_Box *pBoxx=(Bnd_Box *)(&aISRx.BndBox()); + // + pSRx->SetFirst(aTx[0]); + pSRx->SetLast(aTx[1]); + *pBoxx=aBoxMax; + } + // + // 4.2 aPBSx + BOPTools_ListOfPaveBlock& aLPBSx=mySplitShapesPool(myDS->RefEdge(nEx)); + aItLPBS.Initialize(aLPBSx); + for (; aItLPBS.More(); aItLPBS.Next()) { + const BOPTools_PaveBlock& aPBSx=aItLPBS.Value(); + if (!aPBSx.IsEqual(aPBx)) { + continue; + } + // + const IntTools_ShrunkRange& aISRx=aPBSx.ShrunkRange(); + IntTools_Range *pSRx=(IntTools_Range *)(&aISRx.ShrunkRange()); + Bnd_Box *pBoxx=(Bnd_Box *)(&aISRx.BndBox()); + // + pSRx->SetFirst(aTx[0]); + pSRx->SetLast(aTx[1]); + *pBoxx=aBoxMax; + } + // + // + }//for (; aItLPB.More(); aItLPB.Next()) { + }//for (; aItLCB.More(); aItLCB.Next()) { + }//for (nE=1; nE<=aNbS; ++nE) { +} +//======================================================================= +// function: UpdateCommonBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::UpdateCommonBlocks() +{ + myIsDone=Standard_False; + // + Standard_Integer nE, aNbS, nSp, nEx, nSpx; + NMTTools_ListIteratorOfListOfCommonBlock aCBIt; + BOPTools_ListIteratorOfListOfPaveBlock aPBIt; + // + aNbS=myDS->NumberOfShapesOfTheObject(); + // + for (nE=1; nE<=aNbS; ++nE) { + if (myDS->GetShapeType(nE)!=TopAbs_EDGE){ + continue; + } + if (BRep_Tool::Degenerated(TopoDS::Edge(myDS->Shape(nE)))){ + continue; + } + // + NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE)); + /*BOPTools_ListOfPaveBlock& aLPB=*/mySplitShapesPool (myDS->RefEdge(nE)); + // + aCBIt.Initialize(aLCB); + for (; aCBIt.More(); aCBIt.Next()) { + NMTTools_CommonBlock& aCB=aCBIt.ChangeValue(); + // + // Among all PBs of aCB the first PB will be one + // that have max tolerance value + { + Standard_Real aTolEx, aTolExMax; + BOPTools_ListOfPaveBlock *pLPB, aLPBx; + // + aTolExMax=-1.; + pLPB=(BOPTools_ListOfPaveBlock *)&aCB.PaveBlocks(); + aPBIt.Initialize(*pLPB); + for (; aPBIt.More(); aPBIt.Next()) { + const BOPTools_PaveBlock& aPBx=aPBIt.Value(); + nEx=aPBx.OriginalEdge(); + const TopoDS_Edge& aEx=TopoDS::Edge(myDS->Shape(nEx)); + aTolEx=BRep_Tool::Tolerance(aEx); + if (aTolEx>aTolExMax) { + aTolExMax=aTolEx; + aLPBx.Prepend(aPBx); + } + else{ + aLPBx.Append(aPBx); + } + } + // + pLPB->Clear(); + *pLPB=aLPBx; + } + // + BOPTools_PaveBlock& aPB=aCB.PaveBlock1(nE); + nSp=SplitIndex(aPB); + aPB.SetEdge(nSp); + // + const BOPTools_ListOfPaveBlock& aCBLPB=aCB.PaveBlocks(); + aPBIt.Initialize(aCBLPB); + for (; aPBIt.More(); aPBIt.Next()) { + BOPTools_PaveBlock& aPBx=aPBIt.Value(); + nEx=aPBx.OriginalEdge(); + if (nEx==nE) { + continue; + } + // + nSpx=SplitIndex(aPBx); + aPBx.SetEdge(nSpx); + } + // + } + } +} +//======================================================================= +// function: SplitIndex +// purpose: +//======================================================================= +Standard_Integer NMTTools_PaveFiller::SplitIndex + (const BOPTools_PaveBlock& aPBx) const +{ + Standard_Integer anOriginalEdge, anEdgeIndex=0; + + anOriginalEdge=aPBx.OriginalEdge(); + + const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(anOriginalEdge)); + // + BOPTools_ListIteratorOfListOfPaveBlock anIt(aLPB); + for (; anIt.More(); anIt.Next()) { + BOPTools_PaveBlock& aPB=anIt.Value(); + if (aPB.IsEqual(aPBx)) { + anEdgeIndex=aPB.Edge(); + return anEdgeIndex; + } + } + return anEdgeIndex; +} + +//======================================================================= +// function: UpdatePaveBlocks +// purpose: +//======================================================================= +void NMTTools_PaveFiller::UpdatePaveBlocks() +{ + myIsDone=Standard_False; + // + Standard_Integer i, aNbFFs, nF1, nF2, aNbF, nF, iRankF, nE, nV1, nV2, aNbPB; + Standard_Real aT1, aT2; + TColStd_IndexedMapOfInteger aMF, aME; + TopExp_Explorer aExp; + TopoDS_Vertex aV1, aV2; + TopoDS_Edge aE; + BOPTools_Pave aPave1, aPave2; + BOPTools_PaveBlock aPB; + // + BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); + // + aNbFFs=aFFs.Extent(); + for (i=1; i<=aNbFFs; ++i) { + BOPTools_SSInterference& aFFi=aFFs(i); + aFFi.Indices(nF1, nF2); + aMF.Add(nF1); + aMF.Add(nF2); + } + // + aNbF=aMF.Extent(); + for(i=1; i<=aNbF; ++i) { + nF=aMF(i); + iRankF=myDS->Rank(nF); + const TopoDS_Shape aF=myDS->Shape(nF);//mpv + aExp.Init(aF, TopAbs_EDGE); + for(; aExp.More(); aExp.Next()) { + aE=TopoDS::Edge(aExp.Current()); + // + if (BRep_Tool::Degenerated(aE)) { + continue; + } + // + nE=myDS->ShapeIndex(aE, iRankF); + // + if (aME.Contains(nE)) { + continue; + } + aME.Add(nE); + // + BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + aNbPB=aLPB.Extent(); + if (aNbPB) { + continue; + } + TopExp::Vertices(aE, aV1, aV2); + // + nV1=myDS->ShapeIndex(aV1, iRankF); + aT1=BRep_Tool::Parameter(aV1, aE); + aPave1.SetIndex(nV1); + aPave1.SetParam(aT1); + // + nV2=myDS->ShapeIndex(aV2, iRankF); + aT2=BRep_Tool::Parameter(aV2, aE); + aPave2.SetIndex(nV2); + aPave2.SetParam(aT2); + // + aPB.SetEdge(nE); + aPB.SetOriginalEdge(nE); + aPB.SetPave1(aPave1); + aPB.SetPave2(aPave2); + // + aLPB.Append(aPB); + } + } +} + +//======================================================================= +// function: MakeAloneVertices +// purpose: +//======================================================================= +void NMTTools_PaveFiller::MakeAloneVertices() +{ + Standard_Integer i, aNbFFs, nF1, nF2, j, aNbPnts, nFx, aNbV; + Standard_Real aTolF1, aTolF2, aTolSum, aTolV; + TColStd_ListIteratorOfListOfInteger aIt; + TColStd_ListOfInteger aLI; + TopoDS_Vertex aV; + TopoDS_Compound aCompound; + BRep_Builder aBB; + TopTools_DataMapOfShapeListOfInteger aDMVFF, aDMVFF1; + TopTools_DataMapIteratorOfDataMapOfShapeListOfInteger aItDMVFF; + TopTools_DataMapOfShapeShape aDMVV; + TopTools_DataMapOfIntegerShape aDMIV; + TopTools_DataMapOfShapeInteger aDMVI; + TopTools_DataMapIteratorOfDataMapOfShapeInteger aItDMVI; + TopTools_DataMapIteratorOfDataMapOfIntegerShape aItDMIV; + // + aBB.MakeCompound(aCompound); + // + myAloneVertices.Clear(); + // + BOPTools_CArray1OfSSInterference& aFFs=myIP->SSInterferences(); + // + // 1. Collect alone vertices from FFs + aNbV=0; + aNbFFs=aFFs.Extent(); + for (i=1; i<=aNbFFs; ++i) { + BOPTools_SSInterference& aFFi=aFFs(i); + aFFi.Indices(nF1, nF2); + // + const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));//mpv + const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));//mpv + // + aTolF1=BRep_Tool::Tolerance(aF1); + aTolF2=BRep_Tool::Tolerance(aF2); + aTolSum=aTolF1+aTolF2; + // + aLI.Clear(); + aLI.Append(nF1); + aLI.Append(nF2); + // + const IntTools_SequenceOfPntOn2Faces& aSeqAlonePnts=aFFi.AlonePnts(); + aNbPnts=aSeqAlonePnts.Length(); + for (j=1; j<=aNbPnts; ++j) { + const gp_Pnt& aP=aSeqAlonePnts(j).P1().Pnt(); + BOPTools_Tools::MakeNewVertex(aP, aTolSum, aV); + aDMVFF.Bind(aV, aLI); + aBB.Add(aCompound, aV); + ++aNbV; + } + } + if (!aNbV) { + return; + } + // + // 2. Try to fuse alone vertices themselves; + FuseVertices(aCompound, aDMVV); + // + // if some are fused, replace them by new ones + aItDMVFF.Initialize(aDMVFF); + for (; aItDMVFF.More(); aItDMVFF.Next()) { + const TopoDS_Shape& aVx=aItDMVFF.Key(); + const TColStd_ListOfInteger& aLIx=aItDMVFF.Value(); + // + if (!aDMVV.IsBound(aVx)) { + aDMVFF1.Bind(aVx, aLIx); + } + else { + const TopoDS_Shape& aVy=aDMVV.Find(aVx); + + if (aDMVFF1.IsBound(aVy)) { + TColStd_ListOfInteger& aLIy=aDMVFF1.ChangeFind(aVy); + aIt.Initialize(aLIx); + for(; aIt.More(); aIt.Next()) { + nFx=aIt.Value(); + aLIy.Append(nFx); + } + } + else { + aDMVFF1.Bind(aVy, aLIx); + } + } + } + aDMVFF.Clear(); + // + // refine lists of faces in aDMVFF1; + aItDMVFF.Initialize(aDMVFF1); + for (; aItDMVFF.More(); aItDMVFF.Next()) { + TColStd_MapOfInteger aMIy; + TColStd_ListOfInteger aLIy; + // + const TopoDS_Shape& aVx=aItDMVFF.Key(); + TColStd_ListOfInteger& aLIx=aDMVFF1.ChangeFind(aVx); + aIt.Initialize(aLIx); + for(; aIt.More(); aIt.Next()) { + nFx=aIt.Value(); + if (aMIy.Add(nFx)) { + aLIy.Append(nFx); + } + } + aLIx.Clear(); + aLIx.Append(aLIy); + } + //================================== + // + // 3. Collect vertices from DS + Standard_Integer aNbS, nV, nVSD, aNbVDS, i1, i2, aNbVSD; + // + aNbS=myDS->NumberOfShapesOfTheObject(); + // old shapes + for (i=1; i<=aNbS; ++i) { + const TopoDS_Shape& aS=myDS->Shape(i); + if (aS.ShapeType() != TopAbs_VERTEX){ + continue; + } + // + nVSD=FindSDVertex(i); + nV=(nVSD) ? nVSD : i; + const TopoDS_Shape& aVx=myDS->Shape(nV); + if (!aDMVI.IsBound(aVx)) { + aDMVI.Bind(aVx, nV); + } + } + // new shapes + i1=myDS->NumberOfSourceShapes()+1; + i2=myDS->NumberOfInsertedShapes(); + for (i=i1; i<=i2; ++i) { + const TopoDS_Shape aS=myDS->Shape(i);//mpv + if (aS.ShapeType() != TopAbs_VERTEX){ + continue; + } + if (!aDMVI.IsBound(aS)) { + aDMVI.Bind(aS, i); + } + } + // + // 4. Initialize BoundSortBox on aDMVI + // + Handle(Bnd_HArray1OfBox) aHAB; + Bnd_BoundSortBox aBSB; + // + aNbVDS=aDMVI.Extent(); + aHAB=new Bnd_HArray1OfBox(1, aNbVDS); + // + aItDMVI.Initialize(aDMVI); + for (i=1; aItDMVI.More(); aItDMVI.Next(), ++i) { + Bnd_Box aBox; + // + nV=aItDMVI.Value(); + aV=TopoDS::Vertex(aItDMVI.Key()); + aTolV=BRep_Tool::Tolerance(aV); + aBox.SetGap(aTolV); + BRepBndLib::Add(aV, aBox); + aHAB->SetValue(i, aBox); + // + aDMIV.Bind(i, aV); + } + aBSB.Initialize(aHAB); + // + // 5. Compare + aItDMVFF.Initialize(aDMVFF1); + for (; aItDMVFF.More(); aItDMVFF.Next()) { + Bnd_Box aBoxV; + // + const TColStd_ListOfInteger& aLIFF=aItDMVFF.Value(); + aV=TopoDS::Vertex(aItDMVFF.Key()); + // + aTolV=BRep_Tool::Tolerance(aV); + aBoxV.SetGap(aTolV); + BRepBndLib::Add(aV, aBoxV); + // + const TColStd_ListOfInteger& aLIVSD=aBSB.Compare(aBoxV); + aNbVSD=aLIVSD.Extent(); + if (aNbVSD==0) { + // add new vertex in DS and update map myAloneVertices + BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq; + // + myDS->InsertShapeAndAncestorsSuccessors(aV, anASSeq); + nV=myDS->NumberOfInsertedShapes(); + // + aIt.Initialize(aLIFF); + for (; aIt.More(); aIt.Next()) { + nFx=aIt.Value(); + if (myAloneVertices.Contains(nFx)) { + TColStd_IndexedMapOfInteger& aMVx=myAloneVertices.ChangeFromKey(nFx); + aMVx.Add(nV); + } + else { + TColStd_IndexedMapOfInteger aMVx; + aMVx.Add(nV); + myAloneVertices.Add(nFx, aMVx); + } + } + } + } + // qqf + { + Standard_Integer aNbF, aNbAV, nF, k; + NMTTools_IndexedDataMapOfIndexedMapOfInteger aMAVF; + // + aNbF=myAloneVertices.Extent(); + if (aNbF<2) { + return; + } + // + // 1. fill map Alone Vertex/Face -> aMAVF + for (i=1; i<=aNbF; ++i) { + nF=myAloneVertices.FindKey(i); + const TColStd_IndexedMapOfInteger& aMAV=myAloneVertices(i); + aNbAV=aMAV.Extent(); + for(j=1; j<=aNbAV; ++j) { + nV=aMAV(j); + if (aMAVF.Contains(nV)) { + TColStd_IndexedMapOfInteger& aMF=aMAVF.ChangeFromKey(nV); + aMF.Add(nF); + } + else{ + TColStd_IndexedMapOfInteger aMF; + aMF.Add(nF); + aMAVF.Add(nV, aMF); + } + } + } + // + // 2 Obtain pairs of faces + aNbAV=aMAVF.Extent(); + for (i=1; i<=aNbAV; ++i) { + const TColStd_IndexedMapOfInteger& aMF=aMAVF(i); + aNbF=aMF.Extent(); + for(j=1; jAdd(nF1, nF2, Standard_True, NMTDS_TI_FF); + } + } + } + } + // qqt +} +//======================================================================= +// function: AloneVertices +// purpose: +//======================================================================= +const NMTTools_IndexedDataMapOfIndexedMapOfInteger& + NMTTools_PaveFiller::AloneVertices()const +{ + return myAloneVertices; +} +//======================================================================= +// function: FuseVertices +// purpose: +//======================================================================= +void NMTTools_PaveFiller::FuseVertices + (const TopoDS_Shape& aCompound, + TopTools_DataMapOfShapeShape& aDMVV)const +{ + Standard_Integer i, aNbVV, n1, n2, nX; + NMTTools_PaveFiller tPF; + // + tPF.SetCompositeShape(aCompound); + // + tPF.Init(); + // + tPF.PerformVV(); + //tPF.PerformNewVertices(); //qq + // + NMTDS_ShapesDataStructure& tDS=*(tPF.DS()); + NMTDS_InterfPool& tInterfPool=*(tPF.IP()); + BOPTools_CArray1OfVVInterference& aVVt=tInterfPool.VVInterferences(); + // + aNbVV=aVVt.Extent(); + for (i=1; i<=aNbVV; ++i) { + const BOPTools_VVInterference& aVV=aVVt(i); + aVV.Indices(n1, n2); + nX=aVV.NewShape(); + if (nX) { + const TopoDS_Shape& aV1=tDS.Shape(n1); + const TopoDS_Shape& aV2=tDS.Shape(n2); + const TopoDS_Shape& aVx=tDS.Shape(nX); + aDMVV.Bind(aV1, aVx); + aDMVV.Bind(aV2, aVx); + } + } +} diff --git a/src/NMTTools_NEW/NMTTools_PaveFiller_8.cxx b/src/NMTTools_NEW/NMTTools_PaveFiller_8.cxx new file mode 100644 index 000000000..48331d5d4 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_PaveFiller_8.cxx @@ -0,0 +1,830 @@ +// 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: NMTTools_PaveFiller_8.cxx +// Created: Fri Dec 19 11:15:53 2003 +// Author: Peter KURNEV +// +// +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + + +// Modified to add new method Thu Sep 14 14:35:18 2006 +// Contribution of Samtech www.samcef.com BEGIN +//======================================================================= +// function: SharedEdges +// purpose: +//======================================================================= + void NMTTools_PaveFiller::SharedEdges(const Standard_Integer nF1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aLNE, + TopTools_ListOfShape& aLSE) +{ + Standard_Integer nE1, nE2; + TColStd_MapOfInteger aM1; + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + // + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + aM1.Add(nE1); + } + + aExp.Init(nF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE2=aExp.Current(); + if (aM1.Contains(nE2)) { + aLNE.Append(nE2); + const TopoDS_Shape& aE2=myDS->Shape(nE2); + aLSE.Append(aE2); + } + } +} +// Contribution of Samtech www.samcef.com END +// +//======================================================================= +// function: RealPaveBlock +// purpose: +//======================================================================= + const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock + (const BOPTools_PaveBlock& aPB, + TColStd_ListOfInteger& aLB, + Standard_Integer& aIsCommonBlock) +{ + Standard_Integer nE, nSpx; + BOPTools_ListIteratorOfListOfPaveBlock aItPBx; + // + aIsCommonBlock=0; + aLB.Clear(); + nE=aPB.OriginalEdge(); + const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE)); + NMTTools_CommonBlockAPI aCBAPI(aLCBE); + if (aCBAPI.IsCommonBlock(aPB)) { + NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); + // + aIsCommonBlock=1; + // + const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); + aItPBx.Initialize(aLPBx); + for (; aItPBx.More(); aItPBx.Next()) { + const BOPTools_PaveBlock& aPBx=aItPBx.Value(); + nSpx=aPBx.Edge(); + aLB.Append(nSpx); + } + // + const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1(); + return aPBx; + } + return aPB; +} +// +//======================================================================= +// function: RealPaveBlock +// purpose: +//======================================================================= + const BOPTools_PaveBlock& NMTTools_PaveFiller::RealPaveBlock(const BOPTools_PaveBlock& aPB) +{ + Standard_Integer nE; + // + nE=aPB.OriginalEdge(); + const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE)); + NMTTools_CommonBlockAPI aCBAPI(aLCBE); + if (aCBAPI.IsCommonBlock(aPB)) { + NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB); + const BOPTools_PaveBlock& aPBx=aCB.PaveBlock1(); + return aPBx; + } + return aPB; +} +//======================================================================= +// function: CommonBlocksFace +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::CommonBlocksFace(const Standard_Integer nF, + NMTTools_ListOfCommonBlock& aLCB) +{ + Standard_Integer nE; + TopAbs_ShapeEnum aT; + NMTTools_ListIteratorOfListOfCommonBlock anIt; + // + aT=myDS->GetShapeType(nF); + // + if (aT!=TopAbs_FACE) { + return 1; // Type mismatch + } + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + // + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE=aExp.Current(); + const NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(nE)); + anIt.Initialize(aLCBE); + for (; anIt.More(); anIt.Next()) { + const NMTTools_CommonBlock& aCBE=anIt.Value(); + aLCB.Append(aCBE); + } + } + return 0; //Ok +} +// +// 1 RealSplits +// +// +//======================================================================= +// function: RealSplitsFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsFace(const Standard_Integer nF, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + // + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE=aExp.Current(); + const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE)); + anIt.Initialize(aLPBE); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB=anIt.Value(); + const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB); + aLPB.Append(aPBR); + } + } +} +//======================================================================= +// function: HasRealSplitsInOnFace +// purpose: +//======================================================================= + Standard_Boolean NMTTools_PaveFiller::HasRealSplitsInOnFace(const Standard_Integer nF1, + const Standard_Integer nF2) +{ + Standard_Boolean bFlag; + BOPTools_ListOfPaveBlock aLPB; + // + RealSplitsInFace(0, nF1, nF2, aLPB); + // + bFlag=!aLPB.IsEmpty(); + if (bFlag) { + return bFlag; + } + // + RealSplitsInFace(0, nF1, nF2, aLPB); + // + bFlag=!aLPB.IsEmpty(); + return bFlag; +} +//======================================================================= +// function: RealSplitsInFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE1; + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + RealSplitsInFace (nE1, nF2, aLPB); + } +} +//======================================================================= +// function: RealSplitsInFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nF1; + // + TColStd_ListIteratorOfListOfInteger anItLFCB; + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); + // + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.ChangeValue(); + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); + const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1); + + const TColStd_ListOfInteger& aLFCB=aCB.Faces(); + anItLFCB.Initialize(aLFCB); + for (; anItLFCB.More(); anItLFCB.Next()) { + nF1=anItLFCB.Value(); + if (nF1==nF2) { + aLPB.Append(aPB1R); + } + } + } +} +//======================================================================= +// function: RealSplitsOnEdge +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + // + BOPTools_ListIteratorOfListOfPaveBlock anIt; + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); + + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.ChangeValue(); + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); + const BOPTools_PaveBlock& aPB1R=RealPaveBlock(aPB1); + // + const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); + anIt.Initialize(aLPBx); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB2=anIt.Value(); + nE=aPB2.OriginalEdge(); + if (nE==nE2) { + aLPB.Append(aPB1R); + } + } + } +} +//======================================================================= +// function: RealSplitsOnFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE2; + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + aExp.Init(nF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE2=aExp.Current(); + RealSplitsOnEdge(nE1, nE2, aLPB); + } +} +//======================================================================= +// function: RealSplitsOnFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsOnFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE1; + // +// BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*myDS); + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + RealSplitsOnFace(nE1, nF2, aLPB); + } +} + +// 2 SimpleSplits +//======================================================================= +// function: SplitsFace +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + TopAbs_ShapeEnum aT; + BOPTools_ListIteratorOfListOfPaveBlock anIt; + // + aT=myDS->GetShapeType(nF); + // + if (aT!=TopAbs_FACE) { + return 1; // Type mismatch + } + // + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + // + aExp.Init(nF, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE=aExp.Current(); + const BOPTools_ListOfPaveBlock& aLPBE=mySplitShapesPool(myDS->RefEdge(nE)); + anIt.Initialize(aLPBE); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPBE=anIt.Value(); + aLPB.Append(aPBE); + } + } + return 0; //Ok +} + +//======================================================================= +// function: SplitsInFace +// purpose: splits of edges from nF1 in nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE1; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nF1); + aT2=myDS->GetShapeType(nF2); + + if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) { + return 1; // Type mismatch + } + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + SplitsInFace (nE1, nF2, aLPB); + } + return 0; //Ok +} +//======================================================================= +// function: SplitsInFace +// purpose: splits of edge nE1 in aFace2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nF1; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nE1); + aT2=myDS->GetShapeType(nF2); + + if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) { + return 1; // Type mismatch + } + // + TColStd_ListIteratorOfListOfInteger anItLFCB; + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); + // + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.ChangeValue(); + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1); + + const TColStd_ListOfInteger& aLFCB=aCB.Faces(); + anItLFCB.Initialize(aLFCB); + for (; anItLFCB.More(); anItLFCB.Next()) { + nF1=anItLFCB.Value(); + if (nF1==nF2) { + aLPB.Append(aPB1); + } + } + } + return 0; //Ok +} +//======================================================================= +// function: SplitsOnEdge +// purpose: splits of edge nE1 on nE2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nE1); + aT2=myDS->GetShapeType(nE2); + + if (aT1!=TopAbs_EDGE || aT2!=TopAbs_EDGE) { + return 1; // Type mismatch + } + // + BOPTools_ListIteratorOfListOfPaveBlock anIt; + NMTTools_ListIteratorOfListOfCommonBlock anItCB; + // + const NMTTools_ListOfCommonBlock& aLCB=myCommonBlockPool(myDS->RefEdge(nE1)); + + anItCB.Initialize(aLCB); + for (; anItCB.More(); anItCB.Next()) { + NMTTools_CommonBlock& aCB=anItCB.ChangeValue(); + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(nE1);//XXX + // + const BOPTools_ListOfPaveBlock& aLPBx=aCB.PaveBlocks(); + anIt.Initialize(aLPBx); + for (; anIt.More(); anIt.Next()) { + const BOPTools_PaveBlock& aPB2=anIt.Value(); + nE=aPB2.OriginalEdge(); + if (nE==nE2) { + aLPB.Append(aPB1); + } + } + } + return 0; //Ok +} +//======================================================================= +// function: SplitsOnFace +// purpose: splits of edge nE1 on face nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE2, ip; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nE1); + aT2=myDS->GetShapeType(nF2); + + if (aT1!=TopAbs_EDGE || aT2!=TopAbs_FACE) { + return 1; // Type mismatch + } + BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*pDS); + aExp.Init(nF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE2=aExp.Current(); + ip=SplitsOnEdge(nE1, nE2, aLPB); + if (ip) { + return ip; + } + } + return 0; //Ok +} +//======================================================================= +// function: SplitsOnFace +// purpose: splits of edges from face nF1 on face nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + BOPTools_ListOfPaveBlock& aLPB) +{ + Standard_Integer nE1, ip; + TopAbs_ShapeEnum aT1, aT2; + + aT1=myDS->GetShapeType(nF1); + aT2=myDS->GetShapeType(nF2); + + if (aT1!=TopAbs_FACE || aT2!=TopAbs_FACE) { + return 1; // Type mismatch + } +// BooleanOperations_ShapesDataStructure *pDS=myDS; + BooleanOperations_OnceExplorer aExp(*myDS); + aExp.Init(nF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + nE1=aExp.Current(); + ip=SplitsOnFace(nE1, nF2, aLPB); + if (ip) { + return ip; + } + } + return 0; //Ok +} + +// 3 Simple Splits indices +//======================================================================= +// function: SplitsFace +// purpose: +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsFace(const Standard_Integer nF, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsFace(nF, aLPB); + if (iErr) { + return iErr; + } + + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return 0; //Ok +} + +//======================================================================= +// function: SplitsInFace +// purpose: splits of edges from nF1 in nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsInFace(0, nF1, nF2, aLPB); + if (iErr) { + return iErr; + } + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return iErr; +} +//======================================================================= +// function: SplitsInFace +// purpose: splits of edge nE1 in aFace2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsInFace(const Standard_Integer nE1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsInFace(nE1, nF2, aLPB); + if (iErr) { + return iErr; + } + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return iErr; +} +//======================================================================= +// function: SplitsOnEdge +// purpose: splits of edge nE1 on nE2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnEdge(const Standard_Integer nE1, + const Standard_Integer nE2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsOnEdge(nE1, nE2, aLPB); + if (iErr) { + return iErr; + } + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return iErr; +} +//======================================================================= +// function: SplitsOnFace +// purpose: splits of edge nE1 on face nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer nE1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsOnEdge(nE1, nF2, aLPB); + if (iErr) { + return iErr; + } + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return iErr; +} +//======================================================================= +// function: SplitsOnFace +// purpose: splits of edges from face nF1 on face nF2 +//======================================================================= + Standard_Integer NMTTools_PaveFiller::SplitsOnFace(const Standard_Integer ,//for overriding + const Standard_Integer nF1, + const Standard_Integer nF2, + TColStd_ListOfInteger& aSplits) +{ + Standard_Integer nE, iErr; + BOPTools_ListIteratorOfListOfPaveBlock aIt; + BOPTools_ListOfPaveBlock aLPB; + // + iErr=SplitsOnFace(0, nF1, nF2, aLPB); + if (iErr) { + return iErr; + } + + aIt.Initialize(aLPB); + for (; aIt.More(); aIt.Next()) { + const BOPTools_PaveBlock& aPB=aIt.Value(); + nE=aPB.Edge(); + aSplits.Append(nE); + } + return 0; //Ok +} +//modified by NIZNHY-PKV Mon Oct 17 12:07:48 2011f +static + void SortPaveBlocks(BOPTools_ListOfPaveBlock &); +static + void SortShell(const Standard_Integer, + BOPTools_PaveBlock *); +static + Standard_Boolean Less(const BOPTools_PaveBlock &, + const BOPTools_PaveBlock &); + +//======================================================================= +// function: RealSplitsInFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::RealSplitsInFace(const Standard_Integer nF, + BOPTools_ListOfPaveBlock& aLPBIn) +{ + Standard_Integer j, aNbCBP, nSpIn; + TColStd_MapOfInteger aMFence; + BOPTools_ListOfPaveBlock aLPB; + BOPTools_ListIteratorOfListOfPaveBlock aItPB; + NMTTools_ListIteratorOfListOfCommonBlock aItCB; + // + NMTTools_CommonBlockPool& aCBP=ChangeCommonBlockPool(); + // + aNbCBP=aCBP.Extent(); + for (j=1; j<=aNbCBP; ++j) { + NMTTools_ListOfCommonBlock& aLCB=aCBP(j); + aItCB.Initialize(aLCB); + for (; aItCB.More(); aItCB.Next()) { + NMTTools_CommonBlock& aCB=aItCB.ChangeValue(); + if (aCB.IsPaveBlockOnFace(nF)) { + const BOPTools_PaveBlock& aPB1=aCB.PaveBlock1(); + nSpIn=aPB1.Edge(); + if (aMFence.Add(nSpIn)){ + aLPB.Append(aPB1); + } + } + } + } + // + SortPaveBlocks(aLPB); + // + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + const BOPTools_PaveBlock& aPB=aItPB.Value(); + aLPBIn.Append(aPB); + } +} +//======================================================================= +// function: SortPaveBlocks +// purpose: +//======================================================================= +void SortPaveBlocks(BOPTools_ListOfPaveBlock &aLPBIn) +{ + Standard_Integer i, aNbPBIn; + BOPTools_ListIteratorOfListOfPaveBlock aItPB; + BOPTools_PaveBlock *pPB; + // + aNbPBIn=aLPBIn.Extent(); + if (aNbPBIn<2) { + return; + } + // + pPB=new BOPTools_PaveBlock[aNbPBIn]; + // + aItPB.Initialize(aLPBIn); + for (i=0; aItPB.More(); aItPB.Next(), ++i) { + const BOPTools_PaveBlock& aPB=aItPB.Value(); + pPB[i]=aPB; + } + // + SortShell(aNbPBIn, pPB); + // + aLPBIn.Clear(); + for (i=0; i -1) goto m30; + }//if (a[l] < a[j]){ + }//for (i=0; i +// +#include + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include + + +//======================================================================= +// function: PrepareFace +// purpose: +//======================================================================= + void NMTTools_PaveFiller::PrepareFace(const Standard_Integer nF, + TopoDS_Face& newFace) +{ + Standard_Boolean bToReverse, bIsDegenerated; + Standard_Integer iRankF, nE, nSp, aNbPB; + Standard_Real aTol; + TopLoc_Location aLoc; + TopoDS_Face aF; + TopoDS_Wire newWire; + TopoDS_Edge aSp; + TopAbs_Orientation anOrF, anOrE; + BRep_Builder aBB; + TopExp_Explorer aExpW, aExpE; + BOPTools_ListIteratorOfListOfPaveBlock aItPB; + // + iRankF=myDS->Rank(nF); + aF=TopoDS::Face(myDS->Shape(nF)); + anOrF=aF.Orientation(); + aF.Orientation(TopAbs_FORWARD); + // + Handle(Geom_Surface) aS=BRep_Tool::Surface(aF, aLoc); + aTol=BRep_Tool::Tolerance(aF); + // + aBB.MakeFace (newFace, aS, aLoc, aTol); + // + aExpW.Init(aF, TopAbs_WIRE); + for (; aExpW.More(); aExpW.Next()) { + const TopoDS_Shape& aW=aExpW.Current(); + aBB.MakeWire(newWire); + // + aExpE.Init(aW, TopAbs_EDGE); + for (; aExpE.More(); aExpE.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExpE.Current()); + bIsDegenerated=BRep_Tool::Degenerated(aE); + anOrE=aE.Orientation(); + // + nE=myDS->ShapeIndex(aE, iRankF); + const BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(nE)); + aNbPB=aLPB.Extent(); + if (!aNbPB) { + aBB.Add(newWire, aE); + continue; + } + // + aItPB.Initialize(aLPB); + for (; aItPB.More(); aItPB.Next()) { + const BOPTools_PaveBlock& aPB=aItPB.Value(); + const BOPTools_PaveBlock& aPBR=RealPaveBlock(aPB); + nSp=aPBR.Edge(); + // + aSp=TopoDS::Edge(myDS->Shape(nSp)); + if (!bIsDegenerated) { + bToReverse=BOPTools_Tools3D::IsSplitToReverse1(aSp, aE, myContext); + if (bToReverse) { + aSp.Reverse(); + } + } + else { + aSp.Orientation(anOrE); + } + aBB.Add(newWire, aSp); + } + } + aBB.Add(newFace, newWire); + } + newFace.Orientation(anOrF); +} diff --git a/src/NMTTools_NEW/NMTTools_Tools.cxx b/src/NMTTools_NEW/NMTTools_Tools.cxx new file mode 100644 index 000000000..9b1f6ceae --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_Tools.cxx @@ -0,0 +1,614 @@ +// 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: NMTTools_Tools.cxx +// Created: Mon Dec 8 10:35:15 2003 +// 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 +#include +#include +#include +#include +#include +// +#include +#include +#include + +static + void ProcessBlock(const Standard_Integer iV, + const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + TColStd_IndexedMapOfInteger& aProcessed, + TColStd_IndexedMapOfInteger& aChain); +static + void ProcessBlock(const TopoDS_Shape& aF, + const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, + TopTools_IndexedMapOfShape& aProcessed, + TopTools_IndexedMapOfShape& aChain); + +//modified by NIZNHY-PKV Thu Nov 16 10:46:53 2006f SKL/PartC5 +//======================================================================= +// function: UpdateEdge +// purpose: +//======================================================================= + void NMTTools_Tools::UpdateEdge(const TopoDS_Edge& aE, + const Standard_Real aTolR) +{ + Standard_Real aTolE, aTolES, aTolV; + TopoDS_Iterator aIt; + BRep_Builder aBB; + // + aTolE=BRep_Tool::Tolerance(aE); + aTolES=Max(aTolR, aTolE); + aBB.UpdateEdge(aE, aTolES); + // + aIt.Initialize(aE); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aIt.Value()); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolVIsPeriodic()) { + BOPTools_Tools2D::AdjustPCurveOnFace(aFFWD, aT1, aT2, aC2D, aC2DA); + } + else { + BOPTools_Tools2D::AdjustPCurveOnFace(aFFWD, aC3DETrim, aC2D, aC2DA); + } + // + aBB.UpdateEdge(aE, aC2DA, aFFWD, aTolE); + BRepLib::SameParameter(aE); +} +/* +//======================================================================= +// function: MakePCurve +// purpose: +//======================================================================= + void NMTTools_Tools::MakePCurve(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Handle(Geom2d_Curve)& aC2Dx, + const Standard_Real aTolR2D) +{ + Standard_Integer k, aNbV; + Standard_Real aTolEdge, aTolFact, aTolV, aTolVmax; + Standard_Real aTFirst, aTLast, aOutFirst, aOutLast, aOutTol; + TopoDS_Face aFFWD; + TopTools_IndexedMapOfShape aVMap; + BRep_Builder aBB; + // + aFFWD=aF; + aFFWD.Orientation(TopAbs_FORWARD); + // + aTolEdge=BRep_Tool::Tolerance(aE); + aTolFact=Max(aTolEdge, aTolR2D); + // + TopExp::MapShapes(aE, TopAbs_VERTEX, aVMap); + // + aTolVmax=-1.; + aNbV=aVMap.Extent(); + for (k=1; k<=aNbV; ++k) { + const TopoDS_Vertex& aV=TopoDS::Vertex(aVMap(k)); + aTolV=BRep_Tool::Tolerance(aV); + if (aTolV>aTolVmax) { + aTolVmax=aTolV; + } + } + // + if (aTolFact>aTolVmax) { + aTolFact=aTolVmax; + } + // + const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aTFirst, aTLast); + Handle(Geom_TrimmedCurve)aC3DETrim=new Geom_TrimmedCurve(aC3DE, aTFirst, aTLast); + // + Handle(Geom2d_Curve) aC2D, aC2DA; + // + aC2D=aC2Dx; + if (aC2D.IsNull()) { + BOPTools_Tools2D::BuildPCurveForEdgeOnFace(aE, aFFWD); + BOPTools_Tools2D::CurveOnSurface(aE, aFFWD, aC2D, aOutFirst, aOutLast, aOutTol, Standard_True); + } + if (aC3DE->IsPeriodic()) { + BOPTools_Tools2D::AdjustPCurveOnFace(aFFWD, aTFirst, aTLast, aC2D, aC2DA); + } + else { + BOPTools_Tools2D::AdjustPCurveOnFace(aFFWD, aC3DETrim, aC2D, aC2DA); + } + // + aBB.UpdateEdge(aE, aC2DA, aFFWD, aTolFact); + BRepLib::SameParameter(aE); +} +*/ +//modified by NIZNHY-PKV Thu Nov 16 10:46:55 2006t +//======================================================================= +// function: IsSplitInOnFace +// purpose: +//======================================================================= + Standard_Boolean NMTTools_Tools::IsSplitInOnFace(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Handle(IntTools_Context)& aContext) +{ + Standard_Boolean bFlag; + Standard_Real aT, aTolE, aTolF, aTol, aDist, aU, aV; + gp_Pnt aP; + gp_Pnt2d aP2D; + // + aTolE=BRep_Tool::Tolerance(aE); + aTolF=BRep_Tool::Tolerance(aF); + aTol=aTolE+aTolF; + // + GeomAPI_ProjectPointOnSurf& aProjector=aContext->ProjPS(aF); + // + aT=BOPTools_Tools2D::IntermediatePoint(aE); + BOPTools_Tools::PointOnEdge(aE, aT, aP); + // + aProjector.Perform(aP); + bFlag=aProjector.IsDone(); + if (!bFlag) { + return bFlag; + } + // + aDist=aProjector.LowerDistance(); + bFlag=(aDist <= aTol); + if (!bFlag) { + return bFlag; + } + // + aProjector.LowerDistanceParameters(aU, aV); + aP2D.SetCoord(aU, aV); + bFlag=aContext->IsPointInOnFace (aF, aP2D); + return bFlag; +} +//======================================================================= +// function: NMTTools_Tools::MakeNewVertex +// purpose : +//======================================================================= + void NMTTools_Tools::MakeNewVertex(const TopTools_ListOfShape& aLVs, + TopoDS_Vertex& aNewVertex) +{ + Standard_Integer aNb; + Standard_Real aTi, aDi, aDmax=-1.e5; + gp_Pnt aPi, aP; + gp_XYZ aXYZ(0.,0.,0.), aXYZi; + TopTools_ListIteratorOfListOfShape anIt; + // + aNb=aLVs.Extent(); + if (!aNb) { + return; + } + // + anIt.Initialize(aLVs); + for (; anIt.More(); anIt.Next()) { + TopoDS_Vertex aVi=TopoDS::Vertex(anIt.Value()); + aPi=BRep_Tool::Pnt(aVi); + aXYZi=aPi.XYZ(); + aXYZ=aXYZ+aXYZi; + } + // + aXYZ.Divide((Standard_Real)aNb); + aP.SetXYZ(aXYZ); + // + anIt.Initialize(aLVs); + for (; anIt.More(); anIt.Next()) { + TopoDS_Vertex aVi=TopoDS::Vertex(anIt.Value()); + aPi=BRep_Tool::Pnt(aVi); + aTi=BRep_Tool::Tolerance(aVi); + aDi=aP.Distance(aPi); + aDi=aDi+aTi; + if (aDi > aDmax) { + aDmax=aDi; + } + } + BRep_Builder aBB; + aBB.MakeVertex (aNewVertex, aP, aDmax); +} +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const BOPTools_CArray1OfSSInterference& FFs, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) +{ + Standard_Boolean bIsTangentFaces; + Standard_Integer j, aNb, anIndex1, anIndex2; + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMCV; + // + aNb=FFs.Extent(); + for (j=1; j<=aNb; ++j) { + const BOPTools_SSInterference& aFF=FFs(j); + // + bIsTangentFaces=aFF.IsTangentFaces(); + if (!bIsTangentFaces) { + continue; + } + // + aFF.Indices(anIndex1, anIndex2); + // + if (aMCV.Contains(anIndex1)) { + TColStd_IndexedMapOfInteger& aMV=aMCV.ChangeFromKey(anIndex1); + aMV.Add(anIndex1); + aMV.Add(anIndex2); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(anIndex1); + aMV.Add(anIndex2); + aMCV.Add(anIndex1, aMV); + } + // + if (aMCV.Contains(anIndex2)) { + TColStd_IndexedMapOfInteger& aMV=aMCV.ChangeFromKey(anIndex2); + aMV.Add(anIndex1); + aMV.Add(anIndex2); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(anIndex1); + aMV.Add(anIndex2); + aMCV.Add(anIndex2, aMV); + } + } + NMTTools_Tools::FindChains(aMCV, aMapChains); +} +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const BOPTools_CArray1OfVVInterference& VVs, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) +{ + Standard_Integer j, aNb, anIndex1, anIndex2; + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger aMCV; + // + aNb=VVs.Extent(); + for (j=1; j<=aNb; ++j) { + const BOPTools_VVInterference& VV=VVs(j); + VV.Indices(anIndex1, anIndex2); + // + if (aMCV.Contains(anIndex1)) { + TColStd_IndexedMapOfInteger& aMV=aMCV.ChangeFromKey(anIndex1); + aMV.Add(anIndex1); + aMV.Add(anIndex2); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(anIndex1); + aMV.Add(anIndex2); + aMCV.Add(anIndex1, aMV); + } + // + if (aMCV.Contains(anIndex2)) { + TColStd_IndexedMapOfInteger& aMV=aMCV.ChangeFromKey(anIndex2); + aMV.Add(anIndex1); + aMV.Add(anIndex2); + } + else { + TColStd_IndexedMapOfInteger aMV; + aMV.Add(anIndex1); + aMV.Add(anIndex2); + aMCV.Add(anIndex2, aMV); + } + } + NMTTools_Tools::FindChains(aMCV, aMapChains); +} + +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMapChains) +{ + Standard_Integer i, j, aNbCV, aNbV, iV, iVx; + TColStd_IndexedMapOfInteger aProcessed, aChain; + // + aNbCV=aMCV.Extent(); + for (i=1; i<=aNbCV; ++i) { + iV=aMCV.FindKey(i); + if (aProcessed.Contains(iV)) { + continue; + } + // + aProcessed.Add(iV); + aChain.Add(iV); + // + const TColStd_IndexedMapOfInteger& aMV=aMCV(i); + aNbV=aMV.Extent(); + for (j=1; j<=aNbV; ++j) { + iVx=aMV(j); + ProcessBlock(iVx, aMCV, aProcessed, aChain); + } + aMapChains.Add(i, aChain); + aChain.Clear(); + } +} +//======================================================================= +// function: ProcessBlock +// purpose: +//======================================================================= +void ProcessBlock(const Standard_Integer iV, + const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + TColStd_IndexedMapOfInteger& aProcessed, + TColStd_IndexedMapOfInteger& aChain) +{ + Standard_Integer j, aNbV, iVx; + // + if (aProcessed.Contains(iV)) { + return; + } + aProcessed.Add(iV); + aChain.Add(iV); + // + const TColStd_IndexedMapOfInteger& aMV=aMCV.FindFromKey(iV); + aNbV=aMV.Extent(); + for (j=1; j<=aNbV; ++j) { + iVx=aMV(j); + ProcessBlock(iVx, aMCV, aProcessed, aChain); + } +} +//======================================================================= +// function: AreFacesSameDomain +// purpose : +//======================================================================= + Standard_Boolean NMTTools_Tools::AreFacesSameDomain(const TopoDS_Face& aF1x, + const TopoDS_Face& aF2y, + const Handle(IntTools_Context)& aCtx) +{ + Standard_Boolean bFlag; + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + Standard_Integer aNbE1, aNbE2; + Standard_Real aTolF1, aTolF2, aTol; + gp_Pnt2d aP2D; + gp_Pnt aP; + TopoDS_Face aF1, aF2; + TopExp_Explorer aExp; + TopTools_MapOfShape aME1, aME2; + TopTools_MapIteratorOfMapOfShape aIt; + // + bFlag=Standard_False; + // Contribution of Samtech www.samcef.com END + // + aF1=aF1x; + aF1.Orientation(TopAbs_FORWARD); + aF2=aF2y; + aF2.Orientation(TopAbs_FORWARD); + // + // Modified Thu Sep 14 14:35:18 2006 + // Contribution of Samtech www.samcef.com BEGIN + // + // 1 + aExp.Init(aF1, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + if (!BRep_Tool::Degenerated(aE)) { + aME1.Add(aE); + } + } + // + aExp.Init(aF2, TopAbs_EDGE); + for (; aExp.More(); aExp.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aExp.Current()); + if (!BRep_Tool::Degenerated(aE)) { + if (!aME1.Contains(aE)) { + return bFlag; + } + aME2.Add(aE); + } + } + // + // Contribution of Samtech www.samcef.com END + // + aNbE1=aME1.Extent(); + aNbE2=aME2.Extent(); + // + if(!aNbE1 || !aNbE2){ + return bFlag; + } + // + if(aNbE1!=aNbE2) { + return bFlag; + } + // + // 2 + aTolF1=BRep_Tool::Tolerance(aF1); + aTolF2=BRep_Tool::Tolerance(aF2); + aTol=aTolF1+aTolF2; + // + aIt.Initialize(aME1); + for (; aIt.More(); aIt.Next()) { + const TopoDS_Edge& aE=TopoDS::Edge(aIt.Key()); + BOPTools_Tools3D::PointNearEdge(aE, aF1, aP2D, aP); + bFlag=aCtx->IsValidPointForFace(aP, aF2, aTol); + break; + } + // + return bFlag; +} +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const NMTTools_ListOfCoupleOfShape& aLCS, + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains) +{ + NMTTools_ListIteratorOfListOfCoupleOfShape aItCS; + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMCV; + // + aItCS.Initialize(aLCS); + for (; aItCS.More(); aItCS.Next()) { + const NMTTools_CoupleOfShape& aCS=aItCS.Value(); + // + const TopoDS_Shape& aF1=aCS.Shape1(); + const TopoDS_Shape& aF2=aCS.Shape2(); + // + // + if (aMCV.Contains(aF1)) { + TopTools_IndexedMapOfShape& aMV=aMCV.ChangeFromKey(aF1); + aMV.Add(aF1); + aMV.Add(aF2); + } + else { + TopTools_IndexedMapOfShape aMV; + aMV.Add(aF1); + aMV.Add(aF2); + aMCV.Add(aF1, aMV); + } + // + if (aMCV.Contains(aF2)) { + TopTools_IndexedMapOfShape& aMV=aMCV.ChangeFromKey(aF2); + aMV.Add(aF1); + aMV.Add(aF2); + } + else { + TopTools_IndexedMapOfShape aMV; + aMV.Add(aF1); + aMV.Add(aF2); + aMCV.Add(aF2, aMV); + } + } + NMTTools_Tools::FindChains(aMCV, aMapChains); +} +//======================================================================= +// function: FindChains +// purpose : +//======================================================================= + void NMTTools_Tools::FindChains(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMapChains) +{ + Standard_Integer i, j, aNbCV, aNbV; + TopTools_IndexedMapOfShape aProcessed, aChain; + // + aNbCV=aMCV.Extent(); + for (i=1; i<=aNbCV; ++i) { + const TopoDS_Shape& aF=aMCV.FindKey(i); + if (aProcessed.Contains(aF)) { + continue; + } + // + aProcessed.Add(aF); + aChain.Add(aF); + // + const TopTools_IndexedMapOfShape& aMV=aMCV(i); + aNbV=aMV.Extent(); + for (j=1; j<=aNbV; ++j) { + const TopoDS_Shape& aFx=aMV(j); + ProcessBlock(aFx, aMCV, aProcessed, aChain); + } + aMapChains.Add(aF, aChain); + aChain.Clear(); + } +} +//======================================================================= +// function: ProcessBlock +// purpose: +//======================================================================= +void ProcessBlock(const TopoDS_Shape& aF, + const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aMCV, + TopTools_IndexedMapOfShape& aProcessed, + TopTools_IndexedMapOfShape& aChain) +{ + Standard_Integer j, aNbV; + // + if (aProcessed.Contains(aF)) { + return; + } + aProcessed.Add(aF); + aChain.Add(aF); + // + const TopTools_IndexedMapOfShape& aMV=aMCV.FindFromKey(aF); + aNbV=aMV.Extent(); + for (j=1; j<=aNbV; ++j) { + const TopoDS_Shape& aFx=aMV(j); + ProcessBlock(aFx, aMCV, aProcessed, aChain); + } +} diff --git a/src/NMTTools_NEW/NMTTools_Tools.hxx b/src/NMTTools_NEW/NMTTools_Tools.hxx new file mode 100644 index 000000000..f63a65281 --- /dev/null +++ b/src/NMTTools_NEW/NMTTools_Tools.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 +// + +// File: NMTTools_Tools.hxx +// Created: Mon Dec 8 10:35:15 2003 +// Author: Peter KURNEV +// + +#ifndef _NMTTools_Tools_HeaderFile +#define _NMTTools_Tools_HeaderFile + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//======================================================================= +//function : NMTTools_Tools +//purpose : +//======================================================================= +class NMTTools_Tools { + public: + Standard_EXPORT + static void MakeNewVertex(const TopTools_ListOfShape& aLV, + TopoDS_Vertex& aNewVertex) ; + + Standard_EXPORT + static void FindChains(const BOPTools_CArray1OfVVInterference& aVVs, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ; + + Standard_EXPORT + static void FindChains(const BOPTools_CArray1OfSSInterference& aVVs, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ; + + Standard_EXPORT + static void FindChains(const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV, + BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ; + + Standard_EXPORT + static Standard_Boolean IsSplitInOnFace(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Handle(IntTools_Context)& aCtx) ; + + Standard_EXPORT + static Standard_Boolean AreFacesSameDomain(const TopoDS_Face& aF1, + const TopoDS_Face& aF2, + const Handle(IntTools_Context)& aCtx) ; + + Standard_EXPORT + static void FindChains(const NMTTools_ListOfCoupleOfShape& aLCS, + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM) ; + + Standard_EXPORT + static void FindChains(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM1, + NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM2) ; + + Standard_EXPORT + static void MakePCurve(const TopoDS_Edge& aE, + const TopoDS_Face& aF, + const Handle(Geom2d_Curve)& aC2D) ; + + Standard_EXPORT + static void UpdateEdge(const TopoDS_Edge& aE, + const Standard_Real aTol) ; + +}; +#endif