Salome HOME
Documenting of Python code
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Sep 2015 12:43:16 +0000 (15:43 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Sep 2015 12:44:01 +0000 (15:44 +0300)
src/GeomAlgoImpl/GEOMAlgo_Splitter.hxx
src/PythonAPI/extension/box.py
src/PythonAPI/geom/missed.py
src/PythonAPI/modeler/boolean.py
src/PythonAPI/modeler/extrusion.py
src/PythonAPI/modeler/part.py
src/PythonAPI/modeler/roots.py
src/PythonAPI/modeler/sketcher.py
src/PythonAddons/addons_Features.py
src/PythonAddons/macros/box/feature.py

index 0796e5579cc690960d1a23d0a13c350d6ef4caba..234765aa26b2b50d1c65da614ecd31510b1fb1ad 100644 (file)
 //class    : GEOMAlgo_Splitter
 //purpose  :
 //=======================================================================
-class GEOMAlgo_Splitter : public BOPAlgo_Builder
+/*!
+ * \class GEOMAlgo_Splitter
+ * \ingroup DataAlgo
+ * A class for shapes partitioning
+ */
+ class GEOMAlgo_Splitter : public BOPAlgo_Builder
 {
  public:
-  
-  GEOMALGOIMPL_EXPORT
-    GEOMAlgo_Splitter();
+  /// Constructor
+  GEOMALGOIMPL_EXPORT GEOMAlgo_Splitter();
 
-  GEOMALGOIMPL_EXPORT
-    GEOMAlgo_Splitter(const Handle(NCollection_BaseAllocator)& theAllocator);
+  /// Constructor
+  /// \param theAllocator an allocator object
+  GEOMALGOIMPL_EXPORT GEOMAlgo_Splitter(const Handle(NCollection_BaseAllocator)& theAllocator);
   
-  GEOMALGOIMPL_EXPORT
-    virtual ~GEOMAlgo_Splitter();
+  GEOMALGOIMPL_EXPORT virtual ~GEOMAlgo_Splitter();
 
-  GEOMALGOIMPL_EXPORT
-    void AddTool(const TopoDS_Shape& theShape);
+  /// Add a tool shape
+  /// \param theShape a tool shape
+  GEOMALGOIMPL_EXPORT void AddTool(const TopoDS_Shape& theShape);
 
-  GEOMALGOIMPL_EXPORT
-    const BOPCol_ListOfShape& Tools()const;
+  /// Returns list of tool shapes
+  GEOMALGOIMPL_EXPORT const BOPCol_ListOfShape& Tools()const;
 
-  GEOMALGOIMPL_EXPORT
-    void SetLimit(const TopAbs_ShapeEnum aLimit);
+  /// Set type of used shapes
+  /// \param aLimit a shape type
+  GEOMALGOIMPL_EXPORT void SetLimit(const TopAbs_ShapeEnum aLimit);
 
-  GEOMALGOIMPL_EXPORT
-    TopAbs_ShapeEnum Limit()const;
+  /// Returns defined limit type
+  GEOMALGOIMPL_EXPORT TopAbs_ShapeEnum Limit()const;
 
-  GEOMALGOIMPL_EXPORT
-    void SetLimitMode(const Standard_Integer aMode);
+  /// Set mode (0 or 1) of limit
+  /// \param aMode the mode value
+  GEOMALGOIMPL_EXPORT void SetLimitMode(const Standard_Integer aMode);
 
-  GEOMALGOIMPL_EXPORT
-    Standard_Integer LimitMode()const;
+  /// Returns mode of limit
+  GEOMALGOIMPL_EXPORT Standard_Integer LimitMode()const;
 
-  GEOMALGOIMPL_EXPORT
-    virtual void Clear();
+  /// Clears all tool shapes
+  GEOMALGOIMPL_EXPORT virtual void Clear();
 
  protected:
-  GEOMALGOIMPL_EXPORT
-    virtual void BuildResult(const TopAbs_ShapeEnum theType);
+   /// Build result.
+   /// \param theType a type of limit
+  GEOMALGOIMPL_EXPORT virtual void BuildResult(const TopAbs_ShapeEnum theType);
 
-  GEOMALGOIMPL_EXPORT
-    virtual void PostTreat();
+  /// Post processing of the calculation
+  GEOMALGOIMPL_EXPORT virtual void PostTreat();
   
  protected:
+   /// List of tools
   BOPCol_ListOfShape myTools; 
+
+  /// Map of tools
   BOPCol_MapOfShape myMapTools;        
+
+  /// A limit type
   TopAbs_ShapeEnum myLimit;   
+
+  /// A limit mode
   Standard_Integer myLimitMode;  
 };
 
index 957da5412f570e9299d0dcdc12cb3e50e098d720..3a6b641a58b8581097a5530b5ebe91d916e74fc8 100644 (file)
@@ -11,6 +11,7 @@ class Box(modeler.Interface):
   """Executes the macro-feature Box.
   """
   def __init__(self, part, dx, dy, dz):
+    """Constructor"""
     modeler.Interface.__init__(self, part, MY.ID())
 
     self.setRealInput( MY.WIDTH_ID(), dx )
index 0aa6db1e394b82a2d65d8e9ef012387f920f542f..f5a6cfca81bba58c2f7e4941090a7882c3de83eb 100644 (file)
@@ -6,20 +6,29 @@ from GeomAPI import *
 
 
 class Ax3:
+  """A class to represent a Coordinate system object"""
 
   def __init__(self, origin, normal, dirx):
+    """Constructor"""
+    ### Create an origin point
     self.o  = origin
+    ### Create a normal vector
     self.n  = normal
+    ### Create X axis direction
     self.dx = dirx
 
   def location (self):
+    """Returns origin point"""
     return self.o
 
   def direction (self):
+    """Returns normal direction"""
     return self.n
 
   def xDirection (self):
+    """Returns direction of X axis"""
     return self.dx
 
   def yDirection (self):
+    """Returns direction of Y axis"""
     return self.n.cross(self.dx)
index adc8d661396d151e93a533507a9245e601eaffdb..23b83a42b7d170a42abe0d55523d01b00ef90e35 100644 (file)
@@ -10,6 +10,8 @@ from GeomAlgoAPI import *
 class Boolean():
   """Abstract root class of Boolean Features."""
   def __init__(self, part, object, tool, type):
+    """Constructor"""
+    ### Create a feature
     self.my = part.addFeature("Boolean")
     self.my.data().reference("main_object").setValue(object)
     self.my.data().reference("tool_object").setValue(tool)
@@ -22,27 +24,30 @@ class Boolean():
 
 
 class Addition(Boolean):
+  """Inserts an addition to the given Part and executes the operation.
+  This operation adds tool to the given object.
+  """
 
   def __init__(self, part, object, tool):
-    """Inserts an addition to the given Part and executes the operation.
-    This operation adds tool to the given object.
-    """
+    """Constructor"""
     Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_FUSE)
 
 
 class Subtraction(Boolean):
