]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Modification of GEOM interface
authorvsv <vsv@opencascade.com>
Mon, 9 Dec 2019 13:11:19 +0000 (16:11 +0300)
committervsv <vsv@opencascade.com>
Mon, 9 Dec 2019 13:11:19 +0000 (16:11 +0300)
idl/GEOM_Gen.idl
src/GEOMImpl/GEOMImpl_IMeasure.hxx
src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx
src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx
src/GEOMImpl/GEOMImpl_MeasureDriver.cxx
src/GEOM_I/GEOM_BaseObject_i.cc
src/GEOM_I/GEOM_BaseObject_i.hh
src/GEOM_I/GEOM_IMeasureOperations_i.cc
src/GEOM_I/GEOM_IMeasureOperations_i.hh
src/GEOM_SWIG/geomBuilder.py

index 59afc08d2538e11ad4066e661563b6520b71d2be..fe78db3961c0633f04d8363260afd003e91e4e6a 100644 (file)
@@ -258,6 +258,7 @@ module GEOM
   typedef sequence<ListOfDouble> ListOfListOfDouble;
   typedef sequence<ListOfLong>   ListOfListOfLong;
 
+  interface GEOM_Gen;
   interface GEOM_Object;
   interface GEOM_BaseObject;
   interface GEOM_Field;
@@ -359,6 +360,11 @@ module GEOM
      * \brief Return name of operation and values of parameters used for object creation
      */
     CreationInformationSeq GetCreationInformation();
+
+    /*!
+     * \brief Return the engine creating this object
+     */
+    GEOM_Gen GetGen();
   };
 
   //# GEOM_Object
@@ -4366,12 +4372,13 @@ module GEOM
     GEOM_Object GetCentreOfMass (in GEOM_Object theShape);
 
     /*
-     *  Get the vertex by index for 1D objects depends the edge/wire orientation
+     *  Get the vertex by index for 1D objects
      *  \param theShape Shape (wire or edge) to find the vertex on it
      *  \param theIndex Index of vertex sub-shape
+     *  \param theUseOri To consider edge/wire orientation or not
      *  \return New GEOM_Object, vertex.
      */
