GeomAPI_Ellipse.h
GeomAPI_Ellipse2d.h
GeomAPI_Tools.h
- GeomAPI_IScreenParams.h
+ GeomAPI_IScreenParams.h
+ GeomAPI_Shell.h
+ GeomAPI_Solid.h
+ GeomAPI_Sphere.h
+ GeomAPI_Cylinder.h
+ GeomAPI_Cone.h
+ GeomAPI_Torus.h
+ GeomAPI_Box.h
)
SET(PROJECT_SOURCES
GeomAPI_Ellipse.cpp
GeomAPI_Ellipse2d.cpp
GeomAPI_Tools.cpp
+ GeomAPI_Shell.cpp
+ GeomAPI_Solid.cpp
+ GeomAPI_Sphere.cpp
+ GeomAPI_Cylinder.cpp
+ GeomAPI_Cone.cpp
+ GeomAPI_Torus.cpp
+ GeomAPI_Box.cpp
)
SET(PROJECT_LIBRARIES
%shared_ptr(GeomAPI_XYZ)
%shared_ptr(GeomAPI_Trsf)
%shared_ptr(GeomAPI_Wire)
+%shared_ptr(GeomAPI_Shell)
+%shared_ptr(GeomAPI_Solid)
+%shared_ptr(GeomAPI_Box)
// all supported interfaces
%include "GeomAPI_XYZ.h"
%include "GeomAPI_Trsf.h"
%include "GeomAPI_Wire.h"
+%include "GeomAPI_Shell.h"
+%include "GeomAPI_Solid.h"
+%include "GeomAPI_Box.h"
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <GeomAPI_Box.h>
+#include <GeomAPI_Ax3.h>
+
+#include <Precision.hxx>
+
+struct Box
+{
+ std::shared_ptr<GeomAPI_Ax3> myCoordSystem;
+ double myWidth;
+ double myDepth;
+ double myHeight;
+
+ Box(const std::shared_ptr<GeomAPI_Ax3>& theCoordSystem,
+ const double theWidth,
+ const double theDepth,
+ const double theHeight)
+ : myCoordSystem(theCoordSystem),
+ myWidth(theWidth),
+ myDepth(theDepth),
+ myHeight(theHeight)
+ {}
+};
+
+#define MY_BOX implPtr<Box>()
+
+//=================================================================================================
+GeomAPI_Box::GeomAPI_Box()
+ : GeomAPI_Interface(new Box(std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3), 0., 0., 0.))
+{
+}
+
+//=================================================================================================
+GeomAPI_Box::GeomAPI_Box(const std::shared_ptr<GeomAPI_Ax3>& theCorner,
+ const double theWidth,
+ const double theDepth,
+ const double theHeight)
+ : GeomAPI_Interface(new Box(theCorner, theWidth, theDepth, theHeight))
+{
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Ax3> GeomAPI_Box::axes() const
+{
+ return MY_BOX->myCoordSystem;
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Box::corner() const
+{
+ return axes()->origin();
+}
+
+//=================================================================================================
+double GeomAPI_Box::width() const
+{
+ return MY_BOX->myWidth;
+}
+
+//=================================================================================================
+double GeomAPI_Box::depth() const
+{
+ return MY_BOX->myDepth;
+}
+
+//=================================================================================================
+double GeomAPI_Box::height() const
+{
+ return MY_BOX->myHeight;
+}
+
+//=================================================================================================
+bool GeomAPI_Box::isAxesAligned() const
+{
+ return Abs(MY_BOX->myCoordSystem->dirX()->x() - 1.0) < Precision::Angular() &&
+ Abs(MY_BOX->myCoordSystem->normal()->z() - 1.0) < Precision::Angular();
+}
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GeomAPI_Box_H_
+#define GeomAPI_Box_H_
+
+#include <GeomAPI_Interface.h>
+#include <memory>
+
+class GeomAPI_Ax3;
+class GeomAPI_Pnt;
+
+/**\class GeomAPI_Box
+ * \ingroup DataModel
+ * \brief Box in 3D
+ */
+class GeomAPI_Box : public GeomAPI_Interface
+{
+public:
+ /// Default constructor
+ GEOMAPI_EXPORT GeomAPI_Box();
+
+ /// Creation of torus defined by center point, direction, major and minor radii
+ GEOMAPI_EXPORT GeomAPI_Box(const std::shared_ptr<GeomAPI_Ax3>& theCorner,
+ const double theWidth,
+ const double theDepth,
+ const double theHeight);
+
+ /// Return axes of the box
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Ax3> axes() const;
+
+ /// Return base corner of the box
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> corner() const;
+
+ /// Return width of the box
+ GEOMAPI_EXPORT double width() const;
+
+ /// Return depth of the box
+ GEOMAPI_EXPORT double depth() const;
+
+ /// Return height of the box
+ GEOMAPI_EXPORT double height() const;
+
+ /// Return \c true is the box is aligned in main axes
+ GEOMAPI_EXPORT bool isAxesAligned() const;
+};
+
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Box> GeomBoxPtr;
+
+#endif
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <GeomAPI_Cone.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+
+#include <gp_Cone.hxx>
+#include <Precision.hxx>
+
+#define MY_CONE implPtr<gp_Cone>()
+
+static gp_Cone* newCone(const gp_Pnt& theApex, const gp_Dir& theAxis,
+ const double theSemiAngle, const double theRadius = 0.0)
+{
+ return new gp_Cone(gp_Ax3(theApex, theAxis), theSemiAngle, theRadius);
+}
+
+//=================================================================================================
+GeomAPI_Cone::GeomAPI_Cone(const std::shared_ptr<GeomAPI_Pnt>& theApex,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theSemiAngle)
+ : GeomAPI_Interface(newCone(theApex->impl<gp_Pnt>(), theAxis->impl<gp_Dir>(), theSemiAngle)),
+ myRadius1(Precision::Infinite()),
+ myRadius2(Precision::Infinite())
+{
+}
+
+//=================================================================================================
+GeomAPI_Cone::GeomAPI_Cone(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theSemiAngle,
+ const double theRadius)
+ : GeomAPI_Interface(
+ newCone(theLocation->impl<gp_Pnt>(), theAxis->impl<gp_Dir>(), theSemiAngle, theRadius)),
+ myRadius1(theRadius),
+ myRadius2(Precision::Infinite())
+{
+}
+
+//=================================================================================================
+GeomAPI_Cone::GeomAPI_Cone(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theSemiAngle,
+ const double theRadius1,
+ const double theRadius2)
+ : GeomAPI_Interface(
+ newCone(theLocation->impl<gp_Pnt>(), theAxis->impl<gp_Dir>(), theSemiAngle, theRadius1)),
+ myRadius1(theRadius1),
+ myRadius2(theRadius2)
+{
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Cone::apex() const
+{
+ const gp_Pnt& anApex = MY_CONE->Apex();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(anApex.X(), anApex.Y(), anApex.Z()));
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Cone::location() const
+{
+ const gp_Pnt& aLoc = MY_CONE->Location();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Cone::axis() const
+{
+ const gp_Dir& anAxis = MY_CONE->Position().Direction();
+ return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(anAxis.X(), anAxis.Y(), anAxis.Z()));
+}
+
+//=================================================================================================
+double GeomAPI_Cone::semiAngle() const
+{
+ return MY_CONE->SemiAngle();
+}
+
+//=================================================================================================
+double GeomAPI_Cone::radius1() const
+{
+ return myRadius1;
+}
+
+//=================================================================================================
+double GeomAPI_Cone::radius2() const
+{
+ return myRadius2;
+}
+
+//=================================================================================================
+double GeomAPI_Cone::height() const
+{
+ if (Precision::IsInfinite(myRadius1) || Precision::IsInfinite(myRadius2))
+ return Precision::Infinite();
+
+ return Abs((myRadius2 - myRadius1) / Tan(semiAngle()));
+}
+
+//=================================================================================================
+bool GeomAPI_Cone::isSemiInfinite() const
+{
+ return (!Precision::IsInfinite(myRadius1) && Precision::IsInfinite(myRadius2)) ||
+ (Precision::IsInfinite(myRadius1) && !Precision::IsInfinite(myRadius2));
+}
+
+//=================================================================================================
+bool GeomAPI_Cone::isInfinite() const
+{
+ return Precision::IsInfinite(myRadius1) && Precision::IsInfinite(myRadius2);
+}
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GeomAPI_Cone_H_
+#define GeomAPI_Cone_H_
+
+#include <GeomAPI_Interface.h>
+#include <memory>
+
+class GeomAPI_Dir;
+class GeomAPI_Pnt;
+
+/**\class GeomAPI_Cone
+ * \ingroup DataModel
+ * \brief Conical surface in 3D
+ */
+class GeomAPI_Cone : public GeomAPI_Interface
+{
+public:
+ /// Creation of infinite cone defined by apex, axis and semi-angle
+ GEOMAPI_EXPORT GeomAPI_Cone(const std::shared_ptr<GeomAPI_Pnt>& theApex,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theSemiAngle);
+
+ /// Creation of semi-infinite cone by location and radius of reference circle, axis, semi-angle
+ GEOMAPI_EXPORT GeomAPI_Cone(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theSemiAngle,
+ const double theRadius);
+
+ /// Creating of cone by location of reference circle, axis, semi-angle and radii of boundary circles
+ GEOMAPI_EXPORT GeomAPI_Cone(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theSemiAngle,
+ const double theRadius1,
+ const double theRadius2);
+
+ /// Return apex of the cone
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> apex() const;
+
+ /// Return location of the cone (center of the circle nearest to the apex)
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> location() const;
+
+ /// Return axis of the cone
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> axis() const;
+
+ /// Return semi-angle of the cone
+ GEOMAPI_EXPORT double semiAngle() const;
+
+ /// Return first radius of the cone or Precision::Infinite() if the cone is infinite
+ GEOMAPI_EXPORT double radius1() const;
+
+ /// Return second radius of the cone or Precision::Infinite() if the cone is infinite
+ GEOMAPI_EXPORT double radius2() const;
+
+ /// Return height of the cone
+ GEOMAPI_EXPORT double height() const;
+
+ /// Return \c true is the cone is semi-infinite
+ GEOMAPI_EXPORT bool isSemiInfinite() const;
+
+ /// Return \c true is the cone is infinite
+ GEOMAPI_EXPORT bool isInfinite() const;
+
+private:
+ double myRadius1, myRadius2;
+};
+
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Cone> GeomConePtr;
+
+#endif
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <GeomAPI_Cylinder.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+
+#include <gp_Cylinder.hxx>
+#include <Precision.hxx>
+
+#define MY_CYL implPtr<gp_Cylinder>()
+
+static gp_Cylinder* newCyl(const gp_Pnt& theLocation, const gp_Dir& theAxis, const double theRadius)
+{
+ return new gp_Cylinder(gp_Ax3(theLocation, theAxis), theRadius);
+}
+
+//=================================================================================================
+GeomAPI_Cylinder::GeomAPI_Cylinder(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theRadius)
+ : GeomAPI_Interface(newCyl(theLocation->impl<gp_Pnt>(), theAxis->impl<gp_Dir>(), theRadius)),
+ myHeight(Precision::Infinite())
+{
+}
+
+//=================================================================================================
+GeomAPI_Cylinder::GeomAPI_Cylinder(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theRadius,
+ const double theHeight)
+ : GeomAPI_Interface(newCyl(theLocation->impl<gp_Pnt>(), theAxis->impl<gp_Dir>(), theRadius)),
+ myHeight(theHeight)
+{
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Cylinder::location() const
+{
+ const gp_Pnt& aCenter = MY_CYL->Location();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Cylinder::axis() const
+{
+ const gp_Dir& anAxis = MY_CYL->Position().Direction();
+ return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(anAxis.X(), anAxis.Y(), anAxis.Z()));
+}
+
+//=================================================================================================
+double GeomAPI_Cylinder::radius() const
+{
+ return MY_CYL->Radius();
+}
+
+//=================================================================================================
+double GeomAPI_Cylinder::height() const
+{
+ return myHeight;
+}
+
+//=================================================================================================
+bool GeomAPI_Cylinder::isInfinite() const
+{
+ return Precision::IsInfinite(myHeight);
+}
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GeomAPI_Cylinder_H_
+#define GeomAPI_Cylinder_H_
+
+#include <GeomAPI_Interface.h>
+#include <memory>
+
+class GeomAPI_Dir;
+class GeomAPI_Pnt;
+
+/**\class GeomAPI_Cylinder
+ * \ingroup DataModel
+ * \brief Cylindrical surface in 3D
+ */
+class GeomAPI_Cylinder : public GeomAPI_Interface
+{
+public:
+ /// Creation of infinite cylinder defined by location, axis and radius
+ GEOMAPI_EXPORT GeomAPI_Cylinder(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theRadius);
+
+ /// Creation of cylinder defined by location, axis, radius and height
+ GEOMAPI_EXPORT GeomAPI_Cylinder(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
+ const std::shared_ptr<GeomAPI_Dir>& theAxis,
+ const double theRadius,
+ const double theHeight);
+
+ /// Return location of the cylinder
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> location() const;
+
+ /// Return axis of the cylinder
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> axis() const;
+
+ /// Return radius of the cylinder
+ GEOMAPI_EXPORT double radius() const;
+
+ /// Return height of the cylinder or Precision::Infinite() if the cylinder is infinite
+ GEOMAPI_EXPORT double height() const;
+
+ /// Return \c true is the cylinder is infinite
+ GEOMAPI_EXPORT bool isInfinite() const;
+
+private:
+ double myHeight;
+};
+
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Cylinder> GeomCylinderPtr;
+
+#endif
return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSecond.X(), aSecond.Y(), aSecond.Z()));
}
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Ellipse::normal() const
+{
+ const gp_Ax1& anAxis = MY_ELIPS->Axis();
+ const gp_Dir& aDir = anAxis.Direction();
+ return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
+
double GeomAPI_Ellipse::minorRadius() const
{
return MY_ELIPS->MinorRadius();
#include <GeomAPI_Interface.h>
#include <memory>
-class GeomAPI_Pnt;
class GeomAPI_Ax2;
+class GeomAPI_Dir;
+class GeomAPI_Pnt;
/**\class GeomAPI_Ellipse
/// Returns second focus of the ellipse
GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> secondFocus() const;
+ /// Return orthogonal direction to the ellipse's plane
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> normal() const;
+
/// Returns minor radius of the ellipse
GEOMAPI_EXPORT double minorRadius() const;
#include "GeomAPI_Dir.h"
#include "GeomAPI_Pln.h"
#include "GeomAPI_Pnt.h"
+#include "GeomAPI_Sphere.h"
+#include "GeomAPI_Cylinder.h"
+#include "GeomAPI_Cone.h"
+#include "GeomAPI_Torus.h"
#include <BOPTools_AlgoTools.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
+#include <BRepTools.hxx>
#include <Geom_Surface.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_ConicalSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
+#include <Geom_ToroidalSurface.hxx>
#include <GeomLib_IsPlanarSurface.hxx>
#include <IntTools_Context.hxx>
+#include <Standard_Type.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
+#include <gp_Sphere.hxx>
+#include <gp_Cylinder.hxx>
+#include <gp_Cone.hxx>
+#include <gp_Torus.hxx>
+
+
GeomAPI_Face::GeomAPI_Face()
: GeomAPI_Shape()
{
aResult = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
return aResult;
}
+
+std::shared_ptr<GeomAPI_Sphere> GeomAPI_Face::getSphere() const
+{
+ GeomSpherePtr aSphere;
+
+ const TopoDS_Face& aFace = TopoDS::Face(impl<TopoDS_Shape>());
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ if (aSurf->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) {
+ gp_Sphere aSph = Handle(Geom_SphericalSurface)::DownCast(aSurf)->Sphere();
+ const gp_Pnt& aCenter = aSph.Location();
+ double aRadius = aSph.Radius();
+
+ GeomPointPtr aCenterPnt(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
+ aSphere = GeomSpherePtr(new GeomAPI_Sphere(aCenterPnt, aRadius));
+ }
+ return aSphere;
+}
+
+std::shared_ptr<GeomAPI_Cylinder> GeomAPI_Face::getCylinder() const
+{
+ GeomCylinderPtr aCylinder;
+
+ const TopoDS_Face& aFace = TopoDS::Face(impl<TopoDS_Shape>());
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ if (aSurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) {
+ gp_Cylinder aCyl = Handle(Geom_CylindricalSurface)::DownCast(aSurf)->Cylinder();
+ gp_Pnt aLoc = aCyl.Location();
+ const gp_Dir& aDir = aCyl.Position().Direction();
+ double aRadius = aCyl.Radius();
+
+ double aUMin, aUMax, aVMin, aVMax;
+ BRepTools::UVBounds(aFace, aUMin, aUMax, aVMin, aVMax);
+ double aHeight = aVMax - aVMin;
+
+ aLoc.ChangeCoord() += aDir.XYZ() * aVMin;
+ GeomPointPtr aLocation(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+ GeomDirPtr aDirection(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+ aCylinder = GeomCylinderPtr(new GeomAPI_Cylinder(aLocation, aDirection, aRadius, aHeight));
+ }
+ return aCylinder;
+}
+
+std::shared_ptr<GeomAPI_Cone> GeomAPI_Face::getCone() const
+{
+ GeomConePtr aCone;
+
+ const TopoDS_Face& aFace = TopoDS::Face(impl<TopoDS_Shape>());
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ if (aSurf->IsKind(STANDARD_TYPE(Geom_ConicalSurface))) {
+ gp_Cone aCon = Handle(Geom_ConicalSurface)::DownCast(aSurf)->Cone();
+ const gp_Pnt& aLoc = aCon.Location();
+ const gp_Dir& aDir = aCon.Position().Direction();
+ double aRadius1 = aCon.RefRadius();
+
+ double aUMin, aUMax, aVMin, aVMax;
+ BRepTools::UVBounds(aFace, aUMin, aUMax, aVMin, aVMax);
+
+ double aSemiAngle = Abs(aCon.SemiAngle());
+ double aRadius2 = aRadius1 - (aVMax - aVMin) * Sin(aSemiAngle);
+
+ GeomPointPtr aLocation(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+ GeomDirPtr aDirection(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+ aCone = GeomConePtr(new GeomAPI_Cone(aLocation, aDirection, aSemiAngle, aRadius1, aRadius2));
+ }
+ return aCone;
+}
+
+std::shared_ptr<GeomAPI_Torus> GeomAPI_Face::getTorus() const
+{
+ GeomTorusPtr aTorus;
+
+ const TopoDS_Face& aFace = TopoDS::Face(impl<TopoDS_Shape>());
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ if (aSurf->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) {
+ gp_Torus aTor = Handle(Geom_ToroidalSurface)::DownCast(aSurf)->Torus();
+ const gp_Pnt& aLoc = aTor.Location();
+ const gp_Dir& aDir = aTor.Position().Direction();
+ double aMajorRadius = aTor.MajorRadius();
+ double aMinorRadius = aTor.MinorRadius();
+
+ GeomPointPtr aCenter(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+ GeomDirPtr aDirection(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+ aTorus = GeomTorusPtr(new GeomAPI_Torus(aCenter, aDirection, aMajorRadius, aMinorRadius));
+ }
+ return aTorus;
+}
#include <GeomAPI_Shape.h>
class GeomAPI_Pln;
+class GeomAPI_Sphere;
+class GeomAPI_Cylinder;
+class GeomAPI_Cone;
+class GeomAPI_Torus;
/**\class GeomAPI_Face
* \ingroup DataModel
/// Returns the base plane of the face (if it is planar) with location in the center of the face
GEOMAPI_EXPORT
std::shared_ptr<GeomAPI_Pln> getPlane() const;
+
+ /// Returns sphere if the face is based on the spherical surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Sphere> getSphere() const;
+
+ /// Returns cylinder if the face is based on the cylindrical surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Cylinder> getCylinder() const;
+
+ /// Returns cone if the face is based on the conical surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Cone> getCone() const;
+
+ /// Returns torus if the face is based on the toroidal surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Torus> getTorus() const;
};
//! Pointer on attribute object
#include "GeomAPI_Shape.h"
+#include <GeomAPI_Vertex.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Wire.h>
+#include <GeomAPI_Face.h>
+#include <GeomAPI_Shell.h>
+#include <GeomAPI_Solid.h>
+
#include <BRep_Tool.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepBndLib.hxx>
return !aShape.IsNull() && aShape.ShapeType() == TopAbs_FACE;
}
+bool GeomAPI_Shape::isShell() const
+{
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ return !aShape.IsNull() && aShape.ShapeType() == TopAbs_SHELL;
+}
+
bool GeomAPI_Shape::isCompound() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
return false;
}
+std::shared_ptr<GeomAPI_Vertex> GeomAPI_Shape::vertex() const
+{
+ GeomVertexPtr aVertex;
+ if (isVertex()) {
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ aVertex = GeomVertexPtr(new GeomAPI_Vertex);
+ aVertex->setImpl(new TopoDS_Shape(aShape));
+ }
+ return aVertex;
+}
+
+std::shared_ptr<GeomAPI_Edge> GeomAPI_Shape::edge() const
+{
+ GeomEdgePtr anEdge;
+ if (isEdge()) {
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ anEdge = GeomEdgePtr(new GeomAPI_Edge);
+ anEdge->setImpl(new TopoDS_Shape(aShape));
+ }
+ return anEdge;
+}
+
+std::shared_ptr<GeomAPI_Wire> GeomAPI_Shape::wire() const
+{
+ GeomWirePtr aWire;
+ if (isWire()) {
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ aWire = GeomWirePtr(new GeomAPI_Wire);
+ aWire->setImpl(new TopoDS_Shape(aShape));
+ }
+ return aWire;
+}
+
+std::shared_ptr<GeomAPI_Face> GeomAPI_Shape::face() const
+{
+ GeomFacePtr aFace;
+ if (isFace()) {
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ aFace = GeomFacePtr(new GeomAPI_Face);
+ aFace->setImpl(new TopoDS_Shape(aShape));
+ }
+ return aFace;
+}
+
+std::shared_ptr<GeomAPI_Shell> GeomAPI_Shape::shell() const
+{
+ GeomShellPtr aShell;
+ if (isShell()) {
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ aShell = GeomShellPtr(new GeomAPI_Shell);
+ aShell->setImpl(new TopoDS_Shape(aShape));
+ }
+ return aShell;
+}
+
+std::shared_ptr<GeomAPI_Solid> GeomAPI_Shape::solid() const
+{
+ GeomSolidPtr aSolid;
+ if (isSolid()) {
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+ aSolid = GeomSolidPtr(new GeomAPI_Solid);
+ aSolid->setImpl(new TopoDS_Shape(aShape));
+ }
+ return aSolid;
+}
+
+std::list<std::shared_ptr<GeomAPI_Shape> >
+GeomAPI_Shape::subShapes(ShapeType theSubShapeType) const
+{
+ ListOfShape aSubs;
+ const TopoDS_Shape& aShape = impl<TopoDS_Shape>();
+ if (aShape.IsNull())
+ return aSubs;
+
+ for (TopExp_Explorer anExp(aShape, (TopAbs_ShapeEnum)theSubShapeType);
+ anExp.More(); anExp.Next()) {
+ GeomShapePtr aSub(new GeomAPI_Shape);
+ aSub->setImpl(new TopoDS_Shape(anExp.Current()));
+ aSubs.push_back(aSub);
+ }
+ return aSubs;
+}
+
GeomAPI_Shape::ShapeType GeomAPI_Shape::shapeType() const
{
const TopoDS_Shape& aShape = impl<TopoDS_Shape>();
#include <memory>
#include <list>
+class GeomAPI_Vertex;
+class GeomAPI_Edge;
+class GeomAPI_Wire;
+class GeomAPI_Face;
+class GeomAPI_Shell;
+class GeomAPI_Solid;
+
/**\class GeomAPI_Shape
* \ingroup DataModel
* \brief Interface to the topological shape object
GEOMAPI_EXPORT
virtual bool isFace() const;
+ /// Returns whether the shape is a shell
+ GEOMAPI_EXPORT
+ virtual bool isShell() const;
+
/// Returns whether the shape is a compound
GEOMAPI_EXPORT
virtual bool isCompound() const;
GEOMAPI_EXPORT
virtual bool isPlanar() const;
+ /// Returns vertex or empty shape
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Vertex> vertex() const;
+
+ /// Returns edge or empty shape
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Edge> edge() const;
+
+ /// Returns wire or empty shape
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Wire> wire() const;
+
+ /// Returns face or empty shape
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Face> face() const;
+
+ /// Returns shell or empty shape
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Shell> shell() const;
+
+ /// Returns solid or empty shape
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Solid> solid() const;
+
+ /// Returns list of sub-shapes of the given type
+ GEOMAPI_EXPORT
+ std::list<std::shared_ptr<GeomAPI_Shape> > subShapes(ShapeType theSubShapeType) const;
+
/// Returns the shape type
GEOMAPI_EXPORT
virtual ShapeType shapeType() const;
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "GeomAPI_Shell.h"
+
+#include "GeomAPI_Ax3.h"
+#include "GeomAPI_Box.h"
+#include "GeomAPI_Cone.h"
+#include "GeomAPI_Cylinder.h"
+#include "GeomAPI_Face.h"
+#include "GeomAPI_Pnt.h"
+#include "GeomAPI_Sphere.h"
+#include "GeomAPI_Torus.h"
+#include "GeomAPI_Wire.h"
+#include "GeomAPI_XYZ.h"
+
+#include <BRep_Builder.hxx>
+#include <Precision.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+
+#include <map>
+
+//=================================================================================================
+GeomAPI_Shell::GeomAPI_Shell()
+{
+ TopoDS_Shell* aShell = new TopoDS_Shell();
+
+ BRep_Builder aBuilder;
+ aBuilder.MakeShell(*aShell);
+
+ this->setImpl(aShell);
+}
+
+//=================================================================================================
+GeomAPI_Shell::GeomAPI_Shell(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+ if (!theShape->isNull() && theShape->isShell()) {
+ setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
+ }
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Sphere> GeomAPI_Shell::getSphere() const
+{
+ bool isSphere = true;
+ bool isFirstFace = true;
+ GeomSpherePtr aSphere;
+
+ for (TopExp_Explorer anExp(impl<TopoDS_Shape>(), TopAbs_FACE); anExp.More(); anExp.Next()) {
+ GeomFacePtr aFace(new GeomAPI_Face);
+ aFace->setImpl(new TopoDS_Shape(anExp.Current()));
+
+ GeomSpherePtr aCurSphere = aFace->getSphere();
+ if (!aCurSphere) {
+ isSphere = false;
+ break;
+ }
+
+ if (isFirstFace) {
+ aSphere = aCurSphere;
+ isFirstFace = false;
+ }
+ else if (aSphere->center()->distance(aCurSphere->center()) >= Precision::Confusion() ||
+ Abs(aSphere->radius() - aCurSphere->radius()) >= Precision::Confusion()) {
+ isSphere = false;
+ break;
+ }
+ }
+
+ return isSphere ? aSphere : GeomSpherePtr();
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Cylinder> GeomAPI_Shell::getCylinder() const
+{
+ bool isCylinder = true;
+ bool isFirstFace = true;
+
+ GeomPointPtr aLocation;
+ GeomDirPtr anAxis;
+ double aRadius;
+ double aHeight;
+
+ for (TopExp_Explorer anExp(impl<TopoDS_Shape>(), TopAbs_FACE); anExp.More(); anExp.Next()) {
+ GeomFacePtr aFace(new GeomAPI_Face);
+ aFace->setImpl(new TopoDS_Shape(anExp.Current()));
+
+ GeomCylinderPtr aCurCyl = aFace->getCylinder();
+ if (!aCurCyl) {
+ isCylinder = false;
+ break;
+ }
+
+ if (isFirstFace) {
+ aLocation = aCurCyl->location();
+ anAxis = aCurCyl->axis();
+ aRadius = aCurCyl->radius();
+ aHeight = aCurCyl->height();
+ isFirstFace = false;
+ }
+ else {
+ // compare radii
+ if (Abs(aRadius - aCurCyl->radius()) >= Precision::Confusion() ||
+ // check directions are collinear
+ !anAxis->isParallel(aCurCyl->axis()) ||
+ // check current center is on the main axis
+ anAxis->xyz()->cross(aLocation->xyz()->decreased(aCurCyl->location()->xyz())
+ )->squareModulus() >= Precision::SquareConfusion()) {
+ isCylinder = false;
+ break;
+ }
+
+ double aMinHeight = 0.0;
+ double aMaxHeight = aHeight;
+
+ std::shared_ptr<GeomAPI_XYZ> aCurCylLoc = aCurCyl->location()->xyz();
+ std::shared_ptr<GeomAPI_XYZ> aCurCylLocHeight =
+ aCurCylLoc->added(aCurCyl->axis()->xyz()->multiplied(aCurCyl->height()));
+
+ std::shared_ptr<GeomAPI_XYZ> anAxisXYZ = anAxis->xyz();
+
+ double aDist = anAxisXYZ->dot(aCurCylLoc->decreased(aLocation->xyz()));
+ if (aDist < aMinHeight)
+ aMinHeight = aDist;
+ else if (aDist > aMaxHeight)
+ aMaxHeight = aDist;
+
+ aDist = anAxisXYZ->dot(aCurCylLocHeight->decreased(aLocation->xyz()));
+ if (aDist < aMinHeight)
+ aMinHeight = aDist;
+ else if (aDist > aMaxHeight)
+ aMaxHeight = aDist;
+
+ if (aMinHeight < 0.0) {
+ // move location of full cylinder
+ aLocation->setX(aLocation->x() + aMinHeight * anAxis->x());
+ aLocation->setY(aLocation->y() + aMinHeight * anAxis->y());
+ aLocation->setZ(aLocation->z() + aMinHeight * anAxis->z());
+ }
+
+ aHeight = aMaxHeight - aMinHeight;
+ }
+ }
+
+ GeomCylinderPtr aCylinder;
+ if (isCylinder)
+ aCylinder = GeomCylinderPtr(new GeomAPI_Cylinder(aLocation, anAxis, aRadius, aHeight));
+ return aCylinder;
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Cone> GeomAPI_Shell::getCone() const
+{
+ bool isCone = true;
+ bool isFirstFace = true;
+
+ GeomPointPtr anApex;
+ GeomDirPtr anAxis;
+ double aSemiAngle, aCosSemiAngle;
+ double aHeight1, aHeight2;
+
+ for (TopExp_Explorer anExp(impl<TopoDS_Shape>(), TopAbs_FACE); anExp.More(); anExp.Next()) {
+ GeomFacePtr aFace(new GeomAPI_Face);
+ aFace->setImpl(new TopoDS_Shape(anExp.Current()));
+
+ GeomConePtr aCurCone = aFace->getCone();
+ if (!aCurCone) {
+ isCone = false;
+ break;
+ }
+
+ if (isFirstFace) {
+ anApex = aCurCone->apex();
+ anAxis = aCurCone->axis();
+ aSemiAngle = aCurCone->semiAngle();
+ aCosSemiAngle = Cos(aSemiAngle);
+ aHeight1 = aCurCone->radius1() * aCosSemiAngle;
+ aHeight2 = aCurCone->radius2() * aCosSemiAngle;
+ isFirstFace = false;
+ }
+ else {
+ // check equal locations
+ if (anApex->distance(aCurCone->apex()) >= Precision::Confusion() ||
+ // check equal angles
+ Abs(aSemiAngle - aCurCone->semiAngle()) >= Precision::Confusion() ||
+ // check directions are collinear
+ !anAxis->isParallel(aCurCone->axis())) {
+ isCone = false;
+ break;
+ }
+
+ double aSign = anAxis->dot(aCurCone->axis());
+ double aCurSemiAngle = aCurCone->semiAngle();
+ double aCosCurSemiAngle = Cos(aSemiAngle);
+
+ double aH = aCurCone->radius1() * aCosCurSemiAngle * aSign;
+ if (aH < aHeight1)
+ aHeight1 = aH;
+ else if (aH > aHeight2)
+ aHeight2 = aH;
+
+ aH = aCurCone->radius2() * aCosCurSemiAngle * aSign;
+ if (aH < aHeight1)
+ aHeight1 = aH;
+ else if (aH > aHeight2)
+ aHeight2 = aH;
+ }
+ }
+
+ GeomConePtr aCone;
+ if (isCone) {
+ GeomPointPtr aLocation(new GeomAPI_Pnt(
+ anApex->xyz()->added(anAxis->xyz()->multiplied(aHeight1))));
+ double aRadius1 = aHeight1 * Tan(aSemiAngle);
+ double aRadius2 = aHeight2 * Tan(aSemiAngle);
+
+ aCone = GeomConePtr(new GeomAPI_Cone(aLocation, anAxis, aSemiAngle, aRadius1, aRadius2));
+ }
+ return aCone;
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Torus> GeomAPI_Shell::getTorus() const
+{
+ bool isTorus = true;
+ bool isFirstFace = true;
+ GeomTorusPtr aTorus;
+
+ for (TopExp_Explorer anExp(impl<TopoDS_Shape>(), TopAbs_FACE); anExp.More(); anExp.Next()) {
+ GeomFacePtr aFace(new GeomAPI_Face);
+ aFace->setImpl(new TopoDS_Shape(anExp.Current()));
+
+ GeomTorusPtr aCurTorus = aFace->getTorus();
+ if (!aCurTorus) {
+ isTorus = false;
+ break;
+ }
+
+ if (isFirstFace) {
+ aTorus = aCurTorus;
+ isFirstFace = false;
+ }
+ else {
+ // compare radii
+ if (Abs(aTorus->majorRadius() - aCurTorus->majorRadius()) >= Precision::Confusion() ||
+ Abs(aTorus->minorRadius() - aCurTorus->minorRadius()) >= Precision::Confusion() ||
+ // check equal centers
+ aTorus->center()->distance(aCurTorus->center()) >= Precision::SquareConfusion() ||
+ // check directions are collinear
+ !aTorus->direction()->isParallel(aCurTorus->direction())) {
+ isTorus = false;
+ break;
+ }
+ }
+ }
+
+ return isTorus ? aTorus : GeomTorusPtr();
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Box> GeomAPI_Shell::getParallelepiped() const
+{
+ struct Plane
+ {
+ std::shared_ptr<GeomAPI_Ax3> myAxes;
+ double myWidth;
+ double myDepth;
+ double myHeight;
+ } aPlanes[6];
+ std::map<int, int> aParallelPlanes;
+
+ int aNbPlanes = 0;
+ for (TopExp_Explorer anExp(impl<TopoDS_Shape>(), TopAbs_WIRE);
+ anExp.More() && aNbPlanes < 6; anExp.Next()) {
+ GeomWirePtr aWire(new GeomAPI_Wire);
+ aWire->setImpl(new TopoDS_Shape(anExp.Current()));
+
+ std::list<GeomPointPtr> aCorners;
+ if (aWire->isRectangle(aCorners)) {
+ // convert rectangle to plane with dimensions
+ GeomPointPtr anOrigin = aCorners.front();
+ aCorners.pop_front();
+
+ GeomPointPtr aFront = aCorners.front();
+ GeomPointPtr aBack = aCorners.back();
+
+ aPlanes[aNbPlanes].myWidth = aBack->distance(anOrigin);
+ aPlanes[aNbPlanes].myDepth = aFront->distance(anOrigin);
+ aPlanes[aNbPlanes].myHeight = Precision::Infinite();
+
+ GeomDirPtr aDX(new GeomAPI_Dir(aBack->x() - anOrigin->x(),
+ aBack->y() - anOrigin->y(),
+ aBack->z() - anOrigin->z()));
+ GeomDirPtr aDY(new GeomAPI_Dir(aFront->x() - anOrigin->x(),
+ aFront->y() - anOrigin->y(),
+ aFront->z() - anOrigin->z()));
+ GeomDirPtr aDZ(new GeomAPI_Dir(aDX->cross(aDY)));
+ aPlanes[aNbPlanes].myAxes =
+ std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(anOrigin, aDX, aDZ));
+
+ // find parallel plane
+ for (int i = 0; i < aNbPlanes; ++i) {
+ double aDot = aPlanes[i].myAxes->normal()->dot(aDZ);
+ if (Abs(aDot + 1.0) < Precision::Angular()) {
+ if (aParallelPlanes.find(i) == aParallelPlanes.end())
+ aParallelPlanes[i] = aNbPlanes;
+ else
+ break; // parallel planes already exist
+ }
+ }
+
+ ++aNbPlanes;
+
+ } else
+ break;
+ }
+
+ if (aNbPlanes != 6 || aParallelPlanes.size() != 3) // not a parallelepiped
+ return GeomBoxPtr();
+
+ // calculate heights for planes computed by rectangles
+ for (std::map<int, int>::iterator it = aParallelPlanes.begin();
+ it != aParallelPlanes.end(); ++it) {
+ GeomDirPtr aNormal = aPlanes[it->first].myAxes->normal();
+ GeomPointPtr anOrigin = aPlanes[it->first].myAxes->origin();
+ GeomPointPtr aNeighbor = aPlanes[it->second].myAxes->origin();
+
+ aPlanes[it->first].myHeight =
+ aPlanes[it->second].myHeight =
+ aNormal->xyz()->dot( aNeighbor->xyz()->decreased(anOrigin->xyz()) );
+ }
+
+ // check if the box is oriented in the main axes
+ int anIndex = 0;
+ for (int i = 0; i < 6; ++i) {
+ if (Abs(aPlanes[i].myAxes->dirX()->x() - 1.) < Precision::Angular() &&
+ Abs(aPlanes[i].myAxes->normal()->z() - 1.) < Precision::Angular()) {
+ anIndex = i;
+ break;
+ }
+ }
+
+ // construct a box
+ GeomBoxPtr aBox(new GeomAPI_Box(aPlanes[anIndex].myAxes,
+ aPlanes[anIndex].myWidth,
+ aPlanes[anIndex].myDepth,
+ aPlanes[anIndex].myHeight));
+ return aBox;
+}
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GeomAPI_Shell_H_
+#define GeomAPI_Shell_H_
+
+#include <GeomAPI_Shape.h>
+
+class GeomAPI_Sphere;
+class GeomAPI_Cylinder;
+class GeomAPI_Cone;
+class GeomAPI_Torus;
+class GeomAPI_Box;
+
+/// \class GeomAPI_Shell
+/// \ingroup DataModel
+/// \brief Interface to the shell object
+class GeomAPI_Shell: public GeomAPI_Shape
+{
+public:
+ /// Makes an undefined shell.
+ GEOMAPI_EXPORT GeomAPI_Shell();
+
+ /// Creation of shell by the shell-shape
+ GEOMAPI_EXPORT GeomAPI_Shell(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
+ /// Returns sphere if the shell consists only of faces
+ /// which are based on the same spherical surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Sphere> getSphere() const;
+
+ /// Returns cylinder if the shell consists only of faces
+ /// which are based on the same cylindrical surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Cylinder> getCylinder() const;
+
+ /// Returns cone if the shell consists only of faces
+ /// which are based on the same conical surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Cone> getCone() const;
+
+ /// Returns torus if the shell consists only of faces
+ /// which are based on the same toroidal surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Torus> getTorus() const;
+
+ /// Returns box if the shell consists of 6 rectangular faces composing a box
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Box> getParallelepiped() const;
+};
+
+typedef std::shared_ptr<GeomAPI_Shell> GeomShellPtr;
+
+#endif
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include "GeomAPI_Solid.h"
+
+#include "GeomAPI_Box.h"
+#include "GeomAPI_Cone.h"
+#include "GeomAPI_Cylinder.h"
+#include "GeomAPI_Dir.h"
+#include "GeomAPI_Face.h"
+#include "GeomAPI_Pln.h"
+#include "GeomAPI_Pnt.h"
+#include "GeomAPI_Shell.h"
+#include "GeomAPI_Sphere.h"
+#include "GeomAPI_Torus.h"
+#include "GeomAPI_XYZ.h"
+
+#include <BRep_Builder.hxx>
+#include <Precision.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS_Wire.hxx>
+
+//==================================================================================================
+GeomAPI_Solid::GeomAPI_Solid() : GeomAPI_Shape()
+{
+}
+
+//==================================================================================================
+GeomAPI_Solid::GeomAPI_Solid(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+ if (!theShape->isNull() && theShape->isSolid()) {
+ setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
+ }
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Sphere> GeomAPI_Solid::getSphere() const
+{
+ GeomSpherePtr aSphere;
+ ListOfShape aShells = subShapes(SHELL);
+ if (aShells.size() == 1)
+ aSphere = aShells.front()->shell()->getSphere();
+ return aSphere;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Cylinder> GeomAPI_Solid::getCylinder() const
+{
+ bool isCylinder = false;
+
+ GeomPointPtr aLocation;
+ GeomDirPtr anAxis;
+ double aRadius;
+ double aHeight;
+
+ GeomPlanePtr aCaps[2];
+
+ for (TopExp_Explorer anExp(impl<TopoDS_Shape>(), TopAbs_FACE); anExp.More(); anExp.Next()) {
+ GeomFacePtr aFace(new GeomAPI_Face);
+ aFace->setImpl(new TopoDS_Shape(anExp.Current()));
+
+ GeomCylinderPtr aCurCyl = aFace->getCylinder();
+ if (aCurCyl) {
+ if (isCylinder) { // at least one cylindrical face is found
+ // compare radii
+ if (Abs(aRadius - aCurCyl->radius()) >= Precision::Confusion() ||
+ // check directions are collinear
+ !anAxis->isParallel(aCurCyl->axis()) ||
+ // check current center is on the main axis
+ anAxis->xyz()->cross(aLocation->xyz()->decreased(aCurCyl->location()->xyz())
+ )->squareModulus() >= Precision::SquareConfusion()) {
+ isCylinder = false;
+ break;
+ }
+ }
+ else { // first cylinder is found
+ aLocation = aCurCyl->location();
+ if (anAxis) {
+ // the plane is found => compare directions
+ if (!anAxis->isParallel(aCurCyl->axis()))
+ break;
+ }
+ else
+ anAxis = aCurCyl->axis();
+ aRadius = aCurCyl->radius();
+ aHeight = aCurCyl->height();
+ isCylinder = true;
+ }
+ }
+ else {
+ // check the face is planar
+ bool isPlaneApplicable = false;
+ GeomPlanePtr aCurPln = aFace->getPlane();
+ if (aCurPln) {
+ // verify the plane is already exists
+ int aLastPlanIndex = 0;
+ while (aLastPlanIndex < 2) {
+ if (!aCaps[aLastPlanIndex]) {
+ // add new plane
+ aCaps[aLastPlanIndex] = aCurPln;
+ break;
+ }
+ if (aCaps[aLastPlanIndex]->isCoincident(aCurPln))
+ break;
+ ++aLastPlanIndex;
+ }
+
+ isPlaneApplicable = aLastPlanIndex < 2;
+ }
+
+ if (isPlaneApplicable) {
+ if (!anAxis) // no cylinder is found, store the normal as further cylinder's axis
+ anAxis = aCurPln->direction();
+ }
+ else {
+ isCylinder = false;
+ break;
+ }
+ }
+ }
+
+ isCylinder = isCylinder && aCaps[0] && aCaps[1] &&
+ aCaps[0]->direction()->isParallel(anAxis) &&
+ aCaps[1]->direction()->isParallel(anAxis);
+
+ GeomCylinderPtr aCylinder;
+ if (isCylinder) {
+ // intersect planes with cylinder's axis
+ std::shared_ptr<GeomAPI_XYZ> anAxisXYZ = anAxis->xyz();
+ std::shared_ptr<GeomAPI_XYZ> aLocationXYZ = aLocation->xyz();
+ double aParam0 = anAxisXYZ->dot( aCaps[0]->location()->xyz()->decreased(aLocationXYZ) );
+ double aParam1 = anAxisXYZ->dot( aCaps[1]->location()->xyz()->decreased(aLocationXYZ) );
+ if (aParam0 > aParam1 + Precision::Confusion()) {
+ double tmp = aParam0;
+ aParam0 = aParam1;
+ aParam1 = tmp;
+ }
+
+ // update location of cylinder to be coincident with one of planes
+ aLocation->setX(aLocation->x() + aParam0 * anAxis->x());
+ aLocation->setY(aLocation->y() + aParam0 * anAxis->y());
+ aLocation->setZ(aLocation->z() + aParam0 * anAxis->z());
+
+ aHeight = aParam1 - aParam0;
+
+ aCylinder = GeomCylinderPtr(new GeomAPI_Cylinder(aLocation, anAxis, aRadius, aHeight));
+ }
+ return aCylinder;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Cone> GeomAPI_Solid::getCone() const
+{
+ bool isCone = false;
+
+ GeomPointPtr anApex;
+ GeomDirPtr anAxis;
+ double aSemiAngle;
+ double aHeight;
+
+ GeomPlanePtr aCaps[2];
+
+ for (TopExp_Explorer anExp(impl<TopoDS_Shape>(), TopAbs_FACE); anExp.More(); anExp.Next()) {
+ GeomFacePtr aFace(new GeomAPI_Face);
+ aFace->setImpl(new TopoDS_Shape(anExp.Current()));
+
+ GeomConePtr aCurCone = aFace->getCone();
+ if (aCurCone) {
+ if (isCone) { // at least one conical face is found
+ // check equal apexes
+ if (anApex->distance(aCurCone->apex()) >= Precision::Confusion() ||
+ // check semi-angle
+ Abs(aSemiAngle - aCurCone->semiAngle() >= Precision::Confusion()) ||
+ // check axes are collinear
+ !anAxis->isParallel(aCurCone->axis())) {
+ isCone = false;
+ break;
+ }
+ }
+ else { // first cone is found
+ anApex = aCurCone->apex();
+ if (anAxis) {
+ // the plane is found => compare directions
+ if (!anAxis->isParallel(aCurCone->axis()))
+ break;
+ }
+ else
+ anAxis = aCurCone->axis();
+ aSemiAngle = aCurCone->semiAngle();
+ aHeight = aCurCone->height();
+ isCone = true;
+ }
+ }
+ else {
+ // check the face is planar
+ bool isPlaneApplicable = false;
+ GeomPlanePtr aCurPln = aFace->getPlane();
+ if (aCurPln) {
+ // verify the plane is already exists
+ int aLastPlanIndex = 0;
+ while (aLastPlanIndex < 2) {
+ if (!aCaps[aLastPlanIndex]) {
+ // add new plane
+ aCaps[aLastPlanIndex] = aCurPln;
+ break;
+ }
+ if (aCaps[aLastPlanIndex]->isCoincident(aCurPln))
+ break;
+ ++aLastPlanIndex;
+ }
+
+ isPlaneApplicable = aLastPlanIndex < 2;
+ }
+
+ if (isPlaneApplicable) {
+ if (!anAxis) // no cone is found, store the normal as further cone's axis
+ anAxis = aCurPln->direction();
+ }
+ else {
+ isCone = false;
+ break;
+ }
+ }
+ }
+
+ isCone = isCone && aCaps[0] && aCaps[0]->direction()->isParallel(anAxis);
+ if (isCone && aCaps[1]) // cone map have only one cap, if it is bounded by the apex
+ isCone = aCaps[1]->direction()->isParallel(anAxis);
+
+ GeomConePtr aCone;
+ if (isCone) {
+ // intersect planes with cone's axis
+ std::shared_ptr<GeomAPI_XYZ> anAxisXYZ = anAxis->xyz();
+ std::shared_ptr<GeomAPI_XYZ> anApexXYZ = anApex->xyz();
+ double aParam0 = anAxisXYZ->dot(aCaps[0]->location()->xyz()->decreased(anApexXYZ));
+ double aParam1 =
+ aCaps[1] ? anAxisXYZ->dot(aCaps[1]->location()->xyz()->decreased(anApexXYZ)) : 0.0;
+ if (aParam0 <= 0.0 && aParam1 <= 0.0) {
+ // reverse axis to make smaller cap be the first
+ anAxis->reverse();
+ aParam0 = -aParam0;
+ aParam1 = -aParam1;
+ }
+ if (aParam0 > aParam1 + Precision::Confusion()) {
+ double tmp = aParam0;
+ aParam0 = aParam1;
+ aParam1 = tmp;
+ }
+
+ // calculate location of cone to be coincident with one of planes
+ GeomPointPtr aLocation(new GeomAPI_Pnt(
+ anApex->x() + aParam0 * anAxis->x(),
+ anApex->y() + aParam0 * anAxis->y(),
+ anApex->z() + aParam0 * anAxis->z()));
+
+ // calculate radii of caps
+ aParam0 /= Cos(aSemiAngle);
+ aParam1 /= Cos(aSemiAngle);
+
+ aCone = GeomConePtr(new GeomAPI_Cone(aLocation, anAxis, aSemiAngle, aParam0, aParam1));
+ }
+ return aCone;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Torus> GeomAPI_Solid::getTorus() const
+{
+ GeomTorusPtr aTorus;
+ ListOfShape aShells = subShapes(SHELL);
+ if (aShells.size() == 1)
+ aTorus = aShells.front()->shell()->getTorus();
+ return aTorus;
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Box> GeomAPI_Solid::getParallelepiped() const
+{
+ GeomBoxPtr aBox;
+ ListOfShape aShells = subShapes(SHELL);
+ if (aShells.size() == 1)
+ aBox = aShells.front()->shell()->getParallelepiped();
+ return aBox;
+}
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GeomAPI_Solid_H_
+#define GeomAPI_Solid_H_
+
+#include <GeomAPI_Shape.h>
+
+class GeomAPI_Sphere;
+class GeomAPI_Cylinder;
+class GeomAPI_Cone;
+class GeomAPI_Torus;
+class GeomAPI_Box;
+
+/// \class GeomAPI_Solid
+/// \ingroup DataModel
+/// \brief Interface to the solid object
+class GeomAPI_Solid: public GeomAPI_Shape
+{
+public:
+ /// Makes an undefined solid.
+ GEOMAPI_EXPORT GeomAPI_Solid();
+
+ /// Creation of solid by the solid-shape
+ GEOMAPI_EXPORT GeomAPI_Solid(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
+ /// Returns sphere if the solid is only bounded by faces
+ /// which are based on the same spherical surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Sphere> getSphere() const;
+
+ /// Returns cylinder if the solid is bounded by faces based on the same cylindrical surface
+ /// and a pair of parallel planar faces
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Cylinder> getCylinder() const;
+
+ /// Returns cone if the solid is bounded by faces based on the same conical surface
+ /// and a pair of parallel planar faces
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Cone> getCone() const;
+
+ /// Returns torus if the shell solid is only bounded by faces
+ /// which are based on the same toroidal surface
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Torus> getTorus() const;
+
+ /// Returns box if the solid is bounded by 6 rectangular faces composing a box
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Box> getParallelepiped() const;
+};
+
+typedef std::shared_ptr<GeomAPI_Solid> GeomSolidPtr;
+
+#endif
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <GeomAPI_Sphere.h>
+#include <GeomAPI_Pnt.h>
+
+#include <gp_Sphere.hxx>
+
+#define MY_SPHERE implPtr<gp_Sphere>()
+
+static gp_Sphere* newSphere(const gp_Pnt& theCenter, const double theRadius)
+{
+ return new gp_Sphere(gp_Ax3(theCenter, gp::DZ()), theRadius);
+}
+
+//=================================================================================================
+GeomAPI_Sphere::GeomAPI_Sphere(const std::shared_ptr<GeomAPI_Pnt>& theCenter, double theRadius)
+ : GeomAPI_Interface(newSphere(theCenter->impl<gp_Pnt>(), theRadius))
+{
+}
+
+//=================================================================================================
+const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Sphere::center() const
+{
+ const gp_Pnt& aCenter = MY_SPHERE->Location();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
+}
+
+//=================================================================================================
+double GeomAPI_Sphere::radius() const
+{
+ return MY_SPHERE->Radius();
+}
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GeomAPI_Sphere_H_
+#define GeomAPI_Sphere_H_
+
+#include <GeomAPI_Interface.h>
+#include <memory>
+
+class GeomAPI_Pnt;
+
+/**\class GeomAPI_Sphere
+ * \ingroup DataModel
+ * \brief Spherical surface in 3D
+ */
+class GeomAPI_Sphere : public GeomAPI_Interface
+{
+public:
+
+ /// Construct sphere by center and radius
+ GEOMAPI_EXPORT GeomAPI_Sphere(const std::shared_ptr<GeomAPI_Pnt>& theCenter, double theRadius);
+
+ /// Return center of the sphere
+ GEOMAPI_EXPORT const std::shared_ptr<GeomAPI_Pnt> center() const;
+
+ /// Return radius of the sphere
+ GEOMAPI_EXPORT double radius() const;
+};
+
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Sphere> GeomSpherePtr;
+
+#endif
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <GeomAPI_Torus.h>
+
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+
+#include <gp_Torus.hxx>
+
+#define MY_TORUS implPtr<gp_Torus>()
+
+static gp_Torus* newTorus(const gp_Pnt& theCenter, const gp_Dir& theDir,
+ const double theMajorRadius, const double theMinorRadius)
+{
+ return new gp_Torus(gp_Ax3(theCenter, theDir), theMajorRadius, theMinorRadius);
+}
+
+//=================================================================================================
+GeomAPI_Torus::GeomAPI_Torus(const std::shared_ptr<GeomAPI_Pnt>& theCenter,
+ const std::shared_ptr<GeomAPI_Dir>& theDir,
+ const double theMajorRadius,
+ const double theMinorRadius)
+ : GeomAPI_Interface(
+ newTorus(theCenter->impl<gp_Pnt>(), theDir->impl<gp_Dir>(), theMajorRadius, theMinorRadius))
+{
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Torus::center() const
+{
+ const gp_Pnt& aCenter = MY_TORUS->Location();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Torus::direction() const
+{
+ const gp_Dir& aDir = MY_TORUS->Axis().Direction();
+ return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
+
+//=================================================================================================
+double GeomAPI_Torus::majorRadius() const
+{
+ return MY_TORUS->MajorRadius();
+}
+
+//=================================================================================================
+double GeomAPI_Torus::minorRadius() const
+{
+ return MY_TORUS->MinorRadius();
+}
--- /dev/null
+// Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef GeomAPI_Torus_H_
+#define GeomAPI_Torus_H_
+
+#include <GeomAPI_Interface.h>
+#include <memory>
+
+class GeomAPI_Dir;
+class GeomAPI_Pnt;
+
+/**\class GeomAPI_Torus
+ * \ingroup DataModel
+ * \brief Toroidal surface in 3D
+ */
+class GeomAPI_Torus : public GeomAPI_Interface
+{
+public:
+ /// Creation of torus defined by center point, direction, major and minor radii
+ GEOMAPI_EXPORT GeomAPI_Torus(const std::shared_ptr<GeomAPI_Pnt>& theCenter,
+ const std::shared_ptr<GeomAPI_Dir>& theDir,
+ const double theMajorRadius,
+ const double theMinorRadius);
+
+ /// Return center of the torus
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> center() const;
+
+ /// Return direction of the torus
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Dir> direction() const;
+
+ /// Return major radius of the torus
+ GEOMAPI_EXPORT double majorRadius() const;
+
+ /// Return minor radius of the torus
+ GEOMAPI_EXPORT double minorRadius() const;
+};
+
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_Torus> GeomTorusPtr;
+
+#endif
//
#include "GeomAPI_Wire.h"
+#include "GeomAPI_Pnt.h"
#include <BRep_Builder.hxx>
+#include <BRepTools_WireExplorer.hxx>
+#include <Geom_Line.hxx>
+#include <Precision.hxx>
+#include <Standard_Type.hxx>
+#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
//==================================================================================================
setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
}
}
+
+//==================================================================================================
+bool GeomAPI_Wire::isClosed() const
+{
+ return BRep_Tool::IsClosed(impl<TopoDS_Shape>());
+}
+
+//==================================================================================================
+bool GeomAPI_Wire::isPolygon(std::list<GeomPointPtr>& thePoints) const
+{
+ const TopoDS_Wire& aWire = TopoDS::Wire(impl<TopoDS_Shape>());
+
+ bool isPolygon = true;
+ const Handle(Standard_Type)& aLineType = STANDARD_TYPE(Geom_Line);
+ for (BRepTools_WireExplorer anExp(aWire); anExp.More() && isPolygon; anExp.Next()) {
+ const TopoDS_Edge& anEdge = anExp.Current();
+ double aT1, aT2;
+ Handle(Geom_Curve) aC3D = BRep_Tool::Curve(anEdge, aT1, aT2);
+ if (!aC3D.IsNull() && aC3D->IsKind(aLineType)) {
+ gp_Pnt aCorner = BRep_Tool::Pnt(anExp.CurrentVertex());
+ thePoints.push_back(GeomPointPtr(new GeomAPI_Pnt(aCorner.X(), aCorner.Y(), aCorner.Z())));
+ }
+ else
+ isPolygon = false;
+ }
+
+ if (!isPolygon)
+ thePoints.clear();
+ return isPolygon;
+}
+
+//==================================================================================================
+bool GeomAPI_Wire::isRectangle(std::list<GeomPointPtr>& thePoints) const
+{
+ const TopoDS_Wire& aWire = TopoDS::Wire(impl<TopoDS_Shape>());
+ const Handle(Standard_Type)& aLineType = STANDARD_TYPE(Geom_Line);
+
+ gp_XYZ aPrevDir(0, 0, 0);
+
+ for (BRepTools_WireExplorer anExp(aWire); anExp.More(); anExp.Next()) {
+ const TopoDS_Edge& anEdge = anExp.Current();
+ double aT1, aT2;
+ Handle(Geom_Curve) aC3D = BRep_Tool::Curve(anEdge, aT1, aT2);
+ if (!aC3D.IsNull() && aC3D->IsKind(aLineType)) {
+ gp_Pnt aCorner = BRep_Tool::Pnt(anExp.CurrentVertex());
+ thePoints.push_back(GeomPointPtr(new GeomAPI_Pnt(aCorner.X(), aCorner.Y(), aCorner.Z())));
+ }
+ else
+ return false;
+
+ if (thePoints.size() > 4)
+ return false;
+
+ // collect length of the edge
+ gp_Pnt aStart = aC3D->Value(aT1);
+ gp_Pnt aEnd = aC3D->Value(aT2);
+
+ // check the edge is orthogonal to the previous
+ gp_XYZ aCurDir = (aEnd.XYZ() - aStart.XYZ()).Normalized();
+ if (aPrevDir.Dot(aCurDir) < Precision::Confusion())
+ aPrevDir = aCurDir;
+ else
+ return false;
+ }
+ return true;
+}
#include "GeomAPI_Shape.h"
+class GeomAPI_Pnt;
+
/// \class GeomAPI_Wire
/// \ingroup DataModel
/// \brief Interface to the wire object
/// Creation of wire by the wire-shape
GEOMAPI_EXPORT GeomAPI_Wire(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
+ /// Returns "closed" status of the wire
+ GEOMAPI_EXPORT bool isClosed() const;
+
+ /// Returns \c true if the wire is a polygon
+ /// \param[out] thePoints vertices of the polygon
+ GEOMAPI_EXPORT bool isPolygon(std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints) const;
+
+ /// Returns \c true if the wire is a rectangle
+ /// \param[out] thePoints corners of the rectangle
+ GEOMAPI_EXPORT bool isRectangle(std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints) const;
};
typedef std::shared_ptr<GeomAPI_Wire> GeomWirePtr;
#include "GeomAPI_Ax1.h"
#include "GeomAPI_Ax2.h"
#include "GeomAPI_Ax3.h"
+ #include "GeomAPI_Box.h"
#include "GeomAPI_Circ.h"
#include "GeomAPI_Circ2d.h"
+ #include "GeomAPI_Cone.h"
#include "GeomAPI_Curve.h"
+ #include "GeomAPI_Cylinder.h"
#include "GeomAPI_DataMapOfShapeMapOfShapes.h"
#include "GeomAPI_DataMapOfShapeShape.h"
#include "GeomAPI_Dir.h"
#include "GeomAPI_Shape.h"
#include "GeomAPI_ShapeExplorer.h"
#include "GeomAPI_ShapeIterator.h"
+ #include "GeomAPI_Shell.h"
+ #include "GeomAPI_Solid.h"
+ #include "GeomAPI_Sphere.h"
+ #include "GeomAPI_Torus.h"
#include "GeomAPI_Vertex.h"
#include "GeomAPI_XY.h"
#include "GeomAPI_XYZ.h"
#include <ModelAPI_Result.h>
+#include <GeomAPI_Ax3.h>
+#include <GeomAPI_Box.h>
+#include <GeomAPI_Circ.h>
+#include <GeomAPI_Cone.h>
+#include <GeomAPI_Cylinder.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Ellipse.h>
+#include <GeomAPI_Face.h>
+#include <GeomAPI_Pln.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Shell.h>
+#include <GeomAPI_Solid.h>
+#include <GeomAPI_Sphere.h>
+#include <GeomAPI_Torus.h>
+#include <GeomAPI_Vertex.h>
+#include <GeomAPI_Wire.h>
+
#include <QLayout>
#include <QScrollArea>
#include <QLabel>
#include <QHeaderView>
#include <QTextBrowser>
-#include <BRep_Tool.hxx>
-#include <BRepTools.hxx>
-#include <BRepGProp.hxx>
-#include <GeomAbs_CurveType.hxx>
-#include <GeomAbs_SurfaceType.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <GeomAdaptor_Surface.hxx>
-#include <Geom_BSplineCurve.hxx>
-#include <GProp_GProps.hxx>
-#include <gp_Circ.hxx>
-#include <gp_Elips.hxx>
-#include <gp_Sphere.hxx>
-#include <gp_Cylinder.hxx>
-#include <gp_Cone.hxx>
-#include <gp_Torus.hxx>
+#include <BRepBndLib.hxx>
+#include <TopoDS_Iterator.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Wire.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic
+// ================ Auxiliary functions ================
+#define TITLE(val) ("<b>" + (val) + "</b>")
+
+static void appendPointToParameters(const QString& thePointTitle,
+ const GeomPointPtr& theCoord,
+ QString& theParams)
+{
+ theParams += TITLE(thePointTitle) +
+ "<br> X: " + QString::number(theCoord->x()) +
+ "<br> Y: " + QString::number(theCoord->y()) +
+ "<br> Z: " + QString::number(theCoord->z()) +
+ "<br>";
+}
+
+static void appendDirToParameters(const QString& theDirTitle,
+ const GeomDirPtr& theDirection,
+ QString& theParams)
+{
+ theParams += TITLE(theDirTitle) +
+ "<br> DX: " + QString::number(theDirection->x()) +
+ "<br> DY: " + QString::number(theDirection->y()) +
+ "<br> DZ: " + QString::number(theDirection->z()) +
+ "<br>";
+}
+
+static void appendGroupNameToParameters(const QString& theGroupTitle, QString& theParams)
+{
+ theParams += TITLE(theGroupTitle) + "<br>";
+}
+
+static void appendNamedValueToParameters(const QString& theName,
+ const double theValue,
+ QString& theParams)
+{
+ theParams += theName + ": " + QString::number(theValue) + "<br>";
+}
+
+static void appendNamedValueToParameters(const QString& theName,
+ const bool theValue,
+ QString& theParams)
+{
+ theParams += theName + ": " + (theValue ? "True" : "False") + "<br>";
+}
+
+
+// ================ XGUI_InspectionPanel ================
+
XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr* theMgr)
: QDockWidget(theParent),
mySelectionMgr(theMgr)
//********************************************************************
void XGUI_InspectionPanel::setShapeParams(const TopoDS_Shape& theShape)
{
- switch (theShape.ShapeType()) {
- case TopAbs_VERTEX:
- fillVertex(theShape);
+ GeomShapePtr aShape(new GeomAPI_Shape);
+ aShape->setImpl(new TopoDS_Shape(theShape));
+
+ switch (aShape->shapeType()) {
+ case GeomAPI_Shape::VERTEX:
+ fillVertex(aShape->vertex());
break;
- case TopAbs_EDGE:
- fillEdge(theShape);
+ case GeomAPI_Shape::EDGE:
+ fillEdge(aShape->edge());
break;
- case TopAbs_FACE:
- fillFace(theShape);
+ case GeomAPI_Shape::FACE:
+ fillFace(aShape->face());
break;
- case TopAbs_SOLID:
- fillSolid(theShape);
+ case GeomAPI_Shape::SOLID:
+ fillSolid(aShape->solid());
break;
- case TopAbs_WIRE:
- case TopAbs_SHELL:
- case TopAbs_COMPSOLID:
- case TopAbs_COMPOUND:
- fillContainer(theShape);
+ case GeomAPI_Shape::WIRE:
+ fillWire(aShape->wire());
+ break;
+ case GeomAPI_Shape::SHELL:
+ fillShell(aShape->shell());
+ break;
+ case GeomAPI_Shape::COMPSOLID:
+ case GeomAPI_Shape::COMPOUND:
+ fillContainer(aShape);
break;
}
}
//********************************************************************
-void XGUI_InspectionPanel::fillVertex(const TopoDS_Shape& theShape)
+void XGUI_InspectionPanel::fillVertex(const GeomVertexPtr& theVertex)
{
- TopoDS_Vertex aV = TopoDS::Vertex(theShape);
- gp_Pnt aP = BRep_Tool::Pnt(aV);
- setVertexType(aP.XYZ());
-}
+ GeomPointPtr aPoint = theVertex->point();
-//********************************************************************
-void XGUI_InspectionPanel::fillEdge(const TopoDS_Shape& theShape)
-{
- TopoDS_Edge aE = TopoDS::Edge(theShape);
-
- bool bDegenerated = BRep_Tool::Degenerated(aE);
-
- double aT1, aT2;
- Handle(Geom_Curve) aC3D = BRep_Tool::Curve(aE, aT1, aT2);
- GeomAdaptor_Curve aGAC(aC3D);
- GeomAbs_CurveType aCT = aGAC.GetType();
-
- if (aCT == GeomAbs_Line) { // Line
- gp_Pnt aP1, aP2;
- aGAC.D0(aT1, aP1);
- aGAC.D0(aT2, aP2);
- setLineType(aP1.XYZ(), aP2.XYZ());
-
- } else if (aCT == GeomAbs_Circle) {
- gp_Circ aCirc = aGAC.Circle();
- gp_Pnt aP = aCirc.Location();
- gp_Ax2 aAx2 = aCirc.Position();
- double aR1 = aCirc.Radius();
- gp_Dir aDir = aAx2.Axis().Direction();
-
- bool isArc = (Abs(aT2 - aT1 - aC3D->Period()) >= Precision::PConfusion());
- if (isArc) {
- gp_Pnt aP1, aP2;
- aGAC.D0(aT1, aP1);
- aGAC.D0(aT2, aP2);
- setArcType(aP.XYZ(), aDir.XYZ(), aR1, aP1.XYZ(), aP2.XYZ());
- } else
- setCircleType(aP.XYZ(), aDir.XYZ(), aR1);
-
- } else if (aCT == GeomAbs_Ellipse) {
- gp_Elips aElips = aGAC.Ellipse();
- gp_Pnt aP = aElips.Location();
- gp_Ax2 aAx2 = aElips.Position();
- double aR1 = aElips.MajorRadius();
- double aR2 = aElips.MinorRadius();
- gp_Dir aDir = aAx2.Axis().Direction();
- gp_Pnt aP1, aP2;
- aGAC.D0(aT1, aP1);
- aGAC.D0(aT2, aP2);
- bool isArc = aP1.Distance(aP2) > Precision::Confusion();
- if (isArc)
- setEllipseArcType(aP.XYZ(), aDir.XYZ(), aR1, aR2, aP1.XYZ(), aP2.XYZ());
- else
- setEllipseType(aP.XYZ(), aDir.XYZ(), aR1, aR2);
- }
+ myTypeLbl->setText(tr("Vertex"));
+
+ QString aParams;
+ appendPointToParameters(tr("Coordinates"), aPoint, aParams);
+ myTypeParams->setText(aParams);
}
//********************************************************************
-void XGUI_InspectionPanel::fillFace(const TopoDS_Shape& theShape)
+void XGUI_InspectionPanel::fillEdge(const GeomEdgePtr& theEdge)
{
- TopoDS_Face aF = TopoDS::Face(theShape);
- //
- Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aF);
- GeomAdaptor_Surface aGAS(aSurf);
- GeomAbs_SurfaceType aST = aGAS.GetType();
-
- // 1. Plane
- if (aST == GeomAbs_Plane) {
- gp_Pln aPln = aGAS.Plane();
- gp_Pnt aP0 = aPln.Location();
- gp_Ax3 aAx3 = aPln.Position();
-
- setPlaneType(aP0.XYZ(), aAx3.Direction().XYZ());
- }
- // 2. Sphere
- else if (aST == GeomAbs_Sphere) {
- gp_Sphere aSphere = aGAS.Sphere();
- gp_Pnt aP0 = aSphere.Location();
- double aR1 = aSphere.Radius();
+ QString aParams;
+ if (theEdge->isDegenerated())
+ appendNamedValueToParameters(tr("Degenerated"), true, aParams);
- setSphereType(aP0.XYZ(), aR1);
- }
- // 3. Cylinder
- else if (aST == GeomAbs_Cylinder) {
- gp_Cylinder aCyl = aGAS.Cylinder();
- gp_Pnt aP0 = aCyl.Location();
- gp_Ax3 aAx3 = aCyl.Position();
- double aR1 = aCyl.Radius();
-
- double aUMin, aUMax, aVMin, aVMax;
- BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
- double dV = aVMax - aVMin;
-
- setCylinderType(aP0.XYZ(), aAx3.Direction().XYZ(), aR1, dV);
- }
- // 4. Cone
- else if (aST == GeomAbs_Cone) {
- gp_Cone aCone = aGAS.Cone();
- gp_Pnt aP0 = aCone.Location();
- gp_Ax3 aAx3 = aCone.Position();
- double aR1 = aCone.RefRadius();
-
- double aUMin, aUMax, aVMin, aVMax;
- BRepTools::UVBounds(aF, aUMin, aUMax, aVMin, aVMax);
- double aSemiAngle = fabs(aCone.SemiAngle());
- double dV = (aVMax - aVMin)*cos(aSemiAngle);
- double aR2 = aR1 - (aVMax - aVMin)*sin(aSemiAngle);
-
- setConeType(aP0.XYZ(), aAx3.Direction().XYZ(), aR1, aR2, dV);
+ GeomPointPtr aStartPnt = theEdge->firstPoint();
+ GeomPointPtr aEndPnt = theEdge->lastPoint();
+ bool addStartEndPoints = false;
+
+ if (theEdge->isLine()) {
+ myTypeLbl->setText(tr("Line segment"));
+ addStartEndPoints = true;
}
- // 5. Torus
- else if (aST == GeomAbs_Torus) {
- gp_Torus aTorus = aGAS.Torus();
- gp_Pnt aP0 = aTorus.Location();
- gp_Ax3 aAx3 = aTorus.Position();
- double aR1 = aTorus.MajorRadius();
- double aR2 = aTorus.MinorRadius();
-
- setTorusType(aP0.XYZ(), aAx3.Direction().XYZ(), aR1, aR2);
+ else {
+ GeomCirclePtr aCircle = theEdge->circle();
+ if (aCircle) {
+ addStartEndPoints = aStartPnt->distance(aEndPnt) >= Precision::Confusion();
+ if (addStartEndPoints)
+ myTypeLbl->setText("Arc of circle");
+ else
+ myTypeLbl->setText("Circle");
+
+ appendPointToParameters(tr("Center"), aCircle->center(), aParams);
+ appendDirToParameters(tr("Normal"), aCircle->normal(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Radius"), aCircle->radius(), aParams);
+ }
+ else {
+ GeomEllipsePtr anEllipse = theEdge->ellipse();
+ if (anEllipse) {
+ addStartEndPoints = aStartPnt->distance(aEndPnt) >= Precision::Confusion();
+ if (addStartEndPoints)
+ myTypeLbl->setText("Arc of ellipse");
+ else
+ myTypeLbl->setText("Ellipse");
+
+ appendPointToParameters(tr("Center"), anEllipse->center(), aParams);
+ appendDirToParameters(tr("Normal"), anEllipse->normal(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Major radius"), anEllipse->majorRadius(), aParams);
+ appendNamedValueToParameters(tr("Minor radius"), anEllipse->minorRadius(), aParams);
+ }
+ else
+ // Common case
+ myTypeLbl->setText(tr("Edge"));
+ }
}
-}
-//********************************************************************
-void XGUI_InspectionPanel::fillSolid(const TopoDS_Shape& theShape)
-{
- myTypeLbl->setText(tr("Solid"));
- TopoDS_Solid aSd = TopoDS::Solid(theShape);
- processSphere(aSd);
+ if (addStartEndPoints) {
+ appendPointToParameters(tr("Start point"), aStartPnt, aParams);
+ appendPointToParameters(tr("End point"), aEndPnt, aParams);
+ }
+ myTypeParams->setText(aParams);
}
-
-
//********************************************************************
-bool IsEqual(const gp_Sphere& aSp1, const gp_Sphere& aSp2, const Standard_Real aTolLin)
+void XGUI_InspectionPanel::fillWire(const GeomWirePtr& theWire)
{
- double aR1 = aSp1.Radius();
- double aR2 = aSp2.Radius();
- if (fabs(aR1 - aR2) > aTolLin) {
- return false;
+ QString aParams;
+ appendNamedValueToParameters(tr("Closed"), theWire->isClosed(), aParams);
+
+ // check the wire is a polygon
+ std::list<GeomPointPtr> aPolygonPoints;
+ if (theWire->isPolygon(aPolygonPoints)) {
+ myTypeLbl->setText(tr("Polygon"));
+ int aCornerIndex = 0;
+ for (std::list<GeomPointPtr>::const_iterator aPtIt = aPolygonPoints.begin();
+ aPtIt != aPolygonPoints.end(); ++aPtIt)
+ appendPointToParameters(tr("Point") + " " + QString::number(++aCornerIndex),
+ *aPtIt, aParams);
}
- const gp_Pnt& aPC1 = aSp1.Position().Location();
- const gp_Pnt& aPC2 = aSp2.Position().Location();
- double aD2 = aPC1.SquareDistance(aPC2);
- return (aD2 < (aTolLin*aTolLin));
-}
+ else
+ myTypeLbl->setText(tr("Wire"));
+ myTypeParams->setText(aParams);
+}
-bool XGUI_InspectionPanel::processSphere(const TopoDS_Solid& theSolid)
+//********************************************************************
+void XGUI_InspectionPanel::fillFace(const GeomFacePtr& theFace)
{
- gp_Sphere aSphere[2];
- GeomAbs_SurfaceType aST;
- Handle(Geom_Surface) aS;
- GeomAdaptor_Surface aGAS;
-
- double aTol = Precision::Confusion();
- double aTolAng = Precision::Angular();
-
- TopExp_Explorer aExp(theSolid, TopAbs_FACE);
- int j;
- for (j = 0; aExp.More(); aExp.Next(), ++j) {
- const TopoDS_Face& aF = *((TopoDS_Face*)&aExp.Current());
- aS = BRep_Tool::Surface(aF);
- aGAS.Load(aS);
- aST = aGAS.GetType();
- if (aST != GeomAbs_Sphere) {
- return false;
+ QString aParams;
+ // 1. Plane and planar faces
+ GeomPlanePtr aPlane = theFace->getPlane();
+ if (aPlane) {
+ bool isCommonCase = true;
+ // Check face bounded by circle or ellipse
+ std::list<GeomShapePtr> aSubs = theFace->subShapes(GeomAPI_Shape::EDGE);
+ if (aSubs.size() == 1) {
+ GeomEdgePtr anEdge = aSubs.front()->edge();
+ if (anEdge->isCircle() || anEdge->isEllipse()) {
+ fillEdge(anEdge);
+ isCommonCase = false;
+ }
}
- aSphere[j] = aGAS.Sphere();
- }
- bool bIsEqual = IsEqual(aSphere[0], aSphere[1], aTol);
- if (!bIsEqual) {
- return false;
- }
- GProp_GProps aGProps;
- bool bOnlyClosed = false;
- double aVolume = aSphere[0].Volume();
- BRepGProp::VolumeProperties(theSolid, aGProps, aTol, bOnlyClosed);
-
- double aVolumeS = aGProps.Mass();
- if (aVolumeS < 0.) {
- aVolumeS = -aVolumeS;
- }
- double dV = fabs(aVolumeS - aVolume);
- if (dV > aTol) {
- return false;
+ else {
+ // Check face bounded by a single wire which is rectangle
+ aSubs = theFace->subShapes(GeomAPI_Shape::WIRE);
+ if (aSubs.size() == 1) {
+ GeomWirePtr aWire = aSubs.front()->wire();
+ std::list<GeomPointPtr> aCorners;
+ if (aWire->isRectangle(aCorners)) {
+ GeomPointPtr aBaseCorner = aCorners.front();
+ aCorners.pop_front();
+
+ double aWidth = aBaseCorner->distance(aCorners.front());
+ double aHeight = aBaseCorner->distance(aCorners.back());
+
+ myTypeLbl->setText(tr("Rectangle"));
+ appendPointToParameters(tr("Corner"), aBaseCorner, aParams);
+ appendDirToParameters(tr("Normal"), aPlane->direction(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Width"), aWidth, aParams);
+ appendNamedValueToParameters(tr("Height"), aHeight, aParams);
+ myTypeParams->setText(aParams);
+
+ isCommonCase = false;
+ }
+ }
+ }
+
+ if (isCommonCase)
+ setPlaneType(tr("Plane"), aPlane);
}
- double aArea = aSphere[0].Area();
- BRepGProp::SurfaceProperties(theSolid, aGProps, aTol);
- double aAreaS = aGProps.Mass();
- double dA = fabs(aAreaS - aArea);
- if (dA > aTol) {
- return false;
+ else {
+ // 2. Sphere
+ GeomSpherePtr aSphere = theFace->getSphere();
+ if (aSphere)
+ setSphereType(tr("Sphere"), aSphere);
+ else {
+ // 3. Cylinder
+ GeomCylinderPtr aCylinder = theFace->getCylinder();
+ if (aCylinder)
+ setCylinderType(tr("Cylinder"), aCylinder);
+ else {
+ // 4. Cone
+ GeomConePtr aCone = theFace->getCone();
+ if (aCone)
+ setConeType(tr("Cone"), aCone);
+ else {
+ // 5. Torus
+ GeomTorusPtr aTorus = theFace->getTorus();
+ if (aTorus)
+ setTorusType(tr("Torus"), aTorus);
+ else
+ // 6. Common case
+ myTypeLbl->setText(tr("Face"));
+ }
+ }
+ }
}
- gp_Pnt aP0 = aSphere[0].Location();
- double aR1 = aSphere[0].Radius();
-
- setSphereType(aP0.XYZ(), aR1);
-
- return true;
}
-
//********************************************************************
-void XGUI_InspectionPanel::fillContainer(const TopoDS_Shape& theShape)
+void XGUI_InspectionPanel::fillShell(const GeomShellPtr& theShell)
{
- TopAbs_ShapeEnum aType = theShape.ShapeType();
- if (aType == TopAbs_SHELL) {
- bool aIsClosed = BRep_Tool::IsClosed(theShape);
- myTypeLbl->setText(tr("Shell"));
- myTypeParams->setText(aIsClosed? tr("Closed") : tr("Non-closed"));
- } else if (aType == TopAbs_WIRE) {
- TopoDS_Wire aW = TopoDS::Wire(theShape);
- bool isClosed = aW.Closed();
- myTypeLbl->setText(tr("Wire"));
- myTypeParams->setText(isClosed ? tr("Closed") : tr("Non-closed"));
+ // 1. Sphere
+ GeomSpherePtr aSphere = theShell->getSphere();
+ if (aSphere)
+ setSphereType(tr("Sphere"), aSphere);
+ else {
+ // 2. Cylinder
+ GeomCylinderPtr aCylinder = theShell->getCylinder();
+ if (aCylinder)
+ setCylinderType(tr("Cylinder"), aCylinder);
+ else {
+ // 3. Cone
+ GeomConePtr aCone = theShell->getCone();
+ if (aCone)
+ setConeType(tr("Cone"), aCone);
+ else {
+ // 4. Torus
+ GeomTorusPtr aTorus = theShell->getTorus();
+ if (aTorus)
+ setTorusType(tr("Torus"), aTorus);
+ else {
+ // 5. Axis-aligned/Rotated Box
+ GeomBoxPtr aBox = theShell->getParallelepiped();
+ if (aBox) {
+ if (aBox->isAxesAligned())
+ setBoxType(tr("Box"), aBox);
+ else
+ setRotatedBoxType(tr("Rotated Box"), aBox);
+ }
+ else
+ // 6. Common case
+ myTypeLbl->setText(tr("Shell"));
+ }
+ }
+ }
}
}
//********************************************************************
-#define TITLE(val) ("<b>" + val + "</b>")
-
-void XGUI_InspectionPanel::setCylinderType(const gp_XYZ& theLoc,
- const gp_XYZ& theDir, double theRadius, double theHeight)
+void XGUI_InspectionPanel::fillSolid(const GeomSolidPtr& theSolid)
{
- myTypeLbl->setText(tr("Cylinder"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Axis")) +
- "<br> DX: " + QString::number(theDir.X()) +
- "<br> DY: " + QString::number(theDir.Y()) +
- "<br> DZ: " + QString::number(theDir.Z()) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + tr("Radius: ") + QString::number(theRadius) +
- "<br>" + tr("Height: ") + QString::number(theHeight);
-
- myTypeParams->setText(aParams);
+ // 1. Sphere
+ GeomSpherePtr aSphere = theSolid->getSphere();
+ if (aSphere)
+ setSphereType(tr("Sphere"), aSphere);
+ else {
+ // 2. Cylinder
+ GeomCylinderPtr aCylinder = theSolid->getCylinder();
+ if (aCylinder)
+ setCylinderType(tr("Cylinder"), aCylinder);
+ else {
+ // 3. Cone
+ GeomConePtr aCone = theSolid->getCone();
+ if (aCone)
+ setConeType(tr("Cone"), aCone);
+ else {
+ // 4. Torus
+ GeomTorusPtr aTorus = theSolid->getTorus();
+ if (aTorus)
+ setTorusType(tr("Torus"), aTorus);
+ else {
+ // 5. Axis-aligned/Rotated Box
+ GeomBoxPtr aBox = theSolid->getParallelepiped();
+ if (aBox) {
+ if (aBox->isAxesAligned())
+ setBoxType(tr("Box"), aBox);
+ else
+ setRotatedBoxType(tr("Rotated Box"), aBox);
+ }
+ else
+ // 6. Common case
+ myTypeLbl->setText(tr("Solid"));
+ }
+ }
+ }
+ }
}
//********************************************************************
-void XGUI_InspectionPanel::setSphereType(const gp_XYZ& theLoc, double theRadius)
+void XGUI_InspectionPanel::fillContainer(const GeomShapePtr& theShape)
{
- myTypeLbl->setText(tr("Sphere"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + tr("Radius: ") + QString::number(theRadius);
- myTypeParams->setText(aParams);
-}
+ if (theShape->shapeType() == GeomAPI_Shape::COMPSOLID)
+ myTypeLbl->setText("CompSolid");
+ else if (theShape->shapeType() == GeomAPI_Shape::COMPOUND)
+ myTypeLbl->setText("Compound");
-//********************************************************************
-void XGUI_InspectionPanel::setBoxType(double theX, double theY, double theZ,
- double theXsize, double theYsize, double theZsize)
-{
- myTypeLbl->setText(tr("Box"));
- QString aParams = TITLE(tr("Position")) +
- "<br> X: " + QString::number(theX) +
- "<br> Y: " + QString::number(theY) +
- "<br> Z: " + QString::number(theZ) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + "Ax :" + QString::number(theXsize) +
- "<br>" + "Ay :" + QString::number(theYsize) +
- "<br>" + "Az :" + QString::number(theZsize);
- myTypeParams->setText(aParams);
-}
+ // fill bounding box
+ Bnd_Box aBB;
+ BRepBndLib::Add(theShape->impl<TopoDS_Shape>(), aBB);
-//********************************************************************
-void XGUI_InspectionPanel::setRotatedBoxType(double theX, double theY, double theZ,
- double theZaxisX, double theZaxisY, double theZaxisZ,
- double theXaxisX, double theXaxisY, double theXaxisZ,
- double theXsize, double theYsize, double theZsize)
-{
- myTypeLbl->setText(tr("Box"));
- QString aParams = TITLE(tr("Position")) +
- "<br> X: " + QString::number(theX) +
- "<br> Y: " + QString::number(theY) +
- "<br> Z: " + QString::number(theZ) +
- "<br>" + TITLE(tr("Z axis")) +
- "<br> DX: " + QString::number(theZaxisX) +
- "<br> DY: " + QString::number(theZaxisY) +
- "<br> DZ: " + QString::number(theZaxisZ) +
- "<br>" + TITLE(tr("X axis")) +
- "<br> DX: " + QString::number(theXaxisX) +
- "<br> DY: " + QString::number(theXaxisY) +
- "<br> DZ: " + QString::number(theXaxisZ) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + "Ax :" + QString::number(theXsize) +
- "<br>" + "Ay :" + QString::number(theYsize) +
- "<br>" + "Az :" + QString::number(theZsize);
- myTypeParams->setText(aParams);
-}
+ gp_Pnt aMinPnt = aBB.CornerMin();
+ GeomPointPtr aMinPoint(new GeomAPI_Pnt(aMinPnt.X(), aMinPnt.Y(), aMinPnt.Z()));
-//********************************************************************
-void XGUI_InspectionPanel::setPlaneType(const gp_XYZ& theLoc, const gp_XYZ& theDir)
-{
- myTypeLbl->setText(tr("Plane"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Normal")) +
- "<br> DX: " + QString::number(theDir.X()) +
- "<br> DY: " + QString::number(theDir.Y()) +
- "<br> DZ: " + QString::number(theDir.Z());
- myTypeParams->setText(aParams);
-}
+ gp_Pnt aMaxPnt = aBB.CornerMax();
+ GeomPointPtr aMaxPoint(new GeomAPI_Pnt(aMaxPnt.X(), aMaxPnt.Y(), aMaxPnt.Z()));
-//********************************************************************
-void XGUI_InspectionPanel::setVertexType(const gp_XYZ& theLoc)
-{
- myTypeLbl->setText(tr("Vertex"));
- QString aParams = TITLE(tr("Coordinates")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z());
- myTypeParams->setText(aParams);
+ QString aParams;
+ appendGroupNameToParameters(tr("Bounding box"), aParams);
+ appendPointToParameters(tr("Minimal corner"), aMinPoint, aParams);
+ appendPointToParameters(tr("Maximal corner"), aMaxPoint, aParams);
}
-//********************************************************************
-void XGUI_InspectionPanel::setCircleType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theRadius)
+void XGUI_InspectionPanel::setPlaneType(const QString& theTitle,
+ const std::shared_ptr<GeomAPI_Pln>& thePlane)
{
- myTypeLbl->setText(tr("Circle"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Normal")) +
- "<br> DX: " + QString::number(theDir.X()) +
- "<br> DY: " + QString::number(theDir.Y()) +
- "<br> DZ: " + QString::number(theDir.Z()) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + tr("Radius: ") + QString::number(theRadius);
+ myTypeLbl->setText(theTitle);
+ QString aParams;
+ appendPointToParameters(tr("Origin"), thePlane->location(), aParams);
+ appendDirToParameters(tr("Normal"), thePlane->direction(), aParams);
myTypeParams->setText(aParams);
}
-//********************************************************************
-void XGUI_InspectionPanel::setArcType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theRadius, const gp_XYZ& theP1, const gp_XYZ& theP2)
+void XGUI_InspectionPanel::setSphereType(const QString& theTitle,
+ const std::shared_ptr<GeomAPI_Sphere>& theSphere)
{
- myTypeLbl->setText(tr("Arc"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Normal")) +
- "<br> DX: " + QString::number(theDir.X()) +
- "<br> DY: " + QString::number(theDir.Y()) +
- "<br> DZ: " + QString::number(theDir.Z()) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + tr("Radius:") + QString::number(theRadius) +
- "<br>" + TITLE(tr("Point 1")) +
- "<br> X: " + QString::number(theP1.X()) +
- "<br> Y: " + QString::number(theP1.Y()) +
- "<br> Z: " + QString::number(theP1.Z()) +
- "<br>" + TITLE(tr("Point 2")) +
- "<br> X: " + QString::number(theP2.X()) +
- "<br> Y: " + QString::number(theP2.Y()) +
- "<br> Z: " + QString::number(theP2.Z());
+ myTypeLbl->setText(theTitle);
+ QString aParams;
+ appendPointToParameters(tr("Center"), theSphere->center(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Radius"), theSphere->radius(), aParams);
myTypeParams->setText(aParams);
}
-//********************************************************************
-void XGUI_InspectionPanel::setEllipseType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theMajorRad, double theMinorRad)
+void XGUI_InspectionPanel::setCylinderType(const QString& theTitle,
+ const std::shared_ptr<GeomAPI_Cylinder>& theCyl)
{
- myTypeLbl->setText(tr("Ellipse"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Normal")) +
- "<br> DX: " + QString::number(theDir.X()) +
- "<br> DY: " + QString::number(theDir.Y()) +
- "<br> DZ: " + QString::number(theDir.Z()) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + tr("Major radius: ") + QString::number(theMajorRad) +
- "<br>" + tr("Minor radius: ") + QString::number(theMinorRad);
+ myTypeLbl->setText(theTitle);
+ QString aParams;
+ appendPointToParameters(tr("Position"), theCyl->location(), aParams);
+ appendDirToParameters(tr("Axis"), theCyl->axis(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Radius"), theCyl->radius(), aParams);
+ appendNamedValueToParameters(tr("Height"), theCyl->height(), aParams);
myTypeParams->setText(aParams);
}
-//********************************************************************
-void XGUI_InspectionPanel::setEllipseArcType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theMajorRad, double theMinorRad, const gp_XYZ& theP1, const gp_XYZ& theP2)
+void XGUI_InspectionPanel::setConeType(const QString& theTitle,
+ const std::shared_ptr<GeomAPI_Cone>& theCone)
{
- myTypeLbl->setText(tr("Elliptical arc"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Normal")) +
- "<br> DX: " + QString::number(theDir.X()) +
- "<br> DY: " + QString::number(theDir.Y()) +
- "<br> DZ: " + QString::number(theDir.Z()) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + tr("Major radius:") + QString::number(theMajorRad) +
- "<br>" + tr("Minor radius:") + QString::number(theMinorRad) +
- "<br>" + TITLE(tr("Point 1")) +
- "<br> X: " + QString::number(theP1.X()) +
- "<br> Y: " + QString::number(theP1.Y()) +
- "<br> Z: " + QString::number(theP1.Z()) +
- "<br>" + TITLE(tr("Point 2")) +
- "<br> X: " + QString::number(theP2.X()) +
- "<br> Y: " + QString::number(theP2.Y()) +
- "<br> Z: " + QString::number(theP2.Z());
+ myTypeLbl->setText(theTitle);
+ QString aParams;
+ appendPointToParameters(tr("Position"), theCone->location(), aParams);
+ appendDirToParameters(tr("Axis"), theCone->axis(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Radius 1"), theCone->radius1(), aParams);
+ appendNamedValueToParameters(tr("Radius 2"), theCone->radius2(), aParams);
+ appendNamedValueToParameters(tr("Height"), theCone->height(), aParams);
myTypeParams->setText(aParams);
}
-void XGUI_InspectionPanel::setLineType(const gp_XYZ& theP1, const gp_XYZ& theP2)
+void XGUI_InspectionPanel::setTorusType(const QString& theTitle,
+ const std::shared_ptr<GeomAPI_Torus>& theTorus)
{
- myTypeLbl->setText(tr("Line"));
- QString aParams = TITLE(tr("Point 1")) +
- "<br> X: " + QString::number(theP1.X()) +
- "<br> Y: " + QString::number(theP1.Y()) +
- "<br> Z: " + QString::number(theP1.Z()) +
- "<br>" + TITLE(tr("Point 2")) +
- "<br> X: " + QString::number(theP2.X()) +
- "<br> Y: " + QString::number(theP2.Y()) +
- "<br> Z: " + QString::number(theP2.Z());
+ myTypeLbl->setText(theTitle);
+ QString aParams;
+ appendPointToParameters(tr("Center"), theTorus->center(), aParams);
+ appendDirToParameters(tr("Axis"), theTorus->direction(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Major radius"), theTorus->majorRadius(), aParams);
+ appendNamedValueToParameters(tr("Minor radius"), theTorus->minorRadius(), aParams);
myTypeParams->setText(aParams);
}
-void XGUI_InspectionPanel::setConeType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theRad1, double theRad2, double theHeight)
+void XGUI_InspectionPanel::setBoxType(const QString& theTitle,
+ const std::shared_ptr<GeomAPI_Box>& theBox)
{
- myTypeLbl->setText(tr("Cone"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Axis")) +
- "<br> DX: " + QString::number(theDir.X()) +
- "<br> DY: " + QString::number(theDir.Y()) +
- "<br> DZ: " + QString::number(theDir.Z()) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + tr("Radius 1: ") + QString::number(theRad1) +
- "<br>" + tr("Radius 2: ") + QString::number(theRad2) +
- "<br>" + tr("Height: ") + QString::number(theHeight);
-
+ myTypeLbl->setText(theTitle);
+ QString aParams;
+ appendPointToParameters(tr("Position"), theBox->axes()->origin(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Width"), theBox->width(), aParams);
+ appendNamedValueToParameters(tr("Depth"), theBox->depth(), aParams);
+ appendNamedValueToParameters(tr("Height"), theBox->height(), aParams);
myTypeParams->setText(aParams);
}
-void XGUI_InspectionPanel::setTorusType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theRad1, double theRad2)
+void XGUI_InspectionPanel::setRotatedBoxType(const QString& theTitle,
+ const std::shared_ptr<GeomAPI_Box>& theBox)
{
- myTypeLbl->setText(tr("Torus"));
- QString aParams = TITLE(tr("Center")) +
- "<br> X: " + QString::number(theLoc.X()) +
- "<br> Y: " + QString::number(theLoc.Y()) +
- "<br> Z: " + QString::number(theLoc.Z()) +
- "<br>" + TITLE(tr("Axis")) +
- "<br> DX: " + QString::number(theDir.X()) +
- "<br> DY: " + QString::number(theDir.Y()) +
- "<br> DZ: " + QString::number(theDir.Z()) +
- "<br>" + TITLE(tr("Dimensions")) +
- "<br>" + tr("Radius 1: ") + QString::number(theRad1) +
- "<br>" + tr("Radius 2: ") + QString::number(theRad2);
-
+ myTypeLbl->setText(theTitle);
+ QString aParams;
+ std::shared_ptr<GeomAPI_Ax3> anAxes = theBox->axes();
+ appendPointToParameters(tr("Position"), anAxes->origin(), aParams);
+ appendDirToParameters(tr("Z axis"), anAxes->normal(), aParams);
+ appendDirToParameters(tr("X axis"), anAxes->dirX(), aParams);
+ appendGroupNameToParameters(tr("Dimensions"), aParams);
+ appendNamedValueToParameters(tr("Width"), theBox->width(), aParams);
+ appendNamedValueToParameters(tr("Depth"), theBox->depth(), aParams);
+ appendNamedValueToParameters(tr("Height"), theBox->height(), aParams);
myTypeParams->setText(aParams);
}
#include "XGUI.h"
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Solid.hxx>
-
#include <QDockWidget>
+#include <memory>
+
class XGUI_SelectionMgr;
class QLineEdit;
class QTableWidget;
class QLabel;
class QTextBrowser;
+class TopoDS_Shape;
+
+class GeomAPI_Vertex;
+class GeomAPI_Edge;
+class GeomAPI_Wire;
+class GeomAPI_Face;
+class GeomAPI_Shell;
+class GeomAPI_Solid;
+class GeomAPI_Shape;
+
+class GeomAPI_Pln;
+class GeomAPI_Sphere;
+class GeomAPI_Cylinder;
+class GeomAPI_Cone;
+class GeomAPI_Torus;
+class GeomAPI_Box;
+
/// Internal name of property panel widget
const static char* INSPECTION_PANEL = "inspection_panel_dock";
void setName(const QString& theName);
- // Set type parameters
- void setCylinderType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theRadius, double theHeight);
-
- void setConeType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theRad1, double theRad2, double theHeight);
-
- void setTorusType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theRad1, double theRad2);
+ void setShapeContent(const TopoDS_Shape& theShape);
- void setSphereType(const gp_XYZ& theLoc, double theRadius);
+ void setShapeParams(const TopoDS_Shape& theShape);
- void setBoxType(double theX, double theY, double theZ,
- double theXsize, double theYsize, double theZsize);
+ void clearContent();
- void setRotatedBoxType(double theX, double theY, double theZ,
- double theZaxisX, double theZaxisY, double theZaxisZ,
- double theXaxisX, double theXaxisY, double theXaxisZ,
- double theXsize, double theYsize, double theZsize);
- void setPlaneType(const gp_XYZ& theLoc, const gp_XYZ& theDir);
+ void fillVertex(const std::shared_ptr<GeomAPI_Vertex>& theVertex);
- void setVertexType(const gp_XYZ& theLoc);
+ void fillEdge(const std::shared_ptr<GeomAPI_Edge>& theEdge);
- void setCircleType(const gp_XYZ& theLoc, const gp_XYZ& theDir, double theRadius);
+ void fillWire(const std::shared_ptr<GeomAPI_Wire>& theWire);
- void setArcType(const gp_XYZ& theLoc, const gp_XYZ& theDir, double theRadius,
- const gp_XYZ& theP1, const gp_XYZ& theP2);
+ void fillFace(const std::shared_ptr<GeomAPI_Face>& theFace);
- void setEllipseType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theMajorRad, double theMinorRad);
+ void fillShell(const std::shared_ptr<GeomAPI_Shell>& theShell);
- void setEllipseArcType(const gp_XYZ& theLoc, const gp_XYZ& theDir,
- double theMajorRad, double theMinorRad, const gp_XYZ& theP1, const gp_XYZ& theP2);
+ void fillSolid(const std::shared_ptr<GeomAPI_Solid>& theSolid);
- void setLineType(const gp_XYZ& theP1, const gp_XYZ& theP2);
+ void fillContainer(const std::shared_ptr<GeomAPI_Shape>& theShape);
- void setShapeContent(const TopoDS_Shape& theShape);
- void setShapeParams(const TopoDS_Shape& theShape);
-
- void clearContent();
+ void setPlaneType(const QString& theTitle, const std::shared_ptr<GeomAPI_Pln>& thePlane);
- void fillVertex(const TopoDS_Shape& theShape);
+ void setSphereType(const QString& theTitle, const std::shared_ptr<GeomAPI_Sphere>& theSphere);
- void fillEdge(const TopoDS_Shape& theShape);
+ void setCylinderType(const QString& theTitle, const std::shared_ptr<GeomAPI_Cylinder>& theCyl);
- void fillFace(const TopoDS_Shape& theShape);
+ void setConeType(const QString& theTitle, const std::shared_ptr<GeomAPI_Cone>& theCone);
- void fillSolid(const TopoDS_Shape& theShape);
+ void setTorusType(const QString& theTitle, const std::shared_ptr<GeomAPI_Torus>& theTorus);
- void fillContainer(const TopoDS_Shape& theShape);
+ void setBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
- bool processSphere(const TopoDS_Solid& theSolid);
+ void setRotatedBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
private:
XGUI_SelectionMgr* mySelectionMgr;