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
src/EntityGUI/Makefile \
src/GEOM/Makefile \
src/GEOMAlgo/Makefile \
+ src/GEOMAlgo_NEW/Makefile \
src/GEOMBase/Makefile \
src/GEOMClient/Makefile \
src/GEOMFiltersSelection/Makefile \
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 \
--- /dev/null
+-- 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;
--- /dev/null
+// 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 <BlockFix.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <ShapeCustom.hxx>
+#include <BRepTools.hxx>
+#include <ShapeBuild_ReShape.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopLoc_Location.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <ShapeFix_Wire.hxx>
+#include <TopoDS_Wire.hxx>
+#include <BRepTools_Modifier.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_ToroidalSurface.hxx>
+#include <BRep_Tool.hxx>
+#include <TopoDS_Edge.hxx>
+#include <Geom2d_Curve.hxx>
+#include <BRep_Builder.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeFix_Edge.hxx>
+#include <ShapeFix.hxx>
+#include <ShapeFix_Face.hxx>
+#include <ShapeAnalysis.hxx>
+
+#include <TColgp_SequenceOfPnt2d.hxx>
+#include <ShapeAnalysis_Curve.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <ShapeBuild_Edge.hxx>
+
+#include <BlockFix_SphereSpaceModifier.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <BlockFix_PeriodicSurfaceModifier.hxx>
+
+#include <TopoDS_Solid.hxx>
+
+
+//=======================================================================
+//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; i<sewd->NbEdges();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;
+}
--- /dev/null
+// 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 <Standard_Real.hxx>
+#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 <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#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
--- /dev/null
+// 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 <BlockFix.jxx>
+
+
+
+
--- /dev/null
+// 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 <TopoDS_Shape.hxx>
+#endif
+#ifndef _BlockFix_HeaderFile
+#include <BlockFix.hxx>
+#endif
--- /dev/null
+-- 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;
--- /dev/null
+// 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 <BlockFix_BlockFixAPI.ixx>
+#include <BlockFix.hxx>
+#include <BlockFix_UnionFaces.hxx>
+#include <BlockFix_UnionEdges.hxx>
+#include <Precision.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// 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 <Standard.hxx>
+#endif
+#ifndef _Handle_BlockFix_BlockFixAPI_HeaderFile
+#include <Handle_BlockFix_BlockFixAPI.hxx>
+#endif
+
+#ifndef _Handle_ShapeBuild_ReShape_HeaderFile
+#include <Handle_ShapeBuild_ReShape.hxx>
+#endif
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
+#ifndef _Standard_Real_HeaderFile
+#include <Standard_Real.hxx>
+#endif
+#ifndef _MMgt_TShared_HeaderFile
+#include <MMgt_TShared.hxx>
+#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 <BlockFix_BlockFixAPI.lxx>
+
+#endif
--- /dev/null
+// 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 <BlockFix_BlockFixAPI.jxx>
+
+#ifndef _Standard_TypeMismatch_HeaderFile
+#include <Standard_TypeMismatch.hxx>
+#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() {}
+
--- /dev/null
+// 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 <ShapeBuild_ReShape.hxx>
+#endif
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
+#ifndef _BlockFix_BlockFixAPI_HeaderFile
+#include <BlockFix_BlockFixAPI.hxx>
+#endif
--- /dev/null
+// 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 <BlockFix_BlockFixAPI.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+-- 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;
--- /dev/null
+// 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 <BlockFix_CheckTool.ixx>
+
+//#include <BlockFix_UnionEdges.hxx>
+//#include <BlockFix_UnionFaces.hxx>
+
+#include <BRep_Tool.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+
+//=======================================================================
+//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<faces.Length() && !HasFacesForUnification; i++) {
+ TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
+ TopTools_MapOfShape Edges;
+ for (TopExp_Explorer expe(F1,TopAbs_EDGE); expe.More(); expe.Next())
+ Edges.Add(expe.Current().Oriented(TopAbs_FORWARD));
+ TopLoc_Location L1;
+ Handle(Geom_Surface) S1 = BRep_Tool::Surface(F1,L1);
+ for(Standard_Integer j=i+1; j<=faces.Length() && !HasFacesForUnification; j++) {
+ TopoDS_Face F2 = TopoDS::Face(faces.Value(j));
+ TopLoc_Location L2;
+ Handle(Geom_Surface) S2 = BRep_Tool::Surface(F2,L2);
+ if( S1==S2 && L1==L2 ) {
+ // faces have equal based surface
+ // now check common edge
+ for(TopExp_Explorer expe2(F2,TopAbs_EDGE); expe2.More(); expe2.Next()) {
+ if(Edges.Contains(expe2.Current().Oriented(TopAbs_FORWARD))) {
+ HasFacesForUnification = Standard_True;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (HasFacesForUnification) {
+ MayBeUF=Standard_True;
+ }
+ }
+
+ Standard_Integer nbe=0;
+ TopTools_MapOfShape DegenEdges;
+ TopExp_Explorer expe (aSolid, TopAbs_EDGE);
+ TopTools_MapOfShape mapE;
+ for (; expe.More(); expe.Next()) {
+ TopoDS_Edge E = TopoDS::Edge(expe.Current());
+ if (!mapE.Add(E)) continue;
+ if (BRep_Tool::Degenerated(E)) {
+ DegenEdges.Add(E);
+ }
+ else {
+ nbe++;
+ }
+ }
+ if (nbe == 12 && DegenEdges.Extent() > 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!"<<endl;
+ else {
+ S<<"dump results of check:"<<endl;
+ S<<" total number of solids = "<<myNbSolids<<endl;
+ S<<" including: number of good blocks = "<<myNbBlocks<<endl;
+ S<<" number of possible blocks = "<<NbPossibleBlocks()<<endl;
+ S<<" including: need remove degenerative = "<<myNbDegen<<endl;
+ S<<" need unionfaces = "<<myNbUF<<endl;
+ S<<" need unionedges = "<<myNbUE<<endl;
+ S<<" need both unionfaces and unionedges = "<<myNbUFUE<<endl;
+ Standard_Integer nbtmp = myNbSolids - myNbBlocks - NbPossibleBlocks();
+ S<<" number of impossible blocks = "<<nbtmp<<endl;
+ }
+}
--- /dev/null
+// 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_CheckTool_HeaderFile
+#define _BlockFix_CheckTool_HeaderFile
+
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Standard_Integer_HeaderFile
+#include <Standard_Integer.hxx>
+#endif
+#ifndef _TopTools_SequenceOfShape_HeaderFile
+#include <TopTools_SequenceOfShape.hxx>
+#endif
+#ifndef _Standard_OStream_HeaderFile
+#include <Standard_OStream.hxx>
+#endif
+class TopoDS_Shape;
+
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#endif
+
+class BlockFix_CheckTool {
+
+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_CheckTool();
+Standard_EXPORT void SetShape(const TopoDS_Shape& aShape) ;
+Standard_EXPORT void Perform() ;
+Standard_EXPORT Standard_Integer NbPossibleBlocks() const;
+Standard_EXPORT TopoDS_Shape PossibleBlock(const Standard_Integer num) const;
+Standard_EXPORT void DumpCheckResult(Standard_OStream& S) const;
+
+
+
+
+
+protected:
+
+ // Methods PROTECTED
+ //
+
+
+ // Fields PROTECTED
+ //
+
+
+private:
+
+ // Methods PRIVATE
+ //
+
+
+ // Fields PRIVATE
+ //
+TopoDS_Shape myShape;
+Standard_Boolean myHasCheck;
+Standard_Integer myNbSolids;
+Standard_Integer myNbBlocks;
+TopTools_SequenceOfShape myPossibleBlocks;
+Standard_Integer myNbDegen;
+Standard_Integer myNbUF;
+Standard_Integer myNbUE;
+Standard_Integer myNbUFUE;
+Standard_Integer myBadRanges;
+
+
+};
+
+
+
+
+
+// other Inline functions and methods (like "C++: function call" methods)
+//
+
+
+#endif
--- /dev/null
+// 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 <BlockFix_CheckTool.jxx>
+
+
+
+
--- /dev/null
+// 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 <TopoDS_Shape.hxx>
+#endif
+#ifndef _BlockFix_CheckTool_HeaderFile
+#include <BlockFix_CheckTool.hxx>
+#endif
--- /dev/null
+-- 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 <F> has been
+ -- modified. In this case, <S> is the new geometric
+ -- support of the face, <L> the new location, <Tol>
+ -- the new tolerance. Otherwise, returns
+ -- Standard_False, and <S>, <L>, <Tol> 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 <E> has been
+ -- modified. In this case, <C> is the new geometric
+ -- support of the edge, <L> the new location, <Tol>
+ -- the new tolerance. Otherwise, returns
+ -- Standard_False, and <C>, <L>, <Tol> 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 <V> has been
+ -- modified. In this case, <P> is the new geometric
+ -- support of the vertex, <Tol> the new tolerance.
+ -- Otherwise, returns Standard_False, and <P>, <Tol>
+ -- 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 <E> has a new
+ -- curve on surface on the face <F>.In this case, <C>
+ -- is the new geometric support of the edge, <L> the
+ -- new location, <Tol> the new tolerance.
+ --
+ -- Otherwise, returns Standard_False, and <C>, <L>,
+ -- <Tol> are not significant.
+ --
+ -- <NewE> is the new edge created from <E>. <NewF>
+ -- is the new face created from <F>. 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 <V> has a new
+ -- parameter on the edge <E>. In this case, <P> is
+ -- the parameter, <Tol> the new tolerance.
+ -- Otherwise, returns Standard_False, and <P>, <Tol>
+ -- 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 <NewE> between <NewF1>
+ -- and <NewF2>.
+ --
+ -- <NewE> is the new edge created from <E>. <NewF1>
+ -- (resp. <NewF2>) is the new face created from <F1>
+ -- (resp. <F2>).
+
+
+fields
+
+ myTolerance : Real;
+ myMapOfFaces : DataMapOfShapeInteger from TopTools;
+ myMapOfSurfaces: IndexedMapOfTransient from TColStd;
+
+end PeriodicSurfaceModifier;
--- /dev/null
+// 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 <BlockFix_PeriodicSurfaceModifier.ixx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <ShapeFix_Edge.hxx>
+#include <TopExp.hxx>
+
+
+//=======================================================================
+//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);
+}
+
--- /dev/null
+// 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 <Standard.hxx>
+#endif
+#ifndef _Handle_BlockFix_PeriodicSurfaceModifier_HeaderFile
+#include <Handle_BlockFix_PeriodicSurfaceModifier.hxx>
+#endif
+
+#ifndef _Standard_Real_HeaderFile
+#include <Standard_Real.hxx>
+#endif
+#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#endif
+#ifndef _TColStd_IndexedMapOfTransient_HeaderFile
+#include <TColStd_IndexedMapOfTransient.hxx>
+#endif
+#ifndef _BRepTools_Modification_HeaderFile
+#include <BRepTools_Modification.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Handle_Geom_Surface_HeaderFile
+#include <Handle_Geom_Surface.hxx>
+#endif
+#ifndef _Handle_Geom_Curve_HeaderFile
+#include <Handle_Geom_Curve.hxx>
+#endif
+#ifndef _Handle_Geom2d_Curve_HeaderFile
+#include <Handle_Geom2d_Curve.hxx>
+#endif
+#ifndef _GeomAbs_Shape_HeaderFile
+#include <GeomAbs_Shape.hxx>
+#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
--- /dev/null
+// 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 <BlockFix_PeriodicSurfaceModifier.jxx>
+
+#ifndef _Standard_TypeMismatch_HeaderFile
+#include <Standard_TypeMismatch.hxx>
+#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() {}
+
--- /dev/null
+// 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 <TopoDS_Face.hxx>
+#endif
+#ifndef _Geom_Surface_HeaderFile
+#include <Geom_Surface.hxx>
+#endif
+#ifndef _TopLoc_Location_HeaderFile
+#include <TopLoc_Location.hxx>
+#endif
+#ifndef _TopoDS_Edge_HeaderFile
+#include <TopoDS_Edge.hxx>
+#endif
+#ifndef _Geom_Curve_HeaderFile
+#include <Geom_Curve.hxx>
+#endif
+#ifndef _TopoDS_Vertex_HeaderFile
+#include <TopoDS_Vertex.hxx>
+#endif
+#ifndef _gp_Pnt_HeaderFile
+#include <gp_Pnt.hxx>
+#endif
+#ifndef _Geom2d_Curve_HeaderFile
+#include <Geom2d_Curve.hxx>
+#endif
+#ifndef _BlockFix_PeriodicSurfaceModifier_HeaderFile
+#include <BlockFix_PeriodicSurfaceModifier.hxx>
+#endif
--- /dev/null
+-- 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 <F> has been
+ -- modified. In this case, <S> is the new geometric
+ -- support of the face, <L> the new location, <Tol>
+ -- the new tolerance. Otherwise, returns
+ -- Standard_False, and <S>, <L>, <Tol> 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 <E> has been
+ -- modified. In this case, <C> is the new geometric
+ -- support of the edge, <L> the new location, <Tol>
+ -- the new tolerance. Otherwise, returns
+ -- Standard_False, and <C>, <L>, <Tol> 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 <V> has been
+ -- modified. In this case, <P> is the new geometric
+ -- support of the vertex, <Tol> the new tolerance.
+ -- Otherwise, returns Standard_False, and <P>, <Tol>
+ -- 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 <E> has a new
+ -- curve on surface on the face <F>.In this case, <C>
+ -- is the new geometric support of the edge, <L> the
+ -- new location, <Tol> the new tolerance.
+ --
+ -- Otherwise, returns Standard_False, and <C>, <L>,
+ -- <Tol> are not significant.
+ --
+ -- <NewE> is the new edge created from <E>. <NewF>
+ -- is the new face created from <F>. 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 <V> has a new
+ -- parameter on the edge <E>. In this case, <P> is
+ -- the parameter, <Tol> the new tolerance.
+ -- Otherwise, returns Standard_False, and <P>, <Tol>
+ -- 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 <NewE> between <NewF1>
+ -- and <NewF2>.
+ --
+ -- <NewE> is the new edge created from <E>. <NewF1>
+ -- (resp. <NewF2>) is the new face created from <F1>
+ -- (resp. <F2>).
+
+ 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;
+
--- /dev/null
+// 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 <BlockFix_SphereSpaceModifier.ixx>
+
+#include <TopLoc_Location.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+#include <ShapeAnalysis.hxx>
+#include <gp_Sphere.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopExp.hxx>
+#include <ShapeFix_Edge.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom2d_Curve.hxx>
+
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// 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 <Standard.hxx>
+#endif
+#ifndef _Handle_BlockFix_SphereSpaceModifier_HeaderFile
+#include <Handle_BlockFix_SphereSpaceModifier.hxx>
+#endif
+
+#ifndef _Standard_Real_HeaderFile
+#include <Standard_Real.hxx>
+#endif
+#ifndef _TopTools_DataMapOfShapeInteger_HeaderFile
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#endif
+#ifndef _TColStd_IndexedMapOfTransient_HeaderFile
+#include <TColStd_IndexedMapOfTransient.hxx>
+#endif
+#ifndef _BRepTools_Modification_HeaderFile
+#include <BRepTools_Modification.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Handle_Geom_Surface_HeaderFile
+#include <Handle_Geom_Surface.hxx>
+#endif
+#ifndef _Handle_Geom_Curve_HeaderFile
+#include <Handle_Geom_Curve.hxx>
+#endif
+#ifndef _Handle_Geom2d_Curve_HeaderFile
+#include <Handle_Geom2d_Curve.hxx>
+#endif
+#ifndef _GeomAbs_Shape_HeaderFile
+#include <GeomAbs_Shape.hxx>
+#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
--- /dev/null
+// 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 <BlockFix_SphereSpaceModifier.jxx>
+
+#ifndef _Standard_TypeMismatch_HeaderFile
+#include <Standard_TypeMismatch.hxx>
+#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() {}
+
--- /dev/null
+// 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 <TopoDS_Face.hxx>
+#endif
+#ifndef _Geom_Surface_HeaderFile
+#include <Geom_Surface.hxx>
+#endif
+#ifndef _TopLoc_Location_HeaderFile
+#include <TopLoc_Location.hxx>
+#endif
+#ifndef _TopoDS_Edge_HeaderFile
+#include <TopoDS_Edge.hxx>
+#endif
+#ifndef _Geom_Curve_HeaderFile
+#include <Geom_Curve.hxx>
+#endif
+#ifndef _TopoDS_Vertex_HeaderFile
+#include <TopoDS_Vertex.hxx>
+#endif
+#ifndef _gp_Pnt_HeaderFile
+#include <gp_Pnt.hxx>
+#endif
+#ifndef _Geom2d_Curve_HeaderFile
+#include <Geom2d_Curve.hxx>
+#endif
+#ifndef _BlockFix_SphereSpaceModifier_HeaderFile
+#include <BlockFix_SphereSpaceModifier.hxx>
+#endif
--- /dev/null
+-- 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;
--- /dev/null
+// 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 <BlockFix_UnionEdges.ixx>
+
+#include <Approx_Curve3d.hxx>
+#include <BRepAdaptor_HCompCurve.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <GC_MakeCircle.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+#include <ShapeFix_Edge.hxx>
+#include <ShapeFix_Face.hxx>
+#include <ShapeFix_Shell.hxx>
+#include <TColgp_SequenceOfPnt.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#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()<SeqEdges.Length()) {
+ MESSAGE ("can not create correct chain...");
+ return Standard_False;
+ }
+ // union edges in chain
+ // first step: union lines and circles
+ TopLoc_Location Loc;
+ Standard_Real fp1,lp1,fp2,lp2;
+ for(j=1; j<aChain.Length(); j++) {
+ TopoDS_Edge edge1 = TopoDS::Edge(aChain.Value(j));
+ Handle(Geom_Curve) c3d1 = BRep_Tool::Curve(edge1,Loc,fp1,lp1);
+ if(c3d1.IsNull()) break;
+ while(c3d1->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;
+}
--- /dev/null
+// 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 <Standard_Real.hxx>
+#endif
+#ifndef _Handle_ShapeBuild_ReShape_HeaderFile
+#include <Handle_ShapeBuild_ReShape.hxx>
+#endif
+class ShapeBuild_ReShape;
+class TopoDS_Shape;
+
+
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#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
--- /dev/null
+// 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 <BlockFix_UnionEdges.jxx>
+
+
+
+
--- /dev/null
+// 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 <ShapeBuild_ReShape.hxx>
+#endif
+#ifndef _TopoDS_Shape_HeaderFile
+#include <TopoDS_Shape.hxx>
+#endif
+#ifndef _BlockFix_UnionEdges_HeaderFile
+#include <BlockFix_UnionEdges.hxx>
+#endif
--- /dev/null
+-- 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;
+
+
--- /dev/null
+// 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 <BlockFix_UnionFaces.ixx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <ShapeAnalysis_WireOrder.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+
+#include <ShapeBuild_Edge.hxx>
+#include <ShapeBuild_ReShape.hxx>
+
+#include <ShapeExtend_WireData.hxx>
+#include <ShapeExtend_CompositeSurface.hxx>
+
+#include <ShapeFix_Face.hxx>
+#include <ShapeFix_ComposeShell.hxx>
+#include <ShapeFix_SequenceOfWireSegment.hxx>
+#include <ShapeFix_WireSegment.hxx>
+#include <ShapeFix_Wire.hxx>
+#include <ShapeFix_Edge.hxx>
+
+#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
+#include <IntPatch_ImpImpIntersection.hxx>
+#else
+#include <IntPatch_TheIIIntOfIntersection.hxx>
+#endif
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+#include <BRepTopAdaptor_TopolTool.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_SequenceOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TColGeom_HArray2OfSurface.hxx>
+
+#include <GeomAdaptor_HSurface.hxx>
+#include <GeomLib_IsPlanarSurface.hxx>
+
+#include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_OffsetSurface.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_SurfaceOfRevolution.hxx>
+#include <Geom_SurfaceOfLinearExtrusion.hxx>
+#include <Geom_RectangularTrimmedSurface.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Line.hxx>
+#include <Geom_Circle.hxx>
+
+#include <Geom2d_Line.hxx>
+
+#include <gp_XY.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <Standard_Failure.hxx>
+#include <Standard_ErrorHandler.hxx> // 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);
+ }
+}
--- /dev/null
+// 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 <Standard_Real.hxx>
+#endif
+#ifndef _Standard_Boolean_HeaderFile
+#include <Standard_Boolean.hxx>
+#endif
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+#ifndef _Standard_Macro_HeaderFile
+#include <Standard_Macro.hxx>
+#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
--- /dev/null
+// 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 <BlockFix_UnionFaces.jxx>
+
+
+
+
--- /dev/null
+// 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 <TopoDS_Shape.hxx>
+#endif
+#ifndef _TopoDS_Face_HeaderFile
+#include <TopoDS_Face.hxx>
+#endif
+#ifndef _BlockFix_UnionFaces_HeaderFile
+#include <BlockFix_UnionFaces.hxx>
+#endif
--- /dev/null
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+-- 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;
+ --
+ --
--- /dev/null
+// 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
+// <peter@PREFEX>
+//
+#include <GEOMAlgo_Algo.hxx>
+
+//=======================================================================
+// 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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_Algo.hxx\r
+// Created: Sat Dec 04 12:39:47 2004\r
+// Author: Peter KURNEV\r
+// <peter@PREFEX>\r
+//\r
+#ifndef _GEOMAlgo_Algo_HeaderFile\r
+#define _GEOMAlgo_Algo_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_Algo\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_Algo \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ virtual void Perform() = 0;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer ErrorStatus() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer WarningStatus() const;\r
+\r
+ //! Allows to omit of creation of internal shapes (manifold topology). <br>\r
+ //! Needed for the SALOME/TRIPOLI module. <br>\r
+ Standard_EXPORT\r
+ void ComputeInternalShapes(const Standard_Boolean theFlag) ;\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ GEOMAlgo_Algo();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_Algo();\r
+ \r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void CheckResult() ;\r
+\r
+\r
+ Standard_Integer myErrorStatus;\r
+ Standard_Integer myWarningStatus;\r
+ Standard_Boolean myComputeInternalShapes; \r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_Builder.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <BRep_Builder.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <BOP_CorrectTolerances.hxx>
+
+#include <BRepLib.hxx>
+#include <NMTTools_PaveFiller.hxx>
+#include <GEOMAlgo_Tools.hxx>
+
+//=======================================================================
+//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; i<myNbTypes; ++i){
+ myShapes1[i].Clear();
+ }
+ myImages.Clear();
+ //
+ myInParts.Clear();
+ mySplitFaces.Clear();
+ mySameDomainShapes.Clear();
+ myDraftSolids.Clear();
+ myMapFence.Clear();
+}
+//=======================================================================
+//function : Prepare
+//purpose :
+//=======================================================================
+ void GEOMAlgo_Builder::Prepare()
+{
+ myErrorStatus=0;
+ //
+ Standard_Integer aNb;
+ BRep_Builder aBB;
+ TopoDS_Compound aC;
+ TopTools_ListIteratorOfListOfShape aIt;
+ //
+ aNb=myShapes.Extent();
+ if (aNb<2) {
+ myErrorStatus=10; // No shapes to process
+ return;
+ }
+ //
+ // 1. myShape is empty compound
+ aBB.MakeCompound(aC);
+ myShape=aC;
+ //
+ // 2. myShapes1
+ aIt.Initialize(myShapes);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aS=aIt.Value();
+ AddShape1(aS);
+ }
+}
+
+//=======================================================================
+//function : AddShape1
+//purpose :
+//=======================================================================
+ void GEOMAlgo_Builder::AddShape1(const TopoDS_Shape& theShape)
+{
+ Standard_Integer iType;
+ TopAbs_ShapeEnum aType;
+ TopoDS_Iterator aIt;
+ TopTools_MapOfShape aM;
+ //
+ aType=theShape.ShapeType();
+ if (aType==TopAbs_COMPOUND) {
+ aIt.Initialize(theShape);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aS=aIt.Value();
+ AddShape1(aS);
+ }
+ }
+ //
+ iType=(Standard_Integer)aType;
+ if (aM.Add(theShape)) {
+ myShapes1[iType].Append(theShape);
+ }
+}
+//=======================================================================
+//function : BuildResult
+//purpose :
+//=======================================================================
+ void GEOMAlgo_Builder::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) {
+ 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 : Perform
+//purpose :
+//=======================================================================
+ void GEOMAlgo_Builder::Perform()
+{
+ myErrorStatus=0;
+ //
+ BRep_Builder aBB;
+ TopoDS_Compound aCS;
+ TopTools_ListIteratorOfListOfShape aIt;
+ //
+ aBB.MakeCompound(aCS);
+ //
+ aIt.Initialize(myShapes);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aS=aIt.Value();
+ aBB.Add(aCS, aS);
+ }
+ //
+ NMTTools_PaveFiller* pPF=new NMTTools_PaveFiller;
+ //
+ pPF->SetCompositeShape(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
+
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_Builder.cxx\r
+// Created: \r
+// Author: Peter KURNEV \r
+//\r
+#ifndef _GEOMAlgo_Builder_HeaderFile\r
+#define _GEOMAlgo_Builder_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <NMTTools_PPaveFiller.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TopTools_MapOfShape.hxx>\r
+#include <BRepAlgo_Image.hxx>\r
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>\r
+#include <TopTools_IndexedDataMapOfShapeShape.hxx>\r
+#include <GEOMAlgo_BuilderShape.hxx>\r
+#include <NMTTools_PaveFiller.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <BRepAlgo_Image.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_Builder\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_Builder : public GEOMAlgo_BuilderShape \r
+{\r
+ public:\r
+ //! Empty constructor <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_Builder();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_Builder();\r
+ \r
+ //! Performs calculations <br>\r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ //! Performs calculations using prepared PaveFiller <br>\r
+ //! object theDSF <br>\r
+ Standard_EXPORT\r
+ virtual void PerformWithFiller(const NMTTools_PaveFiller& theDSF) ;\r
+ \r
+ //! Adds argument theShape of the operation <br>\r
+ Standard_EXPORT\r
+ virtual void AddShape(const TopoDS_Shape& theShape) ;\r
+ \r
+ //! Clears internal fields and arguments <br>\r
+ Standard_EXPORT\r
+ virtual void Clear() ;\r
+ \r
+ //! Returns the arguments of the operation <br>\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Shapes() const;\r
+ \r
+ //! Returns the list of shapes generated from the <br>\r
+ //! shape theS. <br>\r
+ Standard_EXPORT\r
+ virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ;\r
+ \r
+ //! Returns the list of shapes modified from the shape <br>\r
+ //! theS. <br>\r
+ Standard_EXPORT\r
+ virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ;\r
+ \r
+ //! Returns true if the shape theS has been deleted. <br>\r
+ Standard_EXPORT \r
+ virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ;\r
+ \r
+ //! Adds arguments of the operation as <br>\r
+ //! shapes of upper level of container shape theShape <br>\r
+ Standard_EXPORT\r
+ void AddCompound(const TopoDS_Shape& theShape) ;\r
+ \r
+ //! Returns list of arguments of type theType <br>\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Shapes1(const Standard_Integer theType) const;\r
+ \r
+ //! Returns image shapes <br>\r
+ Standard_EXPORT\r
+ const BRepAlgo_Image& Images() const;\r
+ \r
+ //! Returns split-parts of shapes that have <br>\r
+ //! state IN for the domain of shape theShape <br>\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& InParts(const TopoDS_Shape& theShape) const;\r
+\r
+protected:\r
+ //! Performs calculations using prepared DSFiller <br>\r
+ //! object theDSF <br>\r
+ Standard_EXPORT\r
+ virtual void PerformInternal(const NMTTools_PaveFiller& theDSF) ;\r
+ \r
+ //! Prepare information for history support <br>\r
+ Standard_EXPORT \r
+ virtual void PrepareHistory() ;\r
+ \r
+ //! Clears internal fields <br>\r
+ Standard_EXPORT\r
+ virtual void ClearInternals() ;\r
+ \r
+ //! Provides preparing actions <br>\r
+ Standard_EXPORT\r
+ virtual void Prepare() ;\r
+ \r
+ //! Provides post-tratment actions <br>\r
+ Standard_EXPORT\r
+ virtual void PostTreat() ;\r
+ \r
+ //! Append the argument theShape to <br>\r
+ //! typified lists of arguments myShapes1 <br>\r
+ Standard_EXPORT\r
+ void AddShape1(const TopoDS_Shape& theShape) ;\r
+ \r
+ //! Build the resulting shapes of type theType <br>\r
+ Standard_EXPORT\r
+ virtual void BuildResult(const TopAbs_ShapeEnum theType) ;\r
+ \r
+ //! Fill Images for vertices <br>\r
+ Standard_EXPORT\r
+ void FillImagesVertices() ;\r
+ \r
+ //! Fill Images for edges <br>\r
+ Standard_EXPORT\r
+ void FillImagesEdges() ;\r
+ \r
+ //! Fill Images for faces <br>\r
+ Standard_EXPORT\r
+ void FillImagesFaces() ;\r
+ \r
+ //! For each interferred face find split edges <br>\r
+ //! that are in 2-D domain of the face <br>\r
+ Standard_EXPORT\r
+ void FillIn2DParts() ;\r
+ \r
+ //! Build draft faces <br>\r
+ Standard_EXPORT\r
+ void BuildSplitFaces() ;\r
+ \r
+ //! Among draft faces find same domain faces <br>\r
+ Standard_EXPORT\r
+ void FillSameDomainFaces() ;\r
+ \r
+ //! Fill Images for faces <br>\r
+ //! taking into account same domain faces <br>\r
+ Standard_EXPORT\r
+ void FillImagesFaces1() ;\r
+ \r
+ //! Update Images for faces by <br>\r
+ //! internal vertices <br>\r
+ Standard_EXPORT\r
+ void FillInternalVertices() ;\r
+ \r
+ //! Fill Images for Wires, Shells, Compsolids, Compounds <br>\r
+ Standard_EXPORT\r
+ void FillImagesContainers(const TopAbs_ShapeEnum theType) ;\r
+ \r
+ //! Fill Images for solids <br>\r
+ Standard_EXPORT\r
+ void FillImagesSolids() ;\r
+ \r
+ //! For each interferred solid find split faces <br>\r
+ //! that are in 3-D domain of the solid <br>\r
+ Standard_EXPORT\r
+ void FillIn3DParts() ;\r
+ \r
+ //! Build draft solids <br>\r
+ Standard_EXPORT\r
+ void BuildSplitSolids() ;\r
+ \r
+ //! Update draft solids by <br>\r
+ //! internal shells, edges, vertices <br>\r
+ Standard_EXPORT\r
+ void FillInternalShapes() ;\r
+ \r
+ //! Build solid theDraftSolid that consists of <br>\r
+ //! non-internal split faces of the solid <br>\r
+ //! theSolid. <br>\r
+ //! All splits of internal faces of <br>\r
+ //! theSolid are in the list: theInternalFaces <br>\r
+ Standard_EXPORT \r
+ void BuildDraftSolid(const TopoDS_Shape& theSolid,\r
+ TopoDS_Shape& theDraftSolid,\r
+ TopTools_ListOfShape& theInternalFaces) ;\r
+\r
+\r
+ NMTTools_PPaveFiller myPaveFiller;\r
+ TopTools_ListOfShape myShapes;\r
+ Standard_Integer myNbTypes;\r
+ TopTools_MapOfShape myMapFence;\r
+ TopTools_ListOfShape myShapes1[9];\r
+ BRepAlgo_Image myImages;\r
+ TopTools_IndexedDataMapOfShapeListOfShape myInParts;\r
+ BRepAlgo_Image mySplitFaces;\r
+ TopTools_IndexedDataMapOfShapeShape mySameDomainShapes;\r
+ TopTools_IndexedDataMapOfShapeShape myDraftSolids;\r
+ Standard_Integer myEntryPoint;\r
+\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_BuilderArea.hxx>
+
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <IntTools_Context.hxx>
+
+//=======================================================================
+//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()
+{
+}
+
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_BuilderArea.hxx\r
+// Created: \r
+// Author: Peter KURNEV \r
+//\r
+\r
+#ifndef _GEOMAlgo_BuilderArea_HeaderFile\r
+#define _GEOMAlgo_BuilderArea_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopTools_MapOfOrientedShape.hxx>\r
+#include <Handle_IntTools_Context.hxx>\r
+#include <GEOMAlgo_Algo.hxx>\r
+#include <IntTools_Context.hxx>\r
+\r
+//! The root class for algorithms to build <br>\r
+//! faces/solids from set of edges/faces <br>\r
+//=======================================================================\r
+//class : GEOMAlgo_BuilderArea\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_BuilderArea : public GEOMAlgo_Algo \r
+{\r
+ public:\r
+ //! Sets cashed geometrical tools <br>\r
+ Standard_EXPORT\r
+ void SetContext(const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Returns cashed geometrical tools <br>\r
+ Standard_EXPORT\r
+ const Handle_IntTools_Context& Context() const;\r
+ \r
+ //! Sets edges/faces to process <br>\r
+ Standard_EXPORT\r
+ void SetShapes(const TopTools_ListOfShape& theLS) ;\r
+ \r
+ //! Returns edges/faces to process <br>\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Shapes() const;\r
+ \r
+ //! Returns wires/shells that have been built <br>\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Loops() const;\r
+ \r
+ //! Returns faces/solids that have been built <br>\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Areas() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+\r
+ protected:\r
+ //! Empty constructor <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_BuilderArea();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_BuilderArea();\r
+ //! Collect the edges/faces that <br>\r
+ //! a) are internal <br>\r
+ //! b) are the same and have different orientation <br>\r
+ \r
+ Standard_EXPORT\r
+ virtual void PerformShapesToAvoid() ;\r
+\r
+ //! Build draft faces/shells <br>\r
+ //! a)myLoops - draft faces/shells that consist of <br>\r
+ //! boundary edges/faces <br>\r
+ //! b)myLoopsInternal - draft faces/shells that contains <br>\r
+ //! inner edges/faces <br>\r
+ Standard_EXPORT\r
+ virtual void PerformLoops() ;\r
+ //! Build draft faces/solids that contains boundary faces <br>\r
+ \r
+ Standard_EXPORT\r
+ virtual void PerformAreas() ;\r
+ \r
+ //! Build finalized faces/solids with internal wires/shells <br>\r
+ Standard_EXPORT\r
+ virtual void PerformInternalShapes() ;\r
+\r
+ TopTools_ListOfShape myShapes;\r
+ TopTools_ListOfShape myLoops;\r
+ TopTools_ListOfShape myLoopsInternal;\r
+ TopTools_MapOfOrientedShape myShapesToAvoid;\r
+ TopTools_ListOfShape myAreas;\r
+ Handle_IntTools_Context myContext;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_BuilderFace.hxx>
+
+#include <gp_Pnt2d.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+
+#include <Geom_Surface.hxx>
+
+#include <TopAbs.hxx>
+#include <TopLoc_Location.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_MapOfOrientedShape.hxx>
+#include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+
+#include <IntTools_FClass2d.hxx>
+#include <IntTools_Context.hxx>
+
+#include <BOPTools_Tools2D.hxx>
+#include <BOP_WireEdgeSet.hxx>
+#include <BOP_WESCorrector.hxx>
+
+#include <NMTTools_ListOfCoupleOfShape.hxx>
+#include <NMTTools_CoupleOfShape.hxx>
+#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
+
+#include <GEOMAlgo_Tools3D.hxx>
+#include <GEOMAlgo_BuilderTools.hxx>
+#include <GEOMAlgo_WireEdgeSet.hxx>
+#include <GEOMAlgo_WESCorrector.hxx>
+
+//
+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);
+}
+*/
--- /dev/null
+\r
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_BuilderFace.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+//\r
+#ifndef _GEOMAlgo_BuilderFace_HeaderFile\r
+#define _GEOMAlgo_BuilderFace_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <GEOMAlgo_BuilderArea.hxx>\r
+\r
+//! The algorithm to build faces from set of edges <br>\r
+//=======================================================================\r
+//class : GEOMAlgo_BuilderFace\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_BuilderFace : public GEOMAlgo_BuilderArea \r
+{\r
+ public:\r
+ \r
+ //! Empty constructor <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_BuilderFace();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_BuilderFace();\r
+ \r
+ //! Sets the face generatix <br>\r
+ Standard_EXPORT\r
+ void SetFace(const TopoDS_Face& theFace) ;\r
+ \r
+ //! Returns the face generatix <br>\r
+ Standard_EXPORT\r
+ const TopoDS_Face& Face() const;\r
+ \r
+ //! Performs the algorithm <br>\r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+\r
+ protected:\r
+ //! Collect the edges that <br>\r
+ //! a) are internal <br>\r
+ //! b) are the same and have different orientation <br>\r
+ Standard_EXPORT\r
+ virtual void PerformShapesToAvoid() ;\r
+ \r
+ //! Build draft wires <br>\r
+ //! a)myLoops - draft wires that consist of <br>\r
+ //! boundary edges <br>\r
+ //! b)myLoopsInternal - draft wires that contains <br>\r
+ //! inner edges <br>\r
+ Standard_EXPORT\r
+ virtual void PerformLoops() ;\r
+ \r
+ //! Build draft faces that contains boundary edges <br>\r
+ Standard_EXPORT\r
+ virtual void PerformAreas() ;\r
+ \r
+ //! Build finalized faces with internals <br>\r
+ Standard_EXPORT\r
+ virtual void PerformInternalShapes() ;\r
+\r
+\r
+ TopoDS_Face myFace;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_BuilderShape.hxx>
+//=======================================================================
+//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
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_BuilderShape.hxx\r
+// Created: \r
+// Author: Peter KURNEV \r
+//\r
+#ifndef _GEOMAlgo_BuilderShape_HeaderFile\r
+#define _GEOMAlgo_BuilderShape_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopTools_MapOfShape.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>\r
+#include <GEOMAlgo_Algo.hxx>\r
+\r
+\r
+//! Root class for algorithms that has shape as result <br>\r
+//=======================================================================\r
+//class : GEOMAlgo_BuilderShape\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_BuilderShape : public GEOMAlgo_Algo\r
+{\r
+ public:\r
+ //! Returns the result of algorithm <br>\r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape() const;\r
+ \r
+ //! Returns the list of shapes generated from the <br>\r
+ //! shape theS. <br>\r
+ Standard_EXPORT\r
+ virtual const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS) ;\r
+ \r
+ //! Returns the list of shapes modified from the <br>\r
+ //! shape theS. <br>\r
+ Standard_EXPORT\r
+ virtual const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS) ;\r
+ \r
+ //! Returns true if the shape theS has been deleted. <br>\r
+ Standard_EXPORT\r
+ virtual Standard_Boolean IsDeleted(const TopoDS_Shape& theS) ;\r
+ \r
+ //! Returns true if the at least one shape(or sub-shape) <br>\r
+ //! of arguments has been deleted. <br>\r
+ Standard_EXPORT\r
+ Standard_Boolean HasDeleted() const;\r
+ \r
+ //! Returns true if the at least one shape(or sub-shape) <br>\r
+ //! of arguments has generated shapes. <br>\r
+ Standard_EXPORT\r
+ Standard_Boolean HasGenerated() const;\r
+ \r
+ //! Returns true if the at least one shape(or sub-shape) <br>\r
+ //! of arguments has modified shapes. <br>\r
+ Standard_EXPORT\r
+ Standard_Boolean HasModified() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_IndexedDataMapOfShapeListOfShape& ImagesResult() const;\r
+\r
+protected:\r
+ //! Empty constructor <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_BuilderShape();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_BuilderShape();\r
+ \r
+ //! Prepare information for history support <br>\r
+ Standard_EXPORT\r
+ virtual void PrepareHistory() ;\r
+\r
+\r
+ TopoDS_Shape myShape;\r
+ TopTools_ListOfShape myHistShapes;\r
+ TopTools_MapOfShape myMapShape;\r
+ Standard_Boolean myHasDeleted;\r
+ Standard_Boolean myHasGenerated;\r
+ Standard_Boolean myHasModified;\r
+ TopTools_IndexedDataMapOfShapeListOfShape myImagesResult;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_BuilderSolid.hxx>
+
+#include <gp_Pnt2d.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom2d_Curve.hxx>
+
+#include <TopAbs.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_MapOfOrientedShape.hxx>
+#include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+
+#include <IntTools_Context.hxx>
+
+#include <BOPTools_Tools2D.hxx>
+#include <BOPTools_Tools3D.hxx>
+
+#include <NMTTools_ListOfCoupleOfShape.hxx>
+#include <NMTTools_CoupleOfShape.hxx>
+#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
+
+#include <GEOMAlgo_Tools3D.hxx>
+#include <GEOMAlgo_BuilderTools.hxx>
+
+//
+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
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_BuilderSolid.hxx\r
+// Created: \r
+// Author: Peter KURNEV \r
+//\r
+#ifndef _GEOMAlgo_BuilderSolid_HeaderFile\r
+#define _GEOMAlgo_BuilderSolid_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <GEOMAlgo_BuilderArea.hxx>\r
+\r
+//! The algorithm to build solids from set of faces <br>\r
+//=======================================================================\r
+//function : GEOMAlgo_BuilderSolid\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_BuilderSolid : public GEOMAlgo_BuilderArea \r
+{\r
+ public:\r
+ //! Empty constructor <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_BuilderSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_BuilderSolid();\r
+ \r
+ //! Performs the algorithm <br>\r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+\r
+ protected:\r
+ //! Collect the faces that <br>\r
+ //! a) are internal <br>\r
+ //! b) are the same and have different orientation <br>\r
+ Standard_EXPORT\r
+ virtual void PerformShapesToAvoid() ;\r
+ \r
+ //! Build draft shells <br>\r
+ //! a)myLoops - draft shells that consist of <br>\r
+ //! boundary faces <br>\r
+ //! b)myLoopsInternal - draft shells that contains <br>\r
+ //! inner faces <br>\r
+ Standard_EXPORT\r
+ virtual void PerformLoops() ;\r
+ \r
+ //! Build draft solids that contains boundary faces <br>\r
+ Standard_EXPORT\r
+ virtual void PerformAreas() ;\r
+ \r
+ //! Build finalized solids with internal shells <br>\r
+ Standard_EXPORT\r
+ virtual void PerformInternalShapes() ;\r
+\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_BuilderTools.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <TColStd_Array1OfReal.hxx>
+
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt.hxx>
+
+#include <TColgp_Array1OfPnt.hxx>
+
+#include <Poly_Triangulation.hxx>
+#include <Poly_Array1OfTriangle.hxx>
+#include <Poly_Triangle.hxx>
+
+#include <Geom2d_Curve.hxx>
+#include <Geom2dInt_Geom2dCurveTool.hxx>
+
+#include <TopLoc_Location.hxx>
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopExp_Explorer.hxx>
+
+#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
+#include <TopExp.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#endif
+
+#include <BRep_Tool.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepMesh_FastDiscret.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepAdaptor_Curve2d.hxx>
+
+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
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: GEOMAlgo_BuilderTools.hxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _GEOMAlgo_BuilderTools_HeaderFile\r
+#define _GEOMAlgo_BuilderTools_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_BuilderTools\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_BuilderTools \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsHole(const TopoDS_Shape& aW,\r
+ const TopoDS_Shape& aF) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean IsHole(const TopoDS_Shape& aShell) ;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_Builder.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+//#include <NMTTools_DSFiller.hxx>
+#include <NMTTools_PaveFiller.hxx>
+#include <IntTools_Context.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_PaveBlock.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// 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 <GEOMAlgo_Builder.hxx>
+//
+#include <TColStd_ListOfInteger.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Iterator.hxx>
+//
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+//
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+//
+#include <IntTools_Context.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_PaveBlock.hxx>
+//
+#include <NMTDS_ShapesDataStructure.hxx>
+//
+#include <NMTTools_PaveFiller.hxx>
+#include <NMTTools_CommonBlockPool.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+#include <NMTTools_CommonBlock.hxx>
+#include <NMTTools_CommonBlockPool.hxx>
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_CommonBlockAPI.hxx>
+//
+#include <GEOMAlgo_Tools3D.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+
+
+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);
+}
--- /dev/null
+// 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 <GEOMAlgo_Builder.hxx>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepAlgo_Image.hxx>
+#include <BRepTools.hxx>
+
+#include <IntTools_Context.hxx>
+#include <IntTools_FClass2d.hxx>
+
+#include <BooleanOperations_OnceExplorer.hxx>
+#include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_CArray1OfSSInterference.hxx>
+#include <BOPTools_SSInterference.hxx>
+#include <BOPTools_SequenceOfCurves.hxx>
+#include <BOPTools_Curve.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_Tools3D.hxx>
+#include <BOPTools_CArray1OfVSInterference.hxx>
+#include <BOPTools_VSInterference.hxx>
+#include <BOPTools_ESInterference.hxx>
+#include <BOPTools_CArray1OfESInterference.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_InterfPool.hxx>
+
+#include <NMTTools_PaveFiller.hxx>
+#include <NMTTools_ListOfCoupleOfShape.hxx>
+#include <NMTTools_Tools.hxx>
+#include <NMTTools_CoupleOfShape.hxx>
+#include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
+#include <NMTTools_Tools.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_CommonBlock.hxx>
+#include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
+//
+#include <GEOMAlgo_Tools3D.hxx>
+#include <GEOMAlgo_WireEdgeSet.hxx>
+#include <GEOMAlgo_BuilderFace.hxx>
+
+#include <GEOMAlgo_ShapeSet.hxx>
+//
+#include <NMTDS_BoxBndTree.hxx>
+#include <NCollection_UBTreeFiller.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
+#include <TopTools_DataMapOfIntegerShape.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TopTools_DataMapOfShapeInteger.hxx>
+
+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 <Standard_Integer, Bnd_Box> aTreeFiller(aBBTree);
+ //
+ aNbF1=aLF1r.Extent();
+ aNbF2=aLF2r.Extent();
+ bForward=(aNbF1<aNbF2);
+ //
+ const TopTools_ListOfShape& aLF1=bForward ? aLF1r : aLF2r;
+ const TopTools_ListOfShape& aLF2=bForward ? aLF2r : aLF1r;
+ //
+ // 1. aTreeFiller
+ aItF2.Initialize(aLF2);
+ for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
+ Bnd_Box aBoxF2s;
+ //
+ const TopoDS_Face& aF2s=*((TopoDS_Face*)(&aItF2.Value()));
+ //
+ BRepBndLib::Add(aF2s, aBoxF2s);
+ //
+ aMIS.Bind(i2s, aF2s);
+ //
+ aTreeFiller.Add(i2s, aBoxF2s);
+ }//for (i2s=1; aItF2.More(); aItF2.Next(), ++i2s) {
+ //
+ aTreeFiller.Fill();
+ //
+ // 2.
+ aItF1.Initialize(aLF1);
+ for (j=1; aItF1.More(); aItF1.Next(), ++j) {
+ Bnd_Box aBoxF1x;
+ //
+ const TopoDS_Face& aF1x=*((TopoDS_Face*)(&aItF1.Value()));
+ //
+ BRepBndLib::Add(aF1x, aBoxF1x);
+ //
+ aSelector.Clear();
+ aSelector.SetBox(aBoxF1x);
+ aNbSD=aBBTree.Select(aSelector);
+ if (!aNbSD) {
+ continue;
+ }
+ //
+ const TColStd_ListOfInteger& aLI=aSelector.Indices();
+ aItLI.Initialize(aLI);
+ for (; aItLI.More(); aItLI.Next()) {
+ i2s=aItLI.Value();
+ const TopoDS_Face& aF2y=*((TopoDS_Face*)(&aMIS.Find(i2s)));
+ //
+ bIsSDF=NMTTools_Tools::AreFacesSameDomain(aF1x, aF2y, aCtx);
+ if (bIsSDF) {
+ if (aMFence.Contains(aF1x) || aMFence.Contains(aF2y)) {
+ continue;
+ }
+ aMFence.Add(aF1x);
+ aMFence.Add(aF2y);
+ //
+ NMTTools_CoupleOfShape aCS;
+ //
+ aCS.SetShape1(aF1x);
+ aCS.SetShape2(aF2y);
+ aLCS.Append(aCS);
+ //
+ if (bForward) {
+ if (aF1x==aF1) {
+ if (!mySplitFaces.HasImage(aF1)) {
+ mySplitFaces.Bind(aF1, aF1);
+ }
+ }
+ if (aF2y==aF2) {
+ if (!mySplitFaces.HasImage(aF2)) {
+ mySplitFaces.Bind(aF2, aF2);
+ }
+ }
+ }
+ else {
+ if (aF1x==aF2) {
+ if (!mySplitFaces.HasImage(aF2)) {
+ mySplitFaces.Bind(aF2, aF2);
+ }
+ }
+ if (aF2y==aF1) {
+ if (!mySplitFaces.HasImage(aF1)) {
+ mySplitFaces.Bind(aF1, aF1);
+ }
+ }
+ }
+ //
+ break;
+ }//if (bIsSDF) {
+ }//for (; aItLI.More(); aItLI.Next()) {
+ }//for (; aItF1.More(); aItF1.Next()) {
+ }//for (i=1; i<=aNbFF; ++i)
+ //-------------------------------------------------------------
+ aNbC=aLCS.Extent();
+ if (!aNbC) {
+ return;
+ }
+ //
+ // 2. Find Chains
+ NMTTools_IndexedDataMapOfShapeIndexedMapOfShape aMC;
+ //
+ NMTTools_Tools::FindChains(aLCS, aMC);
+ //
+ Standard_Boolean bIsImage;
+ Standard_Integer aIx, aIxMin, aNbMSDF, k, aNbMFj;
+ TopoDS_Shape aFOld, aFSDmin;
+ TopTools_IndexedMapOfShape aMFj;
+ TopTools_DataMapOfShapeInteger aDMSI;
+ //
+ aItF1.Initialize(myShapes);
+ for (j=1; aItF1.More(); aItF1.Next(), ++j) {
+ const TopoDS_Shape& aSj=aItF1.Value();
+ aMFj.Clear();
+ TopExp::MapShapes(aSj, TopAbs_FACE, aMFj);
+ aNbMFj=aMFj.Extent();
+ for (k=1; k<=aNbMFj; ++k) {
+ const TopoDS_Shape& aFk=aMFj(k);
+ if (!aDMSI.IsBound(aFk)) {
+ aDMSI.Bind(aFk, j);
+ }
+ }
+ }
+ //
+ // 3. Fill the map of SDF mySameDomainFaces
+ aNbC=aMC.Extent();
+ for (i=1; i<=aNbC; ++i) {
+ // const TopoDS_Shape& aF=aMC.FindKey(i);
+ const TopTools_IndexedMapOfShape& aMSDF=aMC(i);
+ //
+ aNbMSDF=aMSDF.Extent();
+ for (j=1; j<=aNbMSDF; ++j) {
+ const TopoDS_Shape& aFSD=aMSDF(j);
+ bIsImage=mySplitFaces.IsImage(aFSD);
+ aFOld=aFSD;
+ if (bIsImage) {
+ aFOld=mySplitFaces.ImageFrom(aFSD);
+ }
+ //
+ aIx=aDMSI.Find(aFOld);
+ if (j==1) {
+ aIxMin=aIx;
+ aFSDmin=aFSD;
+ continue;
+ }
+ else {
+ if (aIx<aIxMin) {
+ aIxMin=aIx;
+ aFSDmin=aFSD;
+ }
+ }
+ }
+ //
+ for (j=1; j<=aNbMSDF; ++j) {
+ const TopoDS_Shape& aFSD=aMSDF(j);
+ mySameDomainShapes.Add(aFSD, aFSDmin);
+ }
+ }
+ //
+}
+
+//=======================================================================
+// function: FillImagesFaces1
+// purpose:
+//=======================================================================
+void GEOMAlgo_Builder::FillImagesFaces1()
+{
+ Standard_Integer i, aNb, iSense, aNbLFx;
+ TopoDS_Face aF, aFSp, aFSD;
+ TopTools_ListOfShape aLFx;
+ TopTools_ListIteratorOfListOfShape aIt;
+ //
+ const NMTDS_ShapesDataStructure& aDS=*myPaveFiller->DS();
+ //
+ 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;
+ }
+ */
--- /dev/null
+// 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 <GEOMAlgo_Builder.hxx>
+
+#include <TopAbs_State.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
+#include <TopTools_MapOfShape.hxx>
+
+#include <IntTools_Context.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTTools_PaveFiller.hxx>
+
+#include <GEOMAlgo_Tools3D.hxx>
+#include <GEOMAlgo_BuilderSolid.hxx>
+#include <GEOMAlgo_ShapeSet.hxx>
+#include <GEOMAlgo_DataMapOfShapeShapeSet.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx>
+
+
+
+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
--- /dev/null
+// 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 <GEOMAlgo_Builder.hxx>
+
+#include <TopoDS_Iterator.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+
+#include <IntTools_Context.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+
+#include <NMTTools_PaveFiller.hxx>
+
+#include <GEOMAlgo_Tools3D.hxx>
+
+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);
+ }
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_Clsf.hxx>
+
+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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_Clsf.hxx\r
+// Created: Wed Nov 22 10:23:04 2006\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_Clsf_HeaderFile\r
+#define _GEOMAlgo_Clsf_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_DefineHandle.hxx>\r
+//#include <Handle_GEOMAlgo_Clsf.hxx>\r
+#include <TopAbs_State.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <GEOMAlgo_HAlgo.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Handle_Geom_Curve.hxx>\r
+#include <Handle_Geom_Surface.hxx>\r
+#include <Geom_Curve.hxx>\r
+#include <Geom_Surface.hxx>\r
+\r
+DEFINE_STANDARD_HANDLE(GEOMAlgo_Clsf, GEOMAlgo_HAlgo);\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_Clsf\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_Clsf : public GEOMAlgo_HAlgo \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ void SetPnt(const gp_Pnt& aP) ;\r
+ \r
+ Standard_EXPORT\r
+ const gp_Pnt& Pnt() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetTolerance(const Standard_Real aT) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Real Tolerance() const;\r
+ \r
+ Standard_EXPORT\r
+ TopAbs_State State() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aCT) const;\r
+ \r
+ Standard_EXPORT\r
+ virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const;\r
+\r
+ DEFINE_STANDARD_RTTI(GEOMAlgo_Clsf);\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ GEOMAlgo_Clsf();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_Clsf();\r
+\r
+ TopAbs_State myState;\r
+ gp_Pnt myPnt;\r
+ Standard_Real myTolerance;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_ClsfBox.hxx>
+
+#include <GeomAbs_SurfaceType.hxx>
+#include <GEOMAlgo_SurfaceTools.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS.hxx>
+#include <Geom_Surface.hxx>
+#include <BRep_Tool.hxx>
+#include <Geom_Plane.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Ax1.hxx>
+#include <Geom_Plane.hxx>
+
+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<aNbS && iNext; i++) {
+ GEOMAlgo_SurfaceTools::GetState(myPnt, myGAS[i], myTolerance, aSt);
+ //
+ switch (aSt) {
+ case TopAbs_OUT:
+ myState=aSt;
+ iNext=0;
+ break;
+ case TopAbs_ON:
+ ++aNbON;
+ break;
+ case TopAbs_IN:
+ ++aNbIN;
+ break;
+ default:
+ myState=TopAbs_UNKNOWN;
+ iNext=0;
+ break;
+ }
+ }
+ //
+ if (iNext) {
+ myState=TopAbs_UNKNOWN;
+ //
+ if (aNbON && aNbIN) {
+ myState=TopAbs_ON;
+ }
+ else if (aNbIN==aNbS){
+ myState=TopAbs_IN;
+ }
+ }
+}
+//=======================================================================
+//function : CanBeON
+//purpose :
+//=======================================================================
+ Standard_Boolean GEOMAlgo_ClsfBox::CanBeON(const Handle(Geom_Curve)& aC) const
+{
+ return GEOMAlgo_Clsf::CanBeON(aC);
+}
+//=======================================================================
+//function : CanBeON
+//purpose :
+//=======================================================================
+ Standard_Boolean GEOMAlgo_ClsfBox::CanBeON(const Handle(Geom_Surface)& aS1) const
+{
+ Standard_Boolean bRet;
+ GeomAbs_SurfaceType aST1;
+ GeomAdaptor_Surface aGAS1;
+ //
+ aGAS1.Load(aS1);
+ aST1=aGAS1.GetType();
+ bRet=(aST1==GeomAbs_Plane);
+ //
+ return bRet;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_ClsfBox.hxx\r
+// Created: Wed Nov 22 10:41:47 2006\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_ClsfBox_HeaderFile\r
+#define _GEOMAlgo_ClsfBox_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_DefineHandle.hxx>\r
+//#include <Handle_GEOMAlgo_ClsfBox.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <GeomAdaptor_Surface.hxx>\r
+#include <GEOMAlgo_Clsf.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Handle_Geom_Curve.hxx>\r
+#include <Handle_Geom_Surface.hxx>\r
+#include <Geom_Curve.hxx>\r
+#include <Geom_Surface.hxx>\r
+\r
+DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfBox, GEOMAlgo_Clsf)\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_ClsfBox\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ClsfBox : public GEOMAlgo_Clsf \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_ClsfBox();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_ClsfBox();\r
+ \r
+ Standard_EXPORT\r
+ void SetBox(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Box() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aC) const;\r
+ \r
+ Standard_EXPORT\r
+ virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const;\r
+ \r
+ DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfBox)\r
+ \r
+ protected:\r
+ TopoDS_Shape myBox;\r
+ GeomAdaptor_Surface myGAS[6];\r
+\r
+\r
+private: \r
+\r
+\r
+\r
+\r
+};\r
+\r
+\r
+\r
+\r
+\r
+// other Inline functions and methods (like "C++: function call" methods)\r
+\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_ClsfSolid.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Solid.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+
+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
+
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_ClsfSolid.hxx\r
+// Created: Mon Jan 29 10:35:46 2007\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_ClsfSolid_HeaderFile\r
+#define _GEOMAlgo_ClsfSolid_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_DefineHandle.hxx>\r
+//#include <Handle_GEOMAlgo_ClsfSolid.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <Standard_Address.hxx>\r
+#include <GEOMAlgo_Clsf.hxx>\r
+\r
+DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSolid, GEOMAlgo_Clsf)\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_ClsfSolid\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ClsfSolid : public GEOMAlgo_Clsf \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_ClsfSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_ClsfSolid();\r
+ \r
+ Standard_EXPORT\r
+ void SetShape(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+\r
+ DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfSolid)\r
+\r
+ protected:\r
+ TopoDS_Shape myShape;\r
+ Standard_Address myPClsf;\r
+\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_ClsfSurf.hxx>
+#include <GeomAbs_SurfaceType.hxx>
+#include <GEOMAlgo_SurfaceTools.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
+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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_ClsfSurf.hxx\r
+// Created: Wed Nov 22 10:41:47 2006\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_ClsfSurf_HeaderFile\r
+#define _GEOMAlgo_ClsfSurf_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_DefineHandle.hxx>\r
+//#include <Handle_GEOMAlgo_ClsfSurf.hxx>\r
+#include <Handle_Geom_Surface.hxx>\r
+#include <GeomAdaptor_Surface.hxx>\r
+#include <GEOMAlgo_Clsf.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Handle_Geom_Curve.hxx>\r
+#include <Geom_Surface.hxx>\r
+#include <Geom_Curve.hxx>\r
+\r
+DEFINE_STANDARD_HANDLE(GEOMAlgo_ClsfSurf, GEOMAlgo_Clsf)\r
+\r
+//=======================================================================\r
+// class : GEOMAlgo_ClsfSurf\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ClsfSurf : public GEOMAlgo_Clsf \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_ClsfSurf();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_ClsfSurf();\r
+ \r
+ Standard_EXPORT\r
+ void SetSurface(const Handle(Geom_Surface)& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ const Handle_Geom_Surface& Surface() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual Standard_Boolean CanBeON(const Handle(Geom_Curve)& aC) const;\r
+ \r
+ Standard_EXPORT\r
+ virtual Standard_Boolean CanBeON(const Handle(Geom_Surface)& aST) const;\r
+\r
+ DEFINE_STANDARD_RTTI(GEOMAlgo_ClsfSurf);\r
+\r
+ protected:\r
+ Handle_Geom_Surface myS;\r
+ GeomAdaptor_Surface myGAS;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_CoupleOfShapes.hxx>
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_CoupleOfShapes.hxx\r
+// Created: Wed Dec 15 13:03:52 2004\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+\r
+#ifndef _GEOMAlgo_CoupleOfShapes_HeaderFile\r
+#define _GEOMAlgo_CoupleOfShapes_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_CoupleOfShapes\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_CoupleOfShapes \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_CoupleOfShapes();\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopoDS_Shape& aS1,const TopoDS_Shape& aS2) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShape1(const TopoDS_Shape& aS1) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShape2(const TopoDS_Shape& aS2) ;\r
+ \r
+ Standard_EXPORT\r
+ void Shapes(TopoDS_Shape& aS1,TopoDS_Shape& aS2) const;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape1() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape2() const;\r
+\r
+protected:\r
+ TopoDS_Shape myShape1;\r
+ TopoDS_Shape myShape2;\r
+};\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx\r
+// Created: Wed Feb 22 11:05:01 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape_HeaderFile\r
+#define GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape_HeaderFile\r
+\r
+#ifndef GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile\r
+#include <GEOMAlgo_DataMapOfOrientedShapeShape.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx\r
+// Created: Wed Feb 22 10:58:14 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger_HeaderFile\r
+#define GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger_HeaderFile\r
+\r
+#ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile\r
+#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>\r
+#endif\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx\r
+// Created: Wed Feb 22 11:01:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape_HeaderFile\r
+#define GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape_HeaderFile\r
+\r
+#ifndef GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile\r
+#include <GEOMAlgo_DataMapOfPassKeyShapeShape.hxx>\r
+#endif\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx\r
+// Created: Wed Feb 22 10:53:47 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape_HeaderFile\r
+#define GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape_HeaderFile\r
+\r
+#ifndef GEOMAlgo_DataMapOfRealListOfShape_HeaderFile\r
+#include <GEOMAlgo_DataMapOfRealListOfShape.hxx>\r
+#endif\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx\r
+// Created: Wed Feb 22 11:08:26 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile\r
+#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape_HeaderFile\r
+\r
+#ifndef GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile\r
+#include <GEOMAlgo_DataMapOfShapeMapOfShape.hxx>\r
+#endif\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx\r
+// Created: Wed Feb 22 11:11:09 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile\r
+#define GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt_HeaderFile\r
+\r
+#ifndef GEOMAlgo_DataMapOfShapePnt_HeaderFile\r
+#include <GEOMAlgo_DataMapOfShapePnt.hxx>\r
+#endif\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx\r
+// Created: Wed Feb 22 10:49:11 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal_HeaderFile\r
+#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal_HeaderFile\r
+\r
+#ifndef GEOMAlgo_DataMapOfShapeReal_HeaderFile\r
+#include <GEOMAlgo_DataMapOfShapeReal.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx\r
+// Created: Wed Feb 22 08:39:02 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet_HeaderFile\r
+#define GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet_HeaderFile\r
+\r
+#ifndef GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile\r
+#include <GEOMAlgo_DataMapOfShapeShapeSet.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapOfOrientedShapeShape.hxx\r
+// Created: Wed Feb 22 11:03:36 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile\r
+#define GEOMAlgo_DataMapOfOrientedShapeShape_HeaderFile\r
+\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_OrientedShapeMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+\r
+typedef NCollection_DataMap<TopoDS_Shape, TopoDS_Shape, TopTools_OrientedShapeMapHasher> GEOMAlgo_DataMapOfOrientedShapeShape; \r
+typedef GEOMAlgo_DataMapOfOrientedShapeShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape;\r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapOfPassKeyInteger.hxx\r
+// Created: Wed Feb 22 10:55:55 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile\r
+#define GEOMAlgo_DataMapOfPassKeyInteger_HeaderFile\r
+\r
+#include <GEOMAlgo_PassKey.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <GEOMAlgo_PassKeyMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+typedef NCollection_DataMap<GEOMAlgo_PassKey, Standard_Integer, GEOMAlgo_PassKeyMapHasher> GEOMAlgo_DataMapOfPassKeyInteger; \r
+typedef GEOMAlgo_DataMapOfPassKeyInteger::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger;\r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapOfPassKeyShapeShape.hxx\r
+// Created: Wed Feb 22 11:00:16 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile\r
+#define GEOMAlgo_DataMapOfPassKeyShapeShape_HeaderFile\r
+\r
+#include <GEOMAlgo_PassKey.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <GEOMAlgo_PassKeyMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+\r
+typedef NCollection_DataMap<GEOMAlgo_PassKey, TopoDS_Shape, GEOMAlgo_PassKeyMapHasher> GEOMAlgo_DataMapOfPassKeyShapeShape;\r
+typedef GEOMAlgo_DataMapOfPassKeyShapeShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape;\r
+ \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapOfRealListOfShape.hxx\r
+// Created: Wed Feb 22 10:51:48 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapOfRealListOfShape_HeaderFile\r
+#define GEOMAlgo_DataMapOfRealListOfShape_HeaderFile\r
+\r
+#include <Standard_Real.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TColStd_MapRealHasher.hxx>\r
+\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+typedef NCollection_DataMap<Standard_Real, TopTools_ListOfShape, TColStd_MapRealHasher> GEOMAlgo_DataMapOfRealListOfShape; \r
+typedef GEOMAlgo_DataMapOfRealListOfShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape;\r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapOfShapeMapOfShape.hxx\r
+// Created: Wed Feb 22 11:07:16 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile\r
+#define GEOMAlgo_DataMapOfShapeMapOfShape_HeaderFile\r
+\r
+\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_MapOfShape.hxx>\r
+#include <TopTools_ShapeMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+\r
+typedef NCollection_DataMap<TopoDS_Shape, TopTools_MapOfShape, TopTools_ShapeMapHasher> GEOMAlgo_DataMapOfShapeMapOfShape; \r
+typedef GEOMAlgo_DataMapOfShapeMapOfShape::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape;\r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapOfShapePnt.hxx\r
+// Created: Wed Feb 22 11:10:15 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapOfShapePnt_HeaderFile\r
+#define GEOMAlgo_DataMapOfShapePnt_HeaderFile\r
+\r
+\r
+#include <TopoDS_Shape.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <TopTools_ShapeMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+#include <gp_Pnt.hxx>\r
+\r
+typedef NCollection_DataMap<TopoDS_Shape, gp_Pnt, TopTools_ShapeMapHasher> GEOMAlgo_DataMapOfShapePnt; \r
+typedef GEOMAlgo_DataMapOfShapePnt::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt;\r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapOfShapeReal.hxx\r
+// Created: Wed Feb 22 10:47:23 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapOfShapeReal_HeaderFile\r
+#define GEOMAlgo_DataMapOfShapeReal_HeaderFile\r
+\r
+#include <TopoDS_Shape.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <TopTools_ShapeMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+typedef NCollection_DataMap<TopoDS_Shape, Standard_Real, TopTools_ShapeMapHasher> GEOMAlgo_DataMapOfShapeReal; \r
+typedef GEOMAlgo_DataMapOfShapeReal::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal;\r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_DataMapOfShapeShapeSet.hxx\r
+// Created: Wed Feb 22 08:36:15 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile\r
+#define GEOMAlgo_DataMapOfShapeShapeSet_HeaderFile\r
+\r
+#include <TopoDS_Shape.hxx>\r
+#include <GEOMAlgo_ShapeSet.hxx>\r
+#include <TopTools_ShapeMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+\r
+typedef NCollection_DataMap<TopoDS_Shape, GEOMAlgo_ShapeSet, TopTools_ShapeMapHasher> GEOMAlgo_DataMapOfShapeShapeSet; \r
+typedef GEOMAlgo_DataMapOfShapeShapeSet::Iterator GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet;\r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_FinderShapeOn.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
+#include <Precision.hxx>
+#endif
+
+#include <gp_Pnt.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRepLib_MakeFace.hxx>
+#include <BRepLib_FaceError.hxx>
+
+#include <BOPTools_DSFiller.hxx>
+
+#include <GEOMAlgo_WireSolid.hxx>
+#include <GEOMAlgo_ShellSolid.hxx>
+#include <GEOMAlgo_VertexSolid.hxx>
+#include <GEOMAlgo_ShapeSolid.hxx>
+#include <GEOMAlgo_SolidSolid.hxx>
+#include <GEOMAlgo_SurfaceTools.hxx>
+#include <GEOMAlgo_Tools.hxx>
+
+//=======================================================================
+//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
--- /dev/null
+\r
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: GEOMAlgo_FinderShapeOn.hxx\r
+// Created: Tue Jan 11 14:44:31 2005\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _GEOMAlgo_FinderShapeOn_HeaderFile\r
+#define _GEOMAlgo_FinderShapeOn_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Handle_Geom_Surface.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <GEOMAlgo_State.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopTools_DataMapOfShapeShape.hxx>\r
+#include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <GEOMAlgo_ShapeAlgo.hxx>\r
+#include <Geom_Surface.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_FinderShapeOn\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_FinderShapeOn : public GEOMAlgo_ShapeAlgo \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_FinderShapeOn();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_FinderShapeOn();\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ void SetSurface(const Handle(Geom_Surface)& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapeType(const TopAbs_ShapeEnum aST) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetState(const GEOMAlgo_State aSF) ;\r
+ \r
+ Standard_EXPORT\r
+ const Handle_Geom_Surface& Surface() const;\r
+ \r
+ Standard_EXPORT\r
+ TopAbs_ShapeEnum ShapeType() const;\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_State State() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Shapes() const;\r
+ \r
+ Standard_EXPORT\r
+ static void CopySource(const TopoDS_Shape& aS,\r
+ TopTools_DataMapOfShapeShape& aImages,\r
+ TopTools_DataMapOfShapeShape& aOriginals,\r
+ TopoDS_Shape& aSC) ;\r
+ \r
+ Standard_EXPORT \r
+ static Standard_Boolean BuildTriangulation(const TopoDS_Shape& aS) ;\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeArgument1() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeArgument2() ;\r
+ \r
+ Standard_EXPORT\r
+ void Find() ;\r
+ \r
+ Standard_EXPORT\r
+ void Find(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void FindVertices() ;\r
+\r
+\r
+ Handle_Geom_Surface mySurface;\r
+ TopAbs_ShapeEnum myShapeType;\r
+ GEOMAlgo_State myState;\r
+ TopoDS_Shape myArg1;\r
+ TopoDS_Shape myArg2;\r
+ TopTools_ListOfShape myLS;\r
+ TopTools_DataMapOfShapeShape myImages;\r
+ GEOMAlgo_IndexedDataMapOfShapeState myMSS;\r
+ Standard_Boolean myIsAnalytic;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_FinderShapeOn1.hxx>
+
+#include <math.h>
+
+#include <Precision.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+
+#include <gp_Trsf.hxx>
+#include <gp_Cylinder.hxx>
+#include <gp_Pnt.hxx>
+
+#include <TColgp_Array1OfPnt.hxx>
+
+#include <Poly_Array1OfTriangle.hxx>
+#include <Poly_Triangle.hxx>
+#include <Poly_PolygonOnTriangulation.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Poly_Polygon3D.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAdaptor_Surface.hxx>
+#include <GeomAbs_SurfaceType.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAbs_CurveType.hxx>
+
+#include <TopAbs_State.hxx>
+
+#include <TopLoc_Location.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepLib_MakeEdge.hxx>
+
+#include <GEOMAlgo_ListIteratorOfListOfPnt.hxx>
+
+#include <GEOMAlgo_SurfaceTools.hxx>
+#include <GEOMAlgo_StateCollector.hxx>
+#include <GEOMAlgo_FinderShapeOn.hxx>
+
+#include <GEOMAlgo_PassKey.hxx>
+#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
+
+//=======================================================================
+//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; j<aNbT; ++j) {
+ aT=aT1+j*dT;
+ aC3D->D0(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; j<up; ++j) {
+ aP=aNodes(j).Transformed(aTrsf);
+ aLP.Append(aP);
+ }
+ }
+ else {
+ const gp_Trsf& aTrsf=aLoc.Transformation();
+ const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
+ //
+ aNbNodes=aPTE->NbNodes();
+ const TColStd_Array1OfInteger& aInds=aPTE->Nodes();
+ for (j=2; j<aNbNodes; ++j) {
+ aIndex=aInds(j);
+ aP=aNodes(aIndex).Transformed(aTrsf);
+ aLP.Append(aP);
+ }
+ }
+ //
+ aNb=aLP.Extent();
+ if (!aNb && myNbPntsMin) {
+ // try to fill it yourself
+ InnerPoints(aE, myNbPntsMin, aLP);
+ aNb=aLP.Extent();
+ }
+}
+*/
+//modified by NIZNHY-PKV Thu Jan 26 10:01:17 2012t
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: GEOMAlgo_FinderShapeOn1.hxx\r
+// Created: Fri Mar 4 10:31:06 2005\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _GEOMAlgo_FinderShapeOn1_HeaderFile\r
+#define _GEOMAlgo_FinderShapeOn1_HeaderFile\r
+\r
+#include <GEOMAlgo_State.hxx>\r
+#include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>\r
+#include <GEOMAlgo_ShapeAlgo.hxx>\r
+#include <GEOMAlgo_ListOfPnt.hxx>\r
+\r
+#include <TopAbs_State.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <TopoDS_Edge.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+\r
+#include <Geom_Surface.hxx>\r
+#include <Handle_Geom_Surface.hxx>\r
+#include <GeomAdaptor_Surface.hxx>\r
+\r
+#include <gp_Pnt.hxx>\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_FinderShapeOn1\r
+//purpose :\r
+//=======================================================================\r
+class GEOMAlgo_FinderShapeOn1 : public GEOMAlgo_ShapeAlgo\r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_FinderShapeOn1();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_FinderShapeOn1();\r
+\r
+ Standard_EXPORT\r
+ void SetSurface(const Handle(Geom_Surface)& aS) ;\r
+\r
+ Standard_EXPORT\r
+ void SetShapeType(const TopAbs_ShapeEnum aST) ;\r
+\r
+ Standard_EXPORT\r
+ void SetState(const GEOMAlgo_State aSF) ;\r
+\r
+ Standard_EXPORT\r
+ void SetNbPntsMin(const Standard_Integer aNb) ;\r
+\r
+ Standard_EXPORT\r
+ Standard_Integer NbPntsMin() const;\r
+\r
+ Standard_EXPORT\r
+ void SetNbPntsMax(const Standard_Integer aNb) ;\r
+\r
+ Standard_EXPORT\r
+ Standard_Integer NbPntsMax() const;\r
+\r
+ Standard_EXPORT\r
+ const Handle_Geom_Surface& Surface() const;\r
+\r
+ Standard_EXPORT\r
+ TopAbs_ShapeEnum ShapeType() const;\r
+\r
+ Standard_EXPORT\r
+ GEOMAlgo_State State() const;\r
+\r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Shapes() const;\r
+\r
+ Standard_EXPORT\r
+ const GEOMAlgo_IndexedDataMapOfShapeState& MSS() const;\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+\r
+ Standard_EXPORT\r
+ void ProcessVertices() ;\r
+\r
+ Standard_EXPORT\r
+ void ProcessEdges() ;\r
+\r
+ Standard_EXPORT\r
+ void ProcessFaces() ;\r
+\r
+ Standard_EXPORT\r
+ void ProcessSolids() ;\r
+\r
+ Standard_EXPORT\r
+ void InnerPoints(const TopoDS_Face& aF,\r
+ GEOMAlgo_ListOfPnt& aLP) ;\r
+\r
+ Standard_EXPORT\r
+ void InnerPoints(const TopoDS_Edge& aE,\r
+ GEOMAlgo_ListOfPnt& aLP) ;\r
+\r
+ Standard_EXPORT\r
+ void InnerPoints(const TopoDS_Edge& aE,\r
+ const Standard_Integer aNbPnts,\r
+ GEOMAlgo_ListOfPnt& aLP) ;\r
+\r
+ Standard_EXPORT\r
+ virtual TopAbs_State GetPointState(const gp_Pnt& aP) ;\r
+\r
+\r
+ Handle_Geom_Surface mySurface;\r
+ TopAbs_ShapeEnum myShapeType;\r
+ GEOMAlgo_State myState;\r
+ Standard_Integer myNbPntsMin;\r
+ Standard_Integer myNbPntsMax;\r
+ GeomAdaptor_Surface myGAS;\r
+ TopTools_ListOfShape myLS;\r
+ GEOMAlgo_IndexedDataMapOfShapeState myMSS;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_FinderShapeOn2.hxx>
+#include <math.h>
+
+
+#include <Precision.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+
+#include <gp_Trsf.hxx>
+#include <gp_Cylinder.hxx>
+#include <gp_Pnt.hxx>
+
+#include <TColgp_Array1OfPnt.hxx>
+
+#include <Poly_Array1OfTriangle.hxx>
+#include <Poly_Triangle.hxx>
+#include <Poly_PolygonOnTriangulation.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Poly_Polygon3D.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAdaptor_Surface.hxx>
+#include <GeomAbs_SurfaceType.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAbs_CurveType.hxx>
+
+#include <TopAbs_State.hxx>
+
+#include <TopLoc_Location.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepLib_MakeEdge.hxx>
+
+#include <GEOMAlgo_ListIteratorOfListOfPnt.hxx>
+
+#include <GEOMAlgo_SurfaceTools.hxx>
+#include <GEOMAlgo_StateCollector.hxx>
+#include <GEOMAlgo_FinderShapeOn.hxx>
+
+#include <GEOMAlgo_PassKey.hxx>
+#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
+
+//=======================================================================
+//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; j<up; ++j) {
+ aP=aNodes(j).Transformed(aTrsf);
+ aLP.Append(aP);
+ }
+ }
+ else {
+ const gp_Trsf& aTrsf=aLoc.Transformation();
+ const TColgp_Array1OfPnt& aNodes=aTRE->Nodes();
+ //
+ aNbNodes=aPTE->NbNodes();
+ const TColStd_Array1OfInteger& aInds=aPTE->Nodes();
+ for (j=2; j<aNbNodes; ++j) {
+ aIndex=aInds(j);
+ aP=aNodes(aIndex).Transformed(aTrsf);
+ aLP.Append(aP);
+ }
+ }
+ //
+ aNb=aLP.Extent();
+ if (!aNb && myNbPntsMin) {
+ // try to fill it yourself
+ InnerPoints(aE, myNbPntsMin, aLP);
+ aNb=aLP.Extent();
+ }
+}
+//=======================================================================
+//function : InnerPoints
+//purpose :
+//=======================================================================
+ void GEOMAlgo_FinderShapeOn2::InnerPoints(const TopoDS_Edge& aE,
+ const Standard_Integer aNbPntsMin,
+ GEOMAlgo_ListOfPnt& aLP)
+{
+ // try to fill it yourself
+ 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;
+ }
+ //
+ aNbT=myNbPntsMin+1;
+ dT=(aT2-aT1)/aNbT;
+ for (j=1; j<=aNbPntsMin; ++j) {
+ aT=aT1+j*dT;
+ aC3D->D0(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
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_FinderShapeOn2.hxx\r
+// Created: Fri Mar 4 10:31:06 2005\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_FinderShapeOn2_HeaderFile\r
+#define _GEOMAlgo_FinderShapeOn2_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <GEOMAlgo_State.hxx>\r
+#include <Standard_Integer.hxx>\r
+//#include <Handle_GEOMAlgo_Clsf.hxx>\r
+#include <GEOMAlgo_Clsf.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>\r
+#include <GEOMAlgo_ShapeAlgo.hxx>\r
+#include <GEOMAlgo_Clsf.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <TopoDS_Edge.hxx>\r
+#include <GEOMAlgo_ListOfPnt.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_FinderShapeOn2\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_FinderShapeOn2 : public GEOMAlgo_ShapeAlgo \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_FinderShapeOn2();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_FinderShapeOn2();\r
+ \r
+ Standard_EXPORT\r
+ void SetClsf(const Handle(GEOMAlgo_Clsf)& aClsf) ;\r
+ \r
+ Standard_EXPORT\r
+ const Handle_GEOMAlgo_Clsf& Clsf() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapeType(const TopAbs_ShapeEnum aST) ;\r
+ \r
+ Standard_EXPORT\r
+ TopAbs_ShapeEnum ShapeType() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetState(const GEOMAlgo_State aSF) ;\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_State State() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetNbPntsMin(const Standard_Integer aNb) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer NbPntsMin() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetNbPntsMax(const Standard_Integer aNb) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer NbPntsMax() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Shapes() const;\r
+ \r
+ Standard_EXPORT\r
+ const GEOMAlgo_IndexedDataMapOfShapeState& MSS() const;\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+ \r
+ Standard_EXPORT\r
+ void ProcessVertices() ;\r
+ \r
+ Standard_EXPORT\r
+ void ProcessEdges() ;\r
+ \r
+ Standard_EXPORT\r
+ void ProcessFaces() ;\r
+ \r
+ Standard_EXPORT\r
+ void ProcessSolids() ;\r
+ \r
+ Standard_EXPORT\r
+ void InnerPoints(const TopoDS_Face& aF,\r
+ GEOMAlgo_ListOfPnt& aLP) ;\r
+ \r
+ Standard_EXPORT\r
+ void InnerPoints(const TopoDS_Edge& aE,\r
+ GEOMAlgo_ListOfPnt& aLP) ;\r
+ \r
+ Standard_EXPORT\r
+ void InnerPoints(const TopoDS_Edge& aE,\r
+ const Standard_Integer aNbPnts,\r
+ GEOMAlgo_ListOfPnt& aLP) ;\r
+\r
+\r
+ TopAbs_ShapeEnum myShapeType;\r
+ GEOMAlgo_State myState;\r
+ Standard_Integer myNbPntsMin;\r
+ Standard_Integer myNbPntsMax;\r
+ Handle_GEOMAlgo_Clsf myClsf;\r
+ TopTools_ListOfShape myLS;\r
+ GEOMAlgo_IndexedDataMapOfShapeState myMSS;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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 <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <Geom_Plane.hxx>
+
+
+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<<std::endl<<" X Vec : "<<myQuadNormal.X()<<" "<<myQuadNormal.Y()<<" "<<myQuadNormal.Z()<<" "<<endl;
+
+ if ( myQuadNormal.SquareMagnitude() <= DBL_MIN ) {
+ myErrorStatus = 101;
+ return;
+ }
+
+ // detect concave quadrangle sides
+ myConcaveQuad = false;
+ myConcaveSide.resize (4, false);
+ for ( int i = 1; i <= 4; ++i ) {
+ gp_Vec localQN = gp_Vec( myPoints[i], myPoints[i+1] ) ^ gp_Vec( myPoints[i], myPoints[i-1] );
+ if ( myQuadNormal * localQN < 0 )
+ myConcaveSide[i-1] = myConcaveSide[i] = myConcaveQuad = true;
+ }
+
+ // loop on quadrangle sides
+ myPlanes.reserve( 4 );
+ for ( int i = 0; i < 4; ++i )
+ {
+ // point1 -> point2 vector
+ gp_Vec aSideVec( myPoints[ i ], myPoints[ i + 1 ]);
+ //std::cout<<" Y Vec : "<<aSideVec.X()<<" "<<aSideVec.Y()<<" "<<aSideVec.Z()<<" "<<endl;
+
+ // plane normal
+ gp_Vec aSideNorm = aSideVec ^ myQuadNormal;
+ if ( aSideNorm.SquareMagnitude() <= DBL_MIN )
+ continue;
+ //std::cout<<" Z Vec : "<<aSideNorm.X()<<" "<<aSideNorm.Y()<<" "<<aSideNorm.Z()<<" "<<endl;
+
+ // make plane
+ Handle(Geom_Plane) aPlane = new Geom_Plane( myPoints[ i ], aSideNorm );
+ myPlanes.push_back( GeomAdaptor_Surface() );
+ myPlanes.back().Load( aPlane );
+ }
+}
+
+//=======================================================================
+//function : CheckData
+//purpose :
+//=======================================================================
+
+void GEOMAlgo_FinderShapeOnQuad::CheckData()
+{
+ if ( !myPlanes.empty() )
+ mySurface = myPlanes[0].Surface();
+ GEOMAlgo_FinderShapeOn1::CheckData();
+}
+
+//=======================================================================
+//function : GetPointState
+//purpose :
+//=======================================================================
+
+TopAbs_State GEOMAlgo_FinderShapeOnQuad::GetPointState(const gp_Pnt& aP)
+{
+ // Return IN if aP has TopAbs_IN with all sides.
+ // In the case of concave quadrangle, return IN if
+ // aP is OUT of only one concave side
+ double nbIn = 0.;
+ for ( int i = 0; i < myPlanes.size(); ++i )
+ {
+ TopAbs_State aSt;
+ GEOMAlgo_SurfaceTools::GetState(aP, myPlanes[i], myTolerance, aSt);
+ if ( aSt == TopAbs_IN )
+ {
+ nbIn += myConcaveSide[i] ? 0.5 : 1.0;
+ }
+ else if ( aSt == TopAbs_ON )
+ {
+ // check that aP is between quadrangle corners
+ Handle(Geom_Plane) aSidePlane = Handle(Geom_Plane)::DownCast( myPlanes[i].Surface() );
+ gp_Vec aSideNorm = aSidePlane->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;
+}
+
--- /dev/null
+// 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 <gp_Vec.hxx>
+
+#include <vector>
+
+
+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<bool> myConcaveSide;
+ std::vector<gp_Pnt> myPoints;
+ std::vector<GeomAdaptor_Surface> myPlanes;
+ gp_Vec myQuadNormal;
+};
+#endif
--- /dev/null
+// 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 <GEOMAlgo_GetInPlace.hxx>
+
+#include <NMTDS_BoxBndTree.hxx>
+#include <NCollection_UBTreeFiller.hxx>
+
+#include <Bnd_Box.hxx>
+#include <gp_Pnt.hxx>
+
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+
+#include <BRepBndLib.hxx>
+
+#include <TopExp.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+
+
+#include <NMTTools_CoupleOfShape.hxx>
+#include <GEOMAlgo_Tools.hxx>
+
+
+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 <Standard_Integer, Bnd_Box> 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);
+ }
+}
--- /dev/null
+// 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 <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <Standard_Integer.hxx>
+#include <Standard_Real.hxx>
+#include <Standard_Boolean.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <NMTTools_CoupleOfShape.hxx>
+#include <NMTTools_ListOfCoupleOfShape.hxx>
+#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
+
+#include <GEOMAlgo_DataMapOfShapeMapOfShape.hxx>
+#include <GEOMAlgo_GluerAlgo.hxx>
+#include <GEOMAlgo_Algo.hxx>
+#include <GEOMAlgo_DataMapOfShapePnt.hxx>
+
+
+//=======================================================================
+/**
+ * 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
--- /dev/null
+// 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 <GEOMAlgo_GetInPlace.hxx>
+
+#include <math.h>
+
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Dir2d.hxx>
+
+#include <Geom_Surface.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dHatch_Hatcher.hxx>
+#include <Geom2dHatch_Intersector.hxx>
+#include <HatchGen_Domain.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+
+#include <TopAbs_State.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Face.hxx>
+
+#include <BRep_Tool.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRepTools.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+
+#include <IntTools_Tools.hxx>
+
+#include <BOPTools_Tools3D.hxx>
+#include <BOPTools_Tools2D.hxx>
+
+
+
+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;
+}
+
--- /dev/null
+// 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 <GEOMAlgo_GetInPlace.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <gp_Pnt.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <TopExp.hxx>
+
+#include <GProp_GProps.hxx>
+#include <BRepGProp.hxx>
+
+
+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);
+ }
+}
--- /dev/null
+// 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 <GEOMAlgo_GetInPlace.hxx>
+
+#include <NMTTools_CoupleOfShape.hxx>
+
+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<myDim; ++i) {
+ myLists[i].Clear();
+ }
+}
+//=======================================================================
+//function : AppendPair
+//purpose :
+//=======================================================================
+void GEOMAlgo_GetInPlaceIterator::AppendPair(const NMTTools_CoupleOfShape& theCS)
+{
+ Standard_Integer iX;
+ TopAbs_ShapeEnum aType1, aType2;
+ //
+ const TopoDS_Shape& aS1=theCS.Shape1();
+ const TopoDS_Shape& aS2=theCS.Shape2();
+ aType1=aS1.ShapeType();
+ aType2=aS2.ShapeType();
+ //
+ iX=TypeToInteger(aType1, aType2);
+ if (iX>=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;
+}
--- /dev/null
+// 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 <GEOMAlgo_GlueAnalyser.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <BRep_Builder.hxx>
+
+#include <TopExp.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+
+#include <GEOMAlgo_PassKeyShape.hxx>
+#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
+#include <GEOMAlgo_Tools.hxx>
+#include <GEOMAlgo_CoupleOfShapes.hxx>
+#include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
+
+#include <GEOMAlgo_Gluer.hxx>
+#include <Bnd_HArray1OfBox.hxx>
+#include <Bnd_BoundSortBox.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <GEOMAlgo_IndexedDataMapOfIntegerShape.hxx>
+#include <GEOMAlgo_IndexedDataMapOfShapeBox.hxx>
+#include <Bnd_Box.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <BRepBndLib.hxx>
+
+//=======================================================================
+//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);
+ }
+ //
+ */
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: GEOMAlgo_GlueDetector.hxx\r
+// Created: Wed Dec 15 11:08:09 2004\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _GEOMAlgo_GlueAnalyser_HeaderFile\r
+#define _GEOMAlgo_GlueAnalyser_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <GEOMAlgo_ListOfCoupleOfShapes.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <GEOMAlgo_Gluer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_GlueAnalyser\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_GlueAnalyser : public GEOMAlgo_Gluer \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_GlueAnalyser();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_GlueAnalyser();\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean HasSolidsToGlue() const;\r
+ \r
+ Standard_EXPORT\r
+ const GEOMAlgo_ListOfCoupleOfShapes& SolidsToGlue() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean HasSolidsAlone() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& SolidsAlone() const;\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ void DetectVertices() ;\r
+ \r
+ Standard_EXPORT\r
+ void DetectEdges() ;\r
+ \r
+ Standard_EXPORT\r
+ void DetectFaces() ;\r
+ \r
+ Standard_EXPORT\r
+ void DetectShapes(const TopAbs_ShapeEnum aType) ;\r
+ \r
+ Standard_EXPORT\r
+ void DetectSolids() ;\r
+\r
+\r
+ GEOMAlgo_ListOfCoupleOfShapes mySolidsToGlue;\r
+ TopTools_ListOfShape mySolidsAlone;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_GlueDetector.hxx>
+
+#include <Bnd_Box.hxx>
+#include <NCollection_UBTreeFiller.hxx>
+
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+
+#include <TopExp.hxx>
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBndLib.hxx>
+
+#include <NMTDS_BndSphereTree.hxx>
+#include <NMTDS_BndSphere.hxx>
+#include <NMTDS_IndexedDataMapOfShapeBndSphere.hxx>
+
+#include <GEOMAlgo_IndexedDataMapOfIntegerShape.hxx>
+#include <GEOMAlgo_PassKeyShape.hxx>
+#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
+#include <GEOMAlgo_Tools.hxx>
+
+//=======================================================================
+//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 <Standard_Integer, NMTDS_BndSphere> 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);
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#ifndef _GEOMAlgo_GlueDetector_HeaderFile
+#define _GEOMAlgo_GlueDetector_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+#include <GEOMAlgo_GluerAlgo.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <GEOMAlgo_PassKeyShape.hxx>
+#include <GEOMAlgo_Algo.hxx>
+
+//=======================================================================
+//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
--- /dev/null
+// 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
+// <peter@PREFEX>
+//
+#include <GEOMAlgo_Gluer.hxx>
+
+#include <NMTDS_BoxBndTree.hxx>
+#include <NCollection_UBTreeFiller.hxx>
+
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <gp_XYZ.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+
+#include <Bnd_Box.hxx>
+#include <Bnd_HArray1OfBox.hxx>
+#include <Bnd_BoundSortBox.hxx>
+
+#include <TopLoc_Location.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepLib.hxx>
+#include <BRepTools.hxx>
+#include <BRepBndLib.hxx>
+
+#include <IntTools_Context.hxx>
+#include <BOPTools_Tools.hxx>
+#include <BOPTools_Tools3D.hxx>
+#include <BOPTools_Tools2D.hxx>
+#include <BOP_CorrectTolerances.hxx>
+
+#include <GEOMAlgo_IndexedDataMapOfIntegerShape.hxx>
+#include <GEOMAlgo_IndexedDataMapOfShapeBox.hxx>
+#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
+#include <GEOMAlgo_PassKeyShape.hxx>
+#include <GEOMAlgo_Tools.hxx>
+//
+
+#include <NMTDS_BndSphereTree.hxx>
+#include <NMTDS_BndSphere.hxx>
+#include <NMTDS_IndexedDataMapOfShapeBndSphere.hxx>
+
+//
+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<aNb; ++i) {
+ (this->*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 <Standard_Integer, NMTDS_BndSphere> 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 (dH<dHmin) {
+ dHmin=dH;
+ }
+ }
+ //
+ myTol=myTolerance;
+ aCoef=0.01;
+ aTolTresh=aCoef*dHmin;
+ if (myTol>aTolTresh) {
+ 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
+//
--- /dev/null
+\r
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_Gluer.hxx\r
+// Created: Sat Dec 04 12:45:53 2004\r
+// Author: Peter KURNEV\r
+// <peter@PREFEX>\r
+//\r
+#ifndef _GEOMAlgo_Gluer_HeaderFile\r
+#define _GEOMAlgo_Gluer_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <TopTools_DataMapOfShapeListOfShape.hxx>\r
+#include <TopTools_DataMapOfShapeShape.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <GEOMAlgo_ShapeAlgo.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopoDS_Edge.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <TopoDS_Vertex.hxx>\r
+#include <GEOMAlgo_PassKeyShape.hxx>\r
+#include <TopTools_MapOfShape.hxx>\r
+#include <TopoDS_Compound.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_Gluer\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_Gluer : public GEOMAlgo_ShapeAlgo {\r
+public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_Gluer();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_Gluer();\r
+ \r
+ Standard_EXPORT\r
+ void SetCheckGeometry(const Standard_Boolean aFlag) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean CheckGeometry() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetKeepNonSolids(const Standard_Boolean aFlag) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean KeepNonSolids() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer AloneShapes() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Modified(const TopoDS_Shape& S) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Generated(const TopoDS_Shape& S) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsDeleted(const TopoDS_Shape& S) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_DataMapOfShapeListOfShape& Images() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_DataMapOfShapeShape& Origins() const;\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void CheckResult() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeVertices() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeEdges() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeFaces() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeShapes(const TopAbs_ShapeEnum aType) ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeShells() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeSolids() ;\r
+ \r
+ Standard_EXPORT\r
+ void InnerTolerance() ;\r
+ \r
+ Standard_EXPORT\r
+ void EdgePassKey(const TopoDS_Edge& aE,\r
+ GEOMAlgo_PassKeyShape& aPK) ;\r
+ \r
+ Standard_EXPORT\r
+ void FacePassKey(const TopoDS_Face& aF,\r
+ GEOMAlgo_PassKeyShape& aPK) ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeVertex(const TopTools_ListOfShape& aLV,\r
+ TopoDS_Vertex& aNewV) ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeEdge(const TopoDS_Edge& aEdge,\r
+ TopoDS_Edge& aNewEdge) ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeFace(const TopoDS_Face& aFace,\r
+ TopoDS_Face& aNewEdge) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsToReverse(const TopoDS_Face& aFR,\r
+ const TopoDS_Face& aF) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean HasNewSubShape(const TopoDS_Shape& aS) const;\r
+ \r
+ Standard_EXPORT\r
+ void MakeSubShapes(const TopoDS_Shape& aS,\r
+ TopTools_MapOfShape& aM,\r
+ TopoDS_Compound& aC) ;\r
+\r
+\r
+ Standard_Boolean myCheckGeometry;\r
+ Standard_Boolean myKeepNonSolids;\r
+ Standard_Real myTol;\r
+ TopTools_DataMapOfShapeListOfShape myImages;\r
+ TopTools_DataMapOfShapeShape myOrigins;\r
+ Standard_Integer myNbAlone;\r
+ TopTools_ListOfShape myGenerated;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_Gluer2.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <BRep_Builder.hxx>
+#include <TopExp.hxx>
+#include <BRepLib.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <GEOMAlgo_GlueDetector.hxx>
+#include <GEOMAlgo_Tools3D.hxx>
+
+//=======================================================================
+//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
--- /dev/null
+// 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
+// <pkv@irinox>
+
+#ifndef _GEOMAlgo_Gluer2_HeaderFile
+#define _GEOMAlgo_Gluer2_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <Standard_Boolean.hxx>
+#include <GEOMAlgo_GluerAlgo.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <NMTTools_CoupleOfShape.hxx>
+#include <NMTTools_ListOfCoupleOfShape.hxx>
+#include <GEOMAlgo_BuilderShape.hxx>
+
+//=======================================================================
+//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
--- /dev/null
+// 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 <GEOMAlgo_Gluer2.hxx>
+
+#include <gp_XYZ.hxx>
+#include <gp_Pnt.hxx>
+
+#include <TopLoc_Location.hxx>
+
+#include <Geom_Surface.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+
+#include <BRepTools.hxx>
+#include <TopExp.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+
+#include <BOPTools_Tools.hxx>
+#include <BOPTools_Tools2D.hxx>
+#include <BOPTools_Tools3D.hxx>
+
+#include <GEOMAlgo_Tools.hxx>
+
+//=======================================================================
+//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
--- /dev/null
+// 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
+// <peter@PREFEX>
+//
+#include <GEOMAlgo_Gluer2.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <GEOMAlgo_BuilderShape.hxx>
+#include <GEOMAlgo_Tools3D.hxx>
+
+//=======================================================================
+//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);
+ }
+}
--- /dev/null
+// 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 <GEOMAlgo_Gluer2.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <BRep_Tool.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <NMTTools_CoupleOfShape.hxx>
+#include <NMTTools_ListOfCoupleOfShape.hxx>
+#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
+#include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
+#include <NMTTools_Tools.hxx>
+
+#include <GEOMAlgo_GlueDetector.hxx>
+
+
+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();
+ }
+}
+*/
--- /dev/null
+// 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
+// <peter@PREFEX>
+//
+#include <GEOMAlgo_GluerAlgo.hxx>
+#include <IntTools_Context.hxx>
+
+
+//=======================================================================
+//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;
+ }
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#ifndef _GEOMAlgo_GluerAlgo_HeaderFile
+#define _GEOMAlgo_GluerAlgo_HeaderFile
+
+#include <Standard_Macro.hxx>
+#include <TopoDS_Shape.hxx>
+#include <Standard_Real.hxx>
+#include <Standard_Boolean.hxx>
+#include <IntTools_Context.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <GEOMAlgo_BuilderShape.hxx>
+
+//=======================================================================
+//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
--- /dev/null
+// 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
+// <peter@PREFEX>
+//
+#include <GEOMAlgo_HAlgo.hxx>
+
+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
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_HAlgo.hxx\r
+// Created: Sat Dec 04 12:39:47 2004\r
+// Author: Peter KURNEV\r
+// <peter@PREFEX>\r
+//\r
+\r
+#ifndef _GEOMAlgo_HAlgo_HeaderFile\r
+#define _GEOMAlgo_HAlgo_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_DefineHandle.hxx>\r
+//#include <Handle_GEOMAlgo_HAlgo.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <MMgt_TShared.hxx>\r
+\r
+DEFINE_STANDARD_HANDLE(GEOMAlgo_HAlgo, MMgt_TShared);\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_HAlgo\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_HAlgo : public MMgt_TShared \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ virtual void Perform() = 0;\r
+ \r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void CheckResult() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer ErrorStatus() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer WarningStatus() const;\r
+\r
+ DEFINE_STANDARD_RTTI(GEOMAlgo_HAlgo);\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ GEOMAlgo_HAlgo();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_HAlgo();\r
+\r
+ Standard_Integer myErrorStatus;\r
+ Standard_Integer myWarningStatus;\r
+\r
+};\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_IndexedDataMapOfIntegerShape.hxx\r
+// Created: Wed Feb 22 11:22:18 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_IndexedDataMapOfIntegerShape_HeaderFile\r
+#define GEOMAlgo_IndexedDataMapOfIntegerShape_HeaderFile\r
+\r
+\r
+\r
+#include <TopoDS_Shape.hxx> \r
+#include <Standard_Integer.hxx>\r
+#include <TColStd_MapIntegerHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+\r
+typedef NCollection_IndexedDataMap<Standard_Integer, TopoDS_Shape, TColStd_MapIntegerHasher> GEOMAlgo_IndexedDataMapOfIntegerShape; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx\r
+// Created: Wed Feb 22 11:24:27 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape_HeaderFile\r
+#define GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape_HeaderFile\r
+\r
+#include <GEOMAlgo_PassKeyShape.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <GEOMAlgo_PassKeyShapeMapHasher.hxx>\r
+\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+\r
+typedef NCollection_IndexedDataMap<GEOMAlgo_PassKeyShape, TopTools_ListOfShape, GEOMAlgo_PassKeyShapeMapHasher> GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_IndexedDataMapOfShapeBox.hxx\r
+// Created: Wed Feb 22 11:14:14 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_IndexedDataMapOfShapeBox_HeaderFile\r
+#define GEOMAlgo_IndexedDataMapOfShapeBox_HeaderFile\r
+\r
+\r
+#include <TopoDS_Shape.hxx> \r
+#include <TopTools_ShapeMapHasher.hxx>\r
+#include <Bnd_Box.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+\r
+typedef NCollection_IndexedDataMap<TopoDS_Shape, Bnd_Box, TopTools_ShapeMapHasher> GEOMAlgo_IndexedDataMapOfShapeBox; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx\r
+// Created: Wed Feb 22 11:16:54 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_IndexedDataMapOfShapeShapeInfo_HeaderFile\r
+#define GEOMAlgo_IndexedDataMapOfShapeShapeInfo_HeaderFile\r
+\r
+\r
+#include <TopoDS_Shape.hxx> \r
+#include <TopTools_ShapeMapHasher.hxx>\r
+#include <GEOMAlgo_ShapeInfo.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+typedef NCollection_IndexedDataMap<TopoDS_Shape, GEOMAlgo_ShapeInfo, TopTools_ShapeMapHasher> GEOMAlgo_IndexedDataMapOfShapeShapeInfo; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+/// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_IndexedDataMapOfShapeState.hxx\r
+// Created: Wed Feb 22 11:19:56 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_IndexedDataMapOfShapeState_HeaderFile\r
+#define GEOMAlgo_IndexedDataMapOfShapeState_HeaderFile\r
+\r
+\r
+\r
+#include <TopoDS_Shape.hxx> \r
+#include <TopTools_ShapeMapHasher.hxx>\r
+#include <TopAbs_State.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+typedef NCollection_IndexedDataMap<TopoDS_Shape, TopAbs_State, TopTools_ShapeMapHasher> GEOMAlgo_IndexedDataMapOfShapeState; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+#ifndef _GEOMAlgo_KindOfBounds_HeaderFile\r
+#define _GEOMAlgo_KindOfBounds_HeaderFile\r
+\r
+\r
+enum GEOMAlgo_KindOfBounds {\r
+GEOMAlgo_KB_UNKNOWN,\r
+GEOMAlgo_KB_TRIMMED,\r
+GEOMAlgo_KB_INFINITE\r
+};\r
+\r
+#ifndef _Standard_PrimitiveTypes_HeaderFile\r
+#include <Standard_PrimitiveTypes.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+#ifndef _GEOMAlgo_KindOfClosed_HeaderFile\r
+#define _GEOMAlgo_KindOfClosed_HeaderFile\r
+\r
+\r
+enum GEOMAlgo_KindOfClosed {\r
+GEOMAlgo_KC_UNKNOWN,\r
+GEOMAlgo_KC_CLOSED,\r
+GEOMAlgo_KC_NOTCLOSED\r
+};\r
+\r
+#ifndef _Standard_PrimitiveTypes_HeaderFile\r
+#include <Standard_PrimitiveTypes.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+#ifndef _GEOMAlgo_KindOfName_HeaderFile\r
+#define _GEOMAlgo_KindOfName_HeaderFile\r
+\r
+\r
+enum GEOMAlgo_KindOfName {\r
+GEOMAlgo_KN_UNKNOWN,\r
+GEOMAlgo_KN_SPHERE,\r
+GEOMAlgo_KN_CYLINDER,\r
+GEOMAlgo_KN_TORUS,\r
+GEOMAlgo_KN_CONE,\r
+GEOMAlgo_KN_ELLIPSE,\r
+GEOMAlgo_KN_CIRCLE,\r
+GEOMAlgo_KN_PLANE,\r
+GEOMAlgo_KN_LINE,\r
+GEOMAlgo_KN_BOX,\r
+GEOMAlgo_KN_SEGMENT,\r
+GEOMAlgo_KN_ARCCIRCLE,\r
+GEOMAlgo_KN_POLYGON,\r
+GEOMAlgo_KN_POLYHEDRON,\r
+GEOMAlgo_KN_DISKCIRCLE,\r
+GEOMAlgo_KN_DISKELLIPSE,\r
+GEOMAlgo_KN_RECTANGLE,\r
+GEOMAlgo_KN_TRIANGLE,\r
+GEOMAlgo_KN_QUADRANGLE,\r
+GEOMAlgo_KN_ARCELLIPSE\r
+};\r
+\r
+#ifndef _Standard_PrimitiveTypes_HeaderFile\r
+#include <Standard_PrimitiveTypes.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+#ifndef _GEOMAlgo_KindOfShape_HeaderFile\r
+#define _GEOMAlgo_KindOfShape_HeaderFile\r
+\r
+\r
+enum GEOMAlgo_KindOfShape {\r
+GEOMAlgo_KS_UNKNOWN,\r
+GEOMAlgo_KS_SPHERE,\r
+GEOMAlgo_KS_CYLINDER,\r
+GEOMAlgo_KS_BOX,\r
+GEOMAlgo_KS_TORUS,\r
+GEOMAlgo_KS_CONE,\r
+GEOMAlgo_KS_ELLIPSE,\r
+GEOMAlgo_KS_PLANE,\r
+GEOMAlgo_KS_CIRCLE,\r
+GEOMAlgo_KS_LINE,\r
+GEOMAlgo_KS_DEGENERATED\r
+};\r
+\r
+#ifndef _Standard_PrimitiveTypes_HeaderFile\r
+#include <Standard_PrimitiveTypes.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx\r
+// Created: Wed Feb 22 08:26:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+#ifndef GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_HeaderFile\r
+#define GEOMAlgo_ListIteratorOfListOfCoupleOfShapes_HeaderFile\r
+\r
+#ifndef GEOMAlgo_ListOfCoupleOfShapes_HeaderFile\r
+#include <GEOMAlgo_ListOfCoupleOfShapes.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_ListIteratorOfListOfPnt.hxx\r
+// Created: Wed Feb 22 08:33:12 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_ListIteratorOfListOfPnt_HeaderFile\r
+#define GEOMAlgo_ListIteratorOfListOfPnt_HeaderFile\r
+\r
+#ifndef GEOMAlgo_ListOfPnt_HeaderFile\r
+#include <GEOMAlgo_ListOfPnt.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: GEOMAlgo_ListOfCoupleOfShapes.hxx\r
+// Created: Wed Feb 22 08:23:27 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+#ifndef GEOMAlgo_ListOfCoupleOfShapes_HeaderFile\r
+#define GEOMAlgo_ListOfCoupleOfShapes_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <GEOMAlgo_CoupleOfShapes.hxx>\r
+\r
+typedef NCollection_List<GEOMAlgo_CoupleOfShapes> GEOMAlgo_ListOfCoupleOfShapes; \r
+typedef GEOMAlgo_ListOfCoupleOfShapes::Iterator GEOMAlgo_ListIteratorOfListOfCoupleOfShapes;\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_ListOfPnt.hxx\r
+// Created: Wed Feb 22 08:31:47 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef GEOMAlgo_ListOfPnt_HeaderFile\r
+#define GEOMAlgo_ListOfPnt_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <gp_Pnt.hxx>\r
+\r
+typedef NCollection_List<gp_Pnt> GEOMAlgo_ListOfPnt; \r
+typedef GEOMAlgo_ListOfPnt::Iterator GEOMAlgo_ListIteratorOfListOfPnt;\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_PWireEdgeSet.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <peter@PREFEX>\r
+//\r
+#ifndef _GEOMAlgo_PWireEdgeSet_HeaderFile\r
+#define _GEOMAlgo_PWireEdgeSet_HeaderFile\r
+\r
+class GEOMAlgo_WireEdgeSet;\r
+\r
+typedef GEOMAlgo_WireEdgeSet* GEOMAlgo_PWireEdgeSet;\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <peter@PREFEX>
+//
+#include <GEOMAlgo_PassKey.hxx>
+
+#include <stdio.h>
+#include <string.h>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+
+#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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_PassKey.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <peter@PREFEX>\r
+//\r
+#ifndef _GEOMAlgo_PassKey_HeaderFile\r
+#define _GEOMAlgo_PassKey_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TColStd_IndexedMapOfInteger.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TColStd_ListOfInteger.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_PassKey\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_PassKey {\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_PassKey();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_PassKey();\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_PassKey(const GEOMAlgo_PassKey& Other);\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_PassKey& Assign(const GEOMAlgo_PassKey& Other) ;\r
+ \r
+ GEOMAlgo_PassKey& operator =(const GEOMAlgo_PassKey& Other) {\r
+ return Assign(Other);\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ void Clear() ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1,\r
+ const Standard_Integer aI2) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1,\r
+ const Standard_Integer aI2,\r
+ const Standard_Integer aI3) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1,\r
+ const Standard_Integer aI2,\r
+ const Standard_Integer aI3,\r
+ const Standard_Integer aI4) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const TColStd_ListOfInteger& aLS) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer NbIds() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsEqual(const GEOMAlgo_PassKey& aOther) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer HashCode(const Standard_Integer Upper) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer Id(const Standard_Integer aIndex) const;\r
+ \r
+ Standard_EXPORT\r
+ void Dump(const Standard_Integer aHex = 0) const;\r
+\r
+ protected:\r
+ Standard_Integer myNbIds;\r
+ Standard_Integer mySum;\r
+ TColStd_IndexedMapOfInteger myMap;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_PassKeyMapHasher.hxx>
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_PassKeyMapHasher.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_PassKeyMapHasher_HeaderFile\r
+#define _GEOMAlgo_PassKeyMapHasher_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <GEOMAlgo_PassKey.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_PassKeyMapHasher\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_PassKeyMapHasher {\r
+ public:\r
+ Standard_EXPORT\r
+ static Standard_Integer HashCode(const GEOMAlgo_PassKey& aPKey,\r
+ const Standard_Integer Upper) ;\r
+ \r
+ Standard_EXPORT \r
+ static Standard_Boolean IsEqual(const GEOMAlgo_PassKey& aPKey1,\r
+ const GEOMAlgo_PassKey& aPKey2) ;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_PassKeyShape.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+
+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;
+}
--- /dev/null
+\r
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_PassKeyShape.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_PassKeyShape_HeaderFile\r
+#define _GEOMAlgo_PassKeyShape_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TopTools_IndexedMapOfShape.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_PassKeyShape\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_PassKeyShape {\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_PassKeyShape();\r
+ \r
+ Standard_EXPORT \r
+ virtual ~GEOMAlgo_PassKeyShape();\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_PassKeyShape(const GEOMAlgo_PassKeyShape& Other);\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_PassKeyShape& Assign(const GEOMAlgo_PassKeyShape& Other) ;\r
+ \r
+ GEOMAlgo_PassKeyShape& operator =(const GEOMAlgo_PassKeyShape& Other) {\r
+ return Assign(Other);\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopoDS_Shape& aS1,\r
+ const TopoDS_Shape& aS2) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopoDS_Shape& aS1,\r
+ const TopoDS_Shape& aS2,\r
+ const TopoDS_Shape& aS3) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopoDS_Shape& aS1,\r
+ const TopoDS_Shape& aS2,\r
+ const TopoDS_Shape& aS3,\r
+ const TopoDS_Shape& aS4) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopTools_ListOfShape& aLS) ;\r
+ \r
+ Standard_EXPORT\r
+ void Clear() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer NbIds() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aOther) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer HashCode(const Standard_Integer Upper) const;\r
+ \r
+ Standard_EXPORT\r
+ void Dump(const Standard_Integer aHex = 0) const;\r
+\r
+protected:\r
+ Standard_Integer myNbIds;\r
+ Standard_Integer mySum;\r
+ Standard_Integer myUpper;\r
+ TopTools_IndexedMapOfShape myMap;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_PassKeyShapeMapHasher.hxx>
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_PassKeyMapHasher.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_PassKeyShapeMapHasher_HeaderFile\r
+#define _GEOMAlgo_PassKeyShapeMapHasher_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <GEOMAlgo_PassKeyShape.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_PassKeyShapeMapHasher\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_PassKeyShapeMapHasher \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ static Standard_Integer HashCode(const GEOMAlgo_PassKeyShape& aPKey,\r
+ const Standard_Integer Upper) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aPKey1,\r
+ const GEOMAlgo_PassKeyShape& aPKey2) ;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_ShapeAlgo.hxx>
+#include <IntTools_Context.hxx>
+
+//=======================================================================
+//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;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_ShapeAlgo.hxx\r
+// Created: Tue Dec 7 12:06:54 2004\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_ShapeAlgo_HeaderFile\r
+#define _GEOMAlgo_ShapeAlgo_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <Handle_IntTools_Context.hxx>\r
+#include <GEOMAlgo_Algo.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_ShapeAlgo\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ShapeAlgo : public GEOMAlgo_Algo \r
+{\r
+ public:\r
+\r
+ //! Sets cashed geometrical tools <br>\r
+ Standard_EXPORT\r
+ void SetContext(const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Returns cashed geometrical tools <br>\r
+ Standard_EXPORT\r
+ const Handle_IntTools_Context& Context() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetShape(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetTolerance(const Standard_Real aT) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Real Tolerance() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Result() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ GEOMAlgo_ShapeAlgo();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_ShapeAlgo();\r
+\r
+\r
+ TopoDS_Shape myShape;\r
+ Standard_Real myTolerance;\r
+ TopoDS_Shape myResult;\r
+ Handle_IntTools_Context myContext;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_ShapeInfo.hxx>
+
+
+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<myNbTypes; ++i) {
+ myNbSubShapes[i]=0;
+ }
+ //
+ myKindOfShape=GEOMAlgo_KS_UNKNOWN;
+ myKindOfBounds=GEOMAlgo_KB_UNKNOWN;
+ myKindOfClosed=GEOMAlgo_KC_UNKNOWN;
+ myKindOfName=GEOMAlgo_KN_UNKNOWN;
+ //
+ myLocation.SetCoord(99., 99., 99.);
+ myDirection.SetCoord(1.,0.,0.);
+ //
+ myRadius1=-1.;
+ myRadius2=-2.;
+ myLength=-3.;
+ myWidth=-3.;
+ myHeight=-3.;
+}
+//=======================================================================
+//function : SetType
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetType(const TopAbs_ShapeEnum aType)
+{
+ myType=aType;
+}
+//=======================================================================
+//function : Type
+//purpose :
+//=======================================================================
+ TopAbs_ShapeEnum GEOMAlgo_ShapeInfo::Type() const
+{
+ return myType;
+}
+//=======================================================================
+//function : SetNbSubShapes
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetNbSubShapes(const TopAbs_ShapeEnum aType,
+ const Standard_Integer aNb)
+{
+ Standard_Integer iN;
+
+ iN=TypeToInteger(aType);
+ if (iN>=0 && iN<myNbTypes) {
+ myNbSubShapes[iN]=aNb;
+ }
+}
+//=======================================================================
+//function : NbSubShapes
+//purpose :
+//=======================================================================
+ Standard_Integer GEOMAlgo_ShapeInfo::NbSubShapes(const TopAbs_ShapeEnum aType) const
+{
+ Standard_Integer iN;
+
+ iN=TypeToInteger(aType);
+ if (iN>=0 && iN<myNbTypes) {
+ return myNbSubShapes[iN];
+ }
+ return 0;
+}
+//=======================================================================
+//function : SetKindOfShape
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetKindOfShape(const GEOMAlgo_KindOfShape aT)
+{
+ myKindOfShape=aT;
+}
+//=======================================================================
+//function : KindOfShape
+//purpose :
+//=======================================================================
+ GEOMAlgo_KindOfShape GEOMAlgo_ShapeInfo::KindOfShape() const
+{
+ return myKindOfShape;
+}
+//=======================================================================
+//function : SetKindOfName
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetKindOfName(const GEOMAlgo_KindOfName aT)
+{
+ myKindOfName=aT;
+}
+//=======================================================================
+//function : KindOfName
+//purpose :
+//=======================================================================
+ GEOMAlgo_KindOfName GEOMAlgo_ShapeInfo::KindOfName() const
+{
+ return myKindOfName;
+}
+//=======================================================================
+//function : SetKindOfBounds
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetKindOfBounds(const GEOMAlgo_KindOfBounds aT)
+{
+ myKindOfBounds=aT;
+}
+//=======================================================================
+//function : KindOfBounds
+//purpose :
+//=======================================================================
+ GEOMAlgo_KindOfBounds GEOMAlgo_ShapeInfo::KindOfBounds() const
+{
+ return myKindOfBounds;
+}
+//=======================================================================
+//function : SetKindOfClosed
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetKindOfClosed(const GEOMAlgo_KindOfClosed aT)
+{
+ myKindOfClosed=aT;
+}
+//=======================================================================
+//function : KindOfClosed
+//purpose :
+//=======================================================================
+ GEOMAlgo_KindOfClosed GEOMAlgo_ShapeInfo::KindOfClosed() const
+{
+ return myKindOfClosed;
+}
+//=======================================================================
+//function : SetLocation
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetLocation(const gp_Pnt& aP)
+{
+ myLocation=aP;
+}
+//=======================================================================
+//function : Location
+//purpose :
+//=======================================================================
+ const gp_Pnt& GEOMAlgo_ShapeInfo::Location() const
+{
+ return myLocation;
+}
+//=======================================================================
+//function : SetDirection
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetDirection(const gp_Dir& aD)
+{
+ myDirection=aD;
+}
+//=======================================================================
+//function : Direction
+//purpose :
+//=======================================================================
+ const gp_Dir& GEOMAlgo_ShapeInfo::Direction() const
+{
+ return myDirection;
+}
+//=======================================================================
+//function : SetPosition
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax2& aAx2)
+{
+ gp_Ax3 aAx3(aAx2);
+ SetPosition(aAx3);
+}
+//=======================================================================
+//function : SetPosition
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetPosition(const gp_Ax3& aAx3)
+{
+ myPosition=aAx3;
+}
+//=======================================================================
+//function : Position
+//purpose :
+//=======================================================================
+ const gp_Ax3& GEOMAlgo_ShapeInfo::Position() const
+{
+ return myPosition;
+}
+
+//=======================================================================
+//function : SetPnt1
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetPnt1(const gp_Pnt& aP)
+{
+ myPnt1=aP;
+}
+//=======================================================================
+//function : Pnt1
+//purpose :
+//=======================================================================
+ const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt1() const
+{
+ return myPnt1;
+}
+//=======================================================================
+//function : SetPnt2
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetPnt2(const gp_Pnt& aP)
+{
+ myPnt2=aP;
+}
+//=======================================================================
+//function : Pnt2
+//purpose :
+//=======================================================================
+ const gp_Pnt& GEOMAlgo_ShapeInfo::Pnt2() const
+{
+ return myPnt2;
+}
+//=======================================================================
+//function : SetRadius1
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetRadius1(const Standard_Real aR)
+{
+ myRadius1=aR;
+}
+//=======================================================================
+//function : Radius1
+//purpose :
+//=======================================================================
+ Standard_Real GEOMAlgo_ShapeInfo::Radius1() const
+{
+ return myRadius1;
+}
+//=======================================================================
+//function : SetRadius2
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetRadius2(const Standard_Real aR)
+{
+ myRadius2=aR;
+}
+//=======================================================================
+//function : Radius2
+//purpose :
+//=======================================================================
+ Standard_Real GEOMAlgo_ShapeInfo::Radius2() const
+{
+ return myRadius2;
+}
+//=======================================================================
+//function : SetLength
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetLength(const Standard_Real aL)
+{
+ myLength=aL;
+}
+//=======================================================================
+//function : Length
+//purpose :
+//=======================================================================
+ Standard_Real GEOMAlgo_ShapeInfo::Length() const
+{
+ return myLength;
+}
+//=======================================================================
+//function : SetWidth
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetWidth(const Standard_Real aW)
+{
+ myWidth=aW;
+}
+//=======================================================================
+//function : Width
+//purpose :
+//=======================================================================
+ Standard_Real GEOMAlgo_ShapeInfo::Width() const
+{
+ return myWidth;
+}
+//=======================================================================
+//function : SetHeight
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::SetHeight(const Standard_Real aH)
+{
+ myHeight=aH;
+}
+//=======================================================================
+//function : Height
+//purpose :
+//=======================================================================
+ Standard_Real GEOMAlgo_ShapeInfo::Height() const
+{
+ return myHeight;
+}
+//=======================================================================
+//function : TypeToInteger
+//purpose :
+//=======================================================================
+Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aType)
+{
+ Standard_Integer iN;
+ //
+ iN=(Standard_Integer)aType;
+ return iN;
+}
+//=======================================================================
+//function : Dump
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::Dump()const
+{
+ switch (myType) {
+ //
+ case TopAbs_VERTEX:
+ DumpVertex();
+ break;
+ //
+ case TopAbs_EDGE:
+ DumpEdge();
+ break;
+ //
+ case TopAbs_WIRE:
+ DumpWire();
+ break;
+ //
+ case TopAbs_FACE:
+ DumpFace();
+ break;
+ //
+ case TopAbs_SHELL:
+ DumpShell();
+ break;
+ //
+ case TopAbs_SOLID:
+ DumpSolid();
+ break;
+ //
+ case TopAbs_COMPSOLID:
+ DumpCompSolid();
+ break;
+ //
+ case TopAbs_COMPOUND:
+ DumpCompound();
+ break;
+ //
+ default:
+ printf(" * not implememted yet\n");
+ break;
+ }
+}
+//=======================================================================
+//function : DumpCompound
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::DumpCompound()const
+{
+ Standard_Integer aNbV, aNbE, aNbF, aNbS, aNbC, aNbP;
+ GEOMAlgo_KindOfShape aKS;
+ GEOMAlgo_KindOfName aKN;
+ GEOMAlgo_KindOfBounds aKB;
+ GEOMAlgo_KindOfClosed aKC;
+ //
+ aNbV=NbSubShapes(TopAbs_VERTEX);
+ aNbE=NbSubShapes(TopAbs_EDGE);
+ aNbF=NbSubShapes(TopAbs_FACE);
+ aNbS=NbSubShapes(TopAbs_SOLID);
+ aNbC=NbSubShapes(TopAbs_COMPSOLID);
+ aNbP=NbSubShapes(TopAbs_COMPOUND);
+ aKS=KindOfShape();
+ aKN=KindOfName();
+ aKB=KindOfBounds();
+ aKC=KindOfClosed();
+ //
+ printf(" *COMPOUND\n");
+ printf(" number of vertices : %d\n", aNbV);
+ printf(" number of edges : %d\n", aNbE);
+ printf(" number of faces : %d\n", aNbF);
+ printf(" number of solids : %d\n", aNbS);
+ printf(" number of compsolids : %d\n", aNbC);
+ printf(" number of compounds : %d\n", aNbP);
+ DumpKindOfShape (aKS);
+ DumpKindOfName (aKN);
+ DumpKindOfBounds(aKB);
+ DumpKindOfClosed(aKC);
+}
+//=======================================================================
+//function : DumpCompSolid
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::DumpCompSolid()const
+{
+ Standard_Integer aNbV, aNbE, aNbF, aNbS;
+ GEOMAlgo_KindOfShape aKS;
+ GEOMAlgo_KindOfName aKN;
+ GEOMAlgo_KindOfBounds aKB;
+ GEOMAlgo_KindOfClosed aKC;
+ //
+ aNbV=NbSubShapes(TopAbs_VERTEX);
+ aNbE=NbSubShapes(TopAbs_EDGE);
+ aNbF=NbSubShapes(TopAbs_FACE);
+ aNbS=NbSubShapes(TopAbs_SOLID);
+ aKS=KindOfShape();
+ aKN=KindOfName();
+ aKB=KindOfBounds();
+ aKC=KindOfClosed();
+ //
+ printf(" *COMPSOLID\n");
+ printf(" number of vertices: %d\n", aNbV);
+ printf(" number of edges : %d\n", aNbE);
+ printf(" number of faces : %d\n", aNbF);
+ printf(" number of solids : %d\n", aNbS);
+ DumpKindOfShape (aKS);
+ DumpKindOfName (aKN);
+ DumpKindOfBounds(aKB);
+ DumpKindOfClosed(aKC);
+}
+
+//=======================================================================
+//function : DumpSolid
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::DumpSolid()const
+{
+ Standard_Integer aNbV, aNbE, aNbF;
+ GEOMAlgo_KindOfShape aKS;
+ GEOMAlgo_KindOfName aKN;
+ GEOMAlgo_KindOfBounds aKB;
+ GEOMAlgo_KindOfClosed aKC;
+ //
+ aNbV=NbSubShapes(TopAbs_VERTEX);
+ aNbE=NbSubShapes(TopAbs_EDGE);
+ aNbF=NbSubShapes(TopAbs_FACE);
+ aKS=KindOfShape();
+ aKN=KindOfName();
+ aKB=KindOfBounds();
+ aKC=KindOfClosed();
+ //
+ printf(" *SOLID\n");
+ printf(" number of vertices: %d\n", aNbV);
+ printf(" number of edges : %d\n", aNbE);
+ printf(" number of faces : %d\n", aNbF);
+ DumpKindOfShape (aKS);
+ DumpKindOfName (aKN);
+ DumpKindOfBounds(aKB);
+ DumpKindOfClosed(aKC);
+ //
+ if (aKN==GEOMAlgo_KN_SPHERE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ }
+ if (aKN==GEOMAlgo_KN_CYLINDER) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Height : %.3lf\n", myHeight);
+ }
+ else if (aKN==GEOMAlgo_KN_CONE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Radius2 : %.3lf\n", myRadius2);
+ printf(" Height : %.3lf\n", myHeight);
+ }
+ else if (aKN==GEOMAlgo_KN_TORUS) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Radius2 : %.3lf\n", myRadius2);
+ }
+ else if (aKN==GEOMAlgo_KN_POLYHEDRON) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ }
+ else if (aKN==GEOMAlgo_KN_BOX) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Length : %.3lf\n", myLength);
+ printf(" Width : %.3lf\n", myWidth);
+ printf(" Height : %.3lf\n", myHeight);
+ }
+}
+
+//=======================================================================
+//function : DumpFace
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::DumpFace()const
+{
+ Standard_Integer aNbV, aNbE;
+ GEOMAlgo_KindOfShape aKS;
+ GEOMAlgo_KindOfName aKN;
+ GEOMAlgo_KindOfBounds aKB;
+ GEOMAlgo_KindOfClosed aKC;
+ //
+ aNbV=NbSubShapes(TopAbs_VERTEX);
+ aNbE=NbSubShapes(TopAbs_EDGE);
+ aKS=KindOfShape();
+ aKN=KindOfName();
+ aKB=KindOfBounds();
+ aKC=KindOfClosed();
+ //
+ printf(" *FACE\n");
+ printf(" number of vertices: %d\n", aNbV);
+ printf(" number of edges : %d\n", aNbE);
+ DumpKindOfShape (aKS);
+ DumpKindOfName (aKN);
+ DumpKindOfBounds(aKB);
+ DumpKindOfClosed(aKC);
+ //
+ // PLANE
+ if (aKN==GEOMAlgo_KN_PLANE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ }
+ else if (aKN==GEOMAlgo_KN_DISKCIRCLE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ }
+ else if (aKN==GEOMAlgo_KN_DISKELLIPSE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Radius2 : %.3lf\n", myRadius2);
+ }
+ else if (aKN==GEOMAlgo_KN_RECTANGLE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Length : %.3lf\n", myLength);
+ printf(" Width : %.3lf\n", myWidth);
+ }
+ else if (aKN==GEOMAlgo_KN_TRIANGLE ||
+ aKN==GEOMAlgo_KN_QUADRANGLE||
+ aKN==GEOMAlgo_KN_POLYGON) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ }
+ //
+ // SPHERE
+ else if (aKN==GEOMAlgo_KN_SPHERE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf", myRadius1);
+ }
+ //
+ // CYLINDER
+ else if (aKN==GEOMAlgo_KN_CYLINDER) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Height : %.3lf\n", myHeight);
+ }
+ //
+ // CONE
+ else if (aKN==GEOMAlgo_KN_CONE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Radius2 : %.3lf\n", myRadius2);
+ printf(" Height : %.3lf\n", myHeight);
+ }
+ //
+ // TORUS
+ else if (aKN==GEOMAlgo_KN_TORUS) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Radius2 : %.3lf\n", myRadius2);
+ }
+
+
+ printf("\n");
+}
+//=======================================================================
+//function : DumpShell
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::DumpShell()const
+{
+ Standard_Integer aNbV, aNbE, aNbF;
+ GEOMAlgo_KindOfClosed aKC;
+ //
+ printf(" *SHELL\n");
+ //
+ aNbV=NbSubShapes(TopAbs_VERTEX);
+ aNbE=NbSubShapes(TopAbs_EDGE);
+ aNbF=NbSubShapes(TopAbs_FACE);
+ printf(" number of vertices: %d\n", aNbV);
+ printf(" number of edges : %d\n", aNbE);
+ printf(" number of faces : %d\n", aNbF);
+ aKC=KindOfClosed();
+ DumpKindOfClosed(aKC);
+ printf("\n");
+}
+//=======================================================================
+//function : DumpWire
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::DumpWire()const
+{
+ Standard_Integer aNbV, aNbE;
+ GEOMAlgo_KindOfClosed aKC;
+ //
+ printf(" *WIRE\n");
+ //
+ aNbV=NbSubShapes(TopAbs_VERTEX);
+ aNbE=NbSubShapes(TopAbs_EDGE);
+ printf(" number of vertices: %d\n", aNbV);
+ printf(" number of edges : %d\n", aNbE);
+
+ aKC=KindOfClosed();
+ DumpKindOfClosed(aKC);
+ printf("\n");
+}
+//=======================================================================
+//function : DumpEdge
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::DumpEdge()const
+{
+ Standard_Integer aNbV;
+ Standard_Real aX, aY, aZ;
+ GEOMAlgo_KindOfShape aKS;
+ GEOMAlgo_KindOfName aKN;
+ GEOMAlgo_KindOfBounds aKB;
+ GEOMAlgo_KindOfClosed aKC;
+ //
+ aNbV=NbSubShapes(TopAbs_VERTEX);
+ aKS=KindOfShape();
+ aKN=KindOfName();
+ aKB=KindOfBounds();
+ aKC=KindOfClosed();
+ //
+ printf(" *EDGE\n");
+ printf(" number of vertices: %d\n", aNbV);
+ DumpKindOfShape (aKS);
+ DumpKindOfName (aKN);
+ DumpKindOfBounds(aKB);
+ DumpKindOfClosed(aKC);
+ //
+ // LINE
+ if (aKN==GEOMAlgo_KN_LINE) {
+ DumpLocation (myLocation);
+ DumpDirection(myDirection);
+ }
+ else if (aKN==GEOMAlgo_KN_SEGMENT) {
+ DumpLocation (myLocation);
+ DumpDirection(myDirection);
+ printf(" Length : %.3lf\n", myLength);
+ myPnt1.Coord(aX, aY, aZ);
+ printf(" Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
+ myPnt2.Coord(aX, aY, aZ);
+ printf(" Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
+
+ }
+ else if (aKN==GEOMAlgo_KN_CIRCLE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ }
+ else if (aKN==GEOMAlgo_KN_ARCCIRCLE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ myPnt1.Coord(aX, aY, aZ);
+ printf(" Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
+ myPnt2.Coord(aX, aY, aZ);
+ printf(" Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
+ }
+ else if (aKN==GEOMAlgo_KN_ELLIPSE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Radius2 : %.3lf\n", myRadius2);
+ }
+ else if (aKN==GEOMAlgo_KN_ARCELLIPSE) {
+ DumpLocation (myLocation);
+ DumpPosition (myPosition);
+ printf(" Radius1 : %.3lf\n", myRadius1);
+ printf(" Radius2 : %.3lf\n", myRadius2);
+ myPnt1.Coord(aX, aY, aZ);
+ printf(" Pnt1 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
+ myPnt2.Coord(aX, aY, aZ);
+ printf(" Pnt2 : %.3lf %.3lf %.3lf\n", aX, aY, aZ);
+ }
+ printf("\n");
+}
+//=======================================================================
+//function : DumpVertex
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfo::DumpVertex()const
+{
+ printf(" *VERTEX\n");
+ DumpLocation(myLocation);
+}
+//=======================================================================
+//function : DumpLocation
+//purpose :
+//=======================================================================
+ void DumpLocation(const gp_Pnt& aP)
+{
+ Standard_Real aX, aY, aZ;
+ //
+ aP.Coord(aX, aY, aZ);
+ printf(" Location : %.3lf %.3lf %.3lf \n", aX, aY, aZ);
+}
+//=======================================================================
+//function : DumpDirection
+//purpose :
+//=======================================================================
+ void DumpDirection(const gp_Dir& aD)
+{
+ Standard_Real aX, aY, aZ;
+ //
+ aD.Coord(aX, aY, aZ);
+ printf(" Direction: %.3lf %.3lf %.3lf \n", aX, aY, aZ);
+}
+//=======================================================================
+//function : DumpPosition
+//purpose :
+//=======================================================================
+void DumpPosition(const gp_Ax3& aAx3)
+{
+ const gp_Dir& aDZ=aAx3.Axis().Direction();
+ const gp_Dir& aDX=aAx3.XDirection();
+ const gp_Dir& aDY=aAx3.YDirection();
+ printf(" Position:\n");
+ printf(" Axis: %.3lf %.3lf %.3lf \n", aDZ.X(), aDZ.Y(), aDZ.Z());
+ printf(" X : %.3lf %.3lf %.3lf \n", aDX.X(), aDX.Y(), aDX.Z());
+ printf(" Y : %.3lf %.3lf %.3lf \n", aDY.X(), aDY.Y(), aDY.Z());
+}
+//=======================================================================
+//function : DumpKindOfBounds
+//purpose :
+//=======================================================================
+void DumpKindOfBounds(const GEOMAlgo_KindOfBounds aKB)
+{
+ const char *pStr[]={
+ "KB_UNKNOWN",
+ "KB_TRIMMED",
+ "KB_INFINITE"
+ };
+ int i;
+ //
+ i=(Standard_Integer)aKB;
+ printf(" KindOfBounds: %s\n", pStr[i]);
+
+}
+//=======================================================================
+//function : DumpKindOfClosed
+//purpose :
+//=======================================================================
+void DumpKindOfClosed(const GEOMAlgo_KindOfClosed aKC)
+{
+ const char *pStr[]={
+ "KC_UNKNOWN",
+ "KC_CLOSED",
+ "KC_NOTCLOSED"
+ };
+ int i;
+ //
+ i=(Standard_Integer)aKC;
+ printf(" KindOfClosed: %s\n", pStr[i]);
+
+}
+//=======================================================================
+//function : DumpKindOfShape
+//purpose :
+//=======================================================================
+void DumpKindOfShape(const GEOMAlgo_KindOfShape aKS)
+{
+ const char *pStr[]={
+ "KS_UNKNOWN",
+ "KS_SPHERE",
+ "KS_CYLINDER",
+ "KS_BOX",
+ "KS_TORUS",
+ "KS_CONE",
+ "KS_ELLIPSE",
+ "KS_PLANE",
+ "KS_CIRCLE",
+ "KS_LINE",
+ "KS_DEGENERATED"
+ };
+ int i;
+ //
+ i=(Standard_Integer)aKS;
+ printf(" KindOfShape : %s\n", pStr[i]);
+}
+//=======================================================================
+//function : DumpKindOfName
+//purpose :
+//=======================================================================
+void DumpKindOfName(const GEOMAlgo_KindOfName aKS)
+{
+ const char *pStr[]={
+ "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"
+ };
+ int i;
+ //
+ i=(Standard_Integer)aKS;
+ printf(" KindOfName : %s\n", pStr[i]);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+\r
+#ifndef _GEOMAlgo_ShapeInfo_HeaderFile\r
+#define _GEOMAlgo_ShapeInfo_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <GEOMAlgo_KindOfShape.hxx>\r
+#include <GEOMAlgo_KindOfName.hxx>\r
+#include <GEOMAlgo_KindOfBounds.hxx>\r
+#include <GEOMAlgo_KindOfClosed.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <gp_Dir.hxx>\r
+#include <gp_Ax3.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <gp_Ax2.hxx>\r
+\r
+\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_ShapeInfo\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ShapeInfo \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_ShapeInfo();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_ShapeInfo();\r
+ \r
+ Standard_EXPORT\r
+ void Reset() ;\r
+ \r
+ Standard_EXPORT\r
+ void SetType(const TopAbs_ShapeEnum aType) ;\r
+ \r
+ Standard_EXPORT\r
+ TopAbs_ShapeEnum Type() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetNbSubShapes(const TopAbs_ShapeEnum aType,const Standard_Integer aNb) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer NbSubShapes(const TopAbs_ShapeEnum aType) const;\r
+ \r
+ Standard_EXPORT\r
+ void SetKindOfShape(const GEOMAlgo_KindOfShape aT) ;\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_KindOfShape KindOfShape() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetKindOfName(const GEOMAlgo_KindOfName aT) ;\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_KindOfName KindOfName() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetKindOfBounds(const GEOMAlgo_KindOfBounds aT) ;\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_KindOfBounds KindOfBounds() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetKindOfClosed(const GEOMAlgo_KindOfClosed aT) ;\r
+ \r
+ Standard_EXPORT\r
+ GEOMAlgo_KindOfClosed KindOfClosed() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetLocation(const gp_Pnt& aP) ;\r
+ \r
+ Standard_EXPORT\r
+ const gp_Pnt& Location() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetDirection(const gp_Dir& aD) ;\r
+ \r
+ Standard_EXPORT\r
+ const gp_Dir& Direction() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetPosition(const gp_Ax2& aAx2) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetPosition(const gp_Ax3& aAx3) ;\r
+ \r
+ Standard_EXPORT\r
+ const gp_Ax3& Position() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetPnt1(const gp_Pnt& aP) ;\r
+ \r
+ Standard_EXPORT\r
+ const gp_Pnt& Pnt1() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetPnt2(const gp_Pnt& aP) ;\r
+ \r
+ Standard_EXPORT\r
+ const gp_Pnt& Pnt2() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetRadius1(const Standard_Real aR) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Real Radius1() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetRadius2(const Standard_Real aR) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Real Radius2() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetLength(const Standard_Real aL) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Real Length() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetWidth(const Standard_Real aW) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Real Width() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetHeight(const Standard_Real aH) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Real Height() const;\r
+ \r
+ Standard_EXPORT\r
+ void Dump() const;\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ void DumpVertex() const;\r
+ \r
+ Standard_EXPORT\r
+ void DumpEdge() const;\r
+ \r
+ Standard_EXPORT\r
+ void DumpWire() const;\r
+ \r
+ Standard_EXPORT\r
+ void DumpFace() const;\r
+ \r
+ Standard_EXPORT\r
+ void DumpShell() const;\r
+ \r
+ Standard_EXPORT\r
+ void DumpSolid() const;\r
+ \r
+ Standard_EXPORT\r
+ void DumpCompSolid() const;\r
+ \r
+ Standard_EXPORT\r
+ void DumpCompound() const;\r
+\r
+\r
+ TopAbs_ShapeEnum myType;\r
+ Standard_Integer myNbSubShapes[9];\r
+ GEOMAlgo_KindOfShape myKindOfShape;\r
+ GEOMAlgo_KindOfName myKindOfName;\r
+ GEOMAlgo_KindOfBounds myKindOfBounds;\r
+ GEOMAlgo_KindOfClosed myKindOfClosed;\r
+ gp_Pnt myLocation;\r
+ gp_Dir myDirection;\r
+ gp_Ax3 myPosition;\r
+ Standard_Real myRadius1;\r
+ Standard_Real myRadius2;\r
+ Standard_Real myLength;\r
+ Standard_Real myWidth;\r
+ Standard_Real myHeight;\r
+ gp_Pnt myPnt1;\r
+ gp_Pnt myPnt2;\r
+ Standard_Integer myNbTypes;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_ShapeInfoFiller.hxx>
+
+#include <Precision.hxx>
+
+#include <gp_Lin.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+
+#include <Geom_Curve.hxx>
+#include <GeomAdaptor_Curve.hxx>
+
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <BRep_Tool.hxx>
+#include <TopExp.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <gp_Circ.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Elips.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopExp.hxx>
+#include <Geom_Surface.hxx>
+#include <TopoDS_Face.hxx>
+#include <GeomAdaptor_Surface.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Sphere.hxx>
+#include <gp_Ax3.hxx>
+#include <BRepTools.hxx>
+#include <gp_Cylinder.hxx>
+#include <gp_Cone.hxx>
+#include <gp_Torus.hxx>
+#include <TopoDS_Solid.hxx>
+
+
+
+
+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<aNb; ++i) {
+ if (aTypes[i]==aST) {
+ continue;
+ }
+ aM.Clear();
+ TopExp::MapShapes(aS, aTypes[i], aM);
+ aNbS=aM.Extent();
+ aInfo.SetNbSubShapes(aTypes[i], aNbS);
+ }
+}
+//=======================================================================
+//function :NbShells
+//purpose :
+//=======================================================================
+Standard_Integer NbShells(const TopoDS_Solid& aSd)
+{
+ Standard_Integer iCnt;
+ TopoDS_Iterator aIt;
+ //
+ iCnt=0;
+ //
+ aIt.Initialize(aSd);
+ for (; aIt.More(); aIt.Next()){
+ //const TopoDS_Shape& aSh=aIt.Value();
+ ++iCnt;
+ }
+ return iCnt;
+}
+//=======================================================================
+//function : NbWires
+//purpose :
+//=======================================================================
+Standard_Integer NbWires(const TopoDS_Face& aF)
+{
+ Standard_Integer iCnt;
+ TopoDS_Iterator aIt;
+ //
+ iCnt=0;
+ //
+ aIt.Initialize(aF);
+ for (; aIt.More(); aIt.Next()){
+ //const TopoDS_Shape& aW=aIt.Value();
+ ++iCnt;
+ }
+ return iCnt;
+}
+//=======================================================================
+//function : IsAllowedType
+//purpose :
+//=======================================================================
+Standard_Boolean IsAllowedType(const GeomAbs_CurveType aCT)
+{
+ Standard_Boolean bRet;
+ Standard_Integer i, aNb;
+ GeomAbs_CurveType aTypes[]={
+ GeomAbs_Line, GeomAbs_Circle, GeomAbs_Ellipse
+ };
+ //
+ bRet=Standard_False;
+ aNb=sizeof(aTypes)/sizeof(aTypes[0]);
+ for (i=0; i<aNb && !bRet; ++i) {
+ bRet=(aCT==aTypes[i]);
+ }
+ //
+ return bRet;
+}
+//=======================================================================
+//function : IsAllowedType
+//purpose :
+//=======================================================================
+Standard_Boolean IsAllowedType(const GeomAbs_SurfaceType aST)
+{
+ Standard_Boolean bRet;
+ Standard_Integer i, aNb;
+ GeomAbs_SurfaceType aTypes[]={
+ GeomAbs_Plane, GeomAbs_Cylinder,
+ GeomAbs_Cone, GeomAbs_Sphere,
+ GeomAbs_Torus
+ };
+ //
+ bRet=Standard_False;
+ aNb=sizeof(aTypes)/sizeof(aTypes[0]);
+ for (i=0; i<aNb && !bRet; ++i) {
+ bRet=(aST==aTypes[i]);
+ }
+ //
+ return bRet;
+}
+//
+// myErrorStatus
+//
+// 0 - Ok
+// 1 - The object is just initialized
+//
+// 10 - Null shape
+// 11 - circle/ellipse edge without vertices
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+#ifndef _GEOMAlgo_ShapeInfoFiller_HeaderFile\r
+#define _GEOMAlgo_ShapeInfoFiller_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <GEOMAlgo_ShapeInfo.hxx>\r
+#include <GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <GEOMAlgo_Algo.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <gp_Pln.hxx>\r
+#include <gp_Sphere.hxx>\r
+#include <gp_Cylinder.hxx>\r
+#include <gp_Cone.hxx>\r
+#include <gp_Torus.hxx>\r
+#include <TopoDS_Solid.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_ShapeInfoFiller\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ShapeInfoFiller : public GEOMAlgo_Algo \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_ShapeInfoFiller();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_ShapeInfoFiller();\r
+ \r
+ Standard_EXPORT\r
+ void SetShape(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetTolerance(const Standard_Real aT) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Real Tolerance() const;\r
+ \r
+ Standard_EXPORT\r
+ const GEOMAlgo_ShapeInfo& Info() const;\r
+ \r
+ Standard_EXPORT\r
+ const GEOMAlgo_ShapeInfo& Info(const TopoDS_Shape& aS) const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ virtual void CheckData() ;\r
+ \r
+ Standard_EXPORT\r
+ void FillNbSubShapes(const TopoDS_Shape& aS,GEOMAlgo_ShapeInfo& aInfo) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillSubShapes(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillShape(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillVertex(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillEdge(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillFace(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillSolid(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillContainer(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillDetails(const TopoDS_Face& aF,const gp_Pln& aPln) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillDetails(const TopoDS_Face& aF,const gp_Sphere& aSph) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillDetails(const TopoDS_Face& aF,const gp_Cylinder& aCyl) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillDetails(const TopoDS_Face& aF,const gp_Cone& aCone) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillDetails(const TopoDS_Face& aF,const gp_Torus& aTorus) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillDetails(const TopoDS_Solid& aS) ;\r
+\r
+\r
+ TopoDS_Shape myShape;\r
+ GEOMAlgo_ShapeInfo myEmptyInfo;\r
+ GEOMAlgo_IndexedDataMapOfShapeShapeInfo myMapInfo;\r
+ Standard_Real myTolerance;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_ShapeInfoFiller.hxx>
+
+#include <Precision.hxx>
+
+#include <gp_Lin.hxx>
+#include <gp_XYZ.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Ax3.hxx>
+
+#include <ElCLib.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <BRep_Tool.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <BRepTools_WireExplorer.hxx>
+
+#include <GEOMAlgo_ShapeInfo.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+//=======================================================================
+//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; i<aNbFi; ++i) {
+ const TopoDS_Shape& aFi=aMFi(i+1);
+ const GEOMAlgo_ShapeInfo& aIFi=myMapInfo.FindFromKey(aFi);
+ aPi=aIFi.Location();
+ aDist[i]=aPc.Distance(aPi);
+ if (aDist[i]>aDistMax) {
+ aDistMax=aDist[i];
+ iMax=i;
+ }
+ if (aDist[i]<aDistMin) {
+ aDistMin=aDist[i];
+ iMin=i;
+ }
+ gp_Vec aVi(aPc, aPi);
+ gp_Dir aDi(aVi);
+ aDir[i]=aDi;
+ }
+ //
+ if (iMax==iMin) {
+ iMax=0;
+ iMin=1;
+ }
+ iMid=3-iMax-iMin;
+ //
+ aLength=2.*aDist[iMax];
+ aWidth=2.*aDist[iMid];
+ aHeight=2.*aDist[iMin];
+ //
+ gp_Ax2 aAx2(aPc, aDir[iMin], aDir[iMax]);
+ gp_Ax3 aAx3(aAx2);
+ //
+ aInfo.SetKindOfName(GEOMAlgo_KN_BOX);
+ aInfo.SetLocation(aPc);
+ aInfo.SetLength(aLength);
+ aInfo.SetWidth(aWidth);
+ aInfo.SetHeight(aHeight);
+ aInfo.SetPosition(aAx3);
+}
+//=======================================================================
+//function : FillDetails
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
+ const gp_Pln& aPln)
+{
+ Standard_Integer aNbV, aNbE, i, j;
+ Standard_Real aDot, aD0, aD1, aLength, aWidth;
+ gp_Dir aDx[4], aDX;
+ gp_Pnt aPx[4], aP, aPc;
+ gp_XYZ aXYZc;
+ TopExp_Explorer aExp;
+ TopoDS_Shape aE;
+ TopoDS_Wire aW;
+ TopoDS_Edge aEx;
+ TopoDS_Iterator aIt;
+ TopTools_IndexedMapOfShape aMV;
+ BRepTools_WireExplorer aWExp;
+ GEOMAlgo_KindOfName aKN, aKNE;
+ GEOMAlgo_KindOfShape aKS;
+ //
+ GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
+ aKN=GEOMAlgo_KN_UNKNOWN;
+ aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
+ //
+ aKS=aInfo.KindOfShape();
+ if (aKS!=GEOMAlgo_KS_PLANE) {
+ return;
+ }
+ //
+ if (aInfo.KindOfBounds()==GEOMAlgo_KB_INFINITE) {
+ aInfo.SetKindOfName(GEOMAlgo_KN_PLANE);
+ return;
+ }
+ //
+ aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
+ aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
+ //
+ // 1. may be it is circle/ellipse
+ if (aNbV==1 && aNbE==1) {
+ aExp.Init(aF, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ aE=aExp.Current();
+ break;
+ }
+ //
+ const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
+ aKNE=aInfoE.KindOfName();
+ if (aKNE==GEOMAlgo_KN_CIRCLE) {
+ aKN=GEOMAlgo_KN_DISKCIRCLE;
+ aInfo.SetKindOfName(aKN);
+ aInfo.SetRadius1(aInfoE.Radius1());
+ aInfo.SetLocation(aInfoE.Location());
+ aInfo.SetPosition(aInfoE.Position());
+ }
+ if (aKNE==GEOMAlgo_KN_ELLIPSE) {
+ aKN=GEOMAlgo_KN_DISKELLIPSE;
+ aInfo.SetKindOfName(aKN);
+ aInfo.SetRadius1(aInfoE.Radius1());
+ aInfo.SetRadius2(aInfoE.Radius2());
+ aInfo.SetLocation(aInfoE.Location());
+ aInfo.SetPosition(aInfoE.Position());
+ }
+ }
+ //
+ // 2. may be it is rectangle
+ else {
+ aExp.Init(aF, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ aE=aExp.Current();
+ const GEOMAlgo_ShapeInfo& aInfoE=myMapInfo.FindFromKey(aE);
+ aKNE=aInfoE.KindOfName();
+ if (aKNE!=GEOMAlgo_KN_SEGMENT) {
+ return;
+ }
+ }
+ //
+ aInfo.SetKindOfName(GEOMAlgo_KN_POLYGON);
+ //
+ if (aNbV==3 && aNbE==3) {
+ aInfo.SetKindOfName(GEOMAlgo_KN_TRIANGLE);
+ //
+ 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;
+ aPx[i-1]=aP;
+ }
+ aXYZc.Divide(3.);
+ //
+ aPc.SetXYZ(aXYZc);
+ gp_Vec aVX(aPc, aPx[0]);
+ aVX.Normalize();
+ aDX.SetXYZ(aVX.XYZ());
+ const gp_Dir& aDZ=aPln.Axis().Direction();
+ //
+ gp_Ax2 aAx2(aPc, aDZ, aDX);
+ gp_Ax3 aAx3(aAx2);
+ //
+ aInfo.SetLocation(aPc);
+ aInfo.SetPosition(aAx3);
+ //
+ return;
+ }
+ //
+ if (!(aNbV==4 && aNbE==4)) {
+ return;
+ }
+ //
+ // aNbV==4 && aNbE==4 and all edges are segments
+ aIt.Initialize(aF);
+ for (; aIt.More(); aIt.Next()){
+ aW=TopoDS::Wire(aIt.Value());
+ break;
+ }
+ //
+ aWExp.Init(aW, aF);
+ for (i=0; aWExp.More(); aWExp.Next(), ++i) {
+ aEx=aWExp.Current();
+ const GEOMAlgo_ShapeInfo& aInfoEx=myMapInfo.FindFromKey(aEx);
+ aDx[i]=aInfoEx.Direction();
+ aPx[i]=aInfoEx.Location();
+ }
+ //
+ for (i=0; i<4; ++i) {
+ j=(i==3) ? 0 : i+1;
+ aDot=aDx[i]*aDx[j];
+ if (fabs (aDot) > 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 (aD0<aD1) {
+ aLength=aD1;
+ aWidth =aD0;
+ aDX=aL0.Direction();
+ }
+ //
+ aLength=2.*aLength;
+ aWidth =2.*aWidth;
+ //
+ aInfo.SetLocation(aPc);
+ aInfo.SetLength(aLength);
+ aInfo.SetWidth(aWidth);
+ //
+ const gp_Dir& aDZ=aPln.Axis().Direction();
+ gp_Ax2 aAx2(aPc, aDZ, aDX);
+ gp_Ax3 aAx3(aAx2);
+ aInfo.SetPosition(aAx3);
+ }
+
+ return;
+}
+//=======================================================================
+//function : FillDetails
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
+ const gp_Sphere& )
+{
+ Standard_Integer aNbV, aNbE, aNbSE, aNbDE;
+ TopoDS_Edge aE;
+ TopExp_Explorer aExp;
+ TopTools_MapOfShape aM;
+ GEOMAlgo_KindOfShape aKS, aKSE;
+ //
+ GEOMAlgo_ShapeInfo& aInfo=myMapInfo.ChangeFromKey(aF);
+ aInfo.SetKindOfName(GEOMAlgo_KN_UNKNOWN);
+ //
+ aKS=aInfo.KindOfShape();
+ if (aKS!=GEOMAlgo_KS_SPHERE) {
+ return;
+ }
+ //
+ aNbV=aInfo.NbSubShapes(TopAbs_VERTEX);
+ aNbE=aInfo.NbSubShapes(TopAbs_EDGE);
+ if (!(aNbV==2 && aNbE==3)) {
+ return;
+ }
+ //
+ aNbSE=0;
+ aNbDE=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);
+ aKSE=aInfoE.KindOfShape();
+ //
+ if (BRep_Tool::IsClosed(aE, aF)) {
+ ++aNbSE;
+ }
+ else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
+ ++aNbDE;
+ }
+ }
+ }
+ //
+ if (!(aNbSE==1 && aNbDE==2)) {
+ return;
+ }
+ aInfo.SetKindOfName(GEOMAlgo_KN_SPHERE);
+}
+//=======================================================================
+//function : FillDetails
+//purpose :
+//=======================================================================
+ void GEOMAlgo_ShapeInfoFiller::FillDetails(const TopoDS_Face& aF,
+ const gp_Cone& )//aCone)
+{
+ Standard_Integer aNbV, aNbE, aNbCE, aNbSE, aNbDE, i;
+ Standard_Real aR[3], aHeight;
+ gp_Pnt aPC[3], aPD, aPc, aPX[3];
+ TopoDS_Vertex aVD;
+ TopoDS_Edge aE;
+ TopoDS_Iterator aIt;
+ TopExp_Explorer aExp;
+ TopTools_MapOfShape aM;
+ GEOMAlgo_KindOfShape aKS, aKSE;
+ 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_CONE) {
+ 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;
+ aNbDE=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();
+ aKSE=aInfoE.KindOfShape();
+ if (aKNE==GEOMAlgo_KN_CIRCLE && aKCE==GEOMAlgo_KC_CLOSED) {
+ aPC[i]=aInfoE.Location();
+ aR[i]=aInfoE.Radius1();
+ //
+ aIt.Initialize(aE);
+ for (; aIt.More(); aIt.Next()) {
+ aVD=TopoDS::Vertex(aIt.Value());
+ break;
+ }
+ aPX[i]=BRep_Tool::Pnt(aVD);
+ //
+ ++i;
+ ++aNbCE;
+ }
+ else if (aKNE==GEOMAlgo_KN_SEGMENT) {
+ if (BRep_Tool::IsClosed(aE, aF)) {
+ ++aNbSE;
+ }
+ }
+ else if (aKSE==GEOMAlgo_KS_DEGENERATED) {
+ aIt.Initialize(aE);
+ for (; aIt.More(); aIt.Next()) {
+ aVD=TopoDS::Vertex(aIt.Value());
+ break;
+ }
+ //
+ aPD=BRep_Tool::Pnt(aVD);
+ //
+ ++aNbDE;
+ }
+ }
+ }
+ //
+ if (!((aNbCE==2 || (aNbCE==1 && aNbDE==1)) && aNbSE==1)) {
+ return;
+ }
+ //
+ if (aNbDE==1) {
+ aPC[1]=aPD;
+ aR[1]=0.;
+ }
+ //
+ aHeight=aPC[0].Distance(aPC[1]);
+ //
+ Standard_Real aRmin, aRmax;
+ gp_Ax2 aAx2new;
+ //
+ if (aR[0]>aR[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);
+}
--- /dev/null
+// 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 <GEOMAlgo_ShapeSet.hxx>
+
+#include <TopExp_Explorer.hxx>
+
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
+
+//=======================================================================
+//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
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_ShapeSet.hxx\r
+// Created: \r
+// Author: Peter KURNEV \r
+//\r
+#ifndef _GEOMAlgo_ShapeSet_HeaderFile\r
+#define _GEOMAlgo_ShapeSet_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopTools_MapOfOrientedShape.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+\r
+//! Implementation some formal <br>\r
+//! opereations with Set of shapes <br>\r
+//=======================================================================\r
+//class : GEOMAlgo_ShapeSet\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ShapeSet \r
+{\r
+ public:\r
+ //! Empty constructor <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_ShapeSet();\r
+ \r
+ //! Adds shapes from the list theLS to the Set <br>\r
+ Standard_EXPORT\r
+ void Add(const TopTools_ListOfShape& theLS) ;\r
+ \r
+ //! Adds shape theShape to the Set <br>\r
+ Standard_EXPORT\r
+ void Add(const TopoDS_Shape& theShape) ;\r
+ \r
+ //! Adds sub-shapes of shape theShape, <br>\r
+ //! that have type theType to the Set <br>\r
+ Standard_EXPORT\r
+ void Add(const TopoDS_Shape& theShape,const TopAbs_ShapeEnum theType) ;\r
+ \r
+ //! Removes shapes of theSet from the Set <br>\r
+ Standard_EXPORT\r
+ void Subtract(const GEOMAlgo_ShapeSet& theSet) ;\r
+ \r
+ //! Clears internal fields <br>\r
+ Standard_EXPORT void Clear() ;\r
+ \r
+ //! Returns True if the Set contains <br>\r
+ //! all shapes of theSet <br>\r
+ Standard_EXPORT\r
+ Standard_Boolean Contains(const GEOMAlgo_ShapeSet& theSet) const;\r
+ \r
+ //! Returns the Set <br>\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& GetSet() const;\r
+ \r
+ //! Returns True if the Set==theSet <br>\r
+ Standard_EXPORT\r
+ Standard_Boolean IsEqual(const GEOMAlgo_ShapeSet& theOther) const;\r
+ \r
+ Standard_Boolean operator ==(const GEOMAlgo_ShapeSet& theOther) const {\r
+ return IsEqual(theOther);\r
+ }\r
+\r
+ protected:\r
+ TopTools_MapOfOrientedShape myMap;\r
+ TopTools_ListOfShape myList;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_ShapeSolid.hxx>
+
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_ShapeSolid.hxx\r
+// Created: Thu Jan 13 12:54:48 2005\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_ShapeSolid_HeaderFile\r
+#define _GEOMAlgo_ShapeSolid_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <BOPTools_PDSFiller.hxx>\r
+#include <GEOMAlgo_Algo.hxx>\r
+#include <TopAbs_State.hxx>\r
+#include <BOPTools_DSFiller.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_ShapeSolid\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ShapeSolid : public GEOMAlgo_Algo \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ void SetFiller(const BOPTools_DSFiller& aDSF) ;\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_ShapeSolid();\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Shapes(const TopAbs_State aState) const;\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ GEOMAlgo_ShapeSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual void BuildResult() = 0;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Prepare() = 0;\r
+\r
+\r
+ TopTools_ListOfShape myLSIN;\r
+ TopTools_ListOfShape myLSOUT;\r
+ TopTools_ListOfShape myLSON;\r
+ Standard_Integer myRank;\r
+ BOPTools_PDSFiller myDSFiller;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_ShellSolid.hxx>
+
+#include <Standard_Failure.hxx>
+
+#include <gp_Pnt2d.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Solid.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRepClass3d_SolidClassifier.hxx>
+
+#include <IntTools_Context.hxx>
+#include <BOPTColStd_Dump.hxx>
+#include <BooleanOperations_ShapesDataStructure.hxx>
+
+#include <BOPTools_PaveFiller.hxx>
+#include <BOPTools_SolidStateFiller.hxx>
+#include <BOPTools_PCurveMaker.hxx>
+#include <BOPTools_DEProcessor.hxx>
+#include <BOPTools_InterferencePool.hxx>
+#include <BOPTools_CArray1OfSSInterference.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_SSInterference.hxx>
+#include <BOPTools_SequenceOfCurves.hxx>
+#include <BOPTools_Curve.hxx>
+#include <BOPTools_PaveFiller.hxx>
+#include <BOPTools_SplitShapesPool.hxx>
+#include <BOPTools_Tools3D.hxx>
+#include <BOPTools_DSFiller.hxx>
+
+#include <BOP_WireEdgeSet.hxx>
+#include <BOP_SDFWESFiller.hxx>
+#include <BOP_FaceBuilder.hxx>
+
+//=======================================================================
+//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++)
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_ShellSolid.hxx\r
+// Created: Wed Jan 12 12:49:45 2005\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_ShellSolid_HeaderFile\r
+#define _GEOMAlgo_ShellSolid_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <GEOMAlgo_ShapeSolid.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_ShellSolid\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_ShellSolid : public GEOMAlgo_ShapeSolid \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_ShellSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_ShellSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ virtual void Prepare() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void BuildResult() ;\r
+ \r
+ Standard_EXPORT\r
+ void DetectSDFaces() ;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_SolidSolid.hxx>
+
+#include <Standard_Failure.hxx>
+
+#include <TopAbs_State.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopExp.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <BooleanOperations_ShapesDataStructure.hxx>
+#include <BOPTools_DSFiller.hxx>
+
+#include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
+
+//=======================================================================
+//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<aNbF; ++j) {
+ const TopoDS_Shape& aF=aMF(j);
+ //
+ if (!aMFS.Contains(aF)) {// the face is intesected
+ ++aNbFINTR;
+ break;
+ }
+ //
+ aState=aMFS.FindFromKey(aF);
+ switch (aState) {
+ case TopAbs_IN:
+ ++aNbFIN;
+ break;
+ case TopAbs_OUT:
+ ++aNbFOUT;
+ break;
+ case TopAbs_ON:
+ ++aNbFON;
+ break;
+ default:
+ break;
+ }
+ if (aNbFIN && aNbFOUT) {
+ ++aNbFINTR;
+ break;
+ }
+ }
+ //
+ if (!aNbFINTR) {
+ if (aNbFON==aNbF) {
+ myLSON.Append(aSolid);
+ }
+ else if (aNbFIN) {
+ myLSIN.Append(aSolid);
+ }
+ else if (aNbFOUT) {
+ myLSOUT.Append(aSolid);
+ }
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_SolidSolid.hxx\r
+// Created: Wed Jan 26 12:06:26 2005\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_SolidSolid_HeaderFile\r
+#define _GEOMAlgo_SolidSolid_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <GEOMAlgo_ShellSolid.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_SolidSolid\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_SolidSolid : public GEOMAlgo_ShellSolid \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_SolidSolid();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_SolidSolid();\r
+ \r
+ Standard_EXPORT \r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShape2(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape2() const;\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ virtual void BuildResult() ;\r
+\r
+\r
+ TopoDS_Shape myS2;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_Splitter.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopExp.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepLib.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <BOP_CorrectTolerances.hxx>
+
+
+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
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+//\r
+// File: GEOMAlgo_Splitter.hxx\r
+//\r
+// Author: Peter KURNEV\r
+//\r
+#ifndef _GEOMAlgo_Splitter_HeaderFile\r
+#define _GEOMAlgo_Splitter_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopTools_MapOfShape.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <GEOMAlgo_Builder.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+\r
+//! Implementation of Gluing Operation Algorithm (GA) <br>\r
+//=======================================================================\r
+//function : GEOMAlgo_Splitter\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_Splitter : public GEOMAlgo_Builder \r
+{\r
+ public:\r
+\r
+ //! Empty constructor <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_Splitter();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_Splitter();\r
+ \r
+ //! Clears internal fields and arguments <br>\r
+ Standard_EXPORT\r
+ virtual void Clear() ;\r
+ \r
+ //! Adds Tool argument theShape of the operation <br>\r
+ Standard_EXPORT\r
+ virtual void AddTool(const TopoDS_Shape& theShape) ;\r
+ \r
+ //! Returns the arguments of the operation <br>\r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Tools() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetLimit(const TopAbs_ShapeEnum aLimit) ;\r
+ \r
+ Standard_EXPORT\r
+ TopAbs_ShapeEnum Limit() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetLimitMode(const Standard_Integer aLimitMode) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer LimitMode() const;\r
+ //! Adds Tool arguments of the operation as <br>\r
+ //! shapes of upper level of container shape theShape <br>\r
+ //! ===================================================== <br>\r
+ Standard_EXPORT\r
+ void AddToolCompound(const TopoDS_Shape& theShape) ;\r
+\r
+ protected:\r
+ //! Build the resulting shapes of type theType <br>\r
+ Standard_EXPORT\r
+ virtual void BuildResult(const TopAbs_ShapeEnum theType) ;\r
+ //! Provides post-tratment actions <br>\r
+ Standard_EXPORT\r
+ virtual void PostTreat() ;\r
+\r
+\r
+ TopTools_ListOfShape myTools;\r
+ TopTools_MapOfShape myMapTools;\r
+ TopAbs_ShapeEnum myLimit;\r
+ Standard_Integer myLimitMode;\r
+};\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+\r
+#ifndef _GEOMAlgo_State_HeaderFile\r
+#define _GEOMAlgo_State_HeaderFile\r
+enum GEOMAlgo_State {\r
+ GEOMAlgo_ST_UNKNOWN,\r
+ GEOMAlgo_ST_IN,\r
+ GEOMAlgo_ST_OUT,\r
+ GEOMAlgo_ST_ON,\r
+ GEOMAlgo_ST_ONIN,\r
+ GEOMAlgo_ST_ONOUT,\r
+ GEOMAlgo_ST_INOUT\r
+};\r
+\r
+#ifndef _Standard_PrimitiveTypes_HeaderFile\r
+#include <Standard_PrimitiveTypes.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_StateCollector.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_StateCollector.hxx\r
+// Created: Thu Mar 10 09:42:11 2005\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_StateCollector_HeaderFile\r
+#define _GEOMAlgo_StateCollector_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopAbs_State.hxx>\r
+\r
+//=======================================================================\r
+// class : GEOMAlgo_StateCollector\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_StateCollector \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_StateCollector();\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean AppendState(const TopAbs_State aSt) ;\r
+ \r
+ Standard_EXPORT\r
+ TopAbs_State State() const;\r
+\r
+ protected:\r
+ Standard_Integer myCounter[3];\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_SurfaceTools.hxx>
+
+#include <math.h>
+
+#include <gp_Pln.hxx>
+#include <gp_Cylinder.hxx>
+#include <gp_Sphere.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Ax3.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Ax1.hxx>
+#include <gp_Vec.hxx>
+
+#include <GeomAbs_SurfaceType.hxx>
+#include <GeomAdaptor_Surface.hxx>
+
+
+//=======================================================================
+//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<aR-aTol) {
+ aState=TopAbs_IN;
+ }
+ }
+ //
+ return iErr;
+}
+//=======================================================================
+//function : GetState
+//purpose :
+//=======================================================================
+ Standard_Integer GEOMAlgo_SurfaceTools::GetState(const gp_Pnt& aP,
+ const Handle(Geom_Surface)& aSurf,
+ const Standard_Real aTol,
+ TopAbs_State& aState)
+{
+ Standard_Integer iErr;
+ GeomAdaptor_Surface aGAS;
+ //
+ aState=TopAbs_UNKNOWN;
+ aGAS.Load(aSurf);
+ //
+ iErr=GEOMAlgo_SurfaceTools::GetState(aP, aGAS, aTol, aState);
+ //
+ return iErr;
+}
+//=======================================================================
+//function : ReverseState
+//purpose :
+//=======================================================================
+ TopAbs_State GEOMAlgo_SurfaceTools::ReverseState(const TopAbs_State aState)
+{
+ TopAbs_State aRSt=aState;
+ //
+ switch (aState) {
+ case TopAbs_IN:
+ aRSt=TopAbs_OUT;
+ break;
+ case TopAbs_OUT:
+ aRSt=TopAbs_IN;
+ break;
+ default:
+ break;
+ }
+ //
+ return aRSt;
+}
+//=======================================================================
+//function : Distance
+//purpose :
+//=======================================================================
+Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
+ const gp_Sphere& aSph)
+{
+ Standard_Real aD;
+ //
+ const gp_Pnt& aLoc=aSph.Location();
+ aD=aLoc.Distance(aP);
+ //
+ return aD;
+}
+//=======================================================================
+//function : Distance
+//purpose :
+//=======================================================================
+Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
+ const gp_Cylinder& aCyl)
+{
+ Standard_Real aD;
+ //
+ const gp_Ax1& aAxis=aCyl.Axis();
+ gp_Lin aLin(aAxis);
+ aD=aLin.Distance(aP);
+ //
+ return aD;
+}
+//=======================================================================
+//function : Distance
+//purpose :
+//=======================================================================
+Standard_Real GEOMAlgo_SurfaceTools::Distance(const gp_Pnt& aP,
+ const gp_Pln& aPL)
+{
+ Standard_Real aD;
+ //
+ const gp_Ax3& aPos=aPL.Position();
+ const gp_Pnt& aLoc=aPos.Location ();
+ const gp_Dir& aDir=aPos.Direction();
+ //
+ aD= (aDir.X() * (aP.X() - aLoc.X()) +
+ aDir.Y() * (aP.Y() - aLoc.Y()) +
+ aDir.Z() * (aP.Z() - aLoc.Z()));
+ return aD;
+}
+//=======================================================================
+//function : IsCoaxial
+//purpose :
+//=======================================================================
+Standard_Boolean GEOMAlgo_SurfaceTools::IsCoaxial(const gp_Pnt& aP1,
+ const gp_Pnt& aP2,
+ const gp_Cylinder& aCyl,
+ const Standard_Real aTol)
+{
+ Standard_Boolean bRet=Standard_False;
+ Standard_Real aSM;
+ //
+ gp_Vec aV12(aP1, aP2);
+ gp_Dir aD12(aV12);
+ //
+ const gp_Ax1& aAxis=aCyl.Axis();
+ const gp_Dir& aDAxis=aAxis.Direction();
+ //
+ aSM=fabs(aD12*aDAxis);
+ if (fabs(1.-aSM) > 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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_SurfaceTools.hxx\r
+// Created: Thu Jan 27 11:05:16 2005\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_SurfaceTools_HeaderFile\r
+#define _GEOMAlgo_SurfaceTools_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Handle_Geom_Surface.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <TopAbs_State.hxx>\r
+#include <GEOMAlgo_State.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Geom_Surface.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <gp_Cylinder.hxx>\r
+#include <GeomAdaptor_Surface.hxx>\r
+#include <gp_Pln.hxx>\r
+#include <gp_Sphere.hxx>\r
+\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_SurfaceTools\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_SurfaceTools \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsAnalytic(const Handle(Geom_Surface)& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean IsCoaxial(const gp_Pnt& aP1,\r
+ const gp_Pnt& aP2,\r
+ const gp_Cylinder& aCyl,\r
+ const Standard_Real aTol) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean IsConformState(const TopAbs_State aST1,\r
+ const GEOMAlgo_State aST2) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Integer GetState(const gp_Pnt& aP,\r
+ const GeomAdaptor_Surface& aS,\r
+ const Standard_Real aTol,TopAbs_State& aSt) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Integer GetState(const gp_Pnt& aP,\r
+ const Handle(Geom_Surface)& aS,\r
+ const Standard_Real aTol,\r
+ TopAbs_State& aSt) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Real Distance(const gp_Pnt& aP,\r
+ const gp_Pln& aPln) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Real Distance(const gp_Pnt& aP,\r
+ const gp_Cylinder& aCyl) ;\r
+ \r
+ Standard_EXPORT \r
+ static Standard_Real Distance(const gp_Pnt& aP,\r
+ const gp_Sphere& aSph) ;\r
+ \r
+ Standard_EXPORT\r
+ static TopAbs_State ReverseState(const TopAbs_State aSt) ;\r
+\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_Tools.hxx>
+
+#include <gp.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec2d.hxx>
+#include <gp_Dir2d.hxx>
+
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+
+#include <GeomAdaptor_Surface.hxx>
+
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+
+#include <BOPTools_Tools2D.hxx>
+#include <IntTools_Context.hxx>
+
+#include <GEOMAlgo_PassKeyShape.hxx>
+#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
+
+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(aD2<aTol2) {
+ aLESD.Append(aE2);
+ }
+ }
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : ProjectPointOnShape
+//purpose :
+//=======================================================================
+Standard_Boolean GEOMAlgo_Tools::ProjectPointOnShape(const gp_Pnt& aP1,
+ const TopoDS_Shape& aS,
+ gp_Pnt& aP2,
+ const Handle(IntTools_Context)& aCtx)
+{
+ Standard_Boolean bIsDone = Standard_False;
+ Standard_Real aT2;
+ TopAbs_ShapeEnum aType;
+ //
+ aType = aS.ShapeType();
+ switch (aType)
+ {
+ case TopAbs_EDGE:
+ {
+ const TopoDS_Edge& aE2 = TopoDS::Edge(aS);
+ //
+ if (BRep_Tool::Degenerated(aE2)) { // jfa
+ return Standard_True;
+ }
+ else {
+ Standard_Real f, l;
+ Handle(Geom_Curve) aC3D = BRep_Tool::Curve (aE2, f, l);
+ if (aC3D.IsNull()) {
+ return Standard_True;
+ }
+ bIsDone = aCtx->ProjectPointOnEdge(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)<aTol) {
+ aV2DT.Reverse();
+ }
+ }
+ else { // U Closed
+ if (fabs(aU-aUS2)<aTol) {
+ aV2DT.Reverse();
+ }
+ }
+ //
+ aC2DTnew->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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: GEOMAlgo_Tools.hxx\r
+// Created: Mon Dec 6 11:35:29 2004\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _GEOMAlgo_Tools_HeaderFile\r
+#define _GEOMAlgo_Tools_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <Handle_IntTools_Context.hxx>\r
+#include <Handle_Geom_Surface.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>\r
+#include <IntTools_Context.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <TopoDS_Edge.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <Geom_Surface.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_Tools\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_Tools \r
+ {\r
+public:\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsCompositeShape(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Integer RefineSDShapes(GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape& aMSD,\r
+ const Standard_Real aTol,\r
+ const Handle(IntTools_Context)& aCtx) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Integer FindSDShapes(const TopTools_ListOfShape& aLE,\r
+ const Standard_Real aTol,\r
+ TopTools_IndexedDataMapOfShapeListOfShape& aMEE,\r
+ const Handle(IntTools_Context)& aCtx) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Integer FindSDShapes(const TopoDS_Shape& aE1,\r
+ const TopTools_ListOfShape& aLE,\r
+ const Standard_Real aTol,\r
+ TopTools_ListOfShape& aLESD,\r
+ const Handle(IntTools_Context)& aCtx) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean ProjectPointOnShape(const gp_Pnt& aP1,\r
+ const TopoDS_Shape& aS,gp_Pnt& aP2,\r
+ const Handle(IntTools_Context)& aCtx) ;\r
+ \r
+ Standard_EXPORT\r
+ static void PointOnShape(const TopoDS_Shape& aS,\r
+ gp_Pnt& aP3D) ;\r
+ \r
+ Standard_EXPORT\r
+ static void PointOnEdge(const TopoDS_Edge& aE,\r
+ gp_Pnt& aP3D) ;\r
+ \r
+ Standard_EXPORT\r
+ static void PointOnEdge(const TopoDS_Edge& aE,\r
+ const Standard_Real aT,gp_Pnt& aP3D) ;\r
+ \r
+ Standard_EXPORT\r
+ static void PointOnFace(const TopoDS_Face& aF,\r
+ gp_Pnt& aP3D) ;\r
+ \r
+ Standard_EXPORT\r
+ static void PointOnFace(const TopoDS_Face& aF,\r
+ const Standard_Real aU,\r
+ const Standard_Real aV,\r
+ gp_Pnt& aP3D) ;\r
+ \r
+ Standard_EXPORT\r
+ static void RefinePCurveForEdgeOnFace(const TopoDS_Edge& aE,\r
+ const TopoDS_Face& aF,\r
+ const Standard_Real aU1,\r
+ const Standard_Real aU2) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean IsUPeriodic(const Handle(Geom_Surface)& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean CorrectWires(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Integer BuildPCurveForEdgeOnFace(const TopoDS_Edge& aE,\r
+ const TopoDS_Edge& aEold,\r
+ const TopoDS_Face& aF,\r
+ const Handle(IntTools_Context)& aCtx) ;\r
+ \r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_Tools3D.hxx>
+
+#include <Precision.hxx>
+
+#include <gp_Vec.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Pln.hxx>
+#include <gp_XYZ.hxx>
+#include <gp_Dir2d.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2d_Line.hxx>
+
+#include <Geom2dHatch_Intersector.hxx>
+#include <Geom2dHatch_Hatcher.hxx>
+#include <HatchGen_Domain.hxx>
+
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopAbs_State.hxx>
+
+#include <TopLoc_Location.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_CompSolid.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+//
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+
+#include <BRepClass3d_SolidClassifier.hxx>
+#include <BRepTools.hxx>
+
+#include <IntTools_Context.hxx>
+#include <IntTools_Tools.hxx>
+
+#include <BOPTools_Tools3D.hxx>
+#include <BOPTools_Tools2D.hxx>
+#include <BOPTools_Tools.hxx>
+
+#include <NMTTools_ListOfCoupleOfShape.hxx>
+#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
+#include <NMTTools_CoupleOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+//
+#include <GeomAdaptor_Surface.hxx>
+
+
+//
+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 (aA1x<aA12) {
+ bRet=!bRet; //TopAbs_IN;
+ }
+ //
+ return bRet;
+}
+//=======================================================================
+//function : GetFaceOff
+//purpose :
+//=======================================================================
+ void GEOMAlgo_Tools3D::GetFaceOff(const TopoDS_Edge& theE1,
+ const TopoDS_Face& theF1,
+ const NMTTools_ListOfCoupleOfShape& theLCSOff,
+ TopoDS_Face& theFOff)
+{
+ Standard_Real aT, aT1, aT2, aAngle, aTwoPI, aAngleMin;
+ gp_Pnt aPn1, aPn2;
+ gp_Vec aVTgt;
+ gp_Dir aDN1, aDN2;
+ NMTTools_ListIteratorOfListOfCoupleOfShape aIt;
+ //
+ aAngleMin=100.;
+ aTwoPI = M_PI+M_PI;
+ BRep_Tool::Range(theE1, aT1, aT2);
+ aT=BOPTools_Tools2D::IntermediatePoint(aT1, aT2);
+ // Ref
+ BOPTools_Tools2D::EdgeTangent(theE1, aT, aVTgt);
+ gp_Dir aDTtgt(aVTgt);
+ aDTtgt.Reverse();
+ // N1
+ BOPTools_Tools3D::GetApproxNormalToFaceOnEdge(theE1, theF1, aT, aPn1, aDN1);
+ //
+ aIt.Initialize(theLCSOff);
+ for (; aIt.More(); aIt.Next()) {
+ const NMTTools_CoupleOfShape& aCS=aIt.Value();
+ const TopoDS_Edge& aE2=TopoDS::Edge(aCS.Shape1());
+ const TopoDS_Face& aF2=TopoDS::Face(aCS.Shape2());
+ //
+ if (aF2==theF1) {
+ aAngle=M_PI;
+ }
+ else if (aF2.IsSame(theF1)) {
+ aAngle=aTwoPI;
+ }
+ else {
+ BOPTools_Tools3D::GetApproxNormalToFaceOnEdge (aE2, aF2, aT, aPn2, aDN2);
+ aDN2.Reverse();
+ // Angle
+ aAngle=AngleWithRef(aDN1, aDN2, aDTtgt);
+ if(aAngle<0.) {
+ aAngle=aTwoPI+aAngle;
+ }
+ }
+ //
+ if (aAngle<aAngleMin){
+ aAngleMin=aAngle;
+ theFOff=aF2;
+ }
+ }
+}
+//=======================================================================
+//function : GetEdgeOnFace
+//purpose :
+//=======================================================================
+ Standard_Boolean GEOMAlgo_Tools3D::GetEdgeOnFace(const TopoDS_Edge& theE1,
+ const TopoDS_Face& theF2,
+ TopoDS_Edge& theE2)
+{
+ Standard_Boolean bFound;
+ TopoDS_Iterator aItF, aItW;
+ //
+ bFound=Standard_False;
+ //
+ aItF.Initialize(theF2);
+ for (; aItF.More(); aItF.Next()) {
+ const TopoDS_Shape& aW=aItF.Value();
+ aItW.Initialize(aW);
+ for (; aItW.More(); aItW.Next()) {
+ const TopoDS_Shape& aE=aItW.Value();
+ if (aE.IsSame(theE1)) {
+ theE2=TopoDS::Edge(aE);
+ bFound=!bFound;
+ return bFound;
+ }
+ }
+ }
+ return bFound;
+}
+//=======================================================================
+//function : GetEdgeOff
+//purpose :
+//=======================================================================
+Standard_Boolean GEOMAlgo_Tools3D::GetEdgeOff (const TopoDS_Edge& theE1,
+ const TopoDS_Face& theF2,
+ TopoDS_Edge& theE2)
+
+{
+ Standard_Boolean bFound;
+ TopAbs_Orientation aOr1, aOr1C, aOr2;
+ TopExp_Explorer anExp;
+ //
+ bFound=Standard_False;
+ aOr1=theE1.Orientation();
+ aOr1C=TopAbs::Reverse(aOr1);
+ //
+ anExp.Init(theF2, TopAbs_EDGE);
+ for (; anExp.More(); anExp.Next()) {
+ const TopoDS_Edge& aEF2=TopoDS::Edge(anExp.Current());
+ if (aEF2.IsSame(theE1)) {
+ aOr2=aEF2.Orientation();
+ if (aOr2==aOr1C) {
+ theE2=aEF2;
+ bFound=!bFound;
+ return bFound;
+ }
+ }
+ }
+ return bFound;
+}
+//=======================================================================
+// function: ComputeState
+// purpose:
+//=======================================================================
+ TopAbs_State GEOMAlgo_Tools3D::ComputeState(const TopoDS_Face& theF,
+ const TopoDS_Solid& theRef,
+ const Standard_Real theTol,
+ const TopTools_IndexedMapOfShape& theBounds,
+ const Handle(IntTools_Context)& theCtx)
+{
+ TopAbs_State aState;
+ TopExp_Explorer aExp;
+ TopoDS_Edge aE1;
+ gp_Pnt2d aP2D;
+ gp_Pnt aP3D;
+ //
+ aState=TopAbs_UNKNOWN;
+ //
+ aExp.Init(theF, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ const TopoDS_Edge& aSE=TopoDS::Edge(aExp.Current());
+ if (BRep_Tool::Degenerated(aSE)) {
+ continue;
+ }
+ //
+ if (!theBounds.Contains(aSE)) {
+ const TopoDS_Edge& aE=TopoDS::Edge(aSE);
+ aState= GEOMAlgo_Tools3D::ComputeState(aE, theRef, theTol, theCtx);
+ return aState;
+ }
+ if (aE1.IsNull()) {
+ aE1=TopoDS::Edge(aSE);
+ }
+ }
+ // !!<- process edges that are all on theRef
+ if (!aE1.IsNull()) {
+ BOPTools_Tools3D::PointNearEdge(aE1, theF, aP2D, aP3D);
+ aState=GEOMAlgo_Tools3D::ComputeState(aP3D, theRef, theTol, theCtx);
+ }
+ //
+ return aState;
+}
+//=======================================================================
+// function: ComputeStateByOnePoint
+// purpose:
+//=======================================================================
+ TopAbs_State GEOMAlgo_Tools3D::ComputeStateByOnePoint(const TopoDS_Shape& theS,
+ const TopoDS_Solid& theRef,
+ const Standard_Real theTol,
+ const Handle(IntTools_Context)& theCtx)
+{
+ TopAbs_State aState;
+ TopAbs_ShapeEnum aType;
+ //
+ aState=TopAbs_UNKNOWN;
+ aType=theS.ShapeType();
+ if (aType==TopAbs_VERTEX) {
+ const TopoDS_Vertex& aV=TopoDS::Vertex(theS);
+ aState=GEOMAlgo_Tools3D::ComputeState(aV, theRef, theTol, theCtx);
+ }
+ else if (aType==TopAbs_EDGE) {
+ const TopoDS_Edge& aE=TopoDS::Edge(theS);
+ aState=GEOMAlgo_Tools3D::ComputeState(aE, theRef, theTol, theCtx);
+ }
+ return aState;
+}
+//=======================================================================
+// function: ComputeState
+// purpose:
+//=======================================================================
+ TopAbs_State GEOMAlgo_Tools3D::ComputeState(const TopoDS_Vertex& theV,
+ const TopoDS_Solid& theRef,
+ const Standard_Real theTol,
+ const Handle(IntTools_Context)& theCtx)
+{
+ TopAbs_State aState;
+ gp_Pnt aP3D;
+ //
+ aP3D=BRep_Tool::Pnt(theV);
+ aState=GEOMAlgo_Tools3D::ComputeState(aP3D, theRef, theTol, theCtx);
+ return aState;
+}
+//=======================================================================
+// function: ComputeState
+// purpose:
+//=======================================================================
+ TopAbs_State GEOMAlgo_Tools3D::ComputeState(const TopoDS_Edge& theE,
+ const TopoDS_Solid& theRef,
+ const Standard_Real theTol,
+ const Handle(IntTools_Context)& theCtx)
+{
+ Standard_Real aT1, aT2, aT = 0.;
+ TopAbs_State aState;
+ Handle(Geom_Curve) aC3D;
+ gp_Pnt aP3D;
+ //
+ aC3D = BRep_Tool::Curve(theE, aT1, aT2);
+ //
+ if(aC3D.IsNull()) {
+ //it means that we are in degenerated edge
+ const TopoDS_Vertex& aV = TopExp::FirstVertex(theE);
+ if(aV.IsNull()){
+ return TopAbs_UNKNOWN;
+ }
+ aP3D=BRep_Tool::Pnt(aV);
+ }
+ else {//usual case
+ Standard_Boolean bF2Inf, bL2Inf;
+ Standard_Real dT=10.;
+ //
+ bF2Inf = Precision::IsNegativeInfinite(aT1);
+ bL2Inf = Precision::IsPositiveInfinite(aT2);
+ //
+ if (bF2Inf && !bL2Inf) {
+ aT=aT2-dT;
+ }
+ else if (!bF2Inf && bL2Inf) {
+ aT=aT1+dT;
+ }
+ else if (bF2Inf && bL2Inf) {
+ aT=0.;
+ }
+ else {
+ aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
+ }
+ aC3D->D0(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
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File : GEOMAlgo_Tools3D.hxx\r
+// Created :\r
+// Author : Peter KURNEV\r
+\r
+#ifndef _GEOMAlgo_Tools3D_HeaderFile\r
+#define _GEOMAlgo_Tools3D_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Handle_IntTools_Context.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <TopAbs_State.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <NMTTools_ListOfCoupleOfShape.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <IntTools_Context.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <TopoDS_Edge.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopTools_IndexedMapOfShape.hxx>\r
+#include <TopoDS_Solid.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <TopoDS_Vertex.hxx>\r
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>\r
+#include <gp_Pnt2d.hxx>\r
+\r
+\r
+//! Auxiliary tools for Algorithms <br>\r
+//=======================================================================\r
+//class : GEOMAlgo_Tools3D\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_Tools3D {\r
+ public:\r
+ //! Returns True if the shape theSplit has opposite <br>\r
+ //! direction than theShape <br>\r
+ //! theContext - cashed geometrical tools <br>\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsSplitToReverse(const TopoDS_Shape& theSplit,\r
+ const TopoDS_Shape& theShape,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Returns True if normal direction of the face <br>\r
+ //! theShape is not the same as for the face <br>\r
+ //! theSplit <br>\r
+ //! theContext - cashed geometrical tools <br>\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsSplitToReverse(const TopoDS_Face& theSplit,\r
+ const TopoDS_Face& theShape,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Returns True if tangent direction of the edge <br>\r
+ //! theEdge is not the same as for the edge <br>\r
+ //! theSplit <br>\r
+ //! theContext - cashed geometrical tools <br>\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsSplitToReverse(const TopoDS_Edge& theEdge,\r
+ const TopoDS_Edge& theSplit,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! For the couple of faces theF1, theF2 <br>\r
+ //! computes sense value <br>\r
+ //! Returns 0 if the faces are not sensible <br>\r
+ //! Returns 1 if the faces have same sense <br>\r
+ //! Returns 2 if the faces have opposite sense <br>\r
+ Standard_EXPORT \r
+ static Standard_Integer Sense(const TopoDS_Face& theF1,\r
+ const TopoDS_Face& theF2) ;\r
+ \r
+ //! Makes new face theF2 from surface and wires <br>\r
+ //! of the face theF1 <br>\r
+ Standard_EXPORT\r
+ static void CopyFace(const TopoDS_Face& theF1,\r
+ TopoDS_Face& theF2) ;\r
+ \r
+ //! Makes empty shape theShape of the type theType <br>\r
+ Standard_EXPORT\r
+ static void MakeContainer(const TopAbs_ShapeEnum theType,\r
+ TopoDS_Shape& theShape) ;\r
+ \r
+ //! For the list of faces theLS build block <br>\r
+ //! theLSCB in terms of connexity by edges <br>\r
+ //! theMapAvoid - set of edges to avoid for <br>\r
+ //! the treatment <br>\r
+ Standard_EXPORT\r
+ static void MakeConnexityBlock(const TopTools_ListOfShape& theLS,\r
+ const TopTools_IndexedMapOfShape& theMapAvoid,\r
+ TopTools_ListOfShape& theLSCB) ;\r
+ \r
+ //! Computes the 3-D state of the shape theShape <br>\r
+ //! toward solid theSolid. <br>\r
+ //! theTol - value of precision of computation <br>\r
+ //! theContext- cahed geometrical tools <br>\r
+ //! Returns 3-D state. <br>\r
+ Standard_EXPORT\r
+ static TopAbs_State ComputeStateByOnePoint(const TopoDS_Shape& theShape,\r
+ const TopoDS_Solid& theSolid,\r
+ const Standard_Real theTol,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Computes the 3-D state of the point thePoint <br>\r
+ //! toward solid theSolid. <br>\r
+ //! theTol - value of precision of computation <br>\r
+ //! theContext- cahed geometrical tools <br>\r
+ //! Returns 3-D state. <br>\r
+ Standard_EXPORT\r
+ static TopAbs_State ComputeState(const gp_Pnt& thePoint,\r
+ const TopoDS_Solid& theSolid,\r
+ const Standard_Real theTol,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Computes the 3-D state of the vertex theVertex <br>\r
+ //! toward solid theSolid. <br>\r
+ //! theTol - value of precision of computation <br>\r
+ //! theContext- cahed geometrical tools <br>\r
+ //! Returns 3-D state. <br>\r
+ Standard_EXPORT \r
+ static TopAbs_State ComputeState(const TopoDS_Vertex& theVertex,\r
+ const TopoDS_Solid& theSolid,\r
+ const Standard_Real theTol,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Computes the 3-D state of the edge theEdge <br>\r
+ //! toward solid theSolid. <br>\r
+ //! theTol - value of precision of computation <br>\r
+ //! theContext- cahed geometrical tools <br>\r
+ //! Returns 3-D state. <br>\r
+ Standard_EXPORT \r
+ static TopAbs_State ComputeState(const TopoDS_Edge& theEdge,\r
+ const TopoDS_Solid& theSolid,\r
+ const Standard_Real theTol,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Computes the 3-D state of the face theFace <br>\r
+ //! toward solid theSolid. <br>\r
+ //! theTol - value of precision of computation <br>\r
+ //! theBounds - set of edges of theFace to avoid <br>\r
+ //! theContext- cahed geometrical tools <br>\r
+ //! Returns 3-D state. <br>\r
+ Standard_EXPORT \r
+ static TopAbs_State ComputeState(const TopoDS_Face& theFace,\r
+ const TopoDS_Solid& theSolid,\r
+ const Standard_Real theTol,\r
+ const TopTools_IndexedMapOfShape& theBounds,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Returns True if the face theFace is inside of the <br>\r
+ //! couple of faces theFace1, theFace2. <br>\r
+ //! The faces theFace, theFace1, theFace2 must <br>\r
+ //! share the edge theEdge <br>\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace,\r
+ const TopoDS_Edge& theEdge,\r
+ const TopoDS_Face& theFace1,\r
+ const TopoDS_Face& theFace2,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Returns True if the face theFace is inside of the <br>\r
+ //! appropriate couple of faces (from the set theLF) . <br>\r
+ //! The faces of the set theLF and theFace must <br>\r
+ //! share the edge theEdge <br>\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace,\r
+ const TopoDS_Edge& theEdge,\r
+ const TopTools_ListOfShape& theLF,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! Returns True if the face theFace is inside the <br>\r
+ //! solid theSolid. <br>\r
+ //! theMEF - Map Edge/Faces for theSolid <br>\r
+ //! theTol - value of precision of computation <br>\r
+ //! theContext- cahed geometrical tools <br>\r
+ Standard_EXPORT\r
+ static Standard_Boolean IsInternalFace(const TopoDS_Face& theFace,\r
+ const TopoDS_Solid& theSolid,\r
+ const TopTools_IndexedDataMapOfShapeListOfShape& theMEF,\r
+ const Standard_Real theTol,\r
+ const Handle(IntTools_Context)& theContext) ;\r
+ \r
+ //! For the face theFace and its edge theEdge <br>\r
+ //! finds the face suitable to produce shell. <br>\r
+ //! theLCEF - set of faces to search. All faces <br>\r
+ //! from theLCEF must share edge theEdge <br>\r
+ Standard_EXPORT\r
+ static void GetFaceOff(const TopoDS_Edge& theEdge,\r
+ const TopoDS_Face& theFace,\r
+ const NMTTools_ListOfCoupleOfShape& theLCEF,\r
+ TopoDS_Face& theFaceOff) ;\r
+\r
+ //! For the face theFace gets the edge theEdgeOnF <br>\r
+ //! that is the same as theEdge <br>\r
+ //! Returns True if such edge exists <br>\r
+ //! Returns False if there is no such edge <br>\r
+ Standard_EXPORT\r
+ static Standard_Boolean GetEdgeOnFace(const TopoDS_Edge& theEdge,\r
+ const TopoDS_Face& theFace,\r
+ TopoDS_Edge& theEdgeOnF) ;\r
+ \r
+ //! Returns True if the face theFace contains <br>\r
+ //! the edge theEdge but with opposite orientation. <br>\r
+ //! If the method returns True theEdgeOff is the <br>\r
+ //! edge founded <br>\r
+ Standard_EXPORT\r
+ static Standard_Boolean GetEdgeOff(const TopoDS_Edge& theEdge,\r
+ const TopoDS_Face& theFace,\r
+ TopoDS_Edge& theEdgeOff) ;\r
+ \r
+ //! Computes a point <theP> inside the face <theF>. <br>\r
+ //! <theP2D> - 2D representation of <theP> <br>\r
+ //! on the surface of <theF> <br>\r
+ //! Returns 0 in case of success. <br>\r
+ Standard_EXPORT\r
+ static Standard_Integer PntInFace(const TopoDS_Face& theF,\r
+ gp_Pnt& theP,\r
+ gp_Pnt2d& theP2D) ;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+
+#include <GEOMAlgo_Tools.hxx>
+//
+#include <NCollection_DataMap.hxx>
+
+#include <gp_Pnt2d.hxx>
+#include <gp_Pnt.hxx>
+
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dInt_GInter.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <GeomAdaptor_Surface.hxx>
+
+#include <IntRes2d_Domain.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+#include <IntRes2d_Transition.hxx>
+
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopExp_Explorer.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_ShapeMapHasher.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <BRepTools.hxx>
+
+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<TopoDS_Shape, GEOMAlgo_InfoEdge> 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;
+}
+
+
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_VertexSolid.hxx>
+
+#include <gp_Pnt.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopAbs_State.hxx>
+
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Solid.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <TopExp.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
+
+#include <BOPTColStd_Dump.hxx>
+
+#include <IntTools_Context.hxx>
+
+#include <BooleanOperations_StateOfShape.hxx>
+#include <BooleanOperations_ShapesDataStructure.hxx>
+
+#include <BOPTools_InterferencePool.hxx>
+#include <BOPTools_CArray1OfVVInterference.hxx>
+#include <BOPTools_VVInterference.hxx>
+#include <BOPTools_PaveFiller.hxx>
+#include <BOPTools_DSFiller.hxx>
+
+//=======================================================================
+//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);
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_VertexSolid.hxx\r
+// Created: Wed Jan 12 16:36:40 2005\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_VertexSolid_HeaderFile\r
+#define _GEOMAlgo_VertexSolid_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <GEOMAlgo_ShapeSolid.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_VertexSolid\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_VertexSolid : public GEOMAlgo_ShapeSolid\r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_VertexSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_VertexSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ virtual void Prepare() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void BuildResult() ;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_WESCorrector.hxx>
+
+#include <Geom_Surface.hxx>
+
+#include <TopLoc_Location.hxx>
+#include <TopoDS.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
+
+#include <TopTools_IndexedMapOfOrientedShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <BOP_ConnexityBlock.hxx>
+#include <BOP_ListIteratorOfListOfConnexityBlock.hxx>
+
+#include <BOPTColStd_ListOfListOfShape.hxx>
+#include <BOPTColStd_ListIteratorOfListOfListOfShape.hxx>
+
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <GEOMAlgo_WireSplitter.hxx>
+#include <GEOMAlgo_WESScaler.hxx>
+
+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;
+}
+
--- /dev/null
+\r
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTAlgo_WESCorrector.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _GEOMAlgo_WESCorrector_HeaderFile\r
+#define _GEOMAlgo_WESCorrector_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <GEOMAlgo_PWireEdgeSet.hxx>\r
+#include <GEOMAlgo_WireEdgeSet.hxx>\r
+#include <BOP_ListOfConnexityBlock.hxx>\r
+#include <GEOMAlgo_Algo.hxx>\r
+\r
+\r
+//! The algorithm to change the Wire Edges Set (WES) contents. <br>\r
+//! The NewWES will contain only wires instead of wires and edges. <br>\r
+//=======================================================================\r
+//class : GEOMAlgo_WESCorrector\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_WESCorrector : public GEOMAlgo_Algo \r
+{\r
+ public:\r
+ //! Empty constructor; <br>\r
+ //! <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_WESCorrector();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_WESCorrector();\r
+ \r
+ //! Modifier <br>\r
+ Standard_EXPORT\r
+ void SetWES(const GEOMAlgo_WireEdgeSet& aWES) ;\r
+ \r
+ //! Performs the algorithm that consists of two steps <br>\r
+ //! 1. Make conexity blocks ( DoConnexityBlocks() ) <br>\r
+ //! 2. Make corrections ( DoCorrections() ) <br>\r
+ Standard_EXPORT \r
+ virtual void Perform() ;\r
+ \r
+ //! Selector <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_WireEdgeSet& WES() ;\r
+ \r
+ //! Selector <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_WireEdgeSet& NewWES() ;\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ void DoConnexityBlocks() ;\r
+ \r
+ Standard_EXPORT\r
+ void DoCorrections() ;\r
+\r
+\r
+ GEOMAlgo_PWireEdgeSet myWES;\r
+ GEOMAlgo_WireEdgeSet myNewWES;\r
+ BOP_ListOfConnexityBlock myConnexityBlocks;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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:
+// <pkv@VORTEX>
+
+
+#include <GEOMAlgo_WESScaler.hxx>
+
+#include <gp_Pnt.hxx>
+#include <gp_Trsf.hxx>
+
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Wire.hxx>
+#include <BRep_Builder.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <BRepBuilderAPI_Transform.hxx>
+
+
+//=======================================================================
+//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);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: GEOMAlgo_WESScaler.hxx\r
+// Created: \r
+// Author: \r
+// <pkv@VORTEX>\r
+\r
+#ifndef _GEOMAlgo_WESScaler_HeaderFile\r
+#define _GEOMAlgo_WESScaler_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <GEOMAlgo_DataMapOfOrientedShapeShape.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <GEOMAlgo_Algo.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_WESScaler\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_WESScaler : public GEOMAlgo_Algo \r
+{\r
+public:\r
+ //! Empty constructor <br>\r
+ Standard_EXPORT\r
+ GEOMAlgo_WESScaler();\r
+\r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_WESScaler();\r
+ \r
+ //! Modifier <br>\r
+ Standard_EXPORT\r
+ void SetScale(const Standard_Real aWES) ;\r
+ \r
+ //! Selector <br>\r
+ Standard_EXPORT\r
+ Standard_Real Scale() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetFace(const TopoDS_Face& aF) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Face& Face() const;\r
+ \r
+ Standard_EXPORT\r
+ void SetEdges(const TopTools_ListOfShape& aLE) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Edges() const;\r
+ \r
+ //! Performs the algorithm <br>\r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Face& FaceScaled() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& EdgesScaled() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Image(const TopoDS_Shape& aS) const;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Origin(const TopoDS_Shape& aS) const;\r
+ \r
+ //! Selector <br>\r
+ Standard_EXPORT\r
+ const GEOMAlgo_DataMapOfOrientedShapeShape& Images() const;\r
+ \r
+ //! Selector <br>\r
+ Standard_EXPORT\r
+ const GEOMAlgo_DataMapOfOrientedShapeShape& Origins() const;\r
+\r
+ protected:\r
+\r
+ //! Performs the algorithm <br>\r
+ Standard_EXPORT virtual void CheckData() ;\r
+ \r
+ \r
+ Standard_Real myScale;\r
+ TopoDS_Face myFace;\r
+ TopTools_ListOfShape myEdges;\r
+ TopoDS_Face myFaceScaled;\r
+ TopTools_ListOfShape myEdgesScaled;\r
+ GEOMAlgo_DataMapOfOrientedShapeShape myImages;\r
+ GEOMAlgo_DataMapOfOrientedShapeShape myOrigins;\r
+ TopoDS_Shape myShapeTmp;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_WireEdgeSet.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_WireEdgeSet.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+\r
+#ifndef _GEOMAlgo_WireEdgeSet_HeaderFile\r
+#define _GEOMAlgo_WireEdgeSet_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+\r
+//=======================================================================\r
+//function : GEOMAlgo_WireEdgeSet\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_WireEdgeSet {\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_WireEdgeSet();\r
+ \r
+ Standard_EXPORT\r
+ void Clear() ;\r
+ \r
+ Standard_EXPORT\r
+ void SetFace(const TopoDS_Face& aF) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Face& Face() const;\r
+ \r
+ Standard_EXPORT\r
+ void AddStartElement(const TopoDS_Shape& sS) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& StartElements() const;\r
+ \r
+ Standard_EXPORT\r
+ void AddShape(const TopoDS_Shape& sS) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Shapes() const;\r
+\r
+protected:\r
+ TopoDS_Face myFace;\r
+ TopTools_ListOfShape myStartShapes;\r
+ TopTools_ListOfShape myShapes;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <GEOMAlgo_WireSolid.hxx>
+
+#include <Standard_Failure.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <BOPTColStd_Dump.hxx>
+
+#include <BooleanOperations_ShapesDataStructure.hxx>
+#include <BooleanOperations_StateOfShape.hxx>
+
+#include <BOPTools_PaveFiller.hxx>
+#include <BOPTools_SplitShapesPool.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_DSFiller.hxx>
+#include <BOPTools_WireStateFiller.hxx>
+
+//=======================================================================
+//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);
+ }
+ }
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: GEOMAlgo_WireSolid.hxx\r
+// Created: Wed Jan 12 10:19:31 2005\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+\r
+#ifndef _GEOMAlgo_WireSolid_HeaderFile\r
+#define _GEOMAlgo_WireSolid_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <GEOMAlgo_ShapeSolid.hxx>\r
+\r
+//=======================================================================\r
+//class : GEOMAlgo_WireSolid\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_WireSolid : public GEOMAlgo_ShapeSolid \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ GEOMAlgo_WireSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~GEOMAlgo_WireSolid();\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ protected:\r
+ Standard_EXPORT\r
+ virtual void Prepare() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void BuildResult() ;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <GEOMAlgo_WireSplitter.hxx>
+
+#include <TColStd_SequenceOfReal.hxx>
+#include <Precision.hxx>
+
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec2d.hxx>
+#include <TColgp_SequenceOfPnt2d.hxx>
+
+#include <Geom_Curve.hxx>
+#include <Geom2d_Curve.hxx>
+#include <GeomAdaptor_Surface.hxx>
+
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Iterator.hxx>
+
+
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepAdaptor_Curve2d.hxx>
+
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+
+
+
+#include <TopTools_SequenceOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <BOPTColStd_ListOfListOfShape.hxx>
+#include <BOPTColStd_ListIteratorOfListOfListOfShape.hxx>
+
+#include <BOPTools_Tools2D.hxx>
+
+#include <BOP_EdgeInfo.hxx>
+#include <BOP_ListOfEdgeInfo.hxx>
+#include <BOP_ListIteratorOfListOfEdgeInfo.hxx>
+#include <BOP_IndexedDataMapOfVertexListEdgeInfo.hxx>
+
+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<aTol2;
+ }//if (anIsSameV) {
+ //
+ if (anIsSameV && anIsSameV2d) {
+ myShapes.Append(aBuf);
+ //
+ TopTools_SequenceOfShape aLSt, aVertVat;
+ TColgp_SequenceOfPnt2d aCoordVat;
+ //
+ aNbj=i-1;
+ if (aNbj<1) {
+ //
+ aLS.Clear();
+ aVertVa.Clear();
+ aCoordVa.Clear();
+ //
+ return;
+ }
+
+ aVb=TopoDS::Vertex(aVertVa(i));
+
+ for (j=1; j<=aNbj; j++) {
+ aLSt.Append(aLS(j));
+ aVertVat.Append(aVertVa(j));
+ aCoordVat.Append(aCoordVa(j));
+ }
+ //
+ aLS.Clear();
+ aVertVa.Clear();
+ aCoordVa.Clear();
+
+ aLS=aLSt;
+ aVertVa=aVertVat;
+ aCoordVa=aCoordVat;
+ //
+ break;
+ }
+ }
+ }
+ //
+ aTol2D=2.*Tolerance2D(aVb, aGAS);
+ aTol2D2=100.*aTol2D*aTol2D;
+ //
+ // anAngleIn in Vb from edge aEOuta
+ const BOP_ListOfEdgeInfo& aLEInfo=mySmartMap.FindFromKey(aVb);
+ //
+ anAngleIn=AngleIn(aEOuta, aLEInfo);
+ //
+ // aEOutb
+ BOP_EdgeInfo *pEdgeInfo=NULL;
+
+ aMinAngle=100.;
+ anIsFound=Standard_False;
+
+ Standard_Integer aCurIndexE = 0;
+
+ anIt.Initialize(aLEInfo);
+ for (; anIt.More(); anIt.Next()) {
+ BOP_EdgeInfo& anEI=anIt.Value();
+ const TopoDS_Edge& aE=anEI.Edge();
+ anIsOut=!anEI.IsIn();
+ anIsNotPassed=!anEI.Passed();
+
+ if (anIsOut && anIsNotPassed) {
+ aCurIndexE++;
+ //
+ // Is there one way to go out of the vertex
+ // we have to use it only.
+ Standard_Integer iCnt;
+ iCnt=NbWaysOut (aLEInfo);
+ //
+ if (!iCnt) {
+ // no way to go . (Error)
+ return ;
+ }
+ //
+ if (iCnt==1) {
+ // the one and only way to go out .
+ pEdgeInfo=&anEI;
+ anIsFound=Standard_True;
+ break;
+ }
+ //
+ // Look for minimal angle and make the choice.
+ gp_Pnt2d aP2Dx;
+ //
+ aP2Dx=Coord2dVf(aE, myFace);
+ //
+ aD2=aP2Dx.SquareDistance(aPb);
+ if (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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: GEOMAlgo_WireSplitter.hxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _GEOMAlgo_WireSplitter_HeaderFile\r
+#define _GEOMAlgo_WireSplitter_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <BOPTColStd_ListOfListOfShape.hxx>\r
+#include <BOP_IndexedDataMapOfVertexListEdgeInfo.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <GEOMAlgo_Algo.hxx>\r
+\r
+//! the algorithm to split multiconnexed set of edges <br>\r
+//! wires on a face onto simple connexed wires <br>\r
+//! . <br>\r
+//=======================================================================\r
+//class : GEOMAlgo_WireSplitter\r
+//purpose : \r
+//=======================================================================\r
+class GEOMAlgo_WireSplitter : public GEOMAlgo_Algo \r
+{\r
+public:\r
+ Standard_EXPORT \r
+ GEOMAlgo_WireSplitter();\r
+\r
+ Standard_EXPORT \r
+ virtual ~GEOMAlgo_WireSplitter();\r
+ \r
+ Standard_EXPORT\r
+ void SetFace(const TopoDS_Face& aF) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetEdges(const TopTools_ListOfShape& aLE) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopTools_ListOfShape& Edges() const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsNothingToDo() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Face& Face() const;\r
+ \r
+ Standard_EXPORT\r
+ const BOPTColStd_ListOfListOfShape& Shapes() const;\r
+\r
+protected:\r
+ TopoDS_Face myFace;\r
+ Standard_Boolean myIsDone;\r
+ Standard_Boolean myNothingToDo;\r
+ BOPTColStd_ListOfListOfShape myShapes;\r
+ BOP_IndexedDataMapOfVertexListEdgeInfo mySmartMap;\r
+ TopTools_ListOfShape myEdges;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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 <Standard_Macro.hxx>
+#endif
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+
+#ifndef _Handle_MMgt_TShared_HeaderFile
+#include <Handle_MMgt_TShared.hxx>
+#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
--- /dev/null
+// 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 <Standard_Macro.hxx>
+#endif
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+
+#ifndef _Handle_BRepTools_Modification_HeaderFile
+#include <Handle_BRepTools_Modification.hxx>
+#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
--- /dev/null
+// 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 <Standard_Macro.hxx>
+#endif
+#ifndef _Standard_HeaderFile
+#include <Standard.hxx>
+#endif
+
+#ifndef _Handle_BRepTools_Modification_HeaderFile
+#include <Handle_BRepTools_Modification.hxx>
+#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
--- /dev/null
+# 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
# 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
$(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 \
-I$(srcdir)/../SKETCHER \
-I$(srcdir)/../ARCHIMEDE \
-I$(srcdir)/../GEOMImpl \
- -I$(srcdir)/../GEOMAlgo \
+ -I$(srcdir)/../$(GEOMAlgo_VAR) \
-I$(srcdir)/../GEOM \
-I$(top_builddir)/idl
-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 = \
# 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
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 \
--- /dev/null
+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
--- /dev/null
+
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# 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
--- /dev/null
+-- 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;
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTDS_BndSphere.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_BndSphere.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+\r
+#ifndef _NMTDS_BndSphere_HeaderFile\r
+#define _NMTDS_BndSphere_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <Standard_Boolean.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_BndSphere\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_BndSphere {\r
+ public:\r
+ Standard_EXPORT \r
+ NMTDS_BndSphere();\r
+ \r
+ Standard_EXPORT \r
+ virtual ~NMTDS_BndSphere();\r
+ \r
+ void SetCenter(const gp_Pnt& theP) ;\r
+ \r
+ const gp_Pnt& Center() const;\r
+ \r
+ void SetRadius(const Standard_Real theR) ;\r
+ \r
+ Standard_Real Radius() const;\r
+ \r
+ void SetGap(const Standard_Real theGap) ;\r
+ \r
+ Standard_Real Gap() const;\r
+ \r
+ void Add(const NMTDS_BndSphere& theOther) ;\r
+ \r
+ Standard_EXPORT \r
+ Standard_Boolean IsOut(const NMTDS_BndSphere& theOther) const;\r
+ \r
+ Standard_Real SquareExtent() const;\r
+\r
+ protected:\r
+ gp_Pnt myCenter;\r
+ Standard_Real myRadius;\r
+ Standard_Real myGap;\r
+};\r
+\r
+#include <NMTDS_BndSphere.lxx>\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//=======================================================================
+//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;
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTDS_BndSphereTree.hxx>
+//=======================================================================
+//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;
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#ifndef NMTDS_BndSphereTree_HeaderFile
+#define NMTDS_BndSphereTree_HeaderFile
+
+#include <NCollection_UBTree.hxx>
+#include <NMTDS_BndSphere.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+
+typedef NCollection_UBTree <Standard_Integer , NMTDS_BndSphere> 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
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTDS_BoxBndTree.hxx>
+//=======================================================================
+//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;
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#ifndef NMTDS_BoxBndTree_HeaderFile
+#define NMTDS_BoxBndTree_HeaderFile
+
+#include <NCollection_UBTree.hxx>
+#include <Bnd_Box.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+
+typedef NCollection_UBTree <Standard_Integer , Bnd_Box> 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
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_CArray1OfIndexRange.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+\r
+#include <NMTDS_CArray1OfIndexRange.hxx>\r
+\r
+#ifndef _Standard_OutOfRange_HeaderFile\r
+#include <Standard_OutOfRange.hxx>\r
+#endif\r
+#ifndef _Standard_OutOfMemory_HeaderFile\r
+#include <Standard_OutOfMemory.hxx>\r
+#endif\r
+ \r
+\r
+#define Array1Item NMTDS_IndexRange\r
+#define Array1Item_hxx <NMTDS_IndexRange.hxx>\r
+#define BOPTColStd_CArray1 NMTDS_CArray1OfIndexRange\r
+#define BOPTColStd_CArray1_hxx <NMTDS_CArray1OfIndexRange.hxx>\r
+#include <BOPTColStd_CArray1.gxx>\r
+\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_BndSphere.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+\r
+#ifndef _NMTDS_CArray1OfIndexRange_HeaderFile\r
+#define _NMTDS_CArray1OfIndexRange_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Address.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <NMTDS_IndexRange.hxx>\r
+\r
+class Standard_OutOfRange;\r
+class Standard_OutOfMemory;\r
+\r
+\r
+\r
+//=======================================================================\r
+//function : NMTDS_CArray1OfIndexRange\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_CArray1OfIndexRange {\r
+ public:\r
+\r
+ Standard_EXPORT\r
+ NMTDS_CArray1OfIndexRange(const Standard_Integer Length = 0,\r
+ const Standard_Integer BlockLength = 5);\r
+ \r
+ Standard_EXPORT \r
+ void Resize(const Standard_Integer theNewLength) ;\r
+ \r
+ Standard_EXPORT \r
+ void Destroy() ;\r
+\r
+ ~NMTDS_CArray1OfIndexRange() {\r
+ Destroy();\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer Length() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer Extent() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer FactLength() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer Append(const NMTDS_IndexRange& Value) ;\r
+ \r
+ Standard_EXPORT\r
+ void Remove(const Standard_Integer Index) ;\r
+ \r
+ Standard_EXPORT\r
+ const NMTDS_IndexRange& Value(const Standard_Integer Index) const;\r
+ \r
+ const NMTDS_IndexRange& operator ()(const Standard_Integer Index) const {\r
+ return Value(Index);\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_IndexRange& ChangeValue(const Standard_Integer Index) ;\r
+\r
+ NMTDS_IndexRange& operator ()(const Standard_Integer Index) {\r
+ return ChangeValue(Index);\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ void SetBlockLength(const Standard_Integer aBL) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer BlockLength() const;\r
+ \r
+ Standard_EXPORT\r
+ void Purge() ;\r
+\r
+ private:\r
+ Standard_EXPORT\r
+ NMTDS_CArray1OfIndexRange(const NMTDS_CArray1OfIndexRange& AnArray);\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_CArray1OfIndexRange& Assign(const NMTDS_CArray1OfIndexRange& Other) ;\r
+ \r
+ NMTDS_CArray1OfIndexRange& operator =(const NMTDS_CArray1OfIndexRange& Other) {\r
+ return Assign(Other);\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsInvalidIndex(const Standard_Integer Index) const;\r
+\r
+\r
+ Standard_Address myStart;\r
+ Standard_Integer myLength;\r
+ Standard_Integer myFactLength;\r
+ Standard_Integer myBlockLength;\r
+ Standard_Boolean myIsAllocated;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx\r
+// Created: Mon Feb 20 09:31:43 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger_HeaderFile\r
+#define NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger_HeaderFile\r
+\r
+#ifndef NMTDS_DataMapOfIntegerMapOfInteger_HeaderFile\r
+#include <NMTDS_DataMapOfIntegerMapOfInteger.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_DataMapOfIntegerMapOfInteger.hxx\r
+// Created: Mon Feb 20 09:27:40 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_DataMapOfIntegerMapOfInteger_HeaderFile\r
+#define NMTDS_DataMapOfIntegerMapOfInteger_HeaderFile\r
+\r
+#include <TColStd_MapOfInteger.hxx>\r
+#include <TColStd_MapIntegerHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+typedef NCollection_DataMap<Standard_Integer, TColStd_MapOfInteger, TColStd_MapIntegerHasher> NMTDS_DataMapOfIntegerMapOfInteger; \r
+typedef NMTDS_DataMapOfIntegerMapOfInteger::Iterator NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTDS_IndexRange.hxx>
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_IndexRange.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+\r
+#ifndef _NMTDS_IndexRange_HeaderFile\r
+#define _NMTDS_IndexRange_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_IndexRange\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_IndexRange {\r
+ public:\r
+\r
+ Standard_EXPORT \r
+ NMTDS_IndexRange();\r
+ \r
+ Standard_EXPORT void SetFirst(const Standard_Integer aFirst) ;\r
+ \r
+ Standard_EXPORT void SetLast(const Standard_Integer aLast) ;\r
+ \r
+ Standard_EXPORT Standard_Integer First() const;\r
+ \r
+ Standard_EXPORT Standard_Integer Last() const;\r
+ \r
+ Standard_EXPORT Standard_Boolean IsInRange(const Standard_Integer aIndex) const;\r
+\r
+protected:\r
+ Standard_Integer myFirst;\r
+ Standard_Integer myLast;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_IndexedDataMapOfIntegerShape.hxx\r
+// Created: Mon Feb 20 09:20:07 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_IndexedDataMapOfIntegerShape_HeaderFile\r
+#define NMTDS_IndexedDataMapOfIntegerShape_HeaderFile\r
+\r
+#include <TopoDS_Shape.hxx> \r
+#include <Standard_Integer.hxx>\r
+#include <TColStd_MapIntegerHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+\r
+typedef NCollection_IndexedDataMap<Standard_Integer, TopoDS_Shape, TColStd_MapIntegerHasher> NMTDS_IndexedDataMapOfIntegerShape; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_IndexedDataMapOfShapeBndSphere.hxx\r
+// Created: Mon Feb 20 09:17:01 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_IndexedDataMapOfShapeBndSphere_HeaderFile\r
+#define NMTDS_IndexedDataMapOfShapeBndSphere_HeaderFile\r
+\r
+#include <TopoDS_Shape.hxx> \r
+#include <TopTools_ShapeMapHasher.hxx>\r
+#include <NMTDS_BndSphere.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+\r
+\r
+typedef NCollection_IndexedDataMap<TopoDS_Shape, NMTDS_BndSphere, TopTools_ShapeMapHasher> NMTDS_IndexedDataMapOfShapeBndSphere; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_IndexedDataMapOfShapeBox.hxx\r
+// Created: Mon Feb 20 09:17:01 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_IndexedDataMapOfShapeBox_HeaderFile\r
+#define NMTDS_IndexedDataMapOfShapeBox_HeaderFile\r
+\r
+#include <TopoDS_Shape.hxx> \r
+#include <TopTools_ShapeMapHasher.hxx>\r
+#include <Bnd_Box.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+\r
+typedef NCollection_IndexedDataMap<TopoDS_Shape, Bnd_Box, TopTools_ShapeMapHasher> NMTDS_IndexedDataMapOfShapeBox; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// 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 <NMTDS_InterfPool.hxx>
+
+#include <NMTDS_PairBoolean.hxx>
+#include <NMTDS_ListOfPairBoolean.hxx>
+#include <NMTDS_MapIteratorOfMapOfPairBoolean.hxx>
+#include <NMTDS_ListIteratorOfListOfPairBoolean.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+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 && iType<myMaxInd) {
+ bRet=myTable[iType].Add(aPKB);
+ }
+ return bRet;
+}
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+Standard_Boolean NMTDS_InterfPool::Add (const Standard_Integer aInd1,
+ const Standard_Integer aInd2,
+ const NMTDS_InterfType aType)
+{
+ NMTDS_PairBoolean aPKB;
+ //
+ aPKB.SetIds(aInd1, aInd2);
+ return Add(aPKB, aType);
+}
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+Standard_Boolean NMTDS_InterfPool::Add (const Standard_Integer aInd1,
+ const Standard_Integer aInd2,
+ const Standard_Boolean bFlag,
+ const NMTDS_InterfType aType)
+{
+ NMTDS_PairBoolean aPKB;
+ //
+ aPKB.SetIds(aInd1, aInd2);
+ aPKB.SetFlag(bFlag);
+ return Add(aPKB, aType);
+}
+//=======================================================================
+//function : Contains
+//purpose :
+//=======================================================================
+Standard_Boolean NMTDS_InterfPool::Contains(const NMTDS_PairBoolean& aPKB)const
+{
+ Standard_Boolean bRet;
+ Standard_Integer i;
+ //
+ for (i=0; i<myMaxInd; ++i) {
+ bRet=myTable[i].Contains(aPKB);
+ if (bRet) {
+ break;
+ }
+ }
+ return bRet;
+}
+//=======================================================================
+//function : Contains
+//purpose :
+//=======================================================================
+ Standard_Boolean NMTDS_InterfPool::Contains(const Standard_Integer aInd1,
+ const Standard_Integer aInd2)const
+{
+ NMTDS_PairBoolean aPKB;
+ //
+ aPKB.SetIds(aInd1, aInd2);
+ return Contains(aPKB);
+}
+//=======================================================================
+//function : Get
+//purpose :
+//=======================================================================
+const NMTDS_ListOfPairBoolean& NMTDS_InterfPool::Get()const
+{
+ Standard_Integer i;
+ NMTDS_ListOfPairBoolean* pL;
+ //
+ pL=(NMTDS_ListOfPairBoolean*)&myList;
+ pL->Clear();
+ //
+ for (i=0; i<myMaxInd; ++i) {
+ NMTDS_MapIteratorOfMapOfPairBoolean aIt;
+ //
+ aIt.Initialize(myTable[i]);
+ for(; aIt.More(); aIt.Next()) {
+ const NMTDS_PairBoolean& aPKB=aIt.Key();
+ pL->Append(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; i<myMaxInd; ++i) {
+ NMTDS_MapIteratorOfMapOfPairBoolean aIt;
+ //
+ aIt.Initialize(myTable[i]);
+ for(; aIt.More(); aIt.Next()) {
+ const NMTDS_PairBoolean& aPKB=aIt.Key();
+ aPKB.Ids(n1, n2);
+ if(n1==aInd || n2==aInd) {
+ pL->Append(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 && iType<myMaxInd) {
+ NMTDS_MapIteratorOfMapOfPairBoolean aIt;
+ //
+ aIt.Initialize(myTable[iType]);
+ for(; aIt.More(); aIt.Next()) {
+ const NMTDS_PairBoolean& aPKB=aIt.Key();
+ pL->Append(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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_InterfPool.hxx\r
+//\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_InterfPool_HeaderFile\r
+#define _NMTDS_InterfPool_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+\r
+#include <Standard_Integer.hxx>\r
+#include <BOPTools_CArray1OfSSInterference.hxx>\r
+#include <BOPTools_CArray1OfESInterference.hxx>\r
+#include <BOPTools_CArray1OfVSInterference.hxx>\r
+#include <BOPTools_CArray1OfEEInterference.hxx>\r
+#include <BOPTools_CArray1OfVEInterference.hxx>\r
+#include <BOPTools_CArray1OfVVInterference.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <NMTDS_InterfType.hxx>\r
+#include <NMTDS_PairBoolean.hxx>\r
+#include <NMTDS_MapOfPairBoolean.hxx>\r
+#include <NMTDS_ListOfPairBoolean.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_InterfPool\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_InterfPool {\r
+ public:\r
+ Standard_EXPORT \r
+ NMTDS_InterfPool();\r
+ Standard_EXPORT \r
+ virtual ~NMTDS_InterfPool();\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean Add(const NMTDS_PairBoolean& aPKB,\r
+ const NMTDS_InterfType aType) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean Add(const Standard_Integer aInd1,\r
+ const Standard_Integer aInd2,\r
+ const NMTDS_InterfType aType) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean Add(const Standard_Integer aInd1,\r
+ const Standard_Integer aInd2,\r
+ const Standard_Boolean bFlag,\r
+ const NMTDS_InterfType aType) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean Contains(const NMTDS_PairBoolean& aPKB) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean Contains(const Standard_Integer aInd1,\r
+ const Standard_Integer aInd2) const;\r
+ \r
+ Standard_EXPORT\r
+ const NMTDS_ListOfPairBoolean& Get() const;\r
+ \r
+ Standard_EXPORT\r
+ const NMTDS_ListOfPairBoolean& Get(const NMTDS_InterfType aType) const;\r
+ \r
+ Standard_EXPORT\r
+ const NMTDS_ListOfPairBoolean& Get(const Standard_Integer aInd) const;\r
+ \r
+ Standard_EXPORT\r
+ const NMTDS_ListOfPairBoolean& Get(const Standard_Integer aInd,\r
+ const NMTDS_InterfType aType) const;\r
+ \r
+ //! Returns the reference to array Of F/F interferences <br>\r
+ Standard_EXPORT BOPTools_CArray1OfSSInterference& SSInterferences() ;\r
+ \r
+ //! Returns the reference to array Of E/F interferences <br>\r
+ Standard_EXPORT BOPTools_CArray1OfESInterference& ESInterferences() ;\r
+ \r
+ //! Returns the reference to array Of V/F interferences <br>\r
+ Standard_EXPORT BOPTools_CArray1OfVSInterference& VSInterferences() ;\r
+ \r
+ //! Returns the reference to arrray Of E/E interferences <br>\r
+ Standard_EXPORT BOPTools_CArray1OfEEInterference& EEInterferences() ;\r
+ \r
+ //! Returns the reference to arrray Of V/E interferences <br>\r
+ Standard_EXPORT BOPTools_CArray1OfVEInterference& VEInterferences() ;\r
+ \r
+ //! Returns the reference to arrray Of V/V interferences <br>\r
+ Standard_EXPORT BOPTools_CArray1OfVVInterference& VVInterferences() ;\r
+ \r
+ Standard_EXPORT void Purge() ;\r
+\r
+protected:\r
+ NMTDS_MapOfPairBoolean myTable[6];\r
+ NMTDS_ListOfPairBoolean myList;\r
+ Standard_Integer myMaxInd;\r
+ BOPTools_CArray1OfSSInterference mySSInterferences;\r
+ BOPTools_CArray1OfESInterference myESInterferences;\r
+ BOPTools_CArray1OfVSInterference myVSInterferences;\r
+ BOPTools_CArray1OfEEInterference myEEInterferences;\r
+ BOPTools_CArray1OfVEInterference myVEInterferences;\r
+ BOPTools_CArray1OfVVInterference myVVInterferences;\r
+\r
+private:\r
+};\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_InterfType.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+\r
+\r
+#ifndef _NMTDS_InterfType_HeaderFile\r
+#define _NMTDS_InterfType_HeaderFile\r
+\r
+\r
+enum NMTDS_InterfType {\r
+NMTDS_TI_VV,\r
+NMTDS_TI_VE,\r
+NMTDS_TI_VF,\r
+NMTDS_TI_EE,\r
+NMTDS_TI_EF,\r
+NMTDS_TI_FF,\r
+NMTDS_TI_UNKNOWN\r
+};\r
+\r
+#ifndef _Standard_PrimitiveTypes_HeaderFile\r
+#include <Standard_PrimitiveTypes.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// 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 <NMTDS_Iterator.hxx>
+//
+#include <Bnd_Box.hxx>
+//
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include <TColStd_DataMapOfIntegerInteger.hxx>
+#include <TColStd_DataMapOfIntegerListOfInteger.hxx>
+#include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+//
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shape.hxx>
+//
+#include <TopTools_DataMapOfShapeInteger.hxx>
+//
+#include <NMTDS_BoxBndTree.hxx>
+#include <NCollection_UBTreeFiller.hxx>
+#include <NMTDS_CArray1OfIndexRange.hxx>
+#include <NMTDS_IndexRange.hxx>
+#include <NMTDS_PairBoolean.hxx>
+#include <NMTDS_MapOfPairBoolean.hxx>
+#include <NMTDS_IndexedDataMapOfShapeBox.hxx>
+#include <NMTDS_IndexedDataMapOfIntegerShape.hxx>
+#include <NMTDS_Tools.hxx>
+#include <NMTDS_DataMapOfIntegerMapOfInteger.hxx>
+#include <NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+
+//=======================================================================
+//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 <Standard_Integer, Bnd_Box> 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; iR<aNbR; ++iR) {
+ const NMTDS_IndexRange& aR=aRanges(iR);
+ i1=aR.First();
+ i2=aR.Last();
+ for (i=i1; i<=i2; ++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
+ 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<aNbR; ++iR) {
+ //
+ //
+ // Chains
+ //=================
+ myMVSD.Clear();
+ NMTDS_Iterator::FillMVSD(aMVSD, myMVSD);
+
+ //modified by NIZNHY-PKV Mon Dec 12 09:51:29 2011f
+ aMPKXB.Clear();
+ Standard::Purge();
+ //modified by NIZNHY-PKV Mon Dec 12 09:51:33 2011t
+}
+//=======================================================================
+//function : FillMVSD
+//purpose :
+//=======================================================================
+void NMTDS_Iterator::FillMVSD(const TColStd_DataMapOfIntegerListOfInteger& aMVSD,
+ TColStd_DataMapOfIntegerListOfInteger& bMVSD)
+{
+ Standard_Boolean bFound;
+ Standard_Integer aNbVSD, iCnt, i, j, k;
+ TColStd_ListOfInteger aLV;
+ TColStd_ListIteratorOfListOfInteger aIt;
+ TColStd_MapOfInteger aMF;
+ TColStd_MapIteratorOfMapOfInteger aItMI;
+ TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItVSD;
+ NMTDS_DataMapOfIntegerMapOfInteger aDMIMI;
+ NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger aIti, aItj;
+ //
+ aNbVSD=aMVSD.Extent();
+ if (!aNbVSD) {
+ return;
+ }
+ //
+ aItVSD.Initialize(aMVSD);
+ for (; aItVSD.More(); aItVSD.Next()) {
+ TColStd_MapOfInteger aMI;
+ //
+ i=aItVSD.Key();
+ aMI.Add(i);
+ const TColStd_ListOfInteger& aLVSD=aItVSD.Value();
+ aIt.Initialize(aLVSD);
+ for (; aIt.More(); aIt.Next()) {
+ j=aIt.Value();
+ aMI.Add(j);
+ }
+ aDMIMI.Bind(i, aMI);
+ }
+ // i
+ aIti.Initialize(aDMIMI);
+ for (; aIti.More(); aIti.Next()) {
+ i=aIti.Key();
+ if (aMF.Contains(i)) {
+ continue;
+ }
+ aMF.Add(i);
+ //
+ //TColStd_MapOfInteger& aMIi=aDMIMI.ChangeFind(i);
+ TColStd_MapOfInteger *pMIi=(TColStd_MapOfInteger *)&aIti.Value();
+ TColStd_MapOfInteger& aMIi=*pMIi;
+ // j
+ while (1) {
+ iCnt=0;
+ aItj.Initialize(aDMIMI);
+ for (; aItj.More(); aItj.Next()) {
+ j=aItj.Key();
+ if (aMF.Contains(j)) {
+ continue;
+ }
+ //
+ //TColStd_MapOfInteger& aMIj=aDMIMI.ChangeFind(j);
+ TColStd_MapOfInteger *pMj=(TColStd_MapOfInteger *)&aItj.Value();
+ TColStd_MapOfInteger& aMIj=*pMj;
+ //
+ aItMI.Initialize(aMIj);
+ for (; aItMI.More(); aItMI.Next()) {
+ k=aItMI.Key();
+ bFound=aMIi.Contains(k);
+ if (bFound) {
+ break;
+ }
+ }
+ if (!bFound) {
+ continue;
+ }
+ //
+ aItMI.Initialize(aMIj);
+ for (; aItMI.More(); aItMI.Next()) {
+ k=aItMI.Key();
+ aMIi.Add(k);
+ }
+ //
+ if (aMF.Add(j)) {
+ ++iCnt;
+ }
+ } //for (; aItj.More(); aItj.Next()) {
+ if (!iCnt) {
+ break;
+ }
+ } // while (1) {
+ //
+ aLV.Clear();
+ aItMI.Initialize(aMIi);
+ for (; aItMI.More(); aItMI.Next()) {
+ k=aItMI.Key();
+ if (k!=i) {
+ aLV.Append(k);
+ }
+ }
+ bMVSD.Bind(i, aLV);
+ }// for (; aIti.More(); aIti.Next()) {
+}
+
+ /*
+ {
+ // check
+ TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger aItX;
+ //
+ printf(" \n");
+ printf(" myMVSD.Extent()=%d\n", myMVSD.Extent());
+ aItX.Initialize(myMVSD);
+ for (; aItX.More(); aItX.Next()) {
+ i=aItX.Key();
+ printf(" i=%d (", i);
+ const TColStd_ListOfInteger& aLV=aItX.Value();
+ aIt.Initialize(aLV);
+ for (; aIt.More(); aIt.Next()) {
+ j=aIt.Value();
+ printf(" %d", j);
+ }
+ printf(")\n");
+ }
+ }
+*/
+
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_Iterator.hxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_Iterator_HeaderFile\r
+#define _NMTDS_Iterator_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+\r
+#include <Standard_Integer.hxx>\r
+#include <TColStd_DataMapOfIntegerListOfInteger.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <NMTDS_PShapesDataStructure.hxx>\r
+#include <NMTDS_ListOfPairBoolean.hxx>\r
+#include <NMTDS_ListIteratorOfListOfPairBoolean.hxx>\r
+#include <NMTDS_ShapesDataStructure.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_Iterator\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_Iterator {\r
+ public:\r
+ Standard_EXPORT \r
+ NMTDS_Iterator();\r
+\r
+ Standard_EXPORT \r
+ virtual ~NMTDS_Iterator();\r
+ \r
+ Standard_EXPORT\r
+ void SetDS(const NMTDS_PShapesDataStructure& pDS) ;\r
+ \r
+ Standard_EXPORT \r
+ const NMTDS_ShapesDataStructure& DS() const;\r
+ \r
+ Standard_EXPORT \r
+ void Initialize(const TopAbs_ShapeEnum aType1,\r
+ const TopAbs_ShapeEnum aType2) ;\r
+ \r
+ Standard_EXPORT \r
+ Standard_Boolean More() const;\r
+ \r
+ Standard_EXPORT\r
+ void Next() ;\r
+ \r
+ Standard_EXPORT\r
+ void Current(Standard_Integer& aIndex1,\r
+ Standard_Integer& aIndex2,\r
+ Standard_Boolean& aWithSubShape) const;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Prepare() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer ExpectedLength() const;\r
+ \r
+ Standard_EXPORT \r
+ Standard_Integer BlockLength() const;\r
+ \r
+ Standard_EXPORT \r
+ const TColStd_DataMapOfIntegerListOfInteger& SDVertices() const;\r
+ \r
+ Standard_EXPORT \r
+ static void FillMVSD(const TColStd_DataMapOfIntegerListOfInteger& aMVSD1,\r
+ TColStd_DataMapOfIntegerListOfInteger& aMVSD2) ;\r
+\r
+protected:\r
+ Standard_EXPORT \r
+ virtual void Intersect() ;\r
+ //\r
+ \r
+ NMTDS_PShapesDataStructure myDS;\r
+ NMTDS_ListOfPairBoolean myLists[6];\r
+ NMTDS_ListIteratorOfListOfPairBoolean myIterator;\r
+ NMTDS_ListOfPairBoolean myEmptyList;\r
+ Standard_Integer myLength;\r
+ TColStd_DataMapOfIntegerListOfInteger myMVSD;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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 <NMTDS_IteratorCheckerSI.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+#include <gp_Pnt.hxx>
+#include <Bnd_Box.hxx>
+//
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+//
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_DataMapOfIntegerInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include <TColStd_DataMapOfIntegerListOfInteger.hxx>
+#include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+//
+#include <TopTools_DataMapOfShapeInteger.hxx>
+//
+#include <NCollection_UBTreeFiller.hxx>
+#include <NMTDS_BoxBndTree.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_CArray1OfIndexRange.hxx>
+#include <NMTDS_IndexRange.hxx>
+#include <NMTDS_PairBoolean.hxx>
+#include <NMTDS_MapOfPairBoolean.hxx>
+#include <NMTDS_IndexedDataMapOfShapeBox.hxx>
+#include <NMTDS_Tools.hxx>
+
+//=======================================================================
+//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 <Standard_Integer, Bnd_Box> 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);
+}
+
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_IteratorChecker.cxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_IteratorCheckerSI_HeaderFile\r
+#define _NMTDS_IteratorCheckerSI_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <NMTDS_Iterator.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_IteratorCheckerSI\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_IteratorCheckerSI : public NMTDS_Iterator {\r
+ public:\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_IteratorCheckerSI();\r
+ Standard_EXPORT \r
+ virtual ~NMTDS_IteratorCheckerSI();\r
+\r
+protected:\r
+ Standard_EXPORT \r
+ virtual void Intersect() ;\r
+};\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile\r
+#define NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile\r
+\r
+#ifndef NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile\r
+#include <NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx>\r
+#endif \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListIteratorOfListOfPair.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListIteratorOfListOfPair_HeaderFile\r
+#define NMTDS_ListIteratorOfListOfPair_HeaderFile\r
+\r
+#ifndef NMTDS_ListOfPair_HeaderFile\r
+#include <NMTDS_ListOfPair.hxx>\r
+#endif \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListIteratorOfListOfPairBoolean.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListIteratorOfListOfPairBoolean_HeaderFile\r
+#define NMTDS_ListIteratorOfListOfPairBoolean_HeaderFile\r
+\r
+#ifndef NMTDS_ListOfPairBoolean_HeaderFile\r
+#include <NMTDS_ListOfPairBoolean.hxx>\r
+#endif \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListIteratorOfListOfPassKey.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListIteratorOfListOfPassKey_HeaderFile\r
+#define NMTDS_ListIteratorOfListOfPassKey_HeaderFile\r
+\r
+#ifndef NMTDS_ListOfPassKey_HeaderFile\r
+#include <NMTDS_ListOfPassKey.hxx>\r
+#endif \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListIteratorOfListOfPassKeyBoolean_HeaderFile\r
+#define NMTDS_ListIteratorOfListOfPassKeyBoolean_HeaderFile\r
+\r
+#ifndef NMTDS_ListOfPassKeyBoolean_HeaderFile\r
+#include <NMTDS_ListOfPassKeyBoolean.hxx>\r
+#endif \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile\r
+#define NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx>\r
+\r
+typedef NCollection_List<BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors> NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors; \r
+typedef NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors::Iterator NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors; \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListOfPair.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListOfPair_HeaderFile\r
+#define NMTDS_ListOfPair_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <NMTDS_Pair.hxx>\r
+\r
+typedef NCollection_List<NMTDS_Pair> NMTDS_ListOfPair; \r
+typedef NMTDS_ListOfPair::Iterator NMTDS_ListIteratorOfListOfPair; \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListOfPairBoolean.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListOfPairBoolean_HeaderFile\r
+#define NMTDS_ListOfPairBoolean_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <NMTDS_PairBoolean.hxx>\r
+\r
+typedef NCollection_List<NMTDS_PairBoolean> NMTDS_ListOfPairBoolean; \r
+typedef NMTDS_ListOfPairBoolean::Iterator NMTDS_ListIteratorOfListOfPairBoolean; \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListOfPassKey.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListOfPassKey_HeaderFile\r
+#define NMTDS_ListOfPassKey_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <NMTDS_PassKey.hxx>\r
+\r
+typedef NCollection_List<NMTDS_PassKey> NMTDS_ListOfPassKey; \r
+typedef NMTDS_ListOfPassKey::Iterator NMTDS_ListIteratorOfListOfPassKey; \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListOfPassKeyBoolean.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_ListOfPassKeyBoolean_HeaderFile\r
+#define NMTDS_ListOfPassKeyBoolean_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <NMTDS_PassKeyBoolean.hxx>\r
+\r
+typedef NCollection_List<NMTDS_PassKeyBoolean> NMTDS_ListOfPassKeyBoolean; \r
+typedef NMTDS_ListOfPassKeyBoolean::Iterator NMTDS_ListIteratorOfListOfPassKeyBoolean; \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_MapIteratorOfMapOfPairBoolean.hxx\r
+// Created: Mon Feb 20 08:22:39 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_MapIteratorOfMapOfPairBoolean_HeaderFile\r
+#define NMTDS_MapIteratorOfMapOfPairBoolean_HeaderFile\r
+\r
+#ifndef NMTDS_MapOfPairBoolean_HeaderFile\r
+#include <NMTDS_MapOfPairBoolean.hxx> \r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMRCol_MapIteratorOfMapOfPassKey.hxx\r
+// Created: Mon Feb 20 08:22:39 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMRCol_MapIteratorOfMapOfPassKey_HeaderFile\r
+#define NMRCol_MapIteratorOfMapOfPassKey_HeaderFile\r
+\r
+#ifndef NMTDS_MapOfPassKey_HeaderFile\r
+#include <NMTDS_MapOfPassKey.hxx> \r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMRCol_MapIteratorOfMapOfPassKeyBoolean.hxx\r
+// Created: Mon Feb 20 08:22:39 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMRCol_MapIteratorOfMapOfPassKeyBoolean_HeaderFile\r
+#define NMRCol_MapIteratorOfMapOfPassKeyBoolean_HeaderFile\r
+\r
+#ifndef NMTDS_MapOfPassKeyBoolean_HeaderFile\r
+#include <NMTDS_MapOfPassKeyBoolean.hxx> \r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_MapOfPairBoolean.hxx\r
+// Created: Mon Feb 20 08:19:07 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_MapOfPairBoolean_HeaderFile\r
+#define NMTDS_MapOfPairBoolean_HeaderFile\r
+\r
+#include <NMTDS_PairBoolean.hxx> \r
+#include <NMTDS_PairMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_Map.hxx> \r
+\r
+typedef NCollection_Map<NMTDS_PairBoolean, NMTDS_PairMapHasher> NMTDS_MapOfPairBoolean; \r
+typedef NMTDS_MapOfPairBoolean::Iterator NMTDS_MapIteratorOfMapOfPairBoolean; \r
+\r
+#undef _NCollection_MapHasher\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_MapOfPassKey.hxx\r
+// Created: Mon Feb 20 08:19:07 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_MapOfPassKey_HeaderFile\r
+#define NMTDS_MapOfPassKey_HeaderFile\r
+\r
+#include <NMTDS_PassKey.hxx> \r
+#include <NMTDS_PassKeyMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_Map.hxx> \r
+\r
+typedef NCollection_Map<NMTDS_PassKey, NMTDS_PassKeyMapHasher> NMTDS_MapOfPassKey; \r
+typedef NMTDS_MapOfPassKey::Iterator NMTDS_MapIteratorOfMapOfPassKey; \r
+\r
+#undef _NCollection_MapHasher\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_MapOfPassKeyBoolean.hxx\r
+// Created: Mon Feb 20 08:19:07 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTDS_MapOfPassKeyBoolean_HeaderFile\r
+#define NMTDS_MapOfPassKeyBoolean_HeaderFile\r
+\r
+#include <NMTDS_PassKeyBoolean.hxx> \r
+#include <NMTDS_PassKeyMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_Map.hxx> \r
+\r
+typedef NCollection_Map<NMTDS_PassKeyBoolean, NMTDS_PassKeyMapHasher> NMTDS_MapOfPassKeyBoolean; \r
+typedef NMTDS_MapOfPassKeyBoolean::Iterator NMTDS_MapIteratorOfMapOfPassKeyBoolean; \r
+\r
+#undef _NCollection_MapHasher\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_PInterfPool.hxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_PInterfPool_HeaderFile\r
+#define _NMTDS_PInterfPool_HeaderFile\r
+\r
+class NMTDS_InterfPool;\r
+\r
+typedef NMTDS_InterfPool* NMTDS_PInterfPool;\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_PIterator.hxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_PIterator_HeaderFile\r
+#define _NMTDS_PIterator_HeaderFile\r
+\r
+class NMTDS_Iterator;\r
+\r
+typedef NMTDS_Iterator* NMTDS_PIterator;\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_PShapesDataStructure.hxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_PShapesDataStructure_HeaderFile\r
+#define _NMTDS_PShapesDataStructure_HeaderFile\r
+\r
+class NMTDS_ShapesDataStructure;\r
+\r
+typedef NMTDS_ShapesDataStructure* NMTDS_PShapesDataStructure;\r
+\r
+#endif\r
--- /dev/null
+// 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 <NMTDS_Pair.hxx>
+
+#include <stdio.h>
+#include <string.h>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+
+#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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_Pair.hxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_Pair_HeaderFile\r
+#define _NMTDS_Pair_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+\r
+//=======================================================================\r
+//function : NMTDS_Pair\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_Pair {\r
+ public:\r
+ Standard_EXPORT \r
+ NMTDS_Pair();\r
+\r
+ Standard_EXPORT\r
+ virtual ~NMTDS_Pair();\r
+ \r
+ Standard_EXPORT \r
+ NMTDS_Pair(const NMTDS_Pair& Other);\r
+\r
+ Standard_EXPORT\r
+ NMTDS_Pair& operator =(const NMTDS_Pair& Other);\r
+ \r
+ Standard_EXPORT\r
+ void Clear() ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1,\r
+ const Standard_Integer aI2) ;\r
+ \r
+ Standard_EXPORT\r
+ void Ids(Standard_Integer& aI1,\r
+ Standard_Integer& aI2) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsEqual(const NMTDS_Pair& aOther) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer HashCode(const Standard_Integer Upper) const;\r
+\r
+protected:\r
+Standard_Integer myId1;\r
+Standard_Integer myId2;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <NMTDS_PairBoolean.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_PairBoolean.hxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_PairBoolean_HeaderFile\r
+#define _NMTDS_PairBoolean_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <NMTDS_Pair.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_PairBoolean\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_PairBoolean : public NMTDS_Pair {\r
+ public:\r
+ Standard_EXPORT\r
+ NMTDS_PairBoolean();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~NMTDS_PairBoolean();\r
+ \r
+ Standard_EXPORT\r
+ void SetFlag(const Standard_Boolean aFlag) ;\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_PairBoolean& operator =(const NMTDS_PairBoolean& Other);\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean Flag() const;\r
+\r
+protected:\r
+ Standard_Boolean myFlag;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <NMTDS_PairMapHasher.hxx>
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_PairMapHasher.cxx\r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_PairMapHasher_HeaderFile\r
+#define _NMTDS_PairMapHasher_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <NMTDS_Pair.hxx>\r
+#include <Standard_Boolean.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_PairMapHasher\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_PairMapHasher {\r
+ public:\r
+ Standard_EXPORT\r
+ static Standard_Integer HashCode(const NMTDS_Pair& aPKey,\r
+ const Standard_Integer Upper) ;\r
+ \r
+ Standard_EXPORT \r
+ static Standard_Boolean IsEqual(const NMTDS_Pair& aPKey1,\r
+ const NMTDS_Pair& aPKey2) ;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <peter@PREFEX>
+//
+#include <NMTDS_PassKey.hxx>
+
+#include <stdio.h>
+#include <string.h>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+
+#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<aOther.myNbIds) {
+ return bRet;
+ }
+ for (i=1; i<=aOther.myNbIds; ++i) {
+ aId=aOther.myMap(i);
+ if (!myMap.Contains(aId)) {
+ return bRet;
+ }
+ }
+ return !bRet;
+}
+//=======================================================================
+//function :Intersected
+//purpose :
+//=======================================================================
+ Standard_Boolean NMTDS_PassKey::Intersected(const NMTDS_PassKey& aOther) const
+{
+ Standard_Boolean bRet;
+ Standard_Integer i, aId;
+ //
+ bRet=Standard_False;
+ //
+ for (i=1; i<=myNbIds; ++i) {
+ aId=myMap(i);
+ if (aOther.Contains(aId)) {
+ return !bRet;
+ }
+ }
+ return bRet;
+}
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+ void NMTDS_PassKey::Add(const Standard_Integer aId)
+{
+ TColStd_ListOfInteger aLI;
+ aLI.Append(aId);
+ //
+ Add(aLI);
+}
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+ void NMTDS_PassKey::Add(const NMTDS_PassKey& aOther)
+{
+ Standard_Integer i, aId;
+ TColStd_ListOfInteger aLS;
+ //
+ for(i=1; i<=myNbIds; ++i) {
+ aId=myMap(i);
+ aLS.Append(aId);
+ }
+ for(i=1; i<=aOther.myNbIds; ++i) {
+ aId=aOther.myMap(i);
+ aLS.Append(aId);
+ }
+ //
+ Add(aLS);
+}
+//=======================================================================
+//function : Add
+//purpose :
+//=======================================================================
+ void NMTDS_PassKey::Add(const TColStd_ListOfInteger& aLI)
+{
+ Standard_Integer i, aId;
+ TColStd_ListOfInteger aLS;
+ TColStd_ListIteratorOfListOfInteger aIt;
+ //
+ for(i=1; i<=myNbIds; ++i) {
+ aId=myMap(i);
+ aLS.Append(aId);
+ }
+ aIt.Initialize(aLI);
+ for (; aIt.More(); aIt.Next()) {
+ aId=aIt.Value();
+ aLS.Append(aId);
+ }
+ //
+ SetIds(aLS);
+}
+//=========
+*/
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_PassKey.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <peter@PREFEX>\r
+//\r
+#ifndef _NMTDS_PassKey_HeaderFile\r
+#define _NMTDS_PassKey_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TColStd_IndexedMapOfInteger.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TColStd_ListOfInteger.hxx>\r
+\r
+//=======================================================================\r
+//function : NMTDS_PassKey\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_PassKey {\r
+ public:\r
+ Standard_EXPORT \r
+ NMTDS_PassKey();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~NMTDS_PassKey();\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_PassKey(const NMTDS_PassKey& Other);\r
+\r
+ Standard_EXPORT \r
+ NMTDS_PassKey& operator =(const NMTDS_PassKey& Other);\r
+ \r
+ Standard_EXPORT\r
+ void Clear() ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1,\r
+ const Standard_Integer aI2) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1,\r
+ const Standard_Integer aI2,\r
+ const Standard_Integer aI3) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const Standard_Integer aI1,\r
+ const Standard_Integer aI2,\r
+ const Standard_Integer aI3,\r
+ const Standard_Integer aI4) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetIds(const TColStd_ListOfInteger& aLS) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer NbIds() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsEqual(const NMTDS_PassKey& aOther) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer HashCode(const Standard_Integer Upper) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer Id(const Standard_Integer aIndex) const;\r
+ \r
+ Standard_EXPORT\r
+ void Ids(Standard_Integer& aI1,Standard_Integer& aI2) const;\r
+ \r
+ Standard_EXPORT\r
+ void Dump(const Standard_Integer aHex = 0) const;\r
+\r
+protected:\r
+ Standard_Integer myNbIds;\r
+ Standard_Integer mySum;\r
+ TColStd_IndexedMapOfInteger myMap;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTDS_PassKeyBoolean.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_PassKeyBoolean.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTDS_PassKeyBoolean_HeaderFile\r
+#define _NMTDS_PassKeyBoolean_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <NMTDS_PassKey.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_PassKeyBoolean\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_PassKeyBoolean : public NMTDS_PassKey {\r
+ public:\r
+ Standard_EXPORT \r
+ NMTDS_PassKeyBoolean();\r
+\r
+ Standard_EXPORT\r
+ virtual ~NMTDS_PassKeyBoolean();\r
+ \r
+ Standard_EXPORT\r
+ void SetFlag(const Standard_Boolean aFlag) ;\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_PassKeyBoolean& operator =(const NMTDS_PassKeyBoolean& Other);\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean Flag() const;\r
+\r
+ protected:\r
+ Standard_Boolean myFlag;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTDS_PassKeyMapHasher.hxx>
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_PassKeyMapHasher.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTDS_PassKeyMapHasher_HeaderFile\r
+#define _NMTDS_PassKeyMapHasher_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <NMTDS_PassKey.hxx>\r
+#include <Standard_Boolean.hxx>\r
+\r
+\r
+//=======================================================================\r
+//function : NMTDS_PassKeyMapHasher\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_PassKeyMapHasher {\r
+ public:\r
+ Standard_EXPORT\r
+ static Standard_Integer HashCode(const NMTDS_PassKey& aPKey,\r
+ const Standard_Integer Upper) ;\r
+ \r
+ Standard_EXPORT \r
+ static Standard_Boolean IsEqual(const NMTDS_PassKey& aPKey1,\r
+ const NMTDS_PassKey& aPKey2) ;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTDS_PassKeyShape.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopoDS_Shape.hxx>
+
+
+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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_PassKeyShape.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTDS_PassKeyShape_HeaderFile\r
+#define _NMTDS_PassKeyShape_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TopTools_IndexedMapOfShape.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+\r
+//=======================================================================\r
+//function : NMTDS_PassKeyShape\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_PassKeyShape {\r
+ public:\r
+ Standard_EXPORT\r
+ NMTDS_PassKeyShape();\r
+ \r
+ Standard_EXPORT \r
+ virtual ~NMTDS_PassKeyShape();\r
+ \r
+ Standard_EXPORT \r
+ NMTDS_PassKeyShape(const NMTDS_PassKeyShape& Other);\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_PassKeyShape& Assign(const NMTDS_PassKeyShape& Other) ;\r
+ \r
+ NMTDS_PassKeyShape& operator =(const NMTDS_PassKeyShape& Other) {\r
+ return Assign(Other);\r
+ }\r
+ \r
+ Standard_EXPORT \r
+ void SetShapes(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopoDS_Shape& aS1,\r
+ const TopoDS_Shape& aS2) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopoDS_Shape& aS1,\r
+ const TopoDS_Shape& aS2,\r
+ const TopoDS_Shape& aS3) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopoDS_Shape& aS1,\r
+ const TopoDS_Shape& aS2,\r
+ const TopoDS_Shape& aS3,\r
+ const TopoDS_Shape& aS4) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShapes(const TopTools_ListOfShape& aLS) ;\r
+ \r
+ Standard_EXPORT\r
+ void Clear() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer NbIds() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsEqual(const NMTDS_PassKeyShape& aOther) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer HashCode(const Standard_Integer Upper) const;\r
+ \r
+ Standard_EXPORT\r
+ void Dump(const Standard_Integer aHex = 0) const;\r
+\r
+ protected:\r
+ Standard_Integer myNbIds;\r
+ Standard_Integer mySum;\r
+ Standard_Integer myUpper;\r
+ TopTools_IndexedMapOfShape myMap;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTDS_PassKeyShapeMapHasher.hxx>
+
+//=======================================================================
+//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);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTDS_PassKeyMapHasher.cxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTDS_PassKeyShapeMapHasher_HeaderFile\r
+#define _NMTDS_PassKeyShapeMapHasher_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <NMTDS_PassKeyShape.hxx>\r
+#include <Standard_Boolean.hxx>\r
+\r
+//=======================================================================\r
+//function : NMTDS_PassKeyShapeMapHasher\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_PassKeyShapeMapHasher {\r
+ public:\r
+ Standard_EXPORT\r
+ static Standard_Integer HashCode(const NMTDS_PassKeyShape& aPKey,\r
+ const Standard_Integer Upper) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean IsEqual(const NMTDS_PassKeyShape& aPKey1,\r
+ const NMTDS_PassKeyShape& aPKey2) ;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <NMTDS_ShapesDataStructure.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx>
+#include <NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx>
+#include <NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx>
+#include <BooleanOperations_ShapeAndInterferences.hxx>
+#include <NMTDS_IndexRange.hxx>
+//
+#include <BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx>
+#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <NMTDS_Tools.hxx>
+
+
+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; i<aNbSuccessors; ++i) {
+ nSx=pSuccessors[i];
+ GetAllSuccessorsS(nSx, myDS, aMA);
+ }
+}
+//=======================================================================
+// function: ComputeBoxExS
+// purpose:
+//=======================================================================
+void ComputeBoxExS(const Standard_Integer aIx,
+ const NMTDS_ShapesDataStructure* pDS,
+ Bnd_Box& aBoxEx)
+{
+ Standard_Integer i, aNbS, iS;
+ //
+ const Bnd_Box& aBox=pDS->GetBoundingBox(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);
+ }
+}
--- /dev/null
+\r
+#ifndef _NMTDS_ShapesDataStructure_HeaderFile\r
+#define _NMTDS_ShapesDataStructure_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <NMTDS_CArray1OfIndexRange.hxx>\r
+#include <TopTools_DataMapOfShapeInteger.hxx>\r
+#include <BooleanOperations_ShapesDataStructure.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <NMTDS_CArray1OfIndexRange.hxx>\r
+#include <BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors.hxx>\r
+#include <TColStd_IndexedMapOfInteger.hxx>\r
+#include <Bnd_Box.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTDS_ShapesDataStructure\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_ShapesDataStructure : public BooleanOperations_ShapesDataStructure\r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ NMTDS_ShapesDataStructure();\r
+ \r
+ Standard_EXPORT\r
+ void SetCompositeShape(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void Init() ;\r
+ \r
+ Standard_EXPORT\r
+ const NMTDS_CArray1OfIndexRange& Ranges() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& CompositeShape() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer ShapeRangeIndex(const Standard_Integer aId) const;\r
+ \r
+ Standard_EXPORT\r
+ virtual Standard_Integer Rank(const Standard_Integer anIndex) const;\r
+ \r
+ Standard_EXPORT\r
+ virtual Standard_Integer ShapeIndex(const TopoDS_Shape& aS,\r
+ const Standard_Integer iRank) const;\r
+ \r
+ Standard_EXPORT \r
+ void FillMap(const TopoDS_Shape& aS,\r
+ BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSA,\r
+ BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMS) const;\r
+ \r
+ Standard_EXPORT\r
+ void FillSubshapes(const TopoDS_Shape& aS,\r
+ BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMSA,\r
+ BooleanOperations_IndexedDataMapOfShapeAncestorsSuccessors& aMS) const;\r
+ \r
+ Standard_EXPORT \r
+ void GetAllSuccessors(const Standard_Integer anIndex,\r
+ TColStd_IndexedMapOfInteger& aScrs) const;\r
+ \r
+ Standard_EXPORT \r
+ void ComputeBoxEx(const Standard_Integer anIndex,\r
+ Bnd_Box& aBox) const;\r
+\r
+\r
+ protected:\r
+ TopoDS_Shape myCompositeShape;\r
+ NMTDS_CArray1OfIndexRange myRanges;\r
+ TopTools_DataMapOfShapeInteger myShapeIndexMap;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <NMTDS_Tools.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <gp_Pnt.hxx>
+#include <BRep_Tool.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_IndexedDataMapOfShapeShape.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <BRep_Builder.hxx>
+
+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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+\r
+// File: NMTDS_Tools.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+\r
+#ifndef _NMTDS_Tools_HeaderFile\r
+#define _NMTDS_Tools_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <TopoDS_Vertex.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_IndexedDataMapOfShapeShape.hxx>\r
+\r
+//=======================================================================\r
+//function : NMTDS_Tools\r
+//purpose : \r
+//=======================================================================\r
+class NMTDS_Tools \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ static Standard_Integer TypeToInteger(const TopAbs_ShapeEnum aT1,\r
+ const TopAbs_ShapeEnum aT2) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean HasBRep(const TopAbs_ShapeEnum aT) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Integer ComputeVV(const TopoDS_Vertex& aV1,\r
+ const TopoDS_Vertex& aV2) ;\r
+ \r
+ Standard_EXPORT\r
+ static void CopyShape(const TopoDS_Shape& aS,\r
+ TopoDS_Shape& aSC) ;\r
+ \r
+ Standard_EXPORT\r
+ static void CopyShape(const TopoDS_Shape& aS,\r
+ TopoDS_Shape& aSC,\r
+ TopTools_IndexedDataMapOfShapeShape& aMSS) ;\r
+};\r
+#endif\r
--- /dev/null
+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
--- /dev/null
+# 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
--- /dev/null
+-- 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
+-- <pkv@irinox>
+--
+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;
--- /dev/null
+// 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 <NMTTools_CheckerSI.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_IteratorCheckerSI.hxx>
+#include <NMTDS_InterfPool.hxx>
+#include <NMTTools_DEProcessor.hxx>
+#include <IntTools_Context.hxx>
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_CheckerSI.hxx\r
+// Created: Mon Feb 19 11:32:08 2007\r
+// Author: Peter KURNEV\r
+//\r
+#ifndef _NMTTools_CheckerSI_HeaderFile\r
+#define _NMTTools_CheckerSI_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <NMTTools_PaveFiller.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTTools_CheckerSI\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_CheckerSI : public NMTTools_PaveFiller\r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ NMTTools_CheckerSI();\r
+\r
+ Standard_EXPORT\r
+ virtual ~NMTTools_CheckerSI();\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer StopStatus() const;\r
+\r
+ protected:\r
+ Standard_EXPORT\r
+ virtual void Init() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Clear() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void PreparePaveBlocks(const Standard_Integer nE) ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void PreparePaveBlocks(const TopAbs_ShapeEnum aType1,\r
+ const TopAbs_ShapeEnum aType2) ;\r
+\r
+\r
+ Standard_Integer myStopStatus;\r
+};\r
+#endif\r
--- /dev/null
+// 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 <NMTTools_CheckerSI.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_IteratorCheckerSI.hxx>
+
+#include <NMTDS_InterfPool.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <BOPTools_PaveSet.hxx>
+#include <BOPTools_PaveBlockIterator.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <IntTools_Range.hxx>
+#include <BOPTools_Pave.hxx>
+#include <IntTools_ShrunkRange.hxx>
+#include <BOPTColStd_Failure.hxx>
+#include <BOPTColStd_Dump.hxx>
+#include <Geom_Curve.hxx>
+#include <gp_Pnt.hxx>
+
+
+
+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; i<aNbP-1 && !bRet ; ++i) {
+ aTC=aTV1+dT*i;
+ aC->D0(aTC, aPC);
+ aD2=aPV.SquareDistance(aPC);
+ bRet=aD2>aTolV2;
+ }
+ return bRet;
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_CommonBlock.hxx>
+
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+//=======================================================================
+// 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;
+}
+*/
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_CommonBlock.hxx\r
+// Created: Tue Dec 9 12:23:29 2003\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+\r
+#ifndef _NMTTools_CommonBlock_HeaderFile\r
+#define _NMTTools_CommonBlock_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <BOPTools_ListOfPaveBlock.hxx>\r
+#include <TColStd_ListOfInteger.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <BOPTools_PaveBlock.hxx>\r
+\r
+\r
+//=======================================================================\r
+//function : NMTTools_CommonBlock\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_CommonBlock {\r
+ public:\r
+ Standard_EXPORT\r
+ NMTTools_CommonBlock();\r
+ \r
+ Standard_EXPORT\r
+ void AddPaveBlock(const BOPTools_PaveBlock& aPB) ;\r
+ \r
+ Standard_EXPORT\r
+ void AddFace(const Standard_Integer aF) ;\r
+ \r
+ Standard_EXPORT\r
+ void AddFaces(const TColStd_ListOfInteger& aLF) ;\r
+ \r
+ Standard_EXPORT\r
+ const BOPTools_ListOfPaveBlock& PaveBlocks() const;\r
+ \r
+ Standard_EXPORT\r
+ const TColStd_ListOfInteger& Faces() const;\r
+ \r
+ Standard_EXPORT\r
+ const BOPTools_PaveBlock& PaveBlock1() const;\r
+ \r
+ Standard_EXPORT\r
+ BOPTools_PaveBlock& PaveBlock1(const Standard_Integer anIx) ;\r
+ \r
+ Standard_EXPORT\r
+ BOPTools_PaveBlock& PaveBlockOnEdge(const Standard_Integer anIndex) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsPaveBlockOnFace(const Standard_Integer anIndex) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsPaveBlockOnEdge(const Standard_Integer anIndex) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsEqual(const NMTTools_CommonBlock& aCB) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean Contains(const BOPTools_PaveBlock& aPB) const;\r
+\r
+ protected:\r
+ BOPTools_ListOfPaveBlock myPaveBlocks;\r
+ TColStd_ListOfInteger myFaces;\r
+};\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_CommonBlockAPI.hxx>
+
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+
+#include <NMTTools_CommonBlock.hxx>
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+
+//=======================================================================
+// 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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_CommonBlockAPI.hxx\r
+// Created: Mon Dec 15 11:38:04 2003\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTTools_CommonBlockAPI_HeaderFile\r
+#define _NMTTools_CommonBlockAPI_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Address.hxx>\r
+#include <BOPTools_ListOfPaveBlock.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <NMTTools_CommonBlock.hxx>\r
+#include <NMTTools_ListOfCommonBlock.hxx>\r
+#include <BOPTools_ListOfPaveBlock.hxx>\r
+#include <BOPTools_PaveBlock.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTTools_CommonBlockAPI\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_CommonBlockAPI \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ NMTTools_CommonBlockAPI(const NMTTools_ListOfCommonBlock& aList);\r
+ \r
+//! Selector <br>\r
+ Standard_EXPORT\r
+ const NMTTools_ListOfCommonBlock& List() const;\r
+ \r
+//! Returns all PaveBlock-s (from the list) that are <br>\r
+//! common for the given edge with DS-index <anE> <br>\r
+ Standard_EXPORT\r
+ const BOPTools_ListOfPaveBlock& CommonPaveBlocks(const Standard_Integer anE) const;\r
+ \r
+//! Returns TRUE if given PaveBlock <aPB> is <br>\r
+//! common for the Blocks from the list <br>\r
+ Standard_EXPORT\r
+ Standard_Boolean IsCommonBlock(const BOPTools_PaveBlock& aPB) const;\r
+ \r
+ Standard_EXPORT\r
+ NMTTools_CommonBlock& CommonBlock(const BOPTools_PaveBlock& aPB) const;\r
+protected:\r
+//private:\r
+\r
+Standard_Address myListOfCommonBlock;\r
+BOPTools_ListOfPaveBlock myListOfPaveBlock;\r
+};\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_CommonBlockPool.cxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+\r
+\r
+#include <NMTTools_CommonBlockPool.hxx>\r
+\r
+#ifndef _Standard_OutOfRange_HeaderFile\r
+#include <Standard_OutOfRange.hxx>\r
+#endif\r
+#ifndef _Standard_OutOfMemory_HeaderFile\r
+#include <Standard_OutOfMemory.hxx>\r
+#endif\r
+ \r
+\r
+#define Array1Item NMTTools_ListOfCommonBlock\r
+#define Array1Item_hxx <NMTTools_ListOfCommonBlock.hxx>\r
+#define BOPTColStd_CArray1 NMTTools_CommonBlockPool\r
+#define BOPTColStd_CArray1_hxx <NMTTools_CommonBlockPool.hxx>\r
+#include <BOPTColStd_CArray1.gxx>\r
+\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_CommonBlockPool.hxx\r
+// Created: \r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+\r
+#ifndef _NMTTools_CommonBlockPool_HeaderFile\r
+#define _NMTTools_CommonBlockPool_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Address.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <NMTTools_ListOfCommonBlock.hxx>\r
+\r
+class Standard_OutOfRange;\r
+class Standard_OutOfMemory;\r
+\r
+\r
+\r
+//=======================================================================\r
+//class : NMTTools_CommonBlockPool\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_CommonBlockPool \r
+{\r
+ public:\r
+ Standard_EXPORT\r
+ NMTTools_CommonBlockPool(const Standard_Integer Length = 0,const Standard_Integer BlockLength = 5);\r
+ \r
+ Standard_EXPORT\r
+ void Resize(const Standard_Integer theNewLength) ;\r
+ \r
+ Standard_EXPORT\r
+ void Destroy() ;\r
+\r
+ ~NMTTools_CommonBlockPool() {\r
+ Destroy();\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer Length() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer Extent() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer FactLength() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer Append(const NMTTools_ListOfCommonBlock& Value) ;\r
+ \r
+ Standard_EXPORT\r
+ void Remove(const Standard_Integer Index) ;\r
+ \r
+ Standard_EXPORT\r
+ const NMTTools_ListOfCommonBlock& Value(const Standard_Integer Index) const;\r
+ \r
+ const NMTTools_ListOfCommonBlock& operator ()(const Standard_Integer Index) const {\r
+ return Value(Index);\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ NMTTools_ListOfCommonBlock& ChangeValue(const Standard_Integer Index) ;\r
+ \r
+ NMTTools_ListOfCommonBlock& operator ()(const Standard_Integer Index) {\r
+ return ChangeValue(Index);\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ void SetBlockLength(const Standard_Integer aBL) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer BlockLength() const;\r
+ \r
+ Standard_EXPORT\r
+ void Purge() ;\r
+\r
+protected:\r
+\r
+private:\r
+ Standard_EXPORT\r
+ NMTTools_CommonBlockPool(const NMTTools_CommonBlockPool& AnArray);\r
+ \r
+ Standard_EXPORT\r
+ NMTTools_CommonBlockPool& Assign(const NMTTools_CommonBlockPool& Other) ;\r
+ \r
+ NMTTools_CommonBlockPool& operator =(const NMTTools_CommonBlockPool& Other) {\r
+ return Assign(Other);\r
+ }\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsInvalidIndex(const Standard_Integer Index) const;\r
+\r
+\r
+ Standard_Address myStart;\r
+ Standard_Integer myLength;\r
+ Standard_Integer myFactLength;\r
+ Standard_Integer myBlockLength;\r
+ Standard_Boolean myIsAllocated;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_CoupleOfShape.hxx>
+
+//=======================================================================
+// 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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_CoupleOfShape.hxx\r
+// Created: Wed Jan 28 15:06:11 2004\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTTools_CoupleOfShape_HeaderFile\r
+#define _NMTTools_CoupleOfShape_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTTools_CoupleOfShape\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_CoupleOfShape \r
+{\r
+ public:\r
+ Standard_EXPORT \r
+ NMTTools_CoupleOfShape();\r
+ \r
+ Standard_EXPORT \r
+ void SetShape1(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ void SetShape2(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape1() const;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& Shape2() const;\r
+\r
+ protected:\r
+ TopoDS_Shape myShape1;\r
+ TopoDS_Shape myShape2;\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_DEProcessor.hxx>
+
+#include <Precision.hxx>
+
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+
+#include <gp_Pnt2d.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Lin2d.hxx>
+
+#include <ElCLib.hxx>
+
+#include <Geom2d_Curve.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dInt_GInter.hxx>
+
+#include <IntRes2d_IntersectionPoint.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Solid.hxx>
+
+#include <TopExp.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+
+#include <BRepAdaptor_Surface.hxx>
+
+#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
+
+#include <IntTools_Tools.hxx>
+#include <IntTools_Context.hxx>
+
+#include <BOPTools_DEInfo.hxx>
+#include <BOPTools_Pave.hxx>
+#include <BOPTools_ListOfPave.hxx>
+#include <BOPTools_ListIteratorOfListOfPave.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_PaveBlockIterator.hxx>
+#include <BOPTools_SSInterference.hxx>
+#include <BOPTools_PavePool.hxx>
+#include <BOPTools_PaveSet.hxx>
+#include <BOPTools_Tools3D.hxx>
+#include <BOPTools_SequenceOfCurves.hxx>
+#include <BOPTools_Curve.hxx>
+#include <BOPTools_CArray1OfSSInterference.hxx>
+#include <BOPTools_SplitShapesPool.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_InterfPool.hxx>
+
+#include <NMTTools_PaveFiller.hxx>
+
+//=======================================================================
+// 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(dT1<aDT && dT2<aDT) {
+ BOPTools_ListOfPaveBlock* pLPB=(BOPTools_ListOfPaveBlock*)&aSplitEdges;
+ pLPB->Clear();
+ 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;
+}
+
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_DEProcessor.hxx\r
+// Created: Wed Sep 12 12:10:52 2001\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+\r
+#ifndef _NMTTools_DEProcessor_HeaderFile\r
+#define _NMTTools_DEProcessor_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <NMTTools_PPaveFiller.hxx>\r
+#include <NMTDS_PShapesDataStructure.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <BOPTools_IndexedDataMapOfIntegerDEInfo.hxx>\r
+#include <NMTTools_PaveFiller.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <Standard_Real.hxx>\r
+\r
+\r
+//! <br>\r
+//! The Algorithm to compute and store in interferences' pool <br>\r
+//! and in the Data Structure the following values <br>\r
+//! for degenerated edges <br>\r
+//! 1. Paves/Pave set(s) <br>\r
+//! 2. Split parts <br>\r
+//! 3. States (3D) for split parts <br>\r
+//! <br>\r
+//=======================================================================\r
+//class : NMTTools_DEProcessor\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_DEProcessor {\r
+public:\r
+\r
+\r
+ \r
+//! Constructor <br>\r
+//! <br>\r
+//! Constructor <br>\r
+//! <br>\r
+ Standard_EXPORT \r
+ NMTTools_DEProcessor(NMTTools_PaveFiller& aFiller);\r
+ \r
+//! Launches the processor <br>\r
+ Standard_EXPORT \r
+ void Do() ;\r
+ \r
+//! Returns TRUE if it is Ok <br>\r
+ Standard_EXPORT \r
+ Standard_Boolean IsDone() const;\r
+\r
+\r
+\r
+protected:\r
+ Standard_EXPORT\r
+ void FindDegeneratedEdges() ;\r
+ \r
+ Standard_EXPORT\r
+ void DoPaves() ;\r
+ \r
+ Standard_EXPORT\r
+ void FindPaveBlocks(const Standard_Integer nED,\r
+ const Standard_Integer nVD,\r
+ const Standard_Integer nFD,\r
+ BOPTools_ListOfPaveBlock& aLPB) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillPaveSet(const Standard_Integer nED,\r
+ const Standard_Integer nVD,\r
+ const Standard_Integer nFD,\r
+ const BOPTools_ListOfPaveBlock& aLPB) ;\r
+ \r
+ Standard_EXPORT\r
+ void FillSplitEdgesPool(const Standard_Integer nED) ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeSplitEdges(const Standard_Integer nED,\r
+ const Standard_Integer nFD) ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeSplitEdge(const TopoDS_Edge& aS1,\r
+ const TopoDS_Face& aF,\r
+ const TopoDS_Vertex& aV1,\r
+ const Standard_Real aP1,\r
+ const TopoDS_Vertex& aV2,\r
+ const Standard_Real aP2,\r
+ TopoDS_Edge& aNewEdge) ;\r
+\r
+\r
+ NMTTools_PPaveFiller myFiller;\r
+ NMTDS_PShapesDataStructure myDS;\r
+ Standard_Boolean myIsDone;\r
+ BOPTools_IndexedDataMapOfIntegerDEInfo myDEMap;\r
+};\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx\r
+// Created: Mon Feb 20 12:24:47 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo_HeaderFile\r
+#define NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo_HeaderFile\r
+\r
+#ifndef NMTTools_DataMapOfIntegerFaceInfo_HeaderFile\r
+#include <NMTTools_DataMapOfIntegerFaceInfo.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// File: NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx\r
+// Created: Mon Feb 20 12:04:52 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock_HeaderFile\r
+#define NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock_HeaderFile\r
+\r
+#ifndef NMTTools_DataMapOfIntegerListOfPaveBlock_HeaderFile\r
+#include <NMTTools_DataMapOfIntegerListOfPaveBlock.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTTools_DataMapOfIntegerFaceInfo.hxx\r
+// Created: Mon Feb 20 12:21:55 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_DataMapOfIntegerFaceInfo_HeaderFile\r
+#define NMTTools_DataMapOfIntegerFaceInfo_HeaderFile\r
+\r
+#include <NMTTools_FaceInfo.hxx>\r
+#include <TColStd_MapIntegerHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+typedef NCollection_DataMap<Standard_Integer, NMTTools_FaceInfo, TColStd_MapIntegerHasher> NMTTools_DataMapOfIntegerFaceInfo; \r
+typedef NMTTools_DataMapOfIntegerFaceInfo::Iterator NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTTools_DataMapOfIntegerListOfPaveBlock.hxx\r
+// Created: Mon Feb 20 09:27:40 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_DataMapOfIntegerListOfPaveBlock_HeaderFile\r
+#define NMTTools_DataMapOfIntegerListOfPaveBlock_HeaderFile\r
+\r
+\r
+#include <TColStd_MapIntegerHasher.hxx>\r
+#include <BOPTools_ListOfPaveBlock.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_DataMap.hxx>\r
+\r
+typedef NCollection_DataMap<Standard_Integer, BOPTools_ListOfPaveBlock, TColStd_MapIntegerHasher> NMTTools_DataMapOfIntegerListOfPaveBlock; \r
+typedef NMTTools_DataMapOfIntegerListOfPaveBlock::Iterator NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_FaceInfo.hxx>
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_FaceInfo.hxx\r
+// Created: Tue Dec 9 12:23:29 2003\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTTools_FaceInfo_HeaderFile\r
+#define _NMTTools_FaceInfo_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <NMTTools_MapOfPaveBlock.hxx>\r
+#include <TColStd_MapOfInteger.hxx>\r
+#include <NMTTools_MapOfPaveBlock.hxx>\r
+#include <TColStd_MapOfInteger.hxx>\r
+\r
+//=======================================================================\r
+//class : NMTTools_FaceInfo\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_FaceInfo {\r
+ public:\r
+\r
+ //! Empty contructor <br>\r
+ //! <br>\r
+ NMTTools_FaceInfo();\r
+ \r
+ virtual ~NMTTools_FaceInfo();\r
+ \r
+ //! Clears the contents <br>\r
+ Standard_EXPORT void Clear() ;\r
+ \r
+ //! Modifier <br>\r
+ //! Sets the index of the face <theI> <br>\r
+ void SetIndex(const Standard_Integer theI) ;\r
+ \r
+ //! Selector <br>\r
+ //! Returns the index of the face <br>\r
+ //! <br>\r
+ //! In <br>\r
+ //! <br>\r
+ Standard_Integer Index() const;\r
+ \r
+ //! Selector <br>\r
+ //! Returns the pave blocks of the face <br>\r
+ //! that have state In <br>\r
+ const NMTTools_MapOfPaveBlock& PaveBlocksIn() const;\r
+ \r
+//! Selector/Modifier <br>\r
+ //! Returns the pave blocks <br>\r
+ //! of the face <br>\r
+ //! that have state In <br>\r
+ NMTTools_MapOfPaveBlock& ChangePaveBlocksIn() ;\r
+ \r
+ //! Selector <br>\r
+ //! Returns the list of indices for vertices <br>\r
+ //! of the face <br>\r
+ //! that have state In <br>\r
+ const TColStd_MapOfInteger& VerticesIn() const;\r
+ \r
+ //! Selector/Modifier <br>\r
+ //! Returns the list of indices for vertices <br>\r
+ //! of the face <br>\r
+ //! that have state In <br>\r
+ //! <br>\r
+ //! On <br>\r
+ //! <br>\r
+ TColStd_MapOfInteger& ChangeVerticesIn() ;\r
+ \r
+ //! Selector <br>\r
+ //! Returns the pave blocks of the face <br>\r
+ //! that have state On <br>\r
+ const NMTTools_MapOfPaveBlock& PaveBlocksOn() const;\r
+ \r
+ //! Selector/Modifier <br>\r
+ //! Returns the pave blocks <br>\r
+ //! of the face <br>\r
+ //! that have state On <br>\r
+ NMTTools_MapOfPaveBlock& ChangePaveBlocksOn() ;\r
+ \r
+ //! Selector <br>\r
+ //! Returns the list of indices for vertices <br>\r
+ //! of the face <br>\r
+ //! that have state On <br>\r
+ const TColStd_MapOfInteger& VerticesOn() const;\r
+ \r
+ //! Selector/Modifier <br>\r
+ //! Returns the list of indices for vertices <br>\r
+ //! of the face <br>\r
+ //! that have state On <br>\r
+ TColStd_MapOfInteger& ChangeVerticesOn() ;\r
+ \r
+ protected:\r
+ Standard_Integer myIndex;\r
+ NMTTools_MapOfPaveBlock myPaveBlocksIn;\r
+ TColStd_MapOfInteger myVerticesIn;\r
+ NMTTools_MapOfPaveBlock myPaveBlocksOn;\r
+ TColStd_MapOfInteger myVerticesOn;\r
+};\r
+\r
+#include <NMTTools_FaceInfo.lxx>\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+
+//=======================================================================
+//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;
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx\r
+// Created: Mon Feb 20 09:20:07 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_IndexedDataMapOfIndexedMapOfInteger_HeaderFile\r
+#define NMTTools_IndexedDataMapOfIndexedMapOfInteger_HeaderFile\r
+\r
+\r
+#include <Standard_Integer.hxx>\r
+#include <TColStd_MapIntegerHasher.hxx>\r
+#include <TColStd_IndexedMapOfInteger.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+typedef NCollection_IndexedDataMap <Standard_Integer, TColStd_IndexedMapOfInteger, TColStd_MapIntegerHasher> NMTTools_IndexedDataMapOfIndexedMapOfInteger; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx\r
+// Created: Mon Feb 20 09:20:07 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+// File: NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx\r
+// Created: Mon Feb 20 11:59:23 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_HeaderFile\r
+#define NMTTools_IndexedDataMapOfShapeIndexedMapOfShape_HeaderFile\r
+\r
+\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_ShapeMapHasher.hxx>\r
+#include <TopTools_IndexedMapOfShape.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+\r
+typedef NCollection_IndexedDataMap <TopoDS_Shape, TopTools_IndexedMapOfShape, TopTools_ShapeMapHasher> NMTTools_IndexedDataMapOfShapeIndexedMapOfShape; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+#endif\r
+\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTTools_IndexedDataMapOfShapePaveBlock.hxx\r
+// Created: Mon Feb 20 11:55:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_IndexedDataMapOfShapePaveBlock_HeaderFile\r
+#define NMTTools_IndexedDataMapOfShapePaveBlock_HeaderFile\r
+\r
+#include <TopoDS_Shape.hxx>\r
+#include <TopTools_ShapeMapHasher.hxx>\r
+#include <BOPTools_PaveBlock.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_IndexedDataMap.hxx>\r
+\r
+typedef NCollection_IndexedDataMap <TopoDS_Shape, BOPTools_PaveBlock, TopTools_ShapeMapHasher> NMTTools_IndexedDataMapOfShapePaveBlock; \r
+ \r
+#undef _NCollection_MapHasher\r
+\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListIteratorOfListOfCommonBlock.hxx\r
+// Created: Mon Feb 20 11:25:23 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+#ifndef NMTDS_ListIteratorOfListOfCommonBlock_HeaderFile\r
+#define NMTDS_ListIteratorOfListOfCommonBlock_HeaderFile\r
+\r
+#ifndef NMTTools_ListOfCommonBlock_HeaderFile\r
+#include <NMTTools_ListOfCommonBlock.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTDS_ListIteratorOfListOfCoupleOfShape.hxx\r
+// Created: Mon Feb 20 11:25:23 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+#ifndef NMTDS_ListIteratorOfListOfCoupleOfShape_HeaderFile\r
+#define NMTDS_ListIteratorOfListOfCoupleOfShape_HeaderFile\r
+\r
+#ifndef NMTTools_ListOfCoupleOfShape_HeaderFile\r
+#include <NMTTools_ListOfCoupleOfShape.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTTools_ListOfCommonBlock.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+#ifndef NMTTools_ListOfCommonBlock_HeaderFile\r
+#define NMTTools_ListOfCommonBlock_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <NMTTools_CommonBlock.hxx>\r
+\r
+typedef NCollection_List <NMTTools_CommonBlock> NMTTools_ListOfCommonBlock; \r
+typedef NMTTools_ListOfCommonBlock::Iterator NMTTools_ListIteratorOfListOfCommonBlock; \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// File: NMTTools_ListOfCoupleOfShape.hxx\r
+// Created: Mon Feb 20 07:27:34 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+#ifndef NMTTools_ListOfCoupleOfShape_HeaderFile\r
+#define NMTTools_ListOfCoupleOfShape_HeaderFile\r
+\r
+#include <NCollection_List.hxx> \r
+#include <NMTTools_CoupleOfShape.hxx>\r
+\r
+typedef NCollection_List <NMTTools_CoupleOfShape> NMTTools_ListOfCoupleOfShape; \r
+typedef NMTTools_ListOfCoupleOfShape::Iterator NMTTools_ListIteratorOfListOfCoupleOfShape; \r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+// <pkv@BDEURI37616>\r
+// File: NMTTools_MapIteratorOfMapOfPaveBlock.hxx\r
+// Created: Mon Feb 20 11:47:30 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_MapIteratorOfMapOfPaveBlock_HeaderFile\r
+#define NMTTools_MapIteratorOfMapOfPaveBlock_HeaderFile\r
+\r
+#ifndef NMTTools_MapOfPaveBlock_HeaderFile\r
+#include <NMTTools_MapOfPaveBlock.hxx>\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_MapOfPaveBlock.hxx\r
+// Created: Mon Feb 20 08:19:07 2012\r
+// Author: \r
+// <pkv@BDEURI37616>\r
+\r
+\r
+#ifndef NMTTools_MapOfPaveBlock_HeaderFile\r
+#define NMTTools_MapOfPaveBlock_HeaderFile\r
+\r
+#include <BOPTools_PaveBlock.hxx> \r
+#include <BOPTools_PaveBlockMapHasher.hxx>\r
+\r
+#define _NCollection_MapHasher\r
+#include <NCollection_Map.hxx> \r
+\r
+typedef NCollection_Map<BOPTools_PaveBlock, BOPTools_PaveBlockMapHasher> NMTTools_MapOfPaveBlock; \r
+typedef NMTTools_MapOfPaveBlock::Iterator NMTTools_MapIteratorOfMapOfPaveBlock; \r
+\r
+#undef _NCollection_MapHasher\r
+\r
+#endif\r
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_PPaveFiller.hxx\r
+// Created: Tue Dec 9 12:23:29 2003\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTTools_PPaveFiller_HeaderFile\r
+#define _NMTTools_PPaveFiller_HeaderFile\r
+\r
+class NMTTools_PaveFiller;\r
+\r
+typedef NMTTools_PaveFiller* NMTTools_PPaveFiller;\r
+\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
+//
+#include <BOPTColStd_Failure.hxx>
+#include <IntTools_Context.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTTools_DEProcessor.hxx>
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_InterfPool.hxx>
+
+//=======================================================================
+// 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& ) {
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_PaveFiller.hxx\r
+// Created: Fri Dec 5 14:58:54 2003\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+//\r
+#ifndef _NMTTools_PaveFiller_HeaderFile\r
+#define _NMTTools_PaveFiller_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <NMTDS_PShapesDataStructure.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Standard_Integer.hxx>\r
+#include <BOPTools_PavePool.hxx>\r
+#include <NMTTools_CommonBlockPool.hxx>\r
+#include <BOPTools_SplitShapesPool.hxx>\r
+#include <Handle_IntTools_Context.hxx>\r
+#include <BOPTools_SSIntersectionAttribute.hxx>\r
+#include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>\r
+#include <TColStd_DataMapOfIntegerInteger.hxx>\r
+#include <NMTDS_PIterator.hxx>\r
+#include <TopoDS_Shape.hxx>\r
+#include <NMTDS_PInterfPool.hxx>\r
+#include <NMTTools_DataMapOfIntegerFaceInfo.hxx>\r
+#include <TopAbs_ShapeEnum.hxx>\r
+#include <NMTTools_CommonBlock.hxx>\r
+#include <Standard_Real.hxx>\r
+\r
+#include <TopoDS_Shape.hxx>\r
+#include <BOPTools_Pave.hxx>\r
+#include <IntTools_ShrunkRange.hxx>\r
+#include <BOPTools_PavePool.hxx>\r
+#include <NMTTools_CommonBlockPool.hxx>\r
+#include <BOPTools_SplitShapesPool.hxx>\r
+#include <BOPTools_PaveBlock.hxx>\r
+#include <TopoDS_Vertex.hxx>\r
+#include <NMTTools_ListOfCommonBlock.hxx>\r
+#include <BOPTools_IDMapOfPaveBlockIMapOfPaveBlock.hxx>\r
+#include <BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx>\r
+#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>\r
+#include <TColStd_ListOfInteger.hxx>\r
+#include <BOPTools_ListOfPaveBlock.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <BOPTools_PaveSet.hxx>\r
+#include <BOPTools_Curve.hxx>\r
+#include <BOPTools_SSInterference.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopoDS_Edge.hxx>\r
+#include <TopTools_DataMapOfShapeShape.hxx>\r
+\r
+\r
+/*\r
+class TopoDS_Shape;\r
+class BOPTools_Pave;\r
+class IntTools_ShrunkRange;\r
+class BOPTools_PavePool;\r
+class NMTTools_CommonBlockPool;\r
+class BOPTools_SplitShapesPool;\r
+class BOPTools_PaveBlock;\r
+class TopoDS_Vertex;\r
+class NMTTools_ListOfCommonBlock;\r
+class BOPTools_IDMapOfPaveBlockIMapOfPaveBlock;\r
+class BOPTools_IDMapOfPaveBlockIMapOfInteger;\r
+class BooleanOperations_IndexedDataMapOfShapeInteger;\r
+class TColStd_ListOfInteger;\r
+class BOPTools_ListOfPaveBlock;\r
+class TopoDS_Face;\r
+class BOPTools_PaveSet;\r
+class BOPTools_Curve;\r
+class BOPTools_SSInterference;\r
+class gp_Pnt;\r
+class NMTTools_IndexedDataMapOfIndexedMapOfInteger;\r
+class TopTools_ListOfShape;\r
+class TopoDS_Edge;\r
+class TopTools_DataMapOfShapeShape;\r
+class TCoLSTD_MapOfInteger;\r
+*/\r
+\r
+\r
+//=======================================================================\r
+//function : NMTTools_PaveFiller\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_PaveFiller {\r
+ public:\r
+ Standard_EXPORT\r
+ NMTTools_PaveFiller();\r
+ \r
+ Standard_EXPORT\r
+ virtual ~NMTTools_PaveFiller();\r
+ \r
+ Standard_EXPORT\r
+ void SetCompositeShape(const TopoDS_Shape& aS) ;\r
+ \r
+ Standard_EXPORT\r
+ const TopoDS_Shape& CompositeShape() const;\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_PShapesDataStructure DS() ;\r
+ \r
+ Standard_EXPORT\r
+ NMTDS_PIterator DSIt() ;\r
+ \r
+ Standard_EXPORT \r
+ NMTDS_PInterfPool IP() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void Perform() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsDone() const;\r
+ \r
+ Standard_EXPORT\r
+ const Handle_IntTools_Context& Context() const;\r
+ \r
+ Standard_EXPORT\r
+ const BOPTools_PavePool& PavePool() const;\r
+ \r
+ Standard_EXPORT\r
+ BOPTools_PavePool& ChangePavePool() ;\r
+ \r
+ Standard_EXPORT\r
+ const NMTTools_CommonBlockPool& CommonBlockPool() const;\r
+ \r
+ Standard_EXPORT\r
+ NMTTools_CommonBlockPool& ChangeCommonBlockPool() ;\r
+ \r
+ Standard_EXPORT\r
+ const BOPTools_SplitShapesPool& SplitShapesPool() const;\r
+ \r
+ Standard_EXPORT\r
+ BOPTools_SplitShapesPool& ChangeSplitShapesPool() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer FindSDVertex(const Standard_Integer nV) const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsInFace(const Standard_Integer aBid,\r
+ const Standard_Integer nF1,\r
+ const Standard_Integer nF2,\r
+ TColStd_ListOfInteger& aLs) ;\r
+ \r
+ Standard_EXPORT \r
+ Standard_Integer SplitsInFace(const Standard_Integer nE1,\r
+ const Standard_Integer nF2,\r
+ TColStd_ListOfInteger& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsOnEdge(const Standard_Integer nE1,\r
+ const Standard_Integer nE2,\r
+ TColStd_ListOfInteger& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsOnFace(const Standard_Integer nE1,\r
+ const Standard_Integer nF2,\r
+ TColStd_ListOfInteger& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsOnFace(const Standard_Integer aBid,\r
+ const Standard_Integer nF1,\r
+ const Standard_Integer nF2,\r
+ TColStd_ListOfInteger& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsInFace(const Standard_Integer aBid,\r
+ const Standard_Integer nF1,\r
+ const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsInFace(const Standard_Integer nE1,\r
+ const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsOnEdge(const Standard_Integer nE1,\r
+ const Standard_Integer nE2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsOnFace(const Standard_Integer nE1,\r
+ const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsOnFace(const Standard_Integer aBid,\r
+ const Standard_Integer nF1,\r
+ const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsFace(const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitsFace(const Standard_Integer nF2,\r
+ TColStd_ListOfInteger& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer CommonBlocksFace(const Standard_Integer nF,\r
+ NMTTools_ListOfCommonBlock& aLCB) ;\r
+ \r
+ Standard_EXPORT\r
+ void PrepareFace(const Standard_Integer nF,\r
+ TopoDS_Face& aF) ;\r
+ \r
+ Standard_EXPORT\r
+ const BOPTools_PaveBlock& RealPaveBlock(const BOPTools_PaveBlock& aPB) ;\r
+ \r
+ Standard_EXPORT\r
+ const BOPTools_PaveBlock& RealPaveBlock(const BOPTools_PaveBlock& aPB,\r
+ TColStd_ListOfInteger& aLB,\r
+ Standard_Integer& aIsCommonBlock) ;\r
+ \r
+ Standard_EXPORT\r
+ void RealSplitsFace(const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean HasRealSplitsInOnFace(const Standard_Integer nF1,\r
+ const Standard_Integer nF2) ;\r
+ \r
+ Standard_EXPORT\r
+ void RealSplitsInFace(const Standard_Integer aBid,\r
+ const Standard_Integer nF1,\r
+ const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ void RealSplitsInFace(const Standard_Integer nE1,\r
+ const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ void RealSplitsInFace(const Standard_Integer nF1,\r
+ BOPTools_ListOfPaveBlock& aLPB) ;\r
+ \r
+ Standard_EXPORT\r
+ void RealSplitsOnEdge(const Standard_Integer nE1,\r
+ const Standard_Integer nE2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ void RealSplitsOnFace(const Standard_Integer nE1,\r
+ const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ void RealSplitsOnFace(const Standard_Integer aBid,\r
+ const Standard_Integer nF1,\r
+ const Standard_Integer nF2,\r
+ BOPTools_ListOfPaveBlock& aLs) ;\r
+ \r
+ Standard_EXPORT\r
+ void PrepareSetForFace(const Standard_Integer nF1,\r
+ const Standard_Integer nF2,\r
+ const BOPTools_ListOfPaveBlock& aLPB,\r
+ BOPTools_PaveSet& aPSF) ;\r
+ \r
+ Standard_EXPORT\r
+ void PutPaveOnCurve(const BOPTools_PaveSet& aPSF,\r
+ const Standard_Real aTol,\r
+ BOPTools_Curve& aBC) ;\r
+ \r
+ Standard_EXPORT\r
+ void PutBoundPaveOnCurve(BOPTools_Curve& aBC,\r
+ BOPTools_SSInterference& aFF) ;\r
+ \r
+ Standard_EXPORT\r
+ void PutBoundPaveOnCurve(const gp_Pnt& aP,\r
+ const Standard_Real aT,\r
+ BOPTools_Curve& aBC,\r
+ BOPTools_SSInterference& aFF) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean FindPave(const gp_Pnt& aP,\r
+ const Standard_Real aTpV,\r
+ const BOPTools_PaveSet& aPS,\r
+ BOPTools_Pave& aPV) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,\r
+ const BOPTools_PaveBlock& aPBR,\r
+ const Standard_Real aTol) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsExistingPaveBlock(const BOPTools_PaveBlock& aPB,\r
+ const BOPTools_ListOfPaveBlock& aLPB,\r
+ const Standard_Real aTol) ;\r
+ \r
+ Standard_EXPORT\r
+ void MakePCurves() ;\r
+ \r
+ Standard_EXPORT\r
+ const NMTTools_IndexedDataMapOfIndexedMapOfInteger& AloneVertices() const;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsExistingPaveBlock(const BOPTools_PaveBlock& aPB,\r
+ const TopTools_ListOfShape& aLPB,\r
+ const Standard_Real aTol) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean CheckCoincidence(const BOPTools_PaveBlock& aPB,\r
+ const BOPTools_ListOfPaveBlock& aLPB) ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer CheckIntermediatePoint(const BOPTools_PaveBlock& aPB,\r
+ const TopoDS_Edge& aE,\r
+ const Standard_Real aTol) ;\r
+ \r
+ Standard_EXPORT\r
+ void SharedEdges(const Standard_Integer nF1,\r
+ const Standard_Integer nF2,\r
+ TColStd_ListOfInteger& aLNE,\r
+ TopTools_ListOfShape& aLSE) ;\r
+ \r
+ Standard_EXPORT\r
+ void FuseVertices(const TopoDS_Shape& aC,\r
+ TopTools_DataMapOfShapeShape& aDMVV) const;\r
+ \r
+ Standard_EXPORT\r
+ void TreatPaveBlocks(NMTTools_ListOfCommonBlock& theLCB) ;\r
+ \r
+ Standard_EXPORT\r
+ BOPTools_PavePool& ChangePavePoolNew() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean CheckCoincidence(const BOPTools_PaveBlock& aPB1,\r
+ const BOPTools_PaveBlock& aPB2) ;\r
+ \r
+ Standard_EXPORT\r
+ void PutClosingPaveOnCurve(BOPTools_Curve& aBC,\r
+ BOPTools_SSInterference& aFF) ;\r
+\r
+ protected:\r
+ Standard_EXPORT \r
+ virtual void Init() ;\r
+\r
+ Standard_EXPORT \r
+ virtual void Clear() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void PerformVV() ;\r
+ \r
+ Standard_EXPORT \r
+ virtual void PerformVE() ;\r
+ \r
+ Standard_EXPORT \r
+ virtual void PerformVF() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void PerformEE() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void PerformEF() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void PerformFF() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeSplitEdges() ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void PreparePaveBlocks(const TopAbs_ShapeEnum aType1,\r
+ const TopAbs_ShapeEnum aType2) ;\r
+ \r
+ Standard_EXPORT \r
+ void CorrectShrunkRanges(const Standard_Integer aSide,\r
+ const BOPTools_Pave& aPave,\r
+ IntTools_ShrunkRange& aSR) ;\r
+ \r
+ Standard_EXPORT\r
+ virtual void PreparePaveBlocks(const Standard_Integer anE) ;\r
+ \r
+ Standard_EXPORT \r
+ virtual void PrepareEdges() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Boolean IsSuccessorsComputed(const Standard_Integer iF1,\r
+ const Standard_Integer iF2) const;\r
+ \r
+ Standard_EXPORT \r
+ Standard_Boolean IsBlocksCoinside(const BOPTools_PaveBlock& aPB1,\r
+ const BOPTools_PaveBlock& aPB2) const;\r
+ \r
+ Standard_EXPORT \r
+ void RefinePavePool() ;\r
+ \r
+ Standard_EXPORT \r
+ Standard_Integer CheckFacePaves(const TopoDS_Vertex& aV,\r
+ const Standard_Integer nF) ;\r
+ \r
+ Standard_EXPORT \r
+ void ReplaceCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ;\r
+ \r
+ Standard_EXPORT\r
+ void RemoveCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ;\r
+ \r
+ Standard_EXPORT\r
+ void SplitCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB) ;\r
+ \r
+ Standard_EXPORT\r
+ void SplitCommonBlock(const NMTTools_CommonBlock& aCB,NMTTools_ListOfCommonBlock& aLCB) ;\r
+ \r
+ Standard_EXPORT\r
+ void EECommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfPaveBlock& aM) ;\r
+ \r
+ Standard_EXPORT\r
+ void EFCommonBlocks(const BOPTools_IDMapOfPaveBlockIMapOfInteger& aMapCB) ;\r
+ \r
+ Standard_EXPORT\r
+ void EENewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ;\r
+ \r
+ Standard_EXPORT\r
+ void EENewVertices(const TopoDS_Vertex& aV,\r
+ const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ;\r
+ \r
+ Standard_EXPORT \r
+ void EFNewVertices(const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ;\r
+ \r
+ Standard_EXPORT\r
+ void EFNewVertices(const TopoDS_Vertex& aV,\r
+ const BooleanOperations_IndexedDataMapOfShapeInteger& aM) ;\r
+ \r
+ Standard_EXPORT \r
+ void UpdateCommonBlocks() ;\r
+ \r
+ Standard_EXPORT\r
+ void UpdateCommonBlocks(const Standard_Integer aI) ;\r
+ \r
+ Standard_EXPORT\r
+ void UpdatePaveBlocks() ;\r
+ \r
+ Standard_EXPORT\r
+ Standard_Integer SplitIndex(const BOPTools_PaveBlock& aPB) const;\r
+ \r
+ Standard_EXPORT\r
+ void MakeBlocks() ;\r
+ \r
+ Standard_EXPORT\r
+ void PerformVF1() ;\r
+ \r
+ Standard_EXPORT\r
+ void MakeAloneVertices() ;\r
+ \r
+ Standard_EXPORT\r
+ void FillFaceInfo() ;\r
+ \r
+ Standard_EXPORT\r
+ void CorrectTolR3D(const BOPTools_SSInterference& aFF,\r
+ const TColStd_MapOfInteger& aMVStick,\r
+ Standard_Real& aTolR3D) ;\r
+\r
+\r
+ NMTDS_PShapesDataStructure myDS;\r
+ Standard_Boolean myIsDone;\r
+ Standard_Integer myNbSources;\r
+ Standard_Integer myNbEdges;\r
+ BOPTools_PavePool myPavePool;\r
+ BOPTools_PavePool myPavePoolNew;\r
+ NMTTools_CommonBlockPool myCommonBlockPool;\r
+ BOPTools_SplitShapesPool mySplitShapesPool;\r
+ Handle_IntTools_Context myContext;\r
+ BOPTools_SSIntersectionAttribute mySectionAttribute;\r
+ NMTTools_IndexedDataMapOfIndexedMapOfInteger myAloneVertices;\r
+ TColStd_DataMapOfIntegerInteger myVSD;\r
+ NMTDS_PIterator myDSIt;\r
+ TopoDS_Shape myCompositeShape;\r
+ NMTDS_PInterfPool myIP;\r
+ NMTTools_DataMapOfIntegerFaceInfo myFaceInfo;\r
+\r
+\r
+ // private:\r
+\r
+};\r
+#endif\r
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <NMTDS_InterfPool.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_Iterator.hxx>
+
+//=======================================================================
+// 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;
+}
+*/
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
+
+#include <TColStd_DataMapOfIntegerListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+
+#include <IntTools_Tools.hxx>
+#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
+#include <BOPTools_VVInterference.hxx>
+#include <BOPTools_CArray1OfVVInterference.hxx>
+
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_InterfPool.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+
+#include <NMTTools_Tools.hxx>
+
+//=======================================================================
+// 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()
+{
+}
+*/
--- /dev/null
+// 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 <Standard_Version.hxx>
+
+#include <NMTTools_PaveFiller.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <Precision.hxx>
+
+#include <gp_Pnt.hxx>
+
+#include <Geom_Curve.hxx>
+
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+
+#include <BOPTools_Pave.hxx>
+#include <BOPTools_PaveSet.hxx>
+#include <BOPTools_CArray1OfVEInterference.hxx>
+#include <BOPTools_VEInterference.hxx>
+
+#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
+
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_InterfPool.hxx>
+
+
+#include <BOPTools_IndexedMapOfCoupleOfInteger.hxx>
+#include <BOPTools_CoupleOfInteger.hxx>
+#include <BooleanOperations_OnceExplorer.hxx>
+
+#include <IntTools_Context.hxx>
+
+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
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Face.hxx>
+
+#include <TopExp_Explorer.hxx>
+
+#include <BOPTools_VSInterference.hxx>
+#include <BOPTools_CArray1OfVSInterference.hxx>
+
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_InterfPool.hxx>
+#include <IntTools_Context.hxx>
+
+
+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
--- /dev/null
+// 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 <NMTTools_PaveFiller.hxx>
+
+#include <stdio.h>
+#include <Precision.hxx>
+
+#include <gp_XYZ.hxx>
+#include <gp_Pnt.hxx>
+#include <Bnd_Box.hxx>
+
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBndLib.hxx>
+
+#include <BOPTColStd_Dump.hxx>
+#include <BOPTColStd_Failure.hxx>
+
+#include <IntTools_ShrunkRange.hxx>
+#include <IntTools_Range.hxx>
+#include <IntTools_CommonPrt.hxx>
+#include <IntTools_SequenceOfRanges.hxx>
+#include <IntTools_EdgeEdge.hxx>
+#include <IntTools_SequenceOfCommonPrts.hxx>
+#include <IntTools_Tools.hxx>
+#include <IntTools_Context.hxx>
+
+#include <BOPTools_Pave.hxx>
+#include <BOPTools_PaveSet.hxx>
+#include <BOPTools_PaveBlockIterator.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_CArray1OfEEInterference.hxx>
+#include <BOPTools_EEInterference.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_CArray1OfVVInterference.hxx>
+#include <BOPTools_VVInterference.hxx>
+#include <BOPTools_CArray1OfEEInterference.hxx>
+#include <BOPTools_Tools.hxx>
+#include <BOPTools_IDMapOfPaveBlockIMapOfPaveBlock.hxx>
+#include <BOPTools_IMapOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPave.hxx>
+#include <BOPTools_SequenceOfPaveBlock.hxx>
+
+#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
+#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
+#include <BooleanOperations_KindOfInterference.hxx>
+
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_IndexedDataMapOfIntegerShape.hxx>
+#include <NMTDS_IndexedDataMapOfShapeBox.hxx>
+#include <NMTDS_BoxBndTree.hxx>
+#include <NCollection_UBTreeFiller.hxx>
+#include <NMTDS_InterfPool.hxx>
+
+#include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_CommonBlock.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <BRepBndLib.hxx>
+#include <BOPTools_CArray1OfVSInterference.hxx>
+#include <BOPTools_VSInterference.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+
+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 (aD2<aDT2) {
+ iFound=1;
+ break;
+ }
+ }
+ //
+ if (iFound) {
+ continue;
+ }
+ }
+ //
+ // Add Interference to the Pool
+ BOPTools_EEInterference anInterf (aWhat, aWith, aCPart);
+ //
+ anIndexIn=aEEs.Append(anInterf);
+ // qqf
+ {
+ myIP->Add(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 <Standard_Integer, Bnd_Box> 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; i<aNb; ++i) {
+ BOPTools_ListOfPaveBlock& aLPB=mySplitShapesPool(myDS->RefEdge(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 (d1121<aTolSum) {
+ d1222=aP12.Distance(aP22);
+ aTolSum=aCoeff*(aTolV12+aTolV22);
+ if (d1222<aTolSum) {
+ return bRetFlag;
+ }
+ }
+ //
+ d1122=aP11.Distance(aP22);
+ aTolSum=aCoeff*(aTolV11+aTolV22);
+ if (d1122<aTolSum) {
+ d1221=aP12.Distance(aP21);
+ aTolSum=aCoeff*(aTolV12+aTolV21);
+ if (d1221<aTolSum) {
+ return bRetFlag;
+ }
+ }
+ return !bRetFlag;
+}
+
+//=======================================================================
+// function: ReplaceCommonBlocks
+// purpose:
+//=======================================================================
+void NMTTools_PaveFiller::ReplaceCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB)
+{
+ RemoveCommonBlocks(aLCB);
+ SplitCommonBlocks(aLCB);
+}
+
+//=======================================================================
+// function: SplitCommonBlocks
+// purpose:
+//=======================================================================
+void NMTTools_PaveFiller::SplitCommonBlocks(const NMTTools_ListOfCommonBlock& aLCB)
+{
+ Standard_Integer nE;
+ NMTTools_ListOfCommonBlock aLCBx;
+ NMTTools_ListIteratorOfListOfCommonBlock anIt, anItCBx;
+ BOPTools_ListIteratorOfListOfPaveBlock anItLPE;
+ //
+ anIt.Initialize(aLCB);
+ for (; anIt.More(); anIt.Next()) {
+ const NMTTools_CommonBlock& aCB=anIt.Value();
+ //
+ //XXX
+ aLCBx.Clear();
+ //XXX
+ SplitCommonBlock(aCB, aLCBx);
+ //
+ anItCBx.Initialize(aLCBx);
+ for (; anItCBx.More(); anItCBx.Next()) {
+ const NMTTools_CommonBlock& aCBx=anItCBx.Value();
+ const BOPTools_ListOfPaveBlock& aLPBx=aCBx.PaveBlocks();
+ //
+ anItLPE.Initialize(aLPBx);
+ for (; anItLPE.More(); anItLPE.Next()) {
+ const BOPTools_PaveBlock& aPBx=anItLPE.Value();
+ nE=aPBx.OriginalEdge();
+ NMTTools_ListOfCommonBlock& aLCBE=myCommonBlockPool(myDS->RefEdge(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 (aD<aTol) {
+ aT2x=aPPC.LowerDistanceParameter();
+ if (aT2x>aT21 && aT2x<aT22) {
+ return !bRet;
+ }
+ }
+ }
+ return bRet;
+}
+//modified by NIZNHY-PKV Thu Nov 11 08:13:55 2010t
--- /dev/null
+// 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_5.cxx
+// Created: Mon Dec 15 11:28:33 2003
+// Author: Peter KURNEV
+// <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+
+#include <Bnd_Box.hxx>
+
+#include <TopAbs_ShapeEnum.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <TopExp.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <IntTools_ShrunkRange.hxx>
+#include <IntTools_Range.hxx>
+#include <IntTools_EdgeFace.hxx>
+#include <IntTools_SequenceOfCommonPrts.hxx>
+#include <IntTools_CommonPrt.hxx>
+#include <IntTools_Tools.hxx>
+#include <IntTools_Context.hxx>
+
+#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
+#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
+#include <BooleanOperations_OnceExplorer.hxx>
+
+#include <BOPTools_Tools.hxx>
+#include <BOPTools_Pave.hxx>
+#include <BOPTools_PaveSet.hxx>
+#include <BOPTools_ListOfPave.hxx>
+#include <BOPTools_ListIteratorOfListOfPave.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_ESInterference.hxx>
+
+#include <BOPTools_CArray1OfVVInterference.hxx>
+#include <BOPTools_CArray1OfESInterference.hxx>
+#include <BOPTools_VVInterference.hxx>
+#include <BOPTools_ESInterference.hxx>
+#include <BOPTools_IDMapOfPaveBlockIMapOfInteger.hxx>
+#include <BOPTools_IMapOfPaveBlock.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_InterfPool.hxx>
+
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_CommonBlockAPI.hxx>
+#include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
+#include <NMTTools_CommonBlockAPI.hxx>
+#include <NMTTools_ListOfCommonBlock.hxx>
+
+
+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;
+}
--- /dev/null
+// 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 <NMTTools_PaveFiller.hxx>
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <Precision.hxx>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include <TColStd_DataMapOfIntegerListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_DataMapIteratorOfDataMapOfIntegerListOfInteger.hxx>
+
+
+#include <Geom_TrimmedCurve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2d_Curve.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <GeomAdaptor_Surface.hxx>
+#include <Geom_Surface.hxx>
+
+#include <BndLib_Add3dCurve.hxx>
+
+#include <TopoDS_Face.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Compound.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <TopExp.hxx>
+
+#include <BRepLib.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepBndLib.hxx>
+
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+
+#include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
+#include <BOPTColStd_IndexedDataMapOfIntegerInteger.hxx>
+
+#include <BooleanOperations_IndexedDataMapOfShapeInteger.hxx>
+#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
+#include <BooleanOperations_OnceExplorer.hxx>
+#include <BooleanOperations_ShapesDataStructure.hxx>
+
+#include <IntTools_SequenceOfPntOn2Faces.hxx>
+#include <IntTools_SequenceOfCurves.hxx>
+#include <IntTools_FaceFace.hxx>
+#include <IntTools_Tools.hxx>
+#include <IntTools_ShrunkRange.hxx>
+#include <IntTools_Context.hxx>
+
+#include <BOPTools_CArray1OfSSInterference.hxx>
+#include <BOPTools_VSInterference.hxx>
+#include <BOPTools_ESInterference.hxx>
+#include <BOPTools_SSInterference.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPave.hxx>
+#include <BOPTools_Tools.hxx>
+#include <BOPTools_PaveBlockIterator.hxx>
+#include <BOPTools_Tools2D.hxx>
+#include <BOPTools_Tools3D.hxx>
+#include <BOPTools_Curve.hxx>
+
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_InterfPool.hxx>
+
+#include <NMTTools_Tools.hxx>
+#include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
+#include <NMTTools_CommonBlock.hxx>
+#include <NMTTools_CommonBlockAPI.hxx>
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+#include <NMTTools_DataMapOfIntegerListOfPaveBlock.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+#include <NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx>
+#include <NMTTools_MapOfPaveBlock.hxx>
+#include <NMTTools_MapIteratorOfMapOfPaveBlock.hxx>
+#include <NMTTools_FaceInfo.hxx>
+#include <NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx>
+
+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 (aT2<aT1) {
+ aTmp=aT1;
+ aT1=aT2;
+ aT2=aTmp;
+ }
+ //
+ aR.SetFirst(aT1);
+ aR.SetLast(aT2);
+ IntTools_ShrunkRange aSR (aE, aV1, aV2, aR, aCtx);
+ iErr=aSR.ErrorStatus();
+ bRet=!aSR.IsDone();
+ //
+ return bRet;
+}
+//=======================================================================
+// function: PutPaveOnCurve
+// purpose:
+//=======================================================================
+void NMTTools_PaveFiller::PutPaveOnCurve(const BOPTools_PaveSet& aPaveSet,
+ const Standard_Real aTolR3D,
+ BOPTools_Curve& aBC)
+{
+ Standard_Integer nV;
+ Standard_Boolean bIsVertexOnLine;
+ Standard_Real aT;
+ BOPTools_ListIteratorOfListOfPave anIt;
+ Bnd_Box aBBC;
+ GeomAdaptor_Curve aGAC;
+ //
+ const IntTools_Curve& aC=aBC.Curve();
+ Handle (Geom_Curve) aC3D= aC.Curve();
+ aGAC.Load(aC3D);
+ BndLib_Add3dCurve::Add(aGAC, aTolR3D, aBBC);
+ //
+ const BOPTools_ListOfPave& aLP=aPaveSet.Set();
+ anIt.Initialize(aLP);
+ for (; anIt.More(); anIt.Next()) {
+ const BOPTools_Pave& aPave=anIt.Value();
+ //
+ nV=aPave.Index();
+ const TopoDS_Vertex aV=TopoDS::Vertex(myDS->Shape(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 <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Vec.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+//=======================================================================
+//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 (aA<aAmin || aA>aAmax) {
+ 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<aTolTresh) {
+ aTolR3D=aTolR;
+ }
+}
+
+//modified by NIZNHY-PKV Wed Sep 14 13:21:13 2011f
+#if OCC_VERSION_LARGE > 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
--- /dev/null
+// 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 <NMTTools_PaveFiller.hxx>
+
+#include <Bnd_HArray1OfBox.hxx>
+#include <Bnd_BoundSortBox.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
+
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <TopTools_DataMapOfIntegerShape.hxx>
+#include <TopTools_DataMapOfShapeInteger.hxx>
+#include <TopTools_DataMapOfShapeShape.hxx>
+#include <TopTools_DataMapOfShapeListOfInteger.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfIntegerShape.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
+#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfInteger.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+
+#include <TopExp_Explorer.hxx>
+#include <TopExp.hxx>
+//
+#include <IntTools_SequenceOfPntOn2Faces.hxx>
+#include <IntTools_PntOnFace.hxx>
+#include <IntTools_PntOn2Faces.hxx>
+#include <IntTools_Context.hxx>
+
+#include <BooleanOperations_AncestorsSeqAndSuccessorsSeq.hxx>
+
+#include <BOPTools_SSInterference.hxx>
+#include <BOPTools_CArray1OfSSInterference.hxx>
+#include <BOPTools_CArray1OfVVInterference.hxx>
+#include <BOPTools_VVInterference.hxx>
+#include <BOPTools_Tools.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_Pave.hxx>
+#include <BOPTools_Tools.hxx>
+
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_InterfPool.hxx>
+
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+#include <NMTTools_MapOfPaveBlock.hxx>
+
+
+//=======================================================================
+// 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; j<aNbF; ++j) {
+ nF1=aMF(j);
+ for(k=j+1; k<=aNbF; ++k) {
+ nF2=aMF(k);
+ myIP->Add(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);
+ }
+ }
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
+
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
+#include <TopTools_ListOfShape.hxx>
+
+#include <BooleanOperations_ShapesDataStructure.hxx>
+#include <BooleanOperations_OnceExplorer.hxx>
+
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+#include <NMTTools_CommonBlock.hxx>
+#include <NMTTools_CommonBlockAPI.hxx>
+
+
+// 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<aNbPBIn; ++i) {
+ aLPBIn.Append(pPB[i]);
+ }
+ //
+ delete [] (BOPTools_PaveBlock*)pPB;
+}
+//=======================================================================
+//function : SortShell
+//purpose :
+//=======================================================================
+void SortShell(const Standard_Integer n,
+ BOPTools_PaveBlock *a)
+{
+ Standard_Integer nd, i, j, l, d=1;
+ BOPTools_PaveBlock x;
+ //
+ while(d<=n) {
+ d*=2;
+ }
+ //
+ while (d) {
+ d=(d-1)/2;
+ //
+ nd=n-d;
+ for (i=0; i<nd; ++i) {
+ j=i;
+ m30:;
+ l=j+d;
+ if (Less(a[l], a[j])) {
+ //if (a[l] < a[j]){
+ x=a[j];
+ a[j]=a[l];
+ a[l]=x;
+ j-=d;
+ if (j > -1) goto m30;
+ }//if (a[l] < a[j]){
+ }//for (i=0; i<nd; ++i)
+ }//while (1)
+}
+
+//=======================================================================
+//function : Less
+//purpose :
+//=======================================================================
+Standard_Boolean Less(const BOPTools_PaveBlock &aPB1,
+ const BOPTools_PaveBlock &aPB2)
+{
+ Standard_Boolean bRet;
+ Standard_Integer iE1, iE2;
+ Standard_Real aT11, aT12, aT21, aT22;
+ //
+ iE1=aPB1.OriginalEdge();
+ iE2=aPB2.OriginalEdge();
+ if (iE1!=iE2) {
+ bRet=(iE1<iE2);
+ return bRet;
+ }
+ //
+ aPB1.Parameters(aT11, aT12);
+ aPB2.Parameters(aT21, aT22);
+ bRet=(aT11<aT21);
+ return bRet;
+}
+//modified by NIZNHY-PKV Mon Oct 17 11:44:45 2011t
--- /dev/null
+// 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_9.cxx
+// Created: Fri Dec 19 11:15:53 2003
+// Author: Peter KURNEV
+// <pkv@irinox>
+//
+#include <NMTTools_PaveFiller.hxx>
+
+#include <Geom_Surface.hxx>
+
+#include <TopLoc_Location.hxx>
+#include <TopAbs_Orientation.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+
+#include <TopExp_Explorer.hxx>
+
+#include <BOPTools_ListIteratorOfListOfPaveBlock.hxx>
+#include <BOPTools_ListOfPaveBlock.hxx>
+#include <BOPTools_PaveBlock.hxx>
+#include <BOPTools_Tools3D.hxx>
+
+#include <NMTDS_ShapesDataStructure.hxx>
+
+#include <NMTTools_CommonBlockAPI.hxx>
+#include <NMTTools_CommonBlock.hxx>
+
+
+//=======================================================================
+// 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);
+}
--- /dev/null
+// 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
+// <pkv@irinox>
+//
+#include <NMTTools_Tools.hxx>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+#include <gp_Pnt.hxx>
+#include <gp_XYZ.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <Geom_Surface.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+
+#include <TopExp.hxx>
+
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepTools.hxx>
+
+#include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
+#include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>
+
+#include <BOPTools_VVInterference.hxx>
+#include <BOPTools_SSInterference.hxx>
+
+#include <BOPTools_Tools2D.hxx>
+#include <BOPTools_Tools.hxx>
+#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
+#include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
+#include <NMTTools_CoupleOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <BOPTools_Tools2D.hxx>
+#include <BRepLib.hxx>
+#include <BOPTools_Tools3D.hxx>
+#include <TopExp_Explorer.hxx>
+//
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopoDS_Iterator.hxx>
+
+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 (aTolV<aTolES) {
+ aBB.UpdateVertex(aV, aTolES);
+ }
+ }
+}
+//=======================================================================
+// function: MakePCurve
+// purpose:
+//=======================================================================
+ void NMTTools_Tools::MakePCurve(const TopoDS_Edge& aE,
+ const TopoDS_Face& aF,
+ const Handle(Geom2d_Curve)& aC2Dx1)
+
+{
+ Standard_Real aTolE, aT1, aT2, aOutFirst, aOutLast, aOutTol;
+ Handle(Geom2d_Curve) aC2D, aC2DA;
+ TopoDS_Face aFFWD;
+ BRep_Builder aBB;
+ //
+ aFFWD=aF;
+ aFFWD.Orientation(TopAbs_FORWARD);
+ //
+ aTolE=BRep_Tool::Tolerance(aE);
+ //
+ const Handle(Geom_Curve)& aC3DE=BRep_Tool::Curve(aE, aT1, aT2);
+ Handle(Geom_TrimmedCurve)aC3DETrim=new Geom_TrimmedCurve(aC3DE, aT1, aT2);
+ //
+ aC2D=aC2Dx1;
+ 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, 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);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE\r
+//\r
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS\r
+//\r
+// This library is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU Lesser General Public\r
+// License as published by the Free Software Foundation; either\r
+// version 2.1 of the License.\r
+//\r
+// This library is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
+// Lesser General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU Lesser General Public\r
+// License along with this library; if not, write to the Free Software\r
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+//\r
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com\r
+//\r
+\r
+// File: NMTTools_Tools.hxx\r
+// Created: Mon Dec 8 10:35:15 2003\r
+// Author: Peter KURNEV\r
+// <pkv@irinox>\r
+\r
+#ifndef _NMTTools_Tools_HeaderFile\r
+#define _NMTTools_Tools_HeaderFile\r
+\r
+#include <Standard.hxx>\r
+#include <Standard_Macro.hxx>\r
+#include <Standard_Boolean.hxx>\r
+#include <Handle_IntTools_Context.hxx>\r
+#include <Handle_Geom2d_Curve.hxx>\r
+#include <Standard_Real.hxx>\r
+#include <TopTools_ListOfShape.hxx>\r
+#include <TopoDS_Vertex.hxx>\r
+#include <BOPTools_CArray1OfVVInterference.hxx>\r
+#include <BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger.hxx>\r
+#include <BOPTools_CArray1OfSSInterference.hxx>\r
+#include <TopoDS_Edge.hxx>\r
+#include <TopoDS_Face.hxx>\r
+#include <IntTools_Context.hxx>\r
+#include <NMTTools_ListOfCoupleOfShape.hxx>\r
+#include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>\r
+#include <Geom2d_Curve.hxx>\r
+\r
+//=======================================================================\r
+//function : NMTTools_Tools\r
+//purpose : \r
+//=======================================================================\r
+class NMTTools_Tools {\r
+ public:\r
+ Standard_EXPORT\r
+ static void MakeNewVertex(const TopTools_ListOfShape& aLV,\r
+ TopoDS_Vertex& aNewVertex) ;\r
+ \r
+ Standard_EXPORT\r
+ static void FindChains(const BOPTools_CArray1OfVVInterference& aVVs,\r
+ BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ;\r
+ \r
+ Standard_EXPORT \r
+ static void FindChains(const BOPTools_CArray1OfSSInterference& aVVs,\r
+ BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ;\r
+ \r
+ Standard_EXPORT \r
+ static void FindChains(const BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCV,\r
+ BOPTColStd_IndexedDataMapOfIntegerIndexedMapOfInteger& aMCX) ;\r
+ \r
+ Standard_EXPORT \r
+ static Standard_Boolean IsSplitInOnFace(const TopoDS_Edge& aE,\r
+ const TopoDS_Face& aF,\r
+ const Handle(IntTools_Context)& aCtx) ;\r
+ \r
+ Standard_EXPORT\r
+ static Standard_Boolean AreFacesSameDomain(const TopoDS_Face& aF1,\r
+ const TopoDS_Face& aF2,\r
+ const Handle(IntTools_Context)& aCtx) ;\r
+ \r
+ Standard_EXPORT \r
+ static void FindChains(const NMTTools_ListOfCoupleOfShape& aLCS,\r
+ NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM) ;\r
+ \r
+ Standard_EXPORT \r
+ static void FindChains(const NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM1,\r
+ NMTTools_IndexedDataMapOfShapeIndexedMapOfShape& aM2) ;\r
+ \r
+ Standard_EXPORT\r
+ static void MakePCurve(const TopoDS_Edge& aE,\r
+ const TopoDS_Face& aF,\r
+ const Handle(Geom2d_Curve)& aC2D) ;\r
+ \r
+ Standard_EXPORT \r
+ static void UpdateEdge(const TopoDS_Edge& aE,\r
+ const Standard_Real aTol) ;\r
+\r
+};\r
+#endif\r