-    GEOM_Object GetVertexByIndex( in GEOM_Object theShape, in long index );
+    GEOM_Object GetVertexByIndex( in GEOM_Object theShape, in long theIndex, in boolean theUseOri );
 
     /*!
      *  \brief Get a vector, representing the normal of theFace.
index 2c6b2cc1e3e2b1038e670397a7ae89d24849bd39..4ebfa1751aa5f4a634507685b28082cc6c817dd6 100644 (file)
 //
 #include "GEOM_Function.hxx"
 
-//#define MEASURE_ARG_BASE  1
-//#define MEASURE_ARG_POINT 2
-
 class GEOMImpl_IMeasure
 {
   enum {
     MEASURE_ARG_BASE  = 1,
     MEASURE_ARG_POINT = 2,
-    MEASURE_INDEX = 3
+    MEASURE_INDEX = 3,
+    MEASURE_USE_ORI = 4
   };
  public:
 
@@ -52,6 +50,12 @@ class GEOMImpl_IMeasure
     
   int GetIndex() { return _func->GetInteger(MEASURE_INDEX); }
 
+  void SetUseOri(int theIndex) { _func->SetInteger(MEASURE_USE_ORI, theIndex); }
+    
+  bool GetUseOri() { return ( _func->GetInteger(MEASURE_USE_ORI) ||
+                              !_func->IsDone() ); // old behavior was to useOri
+  }
+
  private:
 
   Handle(GEOM_Function) _func;
index 080cc669fc9f179fa976e5d5935d780cc3f7094c..bcb6443d68baa68e87c2cbb7a95f11610a1f2533 100644 (file)
@@ -850,7 +850,8 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetCentreOfMass
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
                                                 (Handle(GEOM_Object) theShape,
-                                                 Standard_Integer theIndex)
+                                                 Standard_Integer theIndex,
+                                                 Standard_Boolean theUseOri)
 {
   SetErrorCode(KO);
 
@@ -873,6 +874,7 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
   GEOMImpl_IMeasure aCI (aFunction);
   aCI.SetBase(aRefShape);
   aCI.SetIndex(theIndex);
+  aCI.SetUseOri(theUseOri);
 
   //Compute
   try {
@@ -888,7 +890,10 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::GetVertexByIndex
   }
 
   //Make a Python command
-  GEOM::TPythonDump(aFunction) << aVertex << " = geompy.GetVertexByIndex(" << theShape << ", " << theIndex << ")";
+  GEOM::TPythonDump(aFunction) << aVertex << " = geompy.GetVertexByIndex("
+                               << theShape << ", "
+                               << theIndex << ", "
+                               << theUseOri << ")";
 
   SetErrorCode(OK);
   return aVertex;
@@ -2139,16 +2144,16 @@ Standard_Integer GEOMImpl_IMeasureOperations::ClosestPoints (Handle(GEOM_Object)
       for (int i = 1; i <= nbSolutions; i++) {
         P1 = dst.PointOnShape1(i);
         P2 = dst.PointOnShape2(i);
-       
+        
         theDoubles->Append(P1.X());
         theDoubles->Append(P1.Y());
         theDoubles->Append(P1.Z());
         theDoubles->Append(P2.X());
         theDoubles->Append(P2.Y());
         theDoubles->Append(P2.Z());
-       
-       Standard_Real Dist = P1.Distance(P2);
-       singularBetter = singularBetter && dist < Dist;
+        
+        Standard_Real Dist = P1.Distance(P2);
+        singularBetter = singularBetter && dist < Dist;
       }
     }
 
index c71e6b881eb30cfb4e58115afe397c0e0544874e..c10c91f9053e8d057dc79018df83d81292d79a54 100644 (file)
@@ -113,7 +113,8 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) GetCentreOfMass (Handle(GEOM_Object) theShape);
 
   Standard_EXPORT Handle(GEOM_Object) GetVertexByIndex (Handle(GEOM_Object) theShape,
-                                                        Standard_Integer theIndex);
+                                                        Standard_Integer theIndex,
+                                                        Standard_Boolean theUseOri);
 
   Standard_EXPORT Handle(GEOM_Object) GetNormal (Handle(GEOM_Object) theFace,
                                                  Handle(GEOM_Object) theOptionalPoint);
@@ -162,9 +163,9 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
                                                Handle(TColStd_HSequenceOfInteger)& theIntersections);
   
   Standard_EXPORT bool CheckSelfIntersectionsFast (Handle(GEOM_Object) theShape,
-                                                  float  deflection, 
-                                                  double tolerance,
-                                                  Handle(TColStd_HSequenceOfInteger)& theIntersections);
+                                                   float  deflection, 
+                                                   double tolerance,
+                                                   Handle(TColStd_HSequenceOfInteger)& theIntersections);
 
   Standard_EXPORT bool CheckBOPArguments (const Handle(GEOM_Object) &theShape);
   
index 0fe1c4eaffd3fe59583e774f7d039ca408793a57..eb89ee9d6e07dee8b2247d39df51749d86e5297a 100644 (file)
@@ -154,6 +154,7 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(Handle(TFunction_Logbook)& log)
     }
 
     int index = aCI.GetIndex();
+    bool useOri = aCI.GetUseOri();
     gp_Pnt aVertex;
 
     if (aShapeBase.ShapeType() == TopAbs_VERTEX) {
@@ -161,23 +162,21 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(Handle(TFunction_Logbook)& log)
         Standard_NullObject::Raise("Vertex index is out of range");
       else
         aVertex = BRep_Tool::Pnt(TopoDS::Vertex(aShapeBase));
-    } else if (aShapeBase.ShapeType() == TopAbs_EDGE) {
-      TopoDS_Vertex aV1, aV2;
-      TopoDS_Edge anEdgeE = TopoDS::Edge(aShapeBase);
-      
-      TopExp::Vertices(anEdgeE, aV1, aV2);
-      gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
-      gp_Pnt aP2 = BRep_Tool::Pnt(aV2);
-
+    }
+    else if (aShapeBase.ShapeType() == TopAbs_EDGE) {
       if (index < 0 || index > 1)
         Standard_NullObject::Raise("Vertex index is out of range");
 
-      if ( ( anEdgeE.Orientation() == TopAbs_FORWARD && index == 0 ) ||
-           ( anEdgeE.Orientation() == TopAbs_REVERSED && index == 1 ) )
-        aVertex = aP1;
-      else
-      aVertex = aP2;
-    } else if (aShapeBase.ShapeType() == TopAbs_WIRE) {
+      TopoDS_Edge anEdgeE = TopoDS::Edge(aShapeBase);
+      if ( anEdgeE.Orientation() != TopAbs_FORWARD && 
+           anEdgeE.Orientation() != TopAbs_REVERSED )
+        anEdgeE.Orientation( TopAbs_FORWARD );
+
+      TopoDS_Vertex aV[2];
+      TopExp::Vertices(anEdgeE, aV[0], aV[1], useOri );
+      aVertex = BRep_Tool::Pnt( aV[ index ]);
+    }
+    else if (aShapeBase.ShapeType() == TopAbs_WIRE) {
       TopTools_IndexedMapOfShape anEdgeShapes;
       TopTools_IndexedMapOfShape aVertexShapes;
       TopoDS_Vertex aV1, aV2;
@@ -198,11 +197,12 @@ Standard_Integer GEOMImpl_MeasureDriver::Execute(Handle(TFunction_Logbook)& log)
       if (index < 0 || index > aVertexShapes.Extent())
         Standard_NullObject::Raise("Vertex index is out of range");
 
-      if (aWire.Orientation() == TopAbs_FORWARD)
+      if ( aWire.Orientation() == TopAbs_FORWARD || !useOri )
         aVertex = BRep_Tool::Pnt(TopoDS::Vertex(aVertexShapes(index+1)));
       else
         aVertex = BRep_Tool::Pnt(TopoDS::Vertex(aVertexShapes(aVertexShapes.Extent() - index)));
-    } else {
+    }
+    else {
       Standard_NullObject::Raise("Shape for vertex calculation is not an edge or wire");
     }
 
@@ -352,6 +352,7 @@ GetCreationInformation(std::string&             theOperationName,
     theOperationName = "GetVertexByIndex";
     AddParam( theParams, "Object", aCI.GetBase() );
     AddParam( theParams, "Index", aCI.GetIndex() );
+    AddParam( theParams, "Oriented", aCI.GetUseOri() );
     break;
   case VECTOR_FACE_NORMALE:
     theOperationName = "NORMALE";
index 953995317e5a468381cb5ee1fe330ffa97979340..a5b14ec7a711e0736de54934b10ab9c95bc9705c 100644 (file)
@@ -312,3 +312,14 @@ GEOM::CreationInformationSeq* GEOM_BaseObject_i::GetCreationInformation()
 
   return info._retn();
 }
+
+//================================================================================
+/*!
+ * \brief Return the engine creating this object
+ */
+//================================================================================
+
+GEOM::GEOM_Gen_ptr GEOM_BaseObject_i::GetGen()
+{
+  return GEOM::GEOM_Gen::_duplicate( _engine );
+}
index c57864b48923c536575a9b66b4abb8433d8567d1..ff83a0017fe88d3486df452b3418f0c6aa04e029 100644 (file)
@@ -66,6 +66,8 @@ class GEOM_I_EXPORT GEOM_BaseObject_i : public virtual POA_GEOM::GEOM_BaseObject
 
   virtual GEOM::CreationInformationSeq* GetCreationInformation();
 
