From 664761d8f973a81c1f6fe6f3fa5e42134ccd42bc Mon Sep 17 00:00:00 2001 From: ptv Date: Thu, 27 Aug 2009 13:02:59 +0000 Subject: [PATCH] 0020098: EDF 899 GEOM : Point on curve/surface with X,Y,Z coordinates. --- src/GEOM_I/GEOM_IBasicOperations_i.cc | 60 +++++++++++++++++++++++++++ src/GEOM_I/GEOM_IBasicOperations_i.hh | 10 +++++ src/GEOM_I_Superv/GEOM_Superv_i.cc | 52 +++++++++++++++++++++++ src/GEOM_I_Superv/GEOM_Superv_i.hh | 11 +++++ src/GEOM_SWIG/GEOM_TestAll.py | 5 +++ src/GEOM_SWIG/geompyDC.py | 32 ++++++++++++++ 6 files changed, 170 insertions(+) diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.cc b/src/GEOM_I/GEOM_IBasicOperations_i.cc index f79e65308..278d9090d 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.cc +++ b/src/GEOM_I/GEOM_IBasicOperations_i.cc @@ -154,6 +154,36 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurve return GetObject(anObject); } +//============================================================================= +/*! + * MakePointOnCurveByCoord + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnCurveByCoord + (GEOM::GEOM_Object_ptr theCurve, + CORBA::Double theXParameter, + CORBA::Double theYParameter, + CORBA::Double theZParameter) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference curve + Handle(GEOM_Object) aReference = GetObjectImpl(theCurve); + if (aReference.IsNull()) return aGEOMObject._retn(); + + //Create the point + Handle(GEOM_Object) anObject = + GetOperations()->MakePointOnCurveByCoord(aReference, theXParameter, + theYParameter, theZParameter); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakePointOnSurface @@ -182,6 +212,36 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurface return GetObject(anObject); } +//============================================================================= +/*! + * MakePointOnSurfaceByCoord + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakePointOnSurfaceByCoord + (GEOM::GEOM_Object_ptr theSurface, + CORBA::Double theXParameter, + CORBA::Double theYParameter, + CORBA::Double theZParameter) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference surface + Handle(GEOM_Object) aReference = GetObjectImpl(theSurface); + if (aReference.IsNull()) return aGEOMObject._retn(); + + //Create the point + Handle(GEOM_Object) anObject = + GetOperations()->MakePointOnSurfaceByCoord(aReference, theXParameter, + theYParameter, theZParameter); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! diff --git a/src/GEOM_I/GEOM_IBasicOperations_i.hh b/src/GEOM_I/GEOM_IBasicOperations_i.hh index 0cf59342f..7910c4e17 100644 --- a/src/GEOM_I/GEOM_IBasicOperations_i.hh +++ b/src/GEOM_I/GEOM_IBasicOperations_i.hh @@ -54,10 +54,20 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i : GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theCurve, CORBA::Double theParameter); + GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theCurve, + CORBA::Double theXParameter, + CORBA::Double theYParameter, + CORBA::Double theZParameter); + GEOM::GEOM_Object_ptr MakePointOnSurface (GEOM::GEOM_Object_ptr theSurface, CORBA::Double theUParameter, CORBA::Double theVParameter); + GEOM::GEOM_Object_ptr MakePointOnSurfaceByCoord (GEOM::GEOM_Object_ptr theSurface, + CORBA::Double theXParameter, + CORBA::Double theYParameter, + CORBA::Double theZParameter); + GEOM::GEOM_Object_ptr MakePointOnLinesIntersection (GEOM::GEOM_Object_ptr theLine1, GEOM::GEOM_Object_ptr theLine2); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 6c8dc843f..2762674fe 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -574,6 +574,58 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurve (GEOM::GEOM_Object_ptr the return anObj; } +//============================================================================= +// MakePointOnCurveByCoord +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theXParameter, + CORBA::Double theYParameter, + CORBA::Double theZParameter) +{ + beginService( " GEOM_Superv_i::MakePointOnCurveByCoord" ); + MESSAGE("GEOM_Superv_i::MakePointOnCurveByCoord"); + getBasicOp(); + GEOM::GEOM_Object_ptr anObj = + myBasicOp->MakePointOnCurveByCoord(theRefCurve, theXParameter, + theYParameter, theZParameter); + endService( " GEOM_Superv_i::MakePointOnCurveByCoord" ); + return anObj; +} + +//============================================================================= +// MakePointOnSurface: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnSurface (GEOM::GEOM_Object_ptr theRefSurface, + CORBA::Double theUParameter, + CORBA::Double theVParameter) +{ + beginService( " GEOM_Superv_i::MakePointOnSurface" ); + MESSAGE("GEOM_Superv_i::MakePointOnSurface"); + getBasicOp(); + GEOM::GEOM_Object_ptr anObj = + myBasicOp->MakePointOnSurface(theRefSurface, theUParameter, theVParameter); + endService( " GEOM_Superv_i::MakePointOnSurface" ); + return anObj; +} + +//============================================================================= +// MakePointOnSurfaceByCoord +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePointOnSurfaceByCoord (GEOM::GEOM_Object_ptr theRefSurface, + CORBA::Double theXParameter, + CORBA::Double theYParameter, + CORBA::Double theZParameter) +{ + beginService( " GEOM_Superv_i::MakePointOnSurfaceByCoord" ); + MESSAGE("GEOM_Superv_i::MakePointOnSurfaceByCoord"); + getBasicOp(); + GEOM::GEOM_Object_ptr anObj = + myBasicOp->MakePointOnSurfaceByCoord(theRefSurface, theXParameter, + theYParameter, theZParameter); + endService( " GEOM_Superv_i::MakePointOnSurfaceByCoord" ); + return anObj; +} + //============================================================================= // MakePointOnLinesIntersection: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index 5198fa024..1ed69ad45 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -148,6 +148,17 @@ public: CORBA::Double theZ); GEOM::GEOM_Object_ptr MakePointOnCurve (GEOM::GEOM_Object_ptr theRefCurve, CORBA::Double theParameter); + GEOM::GEOM_Object_ptr MakePointOnCurveByCoord (GEOM::GEOM_Object_ptr theRefCurve, + CORBA::Double theXParameter, + CORBA::Double theYParameter, + CORBA::Double theZParameter); + GEOM::GEOM_Object_ptr MakePointOnSurface (GEOM::GEOM_Object_ptr theRefSurface, + CORBA::Double theUParameter, + CORBA::Double theVParameter); + GEOM::GEOM_Object_ptr MakePointOnSurfaceByCoord (GEOM::GEOM_Object_ptr theRefSurface, + CORBA::Double theXParameter, + CORBA::Double theYParameter, + CORBA::Double theZParameter); GEOM::GEOM_Object_ptr MakePointOnLinesIntersection (GEOM::GEOM_Object_ptr theRefLine1, GEOM::GEOM_Object_ptr theRefLine2); GEOM::GEOM_Object_ptr MakeTangentOnCurve (GEOM::GEOM_Object_ptr theRefCurve, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index 0d6ff0bd6..60a52f433 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -109,6 +109,7 @@ def TestAll (geompy, math): #Test point on curve creation p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr + p_on_arc2 = geompy.MakeVertexOnCurveByCoord(Arc, 100, -10, 10 ) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr #Test point on lines intersection p_on_l1l2 = geompy.MakeVertexOnLinesIntersection(Line1, Line2) #(2 GEOM_Object_ptr)->GEOM_Object_ptr @@ -176,6 +177,7 @@ def TestAll (geompy, math): #Test point on surface creation p_on_face = geompy.MakeVertexOnSurface(Face, 0.1, 0.8) #(GEOM_Object_ptr, Double, Double)->GEOM_Object_ptr + p_on_face2 = geompy.MakeVertexOnSurface(Face, 0., 0., 0.) #(GEOM_Object_ptr, Double, Double)->GEOM_Object_ptr # Test plane from existing face creation Plane2 = geompy.MakePlaneFace(Face, trimsize) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr @@ -323,6 +325,8 @@ def TestAll (geompy, math): id_Sketcher3d = geompy.addToStudy(Sketcher3d, "Sketcher 3D") id_p_on_arc = geompy.addToStudy(p_on_arc, "Vertex on Arc (0.25)") + id_p_on_arc2 = geompy.addToStudy(p_on_arc2, "Vertex on Arc at(100, -10, 10)" ) + id_p_on_l1l2 = geompy.addToStudy(p_on_l1l2, "Vertex on Lines Intersection") id_tan_on_arc = geompy.addToStudy(tan_on_arc, "Tangent on Arc (0.7)") @@ -359,6 +363,7 @@ def TestAll (geompy, math): id_Shell = geompy.addToStudy(Shell, "Shell") 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_Prism1 = geompy.addToStudy(Prism1, "Prism by Two Pnt") id_Shell1 = geompy.addToStudy(Shell1, "Shell from Prism1 faces") diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 154d15457..0b6d23665 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -366,6 +366,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters) return anObj + ## Create a point by projection give coordinates on the given curve + # @param theRefCurve The referenced curve. + # @param theX X-coordinate in 3D space + # @param theY Y-coordinate in 3D space + # @param theZ Z-coordinate in 3D space + # @return New GEOM_Object, containing the created point. + # + # @ref tui_creation_point "Example" + def MakeVertexOnCurveByCoord(self,theRefCurve, theX, theY, theZ): + # Example: see GEOM_TestAll.py + theX, theY, theZ, Parameters = ParseParameters(theX, theY, theZ) + anObj = self.BasicOp.MakePointOnCurveByCoord(theRefCurve, theX, theY, theZ) + RaiseIfFailed("MakeVertexOnCurveByCoord", self.BasicOp) + anObj.SetParameters(Parameters) + return anObj + ## Create a point, corresponding to the given parameters on the # given surface. # @param theRefSurf The referenced surface. @@ -382,6 +398,22 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj.SetParameters(Parameters); return anObj + ## Create a point by projection give coordinates on the given surface + # @param theRefSurf The referenced surface. + # @param theX X-coordinate in 3D space + # @param theY Y-coordinate in 3D space + # @param theZ Z-coordinate in 3D space + # @return New GEOM_Object, containing the created point. + # + # @ref swig_MakeVertexOnSurfaceByCoord "Example" + def MakeVertexOnSurfaceByCoord(self, theRefSurf, theX, theY, theZ): + theX, theY, theZ, Parameters = ParseParameters(theX, theY, theZ) + # Example: see GEOM_TestAll.py + anObj = self.BasicOp.MakePointOnSurfaceByCoord(theRefSurf, theX, theY, theZ) + RaiseIfFailed("MakeVertexOnSurfaceByCoord", self.BasicOp) + anObj.SetParameters(Parameters); + return anObj + ## Create a point on intersection of two lines. # @param theRefLine1, theRefLine2 The referenced lines. # @return New GEOM_Object, containing the created point. -- 2.39.2