Salome HOME
Implement some methods
authorvsv <vsv@opencascade.com>
Wed, 11 Dec 2019 14:09:39 +0000 (17:09 +0300)
committervsv <vsv@opencascade.com>
Wed, 11 Dec 2019 14:09:39 +0000 (17:09 +0300)
src/PY/SHAPERSTUDY_Object.py
src/StudyData/StudyData_Object.cpp
src/StudyData/StudyData_Object.h

index 7daff7ad2332cf477c297928f249b0dd6df28a39..0f0942a382c6a815296353e6e2767889012f5925 100644 (file)
@@ -69,7 +69,7 @@ class SHAPERSTUDY_BaseObject(SHAPERSTUDY_ORB__POA.BaseObject):
         Return true if geom object representes a shape.
         For example, method return false for GEOM_MARKER
         """
-        return False
+        return True
 
     def IsSame( self, other ):
         """
@@ -98,13 +98,15 @@ class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object):
         """
         Get a GEOM.shape_type of the object value.
         """
-        return GEOM.SHAPE
+        if self.data is None:
+            return GEOM.SHAPE
+        return self.data.type();
 
     def IsMainShape( self ):
         """
         Returns True if this object is not a sub-shape of another object.
         """
-        return False
+        return True
 
     def GetSubShapeIndices( self ):
         """
@@ -116,20 +118,24 @@ class SHAPERSTUDY_Object(SHAPERSTUDY_ORB__POA.SHAPER_Object):
         """
         Get a main shape object to which this object is a sub-shape.
         """
-        return
+        return getShape()
 
     def getShape( self ):
         """
         Get the TopoDS_Shape, for colocated case only.
         Called by GEOM_Client to get TopoDS_Shape pointer
         """
-        return 0
+        if self.data is None:
+            return 0
+        return self.data.shape()
 
     def GetShapeStream( self ):
         """
         Get geometric shape of the object as a byte stream in BRep format
         """
-        return ;
+        if self.data is None:
+            return
+        return self.data.shapeStream()
 
     def SetShapeByStream(self, theStream):
         """
index 13e22ddcb389213986aabb675ac4e02289528c81..87c7e8017c794875551c63cfcfaac4a99a3b367e 100644 (file)
@@ -31,3 +31,43 @@ StudyData_Object::StudyData_Object(const std::string theFile)
   BRep_Builder aBuilder;
   BRepTools::Read(myShape, streamBrep, aBuilder);
 }
+
+
+GEOM::shape_type StudyData_Object::type() const
+{
+  if (myShape.IsNull())
+    return GEOM::SHAPE;
+  return (GEOM::shape_type) myShape.ShapeType();
+}
+
+
+SALOMEDS::TMPFile* StudyData_Object::shapeStream() const
+{
+  if (myShape.IsNull())
+    return NULL;
+
+  std::ostringstream streamShape;
+
+  //Write TopoDS_Shape in ASCII format to the stream
+  BRepTools::Write(myShape, streamShape);
+
+  //Returns the number of bytes that have been stored in the stream's buffer.
+  int size = streamShape.str().size();
+
+  //Allocate octect buffer of required size
+  CORBA::Octet* OctetBuf = SALOMEDS::TMPFile::allocbuf(size);
+
+  //Copy ostrstream content to the octect buffer
+  memcpy(OctetBuf, streamShape.str().c_str(), size);
+
+  //Create and return TMPFile
+  SALOMEDS::TMPFile_var SeqFile = new SALOMEDS::TMPFile(size, size, OctetBuf, 1);
+  return SeqFile._retn();
+}
+
+
+CORBA::LongLong StudyData_Object::shape() const
+{
+  return ((CORBA::LongLong)(&myShape));
+}
+
index e6b3f6a2a8dec26ad6cd31150d22de5c480ceee5..22bc293213e7a3176f507d472a3116942b6d93fe 100644 (file)
@@ -34,6 +34,11 @@ class StudyData_EXPORT StudyData_Object
 public:
   StudyData_Object(const std::string theFile);
 
+  GEOM::shape_type type() const;
+
+  SALOMEDS::TMPFile* shapeStream() const;
+
+  CORBA::LongLong shape() const;
 
 private:
   TopoDS_Shape myShape;