Salome HOME
0020660: EDF 1238 GEOM: Missing equivalent of 2nd contructor of LCS in TUI
authordmv <dmv@opencascade.com>
Tue, 19 Jan 2010 08:21:42 +0000 (08:21 +0000)
committerdmv <dmv@opencascade.com>
Tue, 19 Jan 2010 08:21:42 +0000 (08:21 +0000)
17 files changed:
doc/salome/gui/GEOM/input/creating_lcs.doc
doc/salome/gui/GEOM/input/tui_basic_geom_objs.doc
idl/GEOM_Gen.idl
idl/GEOM_Superv.idl
src/BasicGUI/BasicGUI_MarkerDlg.cxx
src/BasicGUI/BasicGUI_MarkerDlg.h
src/GEOMImpl/GEOMImpl_IBasicOperations.cxx
src/GEOMImpl/GEOMImpl_IBasicOperations.hxx
src/GEOMImpl/GEOMImpl_IMarker.hxx
src/GEOMImpl/GEOMImpl_MarkerDriver.cxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_IBasicOperations_i.cc
src/GEOM_I/GEOM_IBasicOperations_i.hh
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_I_Superv/GEOM_Superv_i.hh
src/GEOM_SWIG/GEOM_TestAll.py
src/GEOM_SWIG/geompyDC.py

index 5f06f4ff3c1a0613c40d08bf85f6a430a4817896..2516af99d3a93fe4e299da8daa8fc9d01fb65e2b 100644 (file)
@@ -17,6 +17,7 @@ YDY, YDZ is a a vector of OY direction of the LCS.
 \n Secondly, you can simply select any object in the object browser or
 3D viewer, in this case the coordinates of origin and axes direction
 of the LCS are calculated automatically basing on the selected object.
+\n <b>TUI command:</b> <em>geompy.MakeMarkerFromShape(theShape)</em>.
 \n <b>Arguments:</b> Name + reference object.
 
 \image html neo-localcs2.png
@@ -24,8 +25,10 @@ of the LCS are calculated automatically basing on the selected object.
 \n The last algorithm of LCS construction allows to define the
 coordinates of origin by a point and axes directions by a line or a
 vector.
-\n <b>Arguments:</b> Name + 1 point of origin + X axis direction, Y
-axis direction.
+\n <b>TUI command:</b> <em>geompy.MakeMarkerPntTwoVec(Center, VectorX, 
+VectorY)</em> where Center is a point specified the coordinate system location,
+VectorX is a derection of OX axis and VectorY direction of OY axis.
+\n <b>Arguments:</b> Name + 1 point of origin + X axis direction, Y axis direction.
 
 \image html neo-localcs3.png
 
@@ -37,4 +40,6 @@ and in 3D viewer.
 
 \image html image145.png "Local Coordinate System"
 
+<b>TUI Script</b> provide you with useful example of creation of
+\ref tui_creation_lcs "Local Coordinate System".
 */
\ No newline at end of file
index 34f782d4533c181d1f3c2015c1c779d93a32ca16..5e1f733128b81a9643d67209b1c41b3ba834e5d1 100644 (file)
@@ -345,4 +345,45 @@ gg.setDisplayMode(id_plane5,1)
 gg.setTransparency(id_plane5,0.5)
 \endcode
 
+\anchor tui_creation_lcs
+<br><h2>Creation of a Local Coordinate System</h2>
+\code
+import GEOM
+import geompy
+import math
+import SALOMEDS
+
+#Create vertexes, vectors and shapes to construct local CS
+Vertex_1 = geompy.MakeVertex(50, 50, 50)
+Vertex_2 = geompy.MakeVertex(70, 70, 70)
+Vertex_3 = geompy.MakeVertex(0, 0, 0)
+Vector_X = geompy.MakeVectorDXDYDZ(50, 0, 0)
+Vector_Y = geompy.MakeVectorDXDYDZ(0, 50, 0)
+Face_1 = geompy.MakeFaceHW(100, 100, 1)
+Box_1 = geompy.MakeBoxTwoPnt(Vertex_1, Vertex_2)
+
+#Construct local CS by manual definition
+LocalCS_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
+
+#Construct local CS by center point and two vectors (X and Y directions)
+LocalCS_2 = geompy.MakeMarkerPntTwoVec(Vertex_3, Vector_X, Vector_Y)
+
+#Construct local CS from shape orientation
+LocalCS_FACE = geompy.MakeMarkerFromShape(Face_1)
+LocalCS_BOX = geompy.MakeMarkerFromShape(Box_1)
+
+#Add created object to study
+geompy.addToStudy( Face_1, "Face_1" )
+geompy.addToStudy( Vertex_1, "Vertex_1" )
+geompy.addToStudy( Vertex_2, "Vertex_2" )
+geompy.addToStudy( Box_1, "Box_1" )
+geompy.addToStudy( Vertex_3, "Vertex_3" )
+geompy.addToStudy( Vector_X, "Vector_X" )
+geompy.addToStudy( Vector_Y, "Vector_Y" )
+geompy.addToStudy( LocalCS_1, "LocalCS_1" )
+geompy.addToStudy( LocalCS_2, "LocalCS_3" )
+geompy.addToStudy( LocalCS_FACE, "LocalCS_FACE" )
+geompy.addToStudy( LocalCS_BOX, "LocalCS_BOX" )
+\endcode
+
 */
