mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-15 10:08:35 +05:00
0021189: [CEA 451] areCoordsInside implementation in GE
This commit is contained in:
parent
ef26af8d03
commit
a3cc005370
@ -138,6 +138,7 @@ module GEOM
|
|||||||
|
|
||||||
typedef sequence<string> string_array;
|
typedef sequence<string> string_array;
|
||||||
typedef sequence<short> short_array;
|
typedef sequence<short> short_array;
|
||||||
|
typedef sequence<boolean> ListOfBool;
|
||||||
typedef sequence<long> ListOfLong;
|
typedef sequence<long> ListOfLong;
|
||||||
typedef sequence<double> ListOfDouble;
|
typedef sequence<double> ListOfDouble;
|
||||||
|
|
||||||
@ -3141,6 +3142,16 @@ module GEOM
|
|||||||
*/
|
*/
|
||||||
string WhatIs (in GEOM_Object theShape);
|
string WhatIs (in GEOM_Object theShape);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Check if points defined by coords = [x1, y1, z1, x2, y2, z2, ...] are inside or on
|
||||||
|
* the shape theShape.
|
||||||
|
* \param theShape Shape to check.
|
||||||
|
* \param coords list of coordinates.
|
||||||
|
* \param tolerance tolerance.
|
||||||
|
* \return list of boolean.
|
||||||
|
*/
|
||||||
|
ListOfBool AreCoordsInside(in GEOM_Object theShape, in ListOfDouble coords, in double tolerance);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Get minimal distance between the given shapes.
|
* Get minimal distance between the given shapes.
|
||||||
* \param theShape1,theShape2 Shapes to find minimal distance between.
|
* \param theShape1,theShape2 Shapes to find minimal distance between.
|
||||||
|
@ -1680,6 +1680,37 @@ static bool CheckSingularCase(const TopoDS_Shape& aSh1,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* AreCoordsInside
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
std::vector<bool> GEOMImpl_IMeasureOperations::AreCoordsInside(Handle(GEOM_Object) theShape,
|
||||||
|
const std::vector<double>& coords,
|
||||||
|
double tolerance)
|
||||||
|
{
|
||||||
|
std::vector<bool> res;
|
||||||
|
if (!theShape.IsNull()) {
|
||||||
|
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
|
||||||
|
if (!aRefShape.IsNull()) {
|
||||||
|
TopoDS_Shape aShape = aRefShape->GetValue();
|
||||||
|
if (!aShape.IsNull()) {
|
||||||
|
BRepClass3d_SolidClassifier SC(aShape);
|
||||||
|
unsigned int nb_points = coords.size()/3;
|
||||||
|
for (int i = 0; i < nb_points; i++) {
|
||||||
|
double x = coords[3*i];
|
||||||
|
double y = coords[3*i+1];
|
||||||
|
double z = coords[3*i+2];
|
||||||
|
gp_Pnt aPnt(x, y, z);
|
||||||
|
SC.Perform(aPnt, tolerance);
|
||||||
|
res.push_back( ( SC.State() == TopAbs_IN ) || ( SC.State() == TopAbs_ON ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* GetMinDistance
|
* GetMinDistance
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <TColStd_HSequenceOfReal.hxx>
|
#include <TColStd_HSequenceOfReal.hxx>
|
||||||
#include <gp_Ax3.hxx>
|
#include <gp_Ax3.hxx>
|
||||||
#include <Geom_Surface.hxx>
|
#include <Geom_Surface.hxx>
|
||||||
|
#include <Precision.hxx>
|
||||||
|
|
||||||
class GEOM_Engine;
|
class GEOM_Engine;
|
||||||
class Handle(GEOM_Object);
|
class Handle(GEOM_Object);
|
||||||
@ -128,6 +129,10 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
|
|||||||
|
|
||||||
Standard_EXPORT TCollection_AsciiString WhatIs (Handle(GEOM_Object) theShape);
|
Standard_EXPORT TCollection_AsciiString WhatIs (Handle(GEOM_Object) theShape);
|
||||||
|
|
||||||
|
Standard_EXPORT std::vector<bool> AreCoordsInside (Handle(GEOM_Object) theShape,
|
||||||
|
const std::vector<double>& coords,
|
||||||
|
double tolerance = Precision::Confusion());
|
||||||
|
|
||||||
Standard_EXPORT Standard_Real GetMinDistance (Handle(GEOM_Object) theShape1,
|
Standard_EXPORT Standard_Real GetMinDistance (Handle(GEOM_Object) theShape1,
|
||||||
Handle(GEOM_Object) theShape2,
|
Handle(GEOM_Object) theShape2,
|
||||||
Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1,
|
Standard_Real& X1, Standard_Real& Y1, Standard_Real& Z1,
|
||||||
|
@ -386,6 +386,34 @@ char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape)
|
|||||||
return CORBA::string_dup(aDescription.ToCString());
|
return CORBA::string_dup(aDescription.ToCString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
/*!
|
||||||
|
* AreCoordsInside
|
||||||
|
*/
|
||||||
|
//=============================================================================
|
||||||
|
GEOM::ListOfBool* GEOM_IMeasureOperations_i::AreCoordsInside (GEOM::GEOM_Object_ptr theShape,
|
||||||
|
const GEOM::ListOfDouble& theCoords,
|
||||||
|
CORBA::Double tolerance)
|
||||||
|
{
|
||||||
|
//Set a not done flag
|
||||||
|
GetOperations()->SetNotDone();
|
||||||
|
|
||||||
|
unsigned int nb_points = theCoords.length()/3;
|
||||||
|
|
||||||
|
GEOM::ListOfBool_var aResults = new GEOM::ListOfBool;
|
||||||
|
aResults->length(nb_points);
|
||||||
|
|
||||||
|
Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
|
||||||
|
|
||||||
|
std::vector<double> tmp(3*nb_points);
|
||||||
|
for (int i = 0; i < 3*nb_points; i++)
|
||||||
|
tmp[i] = theCoords[i];
|
||||||
|
std::vector<bool> res = GetOperations()->AreCoordsInside(aShape, tmp, tolerance);
|
||||||
|
for (int i = 0; i < nb_points; i++)
|
||||||
|
aResults[i] = i < res.size() ? res[i] : false;
|
||||||
|
return aResults._retn();
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
/*!
|
/*!
|
||||||
* GetMinDistance
|
* GetMinDistance
|
||||||
|
@ -88,6 +88,10 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
|
|||||||
|
|
||||||
char* WhatIs (GEOM::GEOM_Object_ptr theShape);
|
char* WhatIs (GEOM::GEOM_Object_ptr theShape);
|
||||||
|
|
||||||
|
GEOM::ListOfBool* AreCoordsInside (GEOM::GEOM_Object_ptr theShape,
|
||||||
|
const GEOM::ListOfDouble& theCoords,
|
||||||
|
CORBA::Double theTolerance);
|
||||||
|
|
||||||
CORBA::Double GetMinDistance (GEOM::GEOM_Object_ptr theShape1,
|
CORBA::Double GetMinDistance (GEOM::GEOM_Object_ptr theShape1,
|
||||||
GEOM::GEOM_Object_ptr theShape2,
|
GEOM::GEOM_Object_ptr theShape2,
|
||||||
CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1,
|
CORBA::Double& X1, CORBA::Double& Y1, CORBA::Double& Z1,
|
||||||
|
@ -3324,6 +3324,14 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
|||||||
RaiseIfFailed("GetInertia", self.MeasuOp)
|
RaiseIfFailed("GetInertia", self.MeasuOp)
|
||||||
return aTuple
|
return aTuple
|
||||||
|
|
||||||
|
## Get if coords are included in the shape (ST_IN or ST_ON)
|
||||||
|
# @param theShape Shape
|
||||||
|
# @param coords list of points coordinates [x1, y1, z1, x2, y2, z2, ...]
|
||||||
|
# @param tolerance to be used (default is 1.0e-7)
|
||||||
|
# @return list_of_boolean = [res1, res2, ...]
|
||||||
|
def AreCoordsInside(self, theShape, coords, tolerance=1.e-7):
|
||||||
|
return self.MeasuOp.AreCoordsInside(theShape, coords, tolerance)
|
||||||
|
|
||||||
## Get minimal distance between the given shapes.
|
## Get minimal distance between the given shapes.
|
||||||
# @param theShape1,theShape2 Shapes to find minimal distance between.
|
# @param theShape1,theShape2 Shapes to find minimal distance between.
|
||||||
# @return Value of the minimal distance between the given shapes.
|
# @return Value of the minimal distance between the given shapes.
|
||||||
|
Loading…
Reference in New Issue
Block a user