#include <Config_PropManager.h>
#include <GeomAPI_Shape.h>
-#include <GeomAlgoAPI_GeometryCalculation.h>
+#include <GeomAlgoAPI_ShapeTools.h>
#include <iomanip>
double aLength;
double aSurfArea;
double aVolume;
- std::string aError;
- if (!getGeometryCalculation(aShape,
- aTolerance,
- aLength,
- aSurfArea,
- aVolume,
- aError))
- setError("Error in Geometry calculation :" + aError);
+
+ aLength = GeomAlgoAPI_ShapeTools::length(aShape);
+ aSurfArea = GeomAlgoAPI_ShapeTools::area(aShape);
+ aVolume = GeomAlgoAPI_ShapeTools::volume(aShape);
streamL << std::setprecision(14) << aLength;
aValues->setValue(0, aLength);
GeomAlgoAPI_Prism.h
GeomAlgoAPI_Revolution.h
GeomAlgoAPI_Boolean.h
- GeomAlgoAPI_GeometryCalculation.h
GeomAlgoAPI_ThroughAll.h
GeomAlgoAPI_Rotation.h
GeomAlgoAPI_Translation.h
GeomAlgoAPI_Prism.cpp
GeomAlgoAPI_Revolution.cpp
GeomAlgoAPI_Boolean.cpp
- GeomAlgoAPI_GeometryCalculation.cpp
GeomAlgoAPI_ThroughAll.cpp
GeomAlgoAPI_Rotation.cpp
GeomAlgoAPI_Translation.cpp
+++ /dev/null
-// Copyright (C) 2014-2020 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
-//
-
-#include "GeomAlgoAPI_GeometryCalculation.h"
-
-#include <GProp_GProps.hxx>
-#include <TopoDS_Shape.hxx>
-#include <BRepGProp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <Standard_ErrorHandler.hxx>
-
-//=================================================================================================
-bool getGeometryCalculation(const std::shared_ptr<GeomAPI_Shape>& theShape,
- const double theTolerance,
- Standard_Real& theLength,
- Standard_Real& theSurfArea,
- Standard_Real& theVolume,
- std::string& theError)
-{
-
- #ifdef _DEBUG
- std::cout << "getGeometryCalculation " << std::endl;
- #endif
-
- if (!theShape.get()) {
- theError = "getGeometryCalculation : An invalid argument";
- return false;
- }
-
- TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
-
- //Compute the parameters
- GProp_GProps aLProps, aSProps;
- Standard_Real anEps = theTolerance >= 0 ? theTolerance : 1.e-6;
- try {
- OCC_CATCH_SIGNALS;
- BRepGProp::LinearProperties(aShape, aLProps, Standard_True);
- theLength = aLProps.Mass();
-
- BRepGProp::SurfaceProperties(aShape, aSProps, anEps, Standard_True);
- theSurfArea = aSProps.Mass();
-
- theVolume = 0.0;
- if (aShape.ShapeType() < TopAbs_SHELL) {
- for (TopExp_Explorer anExp (aShape, TopAbs_SOLID); anExp.More(); anExp.Next()) {
- GProp_GProps aVProps;
- BRepGProp::VolumeProperties(anExp.Current(), aVProps, anEps, Standard_True);
- theVolume += aVProps.Mass();
- }
- }
- }
- catch (Standard_Failure& aFail) {
- theError = aFail.GetMessageString();
- return false;
- }
-
- return true;
-
-}
\ No newline at end of file
+++ /dev/null
-// Copyright (C) 2014-2020 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
-//
-
-#ifndef GeomAlgoAPI_GeometryCalculation_H_
-#define GeomAlgoAPI_GeometryCalculation_H_
-
-#include <GeomAlgoAPI.h>
-#include <GeomAPI_Shape.h>
-#include <Standard_TypeDef.hxx>
-
-/// Run chamfer operation with two distances or with a distance and an angle .
- /// \param theShape the shape
- /// \param theTolerance tolerance desirated
- /// \param theLength length calculated
- /// \param theSurfArea Surface Area calculated
- /// \param theVolume Volume calculated
- /// \param theError error
-GEOMALGOAPI_EXPORT
-bool getGeometryCalculation(const std::shared_ptr<GeomAPI_Shape>& theShape,
- const Standard_Real theTolerance,
- Standard_Real& theLength,
- Standard_Real& theSurfArea,
- Standard_Real& theVolume,
- std::string& theError);
-
-#endif
return aGProps;
}
+//==================================================================================================
+double GeomAlgoAPI_ShapeTools::length(const std::shared_ptr<GeomAPI_Shape> theShape)
+{
+ GProp_GProps aGProps;
+ if(!theShape.get()) {
+ return 0.0;
+ }
+ const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
+ if(aShape.IsNull()) {
+ return 0.0;
+ }
+ BRepGProp::LinearProperties(aShape, aGProps, Standard_True);
+ return aGProps.Mass();
+}
//==================================================================================================
double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr<GeomAPI_Shape> theShape)
{
class GeomAlgoAPI_ShapeTools
{
public:
+ /// \return the lenth of the edges of the current shape or 0.0 if it can be computed.
+ GEOMALGOAPI_EXPORT static double length(const std::shared_ptr<GeomAPI_Shape> theShape);
+
/// \return the total volume of the solids of the current shape or 0.0 if it can be computed.
GEOMALGOAPI_EXPORT static double volume(const std::shared_ptr<GeomAPI_Shape> theShape);