+  """Inserts a subtraction to the given Part and executes the operation.
+  This operation subtracts tool to the given object.
+  """
 
   def __init__(self, part, object, tool):
-    """Inserts a subtraction to the given Part and executes the operation.
-    This operation subtracts tool to the given object.
-    """
+    """Constructor"""
     Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_CUT)
 
 
 class Intersection(Boolean):
+  """Inserts an intersection to the given Part and executes the operation.
+  This operation intersects tool to the given object.
+  """
 
   def __init__(self, part, object, tool):
-    """Inserts an intersection to the given Part and executes the operation.
-    This operation intersects tool to the given object.
-    """
+    """Constructor"""
     Boolean.__init__(self, part, object, tool, GeomAlgoAPI_Boolean.BOOL_COMMON)
\ No newline at end of file
index 9b9b6de32babd623022b65b21a74f5e05e504651..4fcc37106f4d94220f78455b7efbba870f3d60e7 100644 (file)
@@ -7,9 +7,10 @@ from ModelAPI import *
 
 
 class Extrusion():
-
+  """Class for Extrusion feature"""
   def __init__ (self, part, sketch, size):
     """Inserts an extrusion of the given Sketch to the given Part and executes the operation."""
+    ### Create the feature
     self.my = part.addFeature("Extrusion")
     self.my.string("CreationMethod").setValue("BySizes")
     self.my.data().selectionList("base").append(sketch.result(), sketch.buildShape())
index 597d1cc75dd734bd02e552fb155527636b17a802..52632c3c68b2d52eaf9a4280fb5e0835c6f1f98e 100644 (file)
@@ -7,9 +7,11 @@ import modeler     # Required by the temporary implementation of result member f
 
 
 class Part():
-
+  """Class for Part feature"""
+  
   def __init__ (self, partset):
     """Adds a new Part to the given Partset and activates the Part."""
+    ### Create the feature
     self.my = partset.addFeature("Part")
     self.my.execute()
 