index 0763fb49355c05b86db6aa5bd0b4b6ceba217bfe..795212497c300f0bdbe3f7d023e3a1fe0042b2d0 100644 (file)
@@ -539,6 +539,22 @@ module GEOM
                            in double theXDX, in double theXDY, in double theXDZ,
                            in double theYDX, in double theYDY, in double theYDZ);
 
+    /*!
+     *  Create a local coordinate system from shape.
+     *  \param theShape The initial shape to detect the coordinate system.
+     *  \return New GEOM_Object, containing the created coordinate system.
+     */
+    GEOM_Object MakeMarkerFromShape (in GEOM_Object theShape);
+   
+    /*!
+     *  Create a local coordinate system from point and two vectors (DX, DY).
+     *  \param theOrigin Point of coordinate system origin.
+     *  \param theXVec Vector of X direction.
+     *  \param theYVec Vector of Y direction.
+     *  \return New GEOM_Object, containing the created coordinate system.
+     */
+    GEOM_Object MakeMarkerPntTwoVec (in GEOM_Object theOrigin, in GEOM_Object theXVec, in GEOM_Object theYVec);
+       
     /*!
      *  Create a tangent plane to specified face in the point with specified parameters.
      *  Values of parameters should be between 0. and 1.0
index 516f14110cc12ca003f9f866ca9db70887374dae..a120304e30a53646f40a45b2eb72df32c47e9849 100644 (file)
@@ -103,6 +103,10 @@ module GEOM
     GEOM_Object MakeMarker (in double theOX , in double theOY , in double theOZ,
                            in double theXDX, in double theXDY, in double theXDZ,
                            in double theYDX, in double theYDY, in double theYDZ) ;
+                           
+    GEOM_Object MakeMarkerFromShape (in GEOM_Object theShape) ;
+    
+    GEOM_Object MakeMarkerPntTwoVec (in GEOM_Object theOrigin, in GEOM_Object theXVec, in GEOM_Object theYVec) ;
 
     /*!
      *  Create a tangent plane to specified face in the point with specified parameters.
index 9bc0adf136c7090c8841802aa39590bdd617a156..a24113d4e400747f0dabc8b03a62439a31dd0dfb 100644 (file)
@@ -167,6 +167,7 @@ BasicGUI_MarkerDlg::~BasicGUI_MarkerDlg()
 //=================================================================================
 void BasicGUI_MarkerDlg::Init()
 {
+  myShape = myPoint = myVectorX = myVectorY = GEOM::GEOM_Object::_nil();
   myBlockPreview = false;
   myConstructorId = -1;
   myEditCurrentArgument = Group1->LineEdit1;
@@ -218,24 +219,6 @@ void BasicGUI_MarkerDlg::Init()
   myBlockPreview = false;
 
   ConstructorsClicked( 0 );
-
-
-  //@
-  /*
-  QAD_ViewFrame* aFrame = QAD_Application::getDesktop()->getActiveApp()->
-    getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
-
-  VTKViewer_ViewFrame* aVTKFrame = dynamic_cast<VTKViewer_ViewFrame*>( aFrame );
-  if ( aVTKFrame )
-  {
-    aVTKFrame->AdjustTrihedrons( true );
-    return;
-  }
-
-  OCCViewer_ViewFrame* aOCCFrame = dynamic_cast<OCCViewer_ViewFrame*>( aFrame );
-  if ( aOCCFrame )
-    aOCCFrame->AdjustTrihedrons( true );
-  */
 }
 
 //=================================================================================
@@ -248,7 +231,6 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
     globalSelection(); // close local contexts, if any
     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
     activate( GEOM_MARKER );
-    displayPreview();
     return;
   }
 
@@ -276,6 +258,7 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
       globalSelection( GEOM_ALLGEOM );
       myEditCurrentArgument = Group1->LineEdit1;
       Group1->LineEdit1->setText( "" );
+      myShape = GEOM::GEOM_Object::_nil();
       break;
     }
   case 2:
@@ -295,10 +278,15 @@ void BasicGUI_MarkerDlg::ConstructorsClicked( int constructorId )
       Group2->LineEdit1->setEnabled( true );
       Group2->LineEdit2->setEnabled( false );
       Group2->LineEdit3->setEnabled( false );
+      myPoint = GEOM::GEOM_Object::_nil();
+      myVectorX = GEOM::GEOM_Object::_nil();
+      myVectorY = GEOM::GEOM_Object::_nil();
       break;
     }
   }
 
+  displayPreview();
+
   qApp->processEvents();
   updateGeometry();
   resize( minimumSizeHint() );
