// # Internal methods (For sub-shape identification)
// ######################################################################
/*!
- * \brief Get geometric shape of the object as a byte stream
+ * \brief Get geometric shape of the object as a byte stream in BRep format
+ * \note GEOM_IInsertOperations::RestoreShape() method can be used to restore shape from a BRep stream.
*/
SALOMEDS::TMPFile GetShapeStream();
void ExportTranslators (out string_array theFormats,
out string_array thePatterns);
+ /*!
+ * \brief Read a shape from the binary stream, containing its bounding representation (BRep).
+ * \note GEOM_Object::GetShapeStream() method can be used to obtain the shape's BRep stream.
+ * \param theStream The BRep binary stream.
+ * \return New GEOM_Object, containing the shape, read from theStream.
+ */
+ GEOM_Object RestoreShape (in SALOMEDS::TMPFile theStream);
+
/*!
* \brief Load texture from file
* \param theTextureFile texture file name
//Check if its internal function which doesn't requires dumping
if(aDescr == "None") return false;
+ //Check the very specific case of RestoreShape function,
+ //which is not dumped, but the result can be published by the user.
+ //We do not publish such objects to decrease danger of dumped script failure.
+ if(aDescr.Value(1) == '#') {
+ TCollection_AsciiString anObjEntry;
+ TDF_Tool::Entry(theFunction->GetOwnerEntry(), anObjEntry);
+ theIgnoreObjs.insert(anObjEntry);
+ return false;
+ }
+
// 0020001 PTv, check for critical functions, which require dump of objects
if (theIsPublished)
{
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
+#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
+#include <BRepTools.hxx>
#include <gp_Pnt.hxx>
#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
myResMgrUser->Find("Import") || myResMgrUser->Find("Export"));
}
+//=============================================================================
+/*!
+ * RestoreShape
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IInsertOperations::RestoreShape (std::istringstream& theStream)
+{
+ SetErrorCode(KO);
+
+ //Add a new result object
+ Handle(GEOM_Object) result = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
+
+ //Add a Copy function
+ Handle(GEOM_Function) aFunction = result->AddFunction(GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_CopyDriver::GetID()) return NULL;
+
+ //Read a shape from the stream
+ TopoDS_Shape aShape;
+ BRep_Builder B;
+ BRepTools::Read(aShape, theStream, B);
+ if (aShape.IsNull()) {
+ SetErrorCode("RestoreShape error: BREP reading failed");
+ }
+
+ //Set function value
+ aFunction->SetValue(aShape);
+
+ //Special dump to avoid restored shapes publication.
+ //See correcponding code in GEOM_Engine.cxx (method ProcessFunction)
+ GEOM::TPythonDump(aFunction) << "#";
+
+ SetErrorCode(OK);
+
+ return result;
+}
+
int GEOMImpl_IInsertOperations::LoadTexture(const TCollection_AsciiString& theTextureFile)
{
SetErrorCode(KO);
const TCollection_AsciiString& theFormat,
Handle(TCollection_HAsciiString)& theLibName);
+ Standard_EXPORT Handle(GEOM_Object) RestoreShape (std::istringstream& theStream);
+
Standard_EXPORT int LoadTexture(const TCollection_AsciiString& theTextureFile);
Standard_EXPORT int AddTexture(int theWidth, int theHeight,
thePatterns = aPatternsArray._retn();
}
+//=============================================================================
+/*!
+ * RestoreShape
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::RestoreShape (const SALOMEDS::TMPFile& theStream)
+{
+ GEOM::GEOM_Object_var aGEOMObject;
+
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ if (theStream.length() < 1)
+ return aGEOMObject._retn();
+
+ char* buf = (char*)theStream.NP_data();
+ std::istringstream aStream (buf);
+
+ Handle(GEOM_Object) anObject = GetOperations()->RestoreShape(aStream);
+ if (!GetOperations()->IsDone() || anObject.IsNull())
+ return aGEOMObject._retn();
+
+ return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ * LoadTexture
+ */
+//=============================================================================
CORBA::Long GEOM_IInsertOperations_i::LoadTexture(const char* theTextureFile)
{
GetOperations()->SetNotDone();
return GetOperations()->LoadTexture( theTextureFile );
}
+//=============================================================================
+/*!
+ * AddTexture
+ */
+//=============================================================================
CORBA::Long GEOM_IInsertOperations_i::AddTexture(CORBA::Long theWidth, CORBA::Long theHeight,
const SALOMEDS::TMPFile& theTexture)
{
return GetOperations()->AddTexture( theWidth, theHeight, aTexture );
}
+//=============================================================================
+/*!
+ * GetTexture
+ */
+//=============================================================================
SALOMEDS::TMPFile* GEOM_IInsertOperations_i::GetTexture(CORBA::Long theID,
CORBA::Long& theWidth,
CORBA::Long& theHeight)
return aTexture._retn();
}
+//=============================================================================
+/*!
+ * GetAllTextures
+ */
+//=============================================================================
GEOM::ListOfLong* GEOM_IInsertOperations_i::GetAllTextures()
{
std::list<int> localIDs = GetOperations()->GetAllTextures();
void ExportTranslators (GEOM::string_array_out theFormats,
GEOM::string_array_out thePatterns);
+ GEOM::GEOM_Object_ptr RestoreShape (const SALOMEDS::TMPFile& theStream);
+
CORBA::Long LoadTexture(const char* theTextureFile);
CORBA::Long AddTexture(CORBA::Long theWidth, CORBA::Long theHeight,
const SALOMEDS::TMPFile& theTexture);
os.remove(fileExportImportIGES)
os.remove(fileExportImportSTEP)
+ # Test RestoreShape from binary BRep stream
+ aStream = shape.GetShapeStream()
+ aNewShape = geompy.RestoreShape(aStream)
+ geompy.addToStudy(aNewShape, "aNewShape")
+
print "OK"
theR2 Radius of the second cone base.
theH Cone height.
- Note:
+ Note:
If both radiuses are non-zero, the cone will be truncated.
If the radiuses are equal, a cylinder will be created instead.
- Returns:
+ Returns:
New GEOM.GEOM_Object, containing the created cone.
"""
# Example: see GEOM_TestAll.py
If both radiuses are non-zero, the cone will be truncated.
If the radiuses are equal, a cylinder will be created instead.
- Returns:
+ Returns:
New GEOM.GEOM_Object, containing the created cone.
"""
# Example: see GEOM_TestAll.py
# Example: see GEOM_TestOthers.py
return self.ImportFile(theFileName, "STEP")
+ ## Read a shape from the binary stream, containing its bounding representation (BRep).
+ # @note This method will not be dumped to the python script by DumpStudy functionality.
+ # @note GEOM.GEOM_Object.GetShapeStream() method can be used to obtain the shape's BRep stream.
+ # @param theStream The BRep binary stream.
+ # @return New GEOM_Object, containing the shape, read from theStream.
+ #
+ # @ref swig_Import_Export "Example"
+ def RestoreShape (self, theStream):
+ """
+ Read a shape from the binary stream, containing its bounding representation (BRep).
+
+ Note:
+ shape.GetShapeStream() method can be used to obtain the shape's BRep stream.
+
+ Parameters:
+ theStream The BRep binary stream.
+
+ Returns:
+ New GEOM_Object, containing the shape, read from theStream.
+ """
+ # Example: see GEOM_TestOthers.py
+ anObj = self.InsertOp.RestoreShape(theStream)
+ RaiseIfFailed("RestoreShape", self.InsertOp)
+ return anObj
+
## Export the given shape into a file with given name.
# @param theObject Shape to be stored in the file.
# @param theFileName Name of the file to store the given shape in.