index 62288ebb3dfb67a121adfa932a3489e8907ec685..181fd7efc816da21b18ceeb623b26c609b7e8898 100644 (file)
@@ -10,15 +10,19 @@ class Feature(ModelAPI_Feature):
   """Base class of user-defined Python features."""
 
   def __init__(self):
+    """Constructor"""
     ModelAPI_Feature.__init__(self)
 
   def addRealInput (self, inputid):
+    """Add double input"""
     self.data().addAttribute(inputid, ModelAPI_AttributeDouble_typeId())
 
   def getRealInput (self, inputid):
+    """Returns double input"""
     return self.data().real(inputid).value()
 
   def addResult (self, result):
+    """Add result"""
     shape = result.shape()
     body  = self.document().createBody( self.data() )
     body.store(shape)
@@ -29,13 +33,18 @@ class Interface():
   """Base class of hight level Python interfaces to features."""
 
   def __init__(self, container, fid):
+    """Constructor"""
+    ### Create the feature
     self.my = container.addFeature(fid)
 
   def setRealInput (self, inputid, value):
+    """Set real value"""
     self.my.data().real(inputid).setValue(value)
 
   def areInputValid (self):
+    """Returns True if the input is valid"""
     return ModelAPI_Session.get().validators().validate(self.my)
 
   def execute (self):
+    """Build the feature result"""
     self.my.execute()
\ No newline at end of file
index c9737224ea2ec566efc24277c2b4c52283aa74f6..c3bad7c5c565a8db8418f4ad9204717af9fec77f 100644 (file)
@@ -9,6 +9,7 @@ from GeomAlgoAPI import *
 
 
 class Sketch():
+  """ A class of Sketcher"""
 
   def __init__(self, doc, plane):
     """Initializes a 2D Sketch on the given plane and adds the Sketch to the given Part or Partset.
@@ -16,8 +17,10 @@ class Sketch():
        - a 3D axis system (geom.Ax3),
        - an existing face identified by its topological name.
     """
+    ### Create a feature object
     self.my = featureToCompositeFeature( doc.addFeature("Sketch") )
-    self.selection = None         # Entities used for building the result shape
+    ### Entities used for building the result shape
+    self.selection = None         
 #   self.resultype ="Face"        # Type of Sketch result
     if isinstance(plane, str):
       self.__sketchOnFace(doc, plane)
@@ -174,22 +177,30 @@ class Sketch():
 # Class definitions of Sketch features
 
 class Point():
+  """A class which represents a Point object"""
 
   def __init__(self, sketch, x, y):
+    """Constructor"""
+    ### Create the feature
     self.my = sketch.addFeature("SketchPoint")
     geomDataAPI_Point2D( self.my.data().attribute("PointCoordindates") ).setValue(x, y)
     self.my.execute()
 
   def pointData (self):
+    """Returns points attribute"""
     return geomDataAPI_Point2D( self.my.data().attribute("PointCoordindates") )
 
   def result (self):
+    """Returns result object"""
     return self.my.firstResult()
 
 
 class Line():
+  """A class which represents a Line object"""
 
   def __init__(self, sketch, *args):
+    """Constructor"""
+    ### Create the feature
     self.my = sketch.addFeature("SketchLine")
     if   len(args) == 4:
       self.__createByCoordinates(*args)
@@ -201,43 +212,54 @@ class Line():
       raise Exception("cannot create the Line")
 
   def __createByCoordinates(self, x1, y1, x2, y2):
+    """Initialise the feature by coordinates"""
     geomDataAPI_Point2D( self.my.data().attribute("StartPoint") ).setValue(x1, y1)
     geomDataAPI_Point2D( self.my.data().attribute("EndPoint") ).setValue(x2, y2)
     self.my.execute()
 
   def __createByPoints(self, p1, p2):
+    """Initialise the feature by point objects"""
     geomDataAPI_Point2D( self.my.data().attribute("StartPoint") ).setValue(p1.x(), p1.y())
     geomDataAPI_Point2D( self.my.data().attribute("EndPoint") ).setValue(p2.x(), p2.y())
     self.my.execute()
 
   def __createByName(self, sketch, name):
+    """Initialise the feature by name of edge"""
     self.my.data().selection("External").selectSubShape("EDGE", name)
     self.my.execute()
     rigid = sketch.addFeature("SketchConstraintRigid")
     rigid.refattr("ConstraintEntityA").setObject( self.my.firstResult() )
 
   def startPointData (self):
+    """Returns start point"""
     return geomDataAPI_Point2D( self.my.data().attribute("StartPoint") )
 
   def endPointData (self):