@@ -428,39 +416,9 @@ void BasicGUI_MarkerDlg::onSelectionDone()
       QString aName = GEOMBase::GetName( aSelectedObj );
       
       if ( getConstructorId() == 1 ) { // by shape position
-        // Get shape's position
-        CORBA::Double Ox, Oy, Oz,   Zx, Zy, Zz,   Xx, Xy, Xz,   Yx, Yy, Yz;
-        Ox = Oy = Oz = Zx = Zy = Xy = Xz = Yx = Yz = 0;
-        Zz = Xx = Yy = 1.;
-        
-        GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
-          myGeomGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
-        aMeasureOp->GetPosition( aSelectedObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz );
-        
-        // Calculate Y direction
-        if ( aMeasureOp->IsDone() ) {
-          gp_Pnt aPnt  ( Ox, Oy, Oz );
-          gp_Dir aDirN ( Zx, Zy, Zz );
-          gp_Dir aDirX ( Xx, Xy, Xz );
-          gp_Ax3 anAx3 ( aPnt, aDirN, aDirX );
-
-          gp_Dir aDirY = anAx3.YDirection();
-          aDirY.Coord(Yx,Yy,Yz);
-        }
-
-        // Set values
-        myData[ X ]->setValue( Ox );
-        myData[ Y ]->setValue( Oy );
-        myData[ Z ]->setValue( Oz );
-
-        myData[ DX1 ]->setValue( Xx );
-        myData[ DY1 ]->setValue( Xy );
-        myData[ DZ1 ]->setValue( Xz );
-
-        myData[ DX2 ]->setValue( Yx );
-        myData[ DY2 ]->setValue( Yy );
-        myData[ DZ2 ]->setValue( Yz );
-
+        TopoDS_Shape aShape;
+        if ( GEOMBase::GetShape( aSelectedObj, aShape, TopAbs_SHAPE ) )
+          myShape = aSelectedObj;
         myEditCurrentArgument->setText( aName );
       }
       else if ( getConstructorId() == 2 ) { // by point and two vectors
@@ -487,57 +445,27 @@ void BasicGUI_MarkerDlg::onSelectionDone()
 
           if ( myEditCurrentArgument == Group2->LineEdit1 ) {
             if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) {
-              gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) );
-              myData[ X ]->setValue( aPnt.X() );
-              myData[ Y ]->setValue( aPnt.Y() );
-              myData[ Z ]->setValue( aPnt.Z() );
+              myPoint = aSelectedObj;
               myEditCurrentArgument->setText( aName );
               if (Group2->LineEdit2->text() == "")
                 Group2->PushButton2->click();
             }
-            else {
-              myData[ X ]->setValue( 0 );
-              myData[ Y ]->setValue( 0 );
-              myData[ Z ]->setValue( 0 );
-            }
           }
           else if (myEditCurrentArgument == Group2->LineEdit2) {
             if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
-              gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
-              gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
-              gp_Dir aDir( gp_Vec( aP1, aP2 ) );
-
-              myData[ DX1 ]->setValue( aDir.X() );
-              myData[ DY1 ]->setValue( aDir.Y() );
-              myData[ DZ1 ]->setValue( aDir.Z() );
+              myVectorX = aSelectedObj;
               myEditCurrentArgument->setText( aName );
               if (Group2->LineEdit3->text() == "")
                 Group2->PushButton3->click();
             }
-            else {
-              myData[ DX1 ]->setValue( 0 );
-              myData[ DY1 ]->setValue( 0 );
-              myData[ DZ1 ]->setValue( 0 );
-            }
           }
           else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
             if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE ) {
-              gp_Pnt aP1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShape ) ) );
-              gp_Pnt aP2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShape ) ) );
-              gp_Dir aDir(gp_Vec( aP1, aP2 ));
-
-              myData[ DX2 ]->setValue( aDir.X() );
-              myData[ DY2 ]->setValue( aDir.Y() );
-              myData[ DZ2 ]->setValue( aDir.Z() );
+              myVectorY = aSelectedObj;
               myEditCurrentArgument->setText( aName );
               if (Group2->LineEdit1->text() == "")
                 Group2->PushButton1->click();
             }
-            else {
-              myData[ DX2 ]->setValue( 0 );
-              myData[ DY2 ]->setValue( 0 );
-              myData[ DZ2 ]->setValue( 0 );
-            }
           }
         }
       }
@@ -545,34 +473,14 @@ void BasicGUI_MarkerDlg::onSelectionDone()
   }
   else {
     if ( getConstructorId() == 1 ) {
-      myData[ X ]->setValue( 0 );
-      myData[ Y ]->setValue( 0 );
-      myData[ Z ]->setValue( 0 );
-
-      myData[ DX1 ]->setValue( 0 );
-      myData[ DY1 ]->setValue( 0 );
-      myData[ DZ1 ]->setValue( 0 );
-
-      myData[ DX2 ]->setValue( 0 );
-      myData[ DY2 ]->setValue( 0 );
-      myData[ DZ2 ]->setValue( 0 );
-    }
-    else if ( getConstructorId() == 2 ) {
-      if ( myEditCurrentArgument == Group2->LineEdit1 ) {
-        myData[ X ]->setValue( 0 );
-        myData[ Y ]->setValue( 0 );
-        myData[ Z ]->setValue( 0 );
-      }
-      else if ( myEditCurrentArgument == Group2->LineEdit2 ) {
-        myData[ DX1 ]->setValue( 0 );
-        myData[ DY1 ]->setValue( 0 );
-        myData[ DZ1 ]->setValue( 0 );
-      }
-      else if ( myEditCurrentArgument == Group2->LineEdit3 ) {
-        myData[ DX2 ]->setValue( 0 );
-        myData[ DY2 ]->setValue( 0 );
-        myData[ DZ2 ]->setValue( 0 );
-      }
+      myShape = GEOM::GEOM_Object::_nil();
+    } else if ( getConstructorId() == 2 ) {
+      if ( myEditCurrentArgument == Group2->LineEdit1 )
+        myPoint = GEOM::GEOM_Object::_nil();
+      else if ( myEditCurrentArgument == Group2->LineEdit2 )
+        myVectorX = GEOM::GEOM_Object::_nil();
+      else if ( myEditCurrentArgument == Group2->LineEdit3 )
+        myVectorY = GEOM::GEOM_Object::_nil();
     }
   }
 