+  virtual GEOM::GEOM_Gen_ptr GetGen();
+
   Handle(::GEOM_BaseObject) GetImpl() { return _impl; }
 
  protected:
index cc32f3410eaca1b3d35d33709c1839a17135007d..b334c6e27cbfa9d0d32c30ed995df964820b031d 100644 (file)
@@ -440,8 +440,10 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetCentreOfMass
  *  GetVertexByIndex
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetVertexByIndex
-  (GEOM::GEOM_Object_ptr theShape, CORBA::Long theIndex)
+GEOM::GEOM_Object_ptr
+GEOM_IMeasureOperations_i::GetVertexByIndex( GEOM::GEOM_Object_ptr theShape,
+                                             CORBA::Long           theIndex,
+                                             CORBA::Boolean        theUseOri )
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
@@ -453,7 +455,7 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::GetVertexByIndex
   if ( aShape.IsNull() ) return aGEOMObject._retn();
 
   // Get vertex by index
-  Handle(::GEOM_Object) anObject = GetOperations()->GetVertexByIndex(aShape, theIndex);
+  Handle(::GEOM_Object) anObject = GetOperations()->GetVertexByIndex(aShape, theIndex, theUseOri);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
index a64895562dad3a9ad4eab2edd99f0752dbf8b148..1a9595b5caf0eb27fdccb2e27d1deea597c6c11a 100644 (file)
@@ -63,7 +63,8 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
                                    GEOM::GEOM_Object_ptr theOptionalPoint);
 
   GEOM::GEOM_Object_ptr GetVertexByIndex (GEOM::GEOM_Object_ptr theObject,
-                                          CORBA::Long theIndex);
+                                          CORBA::Long           theIndex,
+                                          CORBA::Boolean        theUseOri);
 
   void GetInertia (GEOM::GEOM_Object_ptr theShape,
                    CORBA::Double& I11, CORBA::Double& I12, CORBA::Double& I13,
index e4ebf8d5f68ca02807e9ad1dff0304a16009b528..f41eb5fb4713b23f715411096a81a0c253a9c973 100644 (file)
@@ -11325,9 +11325,10 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
             self._autoPublish(anObj, theName, "centerOfMass")
             return anObj
 
-        ## Get a vertex sub-shape by index depended with orientation.
+        ## Get a vertex sub-shape by index.
         #  @param theShape Shape to find sub-shape.
         #  @param theIndex Index to find vertex by this index (starting from zero)
+        #  @param theUseOri To consider edge/wire orientation or not
         #  @param theName Object name; when specified, this parameter is used
         #         for result publication in the study. Otherwise, if automatic
         #         publication is switched on, default value is used for result name.
@@ -11336,13 +11337,14 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
         #
         #  @ref tui_measurement_tools_page "Example"
         @ManageTransactions("MeasuOp")
-        def GetVertexByIndex(self, theShape, theIndex, theName=None):
+        def GetVertexByIndex(self, theShape, theIndex, theUseOri=True, theName=None):
             """
-            Get a vertex sub-shape by index depended with orientation.
+            Get a vertex sub-shape by index.
 
             Parameters:
                 theShape Shape to find sub-shape.
                 theIndex Index to find vertex by this index (starting from zero)
+                theUseOri To consider edge/wire orientation or not
                 theName Object name; when specified, this parameter is used
                         for result publication in the study. Otherwise, if automatic
                         publication is switched on, default value is used for result name.
@@ -11351,7 +11353,9 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
                 New GEOM.GEOM_Object, containing the created vertex.
             """
             # Example: see GEOM_TestMeasures.py
-            anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex)
+            if isinstance( theUseOri, str ): # theUseOri was inserted before theName
+                theUseOri, theName = True, theUseOri
+            anObj = self.MeasuOp.GetVertexByIndex(theShape, theIndex, theUseOri)
             RaiseIfFailed("GetVertexByIndex", self.MeasuOp)
             self._autoPublish(anObj, theName, "vertex")
             return anObj
@@ -11380,7 +11384,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
             """
             # Example: see GEOM_TestMeasures.py
             # note: auto-publishing is done in self.GetVertexByIndex()
-            return self.GetVertexByIndex(theShape, 0, theName)
+            return self.GetVertexByIndex(theShape, 0, True, theName)
 
         ## Get the last vertex of wire/edge depended orientation.
         #  @param theShape Shape to find last vertex.
@@ -11407,7 +11411,7 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
             # Example: see GEOM_TestMeasures.py
             nb_vert =  self.NumberOfSubShapes(theShape, self.ShapeType["VERTEX"])
             # note: auto-publishing is done in self.GetVertexByIndex()
-            return self.GetVertexByIndex(theShape, (nb_vert-1), theName)
+            return self.GetVertexByIndex(theShape, (nb_vert-1), True, theName)
 
         ## Get a normale to the given face. If the point is not given,
         #  the normale is calculated at the center of mass.