+    """Returns end point"""
     return geomDataAPI_Point2D( self.my.data().attribute("EndPoint") )
 
   def result (self):
+    """Returns result"""
     return self.my.firstResult()
 
 
 class Circle():
+  """A class which represents a Circle object"""
 
   def __init__(self, sketch, x, y, r):
+    """Constructor"""
+    ### Create the feature
     self.my = sketch.addFeature("SketchCircle")
     geomDataAPI_Point2D( self.my.data().attribute("CircleCenter") ).setValue(x, y)
     self.my.data().real("CircleRadius").setValue(r)
     self.my.execute()
 
   def centerData (self):
+    """Returns center point"""
     return geomDataAPI_Point2D( self.my.data().attribute("CircleCenter") )
 
   def result (self):
+    """Returns result"""
     return self.my.lastResult()   # Returns the circular line attribute
 
 
index 90b23b9a9b171ded79eef7fc49ac7c3b3a5b7cdc..0c92f1be1b77f1f6bb466e7a0625e92adf1b791e 100644 (file)
@@ -6,14 +6,17 @@ from macros.box.feature      import BoxFeature
 
 
 class PythonFeaturesPlugin(ModelAPI.ModelAPI_Plugin):
+"""Implementation of features plugin"""
 
     def __init__(self):
+        """Constructor"""
         ModelAPI.ModelAPI_Plugin.__init__(self)
         aSession = ModelAPI.ModelAPI_Session.get()
         aSession.registerPlugin(self)
         pass
 
     def createFeature(self, theFeatureID):
+        """Create a feature by its Id"""
         aFeature = None
 
         if theFeatureID == BoxFeature.ID():
@@ -24,6 +27,6 @@ class PythonFeaturesPlugin(ModelAPI.ModelAPI_Plugin):
 
         return aFeature
 
-
+### The plugin object
 plugin = PythonFeaturesPlugin()
 plugin.__disown__()
index d5d5e8e07c6efaa2bf603bb04e3a5cbf8e8b6adb..1f581be4aafb04b7d0ae67871f1469c18c08749c 100644 (file)
@@ -8,37 +8,43 @@ import geom
 
 
 class BoxFeature(modeler.Feature):
-
+  """An example of Box feature implementation"""
 
 # Initializations
 
   def __init__(self):
+    """Constructor"""
     modeler.Feature.__init__(self)
 
   @staticmethod
   def ID():
+    """Return Id of the feature"""
     return "Box"
 
   @staticmethod
   def WIDTH_ID():
+    """Returns ID of Width parameter"""
     return "width"
 
   @staticmethod
   def LENGTH_ID():
+    """Returns ID of Length parameter"""
     return "length"
 
   @staticmethod
   def HEIGHT_ID():
+    """Returns ID of Height parameter"""
     return "height"
 
   def getKind(self):
+    """Returns ID of еру ауфегку"""
     return BoxFeature.ID()
 
        
 # Creation of the box at default size
 
   def initAttributes(self):
-
+    """Initialise attributes of the feature"""
     # Creating the input arguments of the feature
     self.addRealInput( self.WIDTH_ID() )
     self.addRealInput( self.LENGTH_ID() )
@@ -48,6 +54,7 @@ class BoxFeature(modeler.Feature):
     mypart = modeler.activeDocument()
     xoy    = modeler.defaultPlane("XOY")
 
+    ### A base of the geometry
     self.base = modeler.addSketch( mypart, xoy )
 
     p1 = geom.Pnt2d( 0, 0 )
@@ -62,16 +69,20 @@ class BoxFeature(modeler.Feature):
     self.base.setPerpendicular( line[0].result(), line[3].result() )
 
     # Setting the size of the base with default values
+    ### Width
     self.width  = self.base.setLength( line[0].result(), 50 )   # Keeps the constraint for edition
+    ### Length
     self.length = self.base.setLength( line[3].result(), 50 )   # Keeps the constraint for edition
 
     # Creating the extrusion (the box) at default size
+    ### A box result
     self.box = modeler.addExtrusion( mypart, self.base.selectFace(), 50 )
 
        
 # Edition of the box at user size
 
   def execute(self):
+    """Compute the feature result"""
     # Retrieving the user inputs
     width  = self.getRealInput( self.WIDTH_ID() )
     length = self.getRealInput( self.LENGTH_ID() )
@@ -86,5 +97,6 @@ class BoxFeature(modeler.Feature):
     #self.addResult( self.box.result() )
   
   def isMacro(self):
+    """Returns True"""
     # Box feature is macro: removes itself on the creation transaction finish
     return True