@@ -685,31 +593,28 @@ GEOM::GEOM_IOperations_ptr BasicGUI_MarkerDlg::createOperation()
 bool BasicGUI_MarkerDlg::isValid( QString& msg )
 {
   const int id = getConstructorId();
-  gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
-         v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
-
-  bool isOk = false;
-  // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
-  // Vectors shouldn't be checked for being orthogonal here!
-  if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
-    isOk = !v1.IsParallel( v2, Precision::Angular() );
-    if ( !isOk )
-      msg += tr( "VEC_PARALLEL" );
-  }
-
   switch ( id ) {
-  case 0: {
-    bool ok = true;
-    for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
-      ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
-    return isOk && ok;
-  }
-  case 1:
-    return !Group1->LineEdit1->text().isEmpty() && isOk;
-  case 2:
-    return !Group2->LineEdit1->text().isEmpty() &&
-      !Group2->LineEdit2->text().isEmpty() &&
-      !Group2->LineEdit3->text().isEmpty() && isOk;
+    case 0: {
+      gp_Vec v1( myData[ DX1 ]->value(), myData[ DY1 ]->value(), myData[ DZ1 ]->value() ),
+        v2( myData[ DX2 ]->value(), myData[ DY2 ]->value(), myData[ DZ2 ]->value() );
+      
+      bool isOk = false;
+      // we will got exception if the magnitude of any of the 2 vectors <= gp::Resolution()
+      // Vectors shouldn't be checked for being orthogonal here!
+      if ( v1.Magnitude() > gp::Resolution() && v2.Magnitude() > gp::Resolution() ) {
+        isOk = !v1.IsParallel( v2, Precision::Angular() );
+        if ( !isOk )
+          msg += tr( "VEC_PARALLEL" );
+      }
+      bool ok = true;
+      for ( DataMap::iterator anIter = myData.begin(); anIter != myData.end(); ++anIter )
+        ok = anIter.value()->isValid( msg, !IsPreview()) && ok;
+      return isOk && ok;
+    }
+    case 1:
+      return !myShape->_is_nil();
+    case 2:
+      return !myPoint->_is_nil() && !myVectorX->_is_nil() && !myVectorY->_is_nil();
   }
   return false;
 }
@@ -721,28 +626,32 @@ bool BasicGUI_MarkerDlg::isValid( QString& msg )
 bool BasicGUI_MarkerDlg::execute( ObjectList& objects )
 {
   GEOM::GEOM_IBasicOperations_var anOper = GEOM::GEOM_IBasicOperations::_narrow( getOperation() );
-  GEOM::GEOM_Object_var anObj = anOper->MakeMarker( myData[ X   ]->value(), 
-                                                    myData[ Y   ]->value(), 
-                                                    myData[ Z   ]->value(),
-                                                    myData[ DX1 ]->value(),
-                                                    myData[ DY1 ]->value(), 
-                                                    myData[ DZ1 ]->value(),
-                                                    myData[ DX2 ]->value(),
-                                                    myData[ DY2 ]->value(),
-                                                    myData[ DZ2 ]->value() );
+  GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_nil();
   QStringList aParameters;
-  aParameters<<myData[X]->text();
-  aParameters<<myData[Y]->text();
-  aParameters<<myData[Z]->text();
-  aParameters<<myData[ DX1 ]->text(); 
-  aParameters<<myData[ DY1 ]->text(); 
-  aParameters<<myData[ DZ1 ]->text();
-  aParameters<<myData[ DX2 ]->text();
-  aParameters<<myData[ DY2 ]->text();
-  aParameters<<myData[ DZ2 ]->text();
+  const int id = getConstructorId();
+  if (id == 0) {
+    anObj = anOper->MakeMarker( myData[ X   ]->value(), myData[ Y   ]->value(), 
+                                myData[ Z   ]->value(), myData[ DX1 ]->value(),
+                                myData[ DY1 ]->value(), myData[ DZ1 ]->value(),
+                                myData[ DX2 ]->value(), myData[ DY2 ]->value(),
+                                myData[ DZ2 ]->value() );
+    aParameters<<myData[X]->text();
+    aParameters<<myData[Y]->text();
+    aParameters<<myData[Z]->text();
+    aParameters<<myData[ DX1 ]->text(); 
+    aParameters<<myData[ DY1 ]->text(); 
+    aParameters<<myData[ DZ1 ]->text();
+    aParameters<<myData[ DX2 ]->text();
+    aParameters<<myData[ DY2 ]->text();
+    aParameters<<myData[ DZ2 ]->text();
+  } else if (id == 1) {
+    anObj = anOper->MakeMarkerFromShape( myShape ); 
+  } else if (id == 2) {
+    anObj = anOper->MakeMarkerPntTwoVec( myPoint, myVectorX, myVectorY ); 
+  }
   
   if ( !anObj->_is_nil() ) {
-    if ( !IsPreview() )
+    if ( !IsPreview() && id == 0)
       anObj->SetParameters(aParameters.join(":").toLatin1().constData());
     objects.push_back( anObj._retn() );
   }
index 364b0d7375786a1e1bbaee3650b0dbe759f5c3ee..18e765af46ff7fbc98d20050b1000b4128547fba 100644 (file)
@@ -61,6 +61,11 @@ private:
   void                          enterEvent( QEvent* );
   void                          onSelectionDone0();
 
+  GEOM::GEOM_Object_var         myShape;
+  GEOM::GEOM_Object_var         myPoint;
+  GEOM::GEOM_Object_var         myVectorX;
+  GEOM::GEOM_Object_var         myVectorY;
+
 private slots:
   void                          onOk();
   bool                          onApply();
index ebba432d7f02b268765aba85ffa8377e20698bdc..3bce36434fbfbdc69a4c225ebd8bdf676dd936e4 100644 (file)
@@ -1057,6 +1057,115 @@ Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarker
   return aMarker;
 }
 
