Mantis issue 0021837: [CEA 654] Add new method to make any point inside a face.

This commit is contained in:
jfa 2012-09-13 12:56:49 +00:00
parent 0a03bb2230
commit c7f598c0d8
11 changed files with 136 additions and 34 deletions

View File

@ -37,6 +37,7 @@ Add_line = geompy.MakeLineTwoPnt(px, py)
arc_face = geompy.MakeFaceWires([Arc, Add_line], 1)
p_on_face1 = geompy.MakeVertexOnSurface(arc_face, 0.5, 0.5)
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(arc_face, 35, 35, 35)
p_on_face3 = geompy.MakeVertexInsideFace(arc_face)
# add objects in the study
@ -54,6 +55,7 @@ id_p_on_arc3 = geompy.addToStudy(p_on_arc3, "Vertex on Arc by point projection"
id_p_inter = geompy.addToStudy(p_inter, "Vertex on Lines Intersection")
id_p_on_face1 = geompy.addToStudy(p_on_face1, "Vertex on face by parameter")
id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on face by point projection")
id_p_on_face3 = geompy.addToStudy(p_on_face3, "Vertex inside face")
# display vertices
gg.createAndDisplayGO(id_p0)

View File

@ -40,6 +40,9 @@
\anchor swig_MakeVertexOnSurfaceByCoord
\until p_on_face2
\anchor swig_MakeVertexInsideFace
\until p_on_face3
\until S = geompy.MakeRotation
\anchor swig_MakeLineTwoFaces

View File

@ -540,6 +540,16 @@ module GEOM
in double theYParameter,
in double theZParameter);
/*!
* \brief Create a point, which lays on the given face.
* The point will lay in arbitrary place of the face.
* The only condition on it is a non-zero distance to the face boundary.
* Such point can be used to uniquely identify the face inside any
* shape in case, when the shape does not contain overlapped faces.
* \param theFace The referenced face.
* \return New GEOM_Object, containing the created point.
*/
GEOM_Object MakePointOnFace (in GEOM_Object theFace);
/*!
* \brief Create a point, on two lines intersection.

View File

@ -18,7 +18,6 @@
// 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 <Standard_Stream.hxx>
@ -212,6 +211,7 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
case PointOn_CurveByCoord: fType = POINT_CURVE_COORD; break;
case PointOn_SurfaceByParam: fType = POINT_SURFACE_PAR; break;
case PointOn_SurfaceByCoord: fType = POINT_SURFACE_COORD; break;
case PointOn_Face: fType = POINT_FACE_ANY; break;
default: break;
}
Handle(GEOM_Function) aFunction = aPoint->AddFunction(GEOMImpl_PointDriver::GetID(), fType);
@ -254,6 +254,10 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
aPI.SetX(theParam1);
aPI.SetY(theParam2);
aPI.SetZ(theParam3);
break;
case PointOn_Face:
aPI.SetSurface(aRefFunction);
break;
default: break;
}
@ -285,19 +289,24 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::makePointOnGeom
<< theGeomObj << ", " << theParam1 << ", " << theRefPoint << ")";
break;
case PointOn_CurveByCoord:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ", " << theParam3 << ")";
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnCurveByCoord("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ", " << theParam3 << ")";
break;
case PointOn_SurfaceByParam:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ")";
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurface("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ")";
break;
case PointOn_SurfaceByCoord:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ", " << theParam3 << ")";
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexOnSurfaceByCoord("
<< theGeomObj << ", " << theParam1
<< ", " << theParam2 << ", " << theParam3 << ")";
break;
case PointOn_Face:
GEOM::TPythonDump(aFunction) << aPoint << " = geompy.MakeVertexInsideFace("
<< theGeomObj << ")";
break;
default: break;
}
@ -370,6 +379,15 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnSurfaceByCoord
return makePointOnGeom(theSurface, theXParam, theYParam, theZParam, PointOn_SurfaceByCoord);
}
//=============================================================================
/*!
* MakePointOnFace
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakePointOnFace (Handle(GEOM_Object) theFace)
{
return makePointOnGeom(theFace, 0., 0., 0., PointOn_Face);
}
//=============================================================================
/*!

View File

@ -18,7 +18,6 @@
// 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 _GEOMImpl_IBasicOperations_HXX_
#define _GEOMImpl_IBasicOperations_HXX_
@ -64,6 +63,8 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
double theYParam,
double theZParam);
Standard_EXPORT Handle(GEOM_Object) MakePointOnFace (Handle(GEOM_Object) theFace);
// Vector
Standard_EXPORT Handle(GEOM_Object) MakeVectorDXDYDZ (double theDX, double theDY, double theDZ);
@ -128,7 +129,8 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
PointOn_CurveByCoord,
PointOn_CurveByLength,
PointOn_SurfaceByParam,
PointOn_SurfaceByCoord
PointOn_SurfaceByCoord,
PointOn_Face
};
Handle(GEOM_Object) makePointOnGeom (Handle(GEOM_Object) theGeomObj,

View File

@ -18,7 +18,6 @@
// 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 <Standard_Stream.hxx>
@ -26,6 +25,7 @@
#include <GEOMImpl_IPoint.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
#include <GEOMAlgo_Tools3D.hxx>
#include <ShapeAnalysis.hxx>
@ -124,8 +124,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = gp_Pnt(aPI.GetX(), aPI.GetY(), aPI.GetZ());
}
else if (aType == POINT_XYZ_REF) {
Handle(GEOM_Function) aRefPoint = aPI.GetRef();
TopoDS_Shape aRefShape = aRefPoint->GetValue();
Handle(GEOM_Function) aRefFunc = aPI.GetRef();
TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_VERTEX) {
Standard_TypeMismatch::Raise
("Point creation aborted : referenced shape is not a vertex");
@ -134,8 +134,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = gp_Pnt(P.X() + aPI.GetX(), P.Y() + aPI.GetY(), P.Z() + aPI.GetZ());
}
else if (aType == POINT_CURVE_PAR) {
Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
TopoDS_Shape aRefShape = aRefCurve->GetValue();
Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge");
@ -146,8 +146,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = aCurve->Value(aP);
}
else if (aType == POINT_CURVE_COORD) {
Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
TopoDS_Shape aRefShape = aRefCurve->GetValue();
Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge");
@ -160,12 +160,12 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
}
else if (aType == POINT_CURVE_LENGTH) {
// RefCurve
Handle(GEOM_Function) aRefCurve = aPI.GetCurve();
if (aRefCurve.IsNull()) {
Handle(GEOM_Function) aRefFunc = aPI.GetCurve();
if (aRefFunc.IsNull()) {
Standard_NullObject::Raise
("Point On Curve creation aborted : curve object is null");
}
TopoDS_Shape aRefShape1 = aRefCurve->GetValue();
TopoDS_Shape aRefShape1 = aRefFunc->GetValue();
if (aRefShape1.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise
("Point On Curve creation aborted : curve shape is not an edge");
@ -222,8 +222,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = AdapCurve.Value(aParam);
}
else if (aType == POINT_SURFACE_PAR) {
Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefCurve->GetValue();
Handle(GEOM_Function) aRefFunc = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise
("Point On Surface creation aborted : surface shape is not a face");
@ -238,8 +238,8 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
aPnt = aSurf->Value(U,V);
}
else if (aType == POINT_SURFACE_COORD) {
Handle(GEOM_Function) aRefCurve = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefCurve->GetValue();
Handle(GEOM_Function) aRefFunc = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise
("Point On Surface creation aborted : surface shape is not a face");
@ -250,6 +250,17 @@ Standard_Integer GEOMImpl_PointDriver::Execute(TFunction_Logbook& log) const
("Point On Surface creation aborted : cannot project point");
}
}
else if (aType == POINT_FACE_ANY) {
Handle(GEOM_Function) aRefFunc = aPI.GetSurface();
TopoDS_Shape aRefShape = aRefFunc->GetValue();
if (aRefShape.ShapeType() != TopAbs_FACE) {
Standard_TypeMismatch::Raise
("Point On Surface creation aborted : surface shape is not a face");
}
TopoDS_Face F = TopoDS::Face(aRefShape);
gp_Pnt2d aP2d;
GEOMAlgo_Tools3D::PntInFace(F, aPnt, aP2d);
}
else if (aType == POINT_LINES_INTERSECTION) {
Handle(GEOM_Function) aRef1 = aPI.GetLine1();
Handle(GEOM_Function) aRef2 = aPI.GetLine2();

View File

@ -115,7 +115,8 @@
#define POINT_SURFACE_PAR 5
#define POINT_CURVE_COORD 6
#define POINT_SURFACE_COORD 7
#define POINT_CURVE_LENGTH 8
#define POINT_CURVE_LENGTH 8
#define POINT_FACE_ANY 9
// Vector
#define VECTOR_TWO_PNT 1

View File

@ -18,7 +18,6 @@
// 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 <Standard_Stream.hxx>
@ -277,6 +276,29 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord
return GetObject(anObject);
}
//=============================================================================
/*!
* MakePointOnFace
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnFace (GEOM::GEOM_Object_ptr theFace)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference face
Handle(GEOM_Object) aReference = GetObjectImpl(theFace);
if (aReference.IsNull()) return aGEOMObject._retn();
//Create the point
Handle(GEOM_Object) anObject = GetOperations()->MakePointOnFace(aReference);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!

View File

@ -18,7 +18,6 @@
// 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 _GEOM_IBasicOperations_i_HeaderFile
#define _GEOM_IBasicOperations_i_HeaderFile
@ -73,6 +72,8 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i :
CORBA::Double theYParameter,
CORBA::Double theZParameter);
GEOM::GEOM_Object_ptr MakePointOnFace (GEOM::GEOM_Object_ptr theFace);
GEOM::GEOM_Object_ptr MakePointOnLinesIntersection (GEOM::GEOM_Object_ptr theLine1,
GEOM::GEOM_Object_ptr theLine2);

View File

@ -19,7 +19,6 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
# GEOM GEOM_SWIG : binding of C++ omplementaion with Python
# File : GEOM_usinggeom.py
@ -193,6 +192,7 @@ def TestAll (geompy, math):
#Test point on surface creation
p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8) #(GEOM_Object, Double, Double)->GEOM_Object
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.) #(GEOM_Object, Double, Double, Double)->GEOM_Object
p_on_face3 = geompy.MakeVertexInsideFace(Face) #(GEOM_Object)->GEOM_Object
# Test plane from existing face creation
Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object, Double)->GEOM_Object
@ -386,6 +386,7 @@ def TestAll (geompy, math):
id_p_on_face = geompy.addToStudy(p_on_face, "Vertex on Face (0.1, 0.8)")
id_p_on_face2 = geompy.addToStudy(p_on_face2, "Vertex on Face at(0., 0., 0.)")
id_p_on_face3 = geompy.addToStudy(p_on_face3, "Vertex inside Face")
id_Prism1 = geompy.addToStudy(Prism1, "Prism by Two Pnt")
id_Shell1 = geompy.addToStudy(Shell1, "Shell from Prism1 faces")

View File

@ -822,7 +822,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created point.
Example of usage:
p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8) #(GEOM_Object, Double, Double)->GEOM_Object
p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8)
"""
theUParameter, theVParameter, Parameters = ParseParameters(theUParameter, theVParameter)
# Example: see GEOM_TestAll.py
@ -853,7 +853,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created point.
Example of usage:
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.) #(GEOM_Object, Double, Double, Double)->GEOM_Object
p_on_face2 = geompy.MakeVertexOnSurfaceByCoord(Face, 0., 0., 0.)
"""
theX, theY, theZ, Parameters = ParseParameters(theX, theY, theZ)
# Example: see GEOM_TestAll.py
@ -862,6 +862,37 @@ class geompyDC(GEOM._objref_GEOM_Gen):
anObj.SetParameters(Parameters);
return anObj
## Create a point, which lays on the given face.
# The point will lay in arbitrary place of the face.
# The only condition on it is a non-zero distance to the face boundary.
# Such point can be used to uniquely identify the face inside any
# shape in case, when the shape does not contain overlapped faces.
# @param theFace The referenced face.
# @return New GEOM.GEOM_Object, containing the created point.
#
# @ref swig_MakeVertexInsideFace "Example"
def MakeVertexInsideFace (self, theFace):
"""
Create a point, which lays on the given face.
The point will lay in arbitrary place of the face.
The only condition on it is a non-zero distance to the face boundary.
Such point can be used to uniquely identify the face inside any
shape in case, when the shape does not contain overlapped faces.
Parameters:
theFace The referenced face.
Returns:
New GEOM.GEOM_Object, containing the created point.
Example of usage:
p_on_face = geompy.MakeVertexInsideFace(Face)
"""
# Example: see GEOM_TestAll.py
anObj = self.BasicOp.MakePointOnFace(theFace)
RaiseIfFailed("MakeVertexInsideFace", self.BasicOp)
return anObj
## Create a point on intersection of two lines.
# @param theRefLine1, theRefLine2 The referenced lines.
# @return New GEOM.GEOM_Object, containing the created point.
@ -900,7 +931,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created tangent.
Example of usage:
tan_on_arc = geompy.MakeTangentOnCurve(Arc, 0.7) #(GEOM_Object, Double)->GEOM_Object
tan_on_arc = geompy.MakeTangentOnCurve(Arc, 0.7)
"""
anObj = self.BasicOp.MakeTangentOnCurve(theRefCurve, theParameter)
RaiseIfFailed("MakeTangentOnCurve", self.BasicOp)
@ -1983,7 +2014,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created disk.
Example of usage:
Disk3 = geompy.MakeDiskR(100., 1) #(1 Doubles, 1 Int)->GEOM_Object
Disk3 = geompy.MakeDiskR(100., 1)
"""
# Example: see GEOM_TestAll.py
theR,Parameters = ParseParameters(theR)