+//=============================================================================
+/*!
+ *  MakeMarkerFromShape
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerFromShape
+                                  (const Handle(GEOM_Object)& theShape)
+{
+  SetErrorCode(KO);
+
+  //Add a new Marker object
+  Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
+
+  //Add a new Marker function
+  Handle(GEOM_Function) aFunction =
+    aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_SHAPE);
+  if (aFunction.IsNull()) return NULL;
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
+
+  GEOMImpl_IMarker aPI(aFunction);
+
+  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
+  if (aRefShape.IsNull()) return NULL;
+
+  aPI.SetShape(aRefShape);
+
+  //Compute the marker value
+  try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Marker driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerFromShape(" << theShape << ")";
+
+  SetErrorCode(OK);
+  return aMarker;
+}
+
+//=============================================================================
+/*!
+ *  MakeMarkerPntTwoVec
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IBasicOperations::MakeMarkerPntTwoVec
+                                              (const Handle(GEOM_Object)& theOrigin,
+                                               const Handle(GEOM_Object)& theXVec,
+                                               const Handle(GEOM_Object)& theYVec)
+{
+  SetErrorCode(KO);
+
+  //Add a new Marker object
+  Handle(GEOM_Object) aMarker = GetEngine()->AddObject(GetDocID(), GEOM_MARKER);
+
+  //Add a new Marker function
+  Handle(GEOM_Function) aFunction =
+    aMarker->AddFunction(GEOMImpl_MarkerDriver::GetID(), MARKER_PNT2VEC);
+  if (aFunction.IsNull()) return NULL;
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_MarkerDriver::GetID()) return NULL;
+
+  GEOMImpl_IMarker aPI(aFunction);
+
+  Handle(GEOM_Function) aRefOrigin = theOrigin->GetLastFunction();
+  Handle(GEOM_Function) aRefXVec = theXVec->GetLastFunction();
+  Handle(GEOM_Function) aRefYVec = theYVec->GetLastFunction();
+  if (aRefOrigin.IsNull() || aRefXVec.IsNull() || aRefYVec.IsNull()) return NULL;
+
+  aPI.SetOrigin(aRefOrigin);
+  aPI.SetXVec(aRefXVec);
+  aPI.SetYVec(aRefYVec);
+
+  //Compute the marker value
+  try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Marker driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOM::TPythonDump(aFunction) << aMarker << " = geompy.MakeMarkerPntTwoVec("
+    << theOrigin << ", " << theXVec << ", " << theYVec << ")";
+
+  SetErrorCode(OK);
+  return aMarker;
+}
+
 //=============================================================================
 /*!
  *  MakeTangentPlaneOnFace
index 0b318a72c06bac390fc2848eb2493d8f4d26b49f..195f80354986440e30e0c7cb2b71d99dee49d181 100644 (file)
@@ -100,6 +100,12 @@ class GEOMImpl_IBasicOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) MakeMarker (double theOX,  double theOY,  double theOZ,
                                   double theXDX, double theXDY, double theXDZ,
                                   double theYDX, double theYDY, double theYDZ);
+                                 
+  Standard_EXPORT Handle(GEOM_Object) MakeMarkerFromShape (const Handle(GEOM_Object)& theShape);
+  
+  Standard_EXPORT Handle(GEOM_Object) MakeMarkerPntTwoVec (const Handle(GEOM_Object)& theOrigin,
+                                                           const Handle(GEOM_Object)& theXVec,
+                                                           const Handle(GEOM_Object)& theYVec);
 
   Standard_EXPORT Handle(GEOM_Object) MakeTangentPlaneOnFace(const Handle(GEOM_Object)& theFace,
                                                              double theParamU,
index 54265314f20f58e8552c5592ece4b3dd5cdf48c9..d0cd303e2c2ad29e1f69a2b1cc21bf37e064daaf 100644 (file)
 #define CS_ARG_Y_DY  8
 #define CS_ARG_Y_DZ  9
 
+#define CS_ARG_SHAPE  10
+#define CS_ARG_ORIGIN 11
+#define CS_ARG_XVEC   12
+#define CS_ARG_YVEC   13
+
 class GEOMImpl_IMarker
 {
  public:
@@ -61,6 +66,26 @@ class GEOMImpl_IMarker
     _func->SetReal(CS_ARG_Y_DY, theDY);
     _func->SetReal(CS_ARG_Y_DZ, theDZ);
   }
+  
+  void SetShape (Handle(GEOM_Function) theShape)
+  {
+    _func->SetReference(CS_ARG_SHAPE, theShape);
+  }
+
+  void SetOrigin (Handle(GEOM_Function) theOrigin)
+  {
+    _func->SetReference(CS_ARG_ORIGIN, theOrigin);
+  }
+
+  void SetXVec (Handle(GEOM_Function) theXVec)
+  {
+    _func->SetReference(CS_ARG_XVEC, theXVec);
+  }
+
+  void SetYVec (Handle(GEOM_Function) theYVec)
+  {
+    _func->SetReference(CS_ARG_YVEC, theYVec);
+  }
 
   void GetOrigin (double& theX, double& theY, double& theZ)
   {
@@ -82,6 +107,26 @@ class GEOMImpl_IMarker
     theDY = _func->GetReal(CS_ARG_Y_DY);
     theDZ = _func->GetReal(CS_ARG_Y_DZ);
   }
+  
+  Handle(GEOM_Function) GetShape()
+  {
+    return _func->GetReference(CS_ARG_SHAPE); 
+  }
+
+  Handle(GEOM_Function) GetOrigin()
+  {
+    return _func->GetReference(CS_ARG_ORIGIN); 
+  }
+
+  Handle(GEOM_Function) GetXVec()
+  {
+    return _func->GetReference(CS_ARG_XVEC); 
+  }
+
+  Handle(GEOM_Function) GetYVec()
+  {
+    return _func->GetReference(CS_ARG_YVEC); 
+  }
 
  private:
 
index 12231f722132eb3014142871454886abfaa05cc5..2ffbd23e1912674e0dfeea50e1609389e70165d7 100644 (file)
@@ -25,6 +25,7 @@
 #include <GEOMImpl_IMarker.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
+#include <GEOMImpl_IMeasureOperations.hxx>
 
 #include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRep_Tool.hxx>
@@ -102,6 +103,48 @@ Standard_Integer GEOMImpl_MarkerDriver::Execute(TFunction_Logbook& log) const
     gp_Ax3 anA (aPO, aN, aVX);
     gp_Pln aPln (anA);
 
+    double aTrimSize = 100.0;
+    aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
+  } else if (aType == MARKER_SHAPE) {
+    Handle(GEOM_Function) aRefShape = aPI.GetShape();
+    TopoDS_Shape aSh = aRefShape->GetValue();
+    gp_Ax3 anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aSh);
+    gp_Pln aPln (anAx3);
+
+    double aTrimSize = 100.0;
+    aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
+  } else if (aType == MARKER_PNT2VEC) {
+    Handle(GEOM_Function) aRefOrigin  = aPI.GetOrigin();
+    Handle(GEOM_Function) aRefXVec = aPI.GetXVec();
+    Handle(GEOM_Function) aRefYVec = aPI.GetYVec();
+    TopoDS_Shape aShapeOrigin = aRefOrigin->GetValue();
+    TopoDS_Shape aShapeXVec = aRefXVec->GetValue();
+    TopoDS_Shape aShapeYVec = aRefYVec->GetValue();
+    if (aShapeOrigin.ShapeType() != TopAbs_VERTEX || aShapeOrigin.IsNull()) return 0;
+    if (aShapeXVec.ShapeType() != TopAbs_EDGE || aShapeXVec.IsNull()) return 0;
+    if (aShapeYVec.ShapeType() != TopAbs_EDGE || aShapeYVec.IsNull()) return 0;
+
+    gp_Pnt aPO = BRep_Tool::Pnt( TopoDS::Vertex( aShapeOrigin ) );
+
+    gp_Pnt aPX1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShapeXVec ) ) );
+    gp_Pnt aPX2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShapeXVec ) ) );
+    gp_Vec aVX( aPX1, aPX2 );
+
+    gp_Pnt aPY1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShapeYVec ) ) );
+    gp_Pnt aPY2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShapeYVec ) ) );
+    gp_Vec aVY( aPY1, aPY2 );
+
+    if (aVX.Magnitude() < gp::Resolution() || aVY.Magnitude() < gp::Resolution())
+        Standard_ConstructionError::Raise
+          ("Local CS creation aborted: vector of zero length is given");
+
+    if ( aVX.IsParallel(aVY, Precision::Angular()))
+      Standard_ConstructionError::Raise("Parallel Vectors given");
+    
+    gp_Vec aN = aVX ^ aVY;
+    gp_Ax3 anA (aPO, aN, aVX);
+    gp_Pln aPln (anA);
+    
     double aTrimSize = 100.0;
     aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
   } else {
index 9105d82c8b0840165795b2a04457e3da710afeb7..b6b75345178a45959c8ba115a1721be7cef00835 100755 (executable)
 #define BLOCK_COMPOUND_IMPROVE    10
 
 // Marker
-#define MARKER_CS 1
+#define MARKER_CS      1
+#define MARKER_SHAPE   2
+#define MARKER_PNT2VEC 3
index 278d9090df9c92c7c85d3de0f18882419b677937..06b4fa6b83d522f70cbcba2d697e014fea3e2efe 100644 (file)
@@ -561,6 +561,62 @@ GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarker
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  MakeMarkerFromShape
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerFromShape
+                                              (GEOM::GEOM_Object_ptr theShape)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the referenced object
+  Handle(GEOM_Object) aRef = GetObjectImpl(theShape);
+  if (aRef.IsNull()) return aGEOMObject._retn();
+
+  //Create the point
+  Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerFromShape(aRef);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakeMarkerPntTwoVec
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IBasicOperations_i::MakeMarkerPntTwoVec
+                                              (GEOM::GEOM_Object_ptr theOrigin,
+                                               GEOM::GEOM_Object_ptr theXVec,
+                                               GEOM::GEOM_Object_ptr theYVec)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the referenced objects
+  Handle(GEOM_Object) aRef1 = GetObjectImpl(theOrigin);
+  Handle(GEOM_Object) aRef2 = GetObjectImpl(theXVec);
+  Handle(GEOM_Object) aRef3 = GetObjectImpl(theYVec);
+  if (aRef1.IsNull() || aRef2.IsNull() || aRef3.IsNull()) return aGEOMObject._retn();
+
+  //Create the point
+  Handle(GEOM_Object) anObject = GetOperations()->MakeMarkerPntTwoVec(aRef1,
+                                                                      aRef2,
+                                                                     aRef3);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
 //=============================================================================
 /*!
  *  MakeTangentPlaneOnFace
index 7910c4e172f576b9b365644ae134ce95c7fc0eb6..b999fc9a66a0f16f76835e69132c10b8e42845e0 100644 (file)
@@ -114,6 +114,10 @@ class GEOM_I_EXPORT GEOM_IBasicOperations_i :
                                     CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
                                     CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ);
 
+   GEOM::GEOM_Object_ptr MakeMarkerFromShape (GEOM::GEOM_Object_ptr theShape);
+   
+   GEOM::GEOM_Object_ptr MakeMarkerPntTwoVec (GEOM::GEOM_Object_ptr theOrigin, GEOM::GEOM_Object_ptr theXVec, GEOM::GEOM_Object_ptr theYVec);
+
    GEOM::GEOM_Object_ptr MakeTangentPlaneOnFace (GEOM::GEOM_Object_ptr theFace, 
                                                 CORBA::Double theParameterU,
                                                 CORBA::Double theParameterV,
index 2762674fed62f3dbd53d1db0a1fe47146f51995f..6518d8338f871932ca6f1236976e13541d7e84af 100644 (file)
@@ -802,6 +802,34 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeMarker
   return anObj;
 }
 
+//=============================================================================
+//  MakeMarkerFromShape:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeMarkerFromShape (GEOM::GEOM_Object_ptr theShape)
+{
+  beginService( " GEOM_Superv_i::MakeMarkerFromShape" );
+  MESSAGE("GEOM_Superv_i::MakeMarkerFromShape");
+  getBasicOp();
+  GEOM::GEOM_Object_ptr anObj = myBasicOp->MakeMarkerFromShape(theShape);
+  endService( " GEOM_Superv_i::MakeMarkerFromShape" );
+  return anObj;
+}
+
+//=============================================================================
+//  MakeMarkerPntTwoVec:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeMarkerPntTwoVec (GEOM::GEOM_Object_ptr theOrigin,
+                                                          GEOM::GEOM_Object_ptr theXVec,
+                                                          GEOM::GEOM_Object_ptr theYVec)
+{
+  beginService( " GEOM_Superv_i::MakeMarkerPntTwoVec" );
+  MESSAGE("GEOM_Superv_i::MakeMarkerPntTwoVec");
+  getBasicOp();
+  GEOM::GEOM_Object_ptr anObj = myBasicOp->MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec);
+  endService( " GEOM_Superv_i::MakeMarkerPntTwoVec" );
+  return anObj;
+}
+
 //=============================================================================
 //  MakeTangentPlaneOnFace:
 //=============================================================================
index 1ed69ad457733c7a262eb494d189b5f3c174b239..d726e3b2a37990705ee4897dac812c4c6010f3fc 100644 (file)
@@ -191,6 +191,12 @@ public:
                                    CORBA::Double theXDX, CORBA::Double theXDY, CORBA::Double theXDZ,
                                    CORBA::Double theYDX, CORBA::Double theYDY, CORBA::Double theYDZ);
 
+  GEOM::GEOM_Object_ptr MakeMarkerFromShape (GEOM::GEOM_Object_ptr theShape);
+
+  GEOM::GEOM_Object_ptr MakeMarkerPntTwoVec (GEOM::GEOM_Object_ptr theOrigin,
+                                             GEOM::GEOM_Object_ptr theXVec,
+                                             GEOM::GEOM_Object_ptr theYVec);
+    
   GEOM::GEOM_Object_ptr MakeTangentPlaneOnFace (GEOM::GEOM_Object_ptr theFace, 
                                                 CORBA::Double theParameterU,
                                                 CORBA::Double theParameterV,
index fb759878036c8aea63acd04284bb5ed35eaff347..e0d2599f990ef63e38b1605181fc0e7852569d58 100644 (file)
@@ -107,6 +107,9 @@ def TestAll (geompy, math):
   Sketcher = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW",
                                  [100,0,0, 1,1,1, -1,1,0]) #(String, List of Doubles)->GEOM_Object_ptr
   Sketcher3d = geompy.Make3DSketcher([0,0,0, 50,50,50, 0,50,50, 10,0,0])
+  
+  #Create local coordinate system from shape
+  cs4 = geompy.MakeMarkerFromShape(Plane)
 
   #Test point on curve creation
   p_on_arc = geompy.MakeVertexOnCurve(Arc, 0.25) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
@@ -303,6 +306,7 @@ def TestAll (geompy, math):
   id_cs1 = geompy.addToStudy(cs1, "CS 50,50,50, 1,0,0, 0,1,0")
   id_cs2 = geompy.addToStudy(cs2, "CS 70,80,10, 1,0,1, 1,1,0")
   id_cs3 = geompy.addToStudy(cs3, "CS: pz, vxy, vz")
+  id_cs4 = geompy.addToStudy(cs4, "CS: Plane")
 
   id_Line   = geompy.addToStudy(Line,   "Line")
   id_Line1  = geompy.addToStudy(Line1,  "Line by point and vector")
index 4e05cc58dd0296ccf1e32a41e23809601212e436..1788293dda6d4ee0ab96fb41c63a1e2039bf5f7f 100644 (file)
@@ -641,7 +641,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             anObj.SetParameters(Parameters)
             return anObj
 
-       ## Create a plane, passing through the 2 vectors
+        ## Create a plane, passing through the 2 vectors
         #  with center in a start point of the first vector.
         #  @param theVec1 Vector, defining center point and plane direction.
         #  @param theVec2 Vector, defining the plane normal direction.
@@ -657,10 +657,10 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             anObj.SetParameters(Parameters)
             return anObj
 
-       ## Create a plane, based on a Local coordinate system.
+        ## Create a plane, based on a Local coordinate system.
         #  @param theLCS  coordinate system, defining plane.
         #  @param theTrimSize Half size of a side of quadrangle face, representing the plane.
-       #  @param theOrientation OXY, OYZ or OZX orientation - (1, 2 or 3)
+        #  @param theOrientation OXY, OYZ or OZX orientation - (1, 2 or 3)
         #  @return New GEOM_Object, containing the created plane.
         #
         #  @ref tui_creation_plane "Example"
@@ -686,28 +686,27 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             RaiseIfFailed("MakeMarker", self.BasicOp)
             anObj.SetParameters(Parameters)
             return anObj
+           
+        ## Create a local coordinate system from shape.
+        #  @param theShape The initial shape to detect the coordinate system.
+        #  @return New GEOM_Object, containing the created coordinate system.
+        #
+        #  @ref tui_creation_lcs "Example"
+        def MakeMarkerFromShape(self, theShape):
+            anObj = self.BasicOp.MakeMarkerFromShape(theShape)
+            RaiseIfFailed("MakeMarkerFromShape", self.BasicOp)
+            return anObj
 
-        ## Create a local coordinate system.
+        ## Create a local coordinate system from point and two vectors.
         #  @param theOrigin Point of coordinate system origin.
         #  @param theXVec Vector of X direction
         #  @param theYVec Vector of Y direction
         #  @return New GEOM_Object, containing the created coordinate system.
         #
-        #  @ref swig_MakeMarker "Example"
+       #  @ref tui_creation_lcs "Example"
         def MakeMarkerPntTwoVec(self, theOrigin, theXVec, theYVec):
-            O = self.PointCoordinates( theOrigin )
-            OXOY = []
-            for vec in [ theXVec, theYVec ]:
-                v1, v2 = self.SubShapeAll( vec, ShapeType["VERTEX"] )
-                p1 = self.PointCoordinates( v1 )
-                p2 = self.PointCoordinates( v2 )
-                for i in range( 0, 3 ):
-                    OXOY.append( p2[i] - p1[i] )
-                #
-            anObj = self.BasicOp.MakeMarker( O[0], O[1], O[2],
-                                             OXOY[0], OXOY[1], OXOY[2],
-                                             OXOY[3], OXOY[4], OXOY[5], )
-            RaiseIfFailed("MakeMarker", self.BasicOp)
+            anObj = self.BasicOp.MakeMarkerPntTwoVec(theOrigin, theXVec, theYVec)
+            RaiseIfFailed("MakeMarkerPntTwoVec", self.BasicOp)
             return anObj
 
         # end of l3_basic_go
@@ -1255,7 +1254,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             anObj.SetParameters(Parameters)
             return anObj
 
-       ## Create a shape by extrusion of the base shape along the dx, dy, dz direction
+        ## Create a shape by extrusion of the base shape along the dx, dy, dz direction
         #  @param theBase Base shape to be extruded.
         #  @param theDX, theDY, theDZ Directions of extrusion.
         #  @return New GEOM_Object, containing the created prism.
@@ -1269,7 +1268,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             anObj.SetParameters(Parameters)
             return anObj
 
-       ## Create a shape by extrusion of the base shape along the dx, dy, dz direction
+        ## Create a shape by extrusion of the base shape along the dx, dy, dz direction
         #  i.e. all the space, transfixed by the base shape during its translation
         #  along the vector on the given distance in 2 Ways (forward/backward) .
         #  @param theBase Base shape to be extruded.