// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
#include "Partition_Spliter.hxx"
#include "Archimede_VolumeSection.hxx"
+#include "Sketcher_Profile.hxx"
#include "Utils_CorbaException.hxx"
#include "utilities.h"
#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+#include "Utils_ExceptHandlers.hxx"
+
Standard_EXPORT static Standard_Boolean IsValid(const TopoDS_Shape& S) {
#if OCC_VERSION_MAJOR >= 5
return BRepAlgo::IsValid(S);
{
GEOM::GEOM_Shape_var aShape = GEOM::GEOM_Shape::_narrow(_orb->string_to_object(IORString));
if (!CORBA::is_nil(aShape)) {
- return strdup(aShape->ShapeId());
+ return aShape->ShapeId();
}
return 0;
}
TCollection_ExtendedString MainIOR;
TDF_Label Lab;
TDF_Tool::Label(aDoc->GetData(), aPersRefString, Lab );
+
+ if (Lab.IsNull()) {
+ MESSAGE("Can not find label "<<aPersRefString<<" for study "<<myStudy->StudyId());
+ THROW_SALOME_CORBA_EXCEPTION("Incorrect GEOM data loaded",SALOME::BAD_PARAM);
+ //return ""; empty IORs raise new problem: "display" in popup crashes
+ }
Handle(TNaming_NamedShape) NS;
Lab.FindAttribute( TNaming_NamedShape::GetID(), NS );
TCollection_AsciiString entry;
TDF_Tool::Entry(mainLabel,entry);
- CORBA::String_var ent = strdup(entry.ToCString());
+ CORBA::String_var ent = CORBA::string_dup(entry.ToCString());
/* Create the main object recursively */
MainIOR = LocalPersistentIDToIOR(theSObject, ent, isMultiFile, isASCII) ;
CORBA::Object_ptr theObject,
const char* theName) throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
SALOMEDS::SObject_var aResultSO;
if(CORBA::is_nil(theObject)) return aResultSO;
aShapeName = "Vertex_";
}
if (strlen(theName) == 0) aShapeName += TCollection_AsciiString(aResultSO->Tag());
- else aShapeName = TCollection_AsciiString(strdup(theName));
+ else aShapeName = TCollection_AsciiString((char*)theName);
//Set a name of the added shape
anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
bool isMultiFile) {
SALOMEDS::TMPFile_var aStreamFile;
// Get a temporary directory to store a file
- TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+ TCollection_AsciiString aTmpDir = (isMultiFile)?TCollection_AsciiString((char*)theURL):(char*)SALOMEDS_Tool::GetTmpDir().c_str();
// Create a list to store names of created files
SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
aSeq->length(1);
// Prepare a file name to open
TCollection_AsciiString aNameWithExt("");
if (isMultiFile)
- aNameWithExt = TCollection_AsciiString(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
+ aNameWithExt = TCollection_AsciiString((char*)SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()).c_str());
aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
- aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString());
+ aSeq[0] = aNameWithExt.ToCString();
// Build a full file name of temporary file
TCollection_AsciiString aFullName = aTmpDir + aNameWithExt;
// Save GEOM component in this file
}
// Get a temporary directory for a file
- TCollection_AsciiString aTmpDir = isMultiFile?TCollection_AsciiString((char*)theURL):SALOMEDS_Tool::GetTmpDir();
+ TCollection_AsciiString aTmpDir = isMultiFile?TCollection_AsciiString((char*)theURL):(char*)SALOMEDS_Tool::GetTmpDir().c_str();
// Conver the byte stream theStream to a file and place it in tmp directory
SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
aTmpDir.ToCString(),
// Prepare a file name to open
TCollection_AsciiString aNameWithExt("");
if (isMultiFile)
- aNameWithExt = TCollection_AsciiString(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
+ aNameWithExt = TCollection_AsciiString((char*)SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()).c_str());
aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
TCollection_AsciiString aFullName = aTmpDir + aNameWithExt;
if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.ToCString(), aSeq.in(), true);
SALOMEDS::Study_var Study = theComponent->GetStudy();
- TCollection_AsciiString name( strdup(Study->Name()) );
+ TCollection_AsciiString name( Study->Name() );
int StudyID = Study->StudyId();
myStudyIDToDoc.Bind( StudyID, myCurrentOCAFDoc );
// void GEOM_Gen_i::Save(const char *IORSComponent, const char *aUrlOfFile)
// {
-// TCollection_ExtendedString path(strdup(aUrlOfFile));
+// TCollection_ExtendedString path((char*)aUrlOfFile);
// TCollection_ExtendedString pathWithExt = path + TCollection_ExtendedString(".sgd");
// myOCAFApp->SaveAs(myCurrentOCAFDoc,pathWithExt);
// }
// void GEOM_Gen_i::Load(const char *IORSComponent, const char *aUrlOfFile)
// {
-// TCollection_ExtendedString path(strdup(aUrlOfFile));
+// TCollection_ExtendedString path((char*)aUrlOfFile);
// TCollection_ExtendedString pathWithExt = path + TCollection_ExtendedString(".sgd");
// myOCAFApp->Open(pathWithExt,myCurrentOCAFDoc);
// SALOMEDS::SComponent_var SC = SALOMEDS::SComponent::_narrow(_orb->string_to_object(IORSComponent));
// SALOMEDS::Study_var Study = SC->GetStudy();
-// TCollection_AsciiString name( strdup(Study->Name()) );
+// TCollection_AsciiString name( Study->Name() );
// int StudyID = Study->StudyId();
// myStudyIDToDoc.Bind( StudyID, myCurrentOCAFDoc );
// Handle(TDocStd_Document) anEmptyDoc;
// if (aDoc->Main().Root().FindAttribute(TDocStd_Owner::GetID(), anOwner)) {
// anOwner->SetDocument(anEmptyDoc);
-// cout<<"********** Nullify owner of document"<<endl;
+// MESSAGE("********** Nullify owner of document");
// }
myOCAFApp->Close(aDoc);
myStudyIDToDoc.UnBind(anID); // remove document from GEOM documents data map
//============================================================================
SALOMEDS::TMPFile* GEOM_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
// Declare a sequence of the byte to store the copied object
- SALOMEDS::TMPFile_var aStreamFile;
+ SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
// Try to get GEOM_Shape object by given SObject
SALOMEDS::GenericAttribute_var anAttr;
CORBA::Boolean GEOM_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
// The Geometry component can paste only objects copied by Geometry component
// and with the object type = 1
-// cout<<"********** GEOM_Gen_i::CanPaste ("<<theComponentName<<","<<theObjectID<<")"<<endl;
+// MESSAGE("********** GEOM_Gen_i::CanPaste ("<<theComponentName<<","<<theObjectID<<")");
if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false;
return true;
}
try {
BRepTools::Read(aTopology, aStreamedBrep, aBuilder);
} catch (Standard_Failure) {
-// cout<<"GEOM_Gen_i::PasteInto exception"<<endl;
+ MESSAGE("GEOM_Gen_i::PasteInto exception");
return false;
}
//============================================================================
char* GEOM_Gen_i::ComponentDataType()
{
- return strdup("GEOM");
+ return CORBA::string_dup("GEOM");
}
//============================================================================
void GEOM_Gen_i::register_name(char * name)
{
GEOM::GEOM_Gen_ptr g = GEOM::GEOM_Gen::_narrow(POA_GEOM::GEOM_Gen::_this());
- name_service->Register(g, strdup(name));
+ name_service->Register(g, name);
}
TDF_Label lab ;
Handle(TDF_Data) D = myCurrentOCAFDoc->GetData() ;
- TDF_Tool::Label( D, strdup(shape_ptr->ShapeId()), lab, true ) ;
+ TDF_Tool::Label( D, shape_ptr->ShapeId(), lab, true ) ;
Handle(TNaming_NamedShape) NamedShape ;
bool res = lab.FindAttribute(TNaming_NamedShape::GetID(), NamedShape) ;
{
GEOMDS_Commands GC(OCAFDoc->Main());
/* add attributs S and mystr in a new label */
- TDF_Label Lab = GC.AddShape (S, strdup(mystr));
+ TDF_Label Lab = GC.AddShape (S, (char*)mystr);
TCollection_AsciiString entry;
TDF_Tool::Entry(Lab,entry);
TDF_Tool::Label(OCAFDoc->GetData(), mainshape_ptr->ShapeId(), mainRefLab);
/* add attributs : S, nameIor and ref to main */
- TDF_Label Lab = GC.AddDependentShape(S, strdup(nameIor), mainRefLab);
+ TDF_Label Lab = GC.AddDependentShape(S, (char*)nameIor, mainRefLab);
TCollection_AsciiString entry;
TDF_Tool::Entry(Lab, entry);
//=================================================================================
CORBA::Short GEOM_Gen_i::NbLabels()
{
- return TDF_Tool::NbLabels( myCurrentOCAFDoc->Main() );
+ TDF_ChildIterator ChildIterator(myCurrentOCAFDoc->Main());
+ unsigned int i = 1;
+
+ while (ChildIterator.More()) {
+ i++;
+ ChildIterator.Next();
+ }
+ return i;
+ // return TDF_Tool::NbLabels( myCurrentOCAFDoc->Main() );
}
TopoDS_Shape& aCompoundOfShells )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
BRepTools_Quilt Glue;
aCompoundOfShells.Nullify() ;
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
ListOfID->length(0) ;
if( subShell.IsNull() || subShell.ShapeType() != TopAbs_SHELL ) {
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Gen::ListOfGeomShapes_var listOfGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
listOfGeomShapes->length(0) ;
TopTools_MapOfShape& MSwireEndEdges )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
TopTools_MapOfShape MS ;
TopTools_SequenceOfShape SU ;
FreeEdgesFromMapOfFace(MSfaces, MS) ; /* MS = free edges of MSfaces */
const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdWires )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
if( ListIdWires.length() < 1 )
const GEOM::GEOM_Shape::ListOfSubShapeID& ListIdEndFace )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Face aFace ;
TopoDS_Wire aWire ;
TopoDS_Shape& resultTds )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
BRep_Builder B;
TopExp_Explorer exp ;
TopoDS_Face newFace ;
TopoDS_Shape& resultTds )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
BRep_Builder B;
TopExp_Explorer exp ;
TopoDS_Face newFace ;
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
return SubShapesOne(shape, (TopAbs_ShapeEnum) ShapeType, ListOfID);
}
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
return SubShapesOne(shape, (TopAbs_ShapeEnum) ShapeType, ListOfID, Standard_True);
}
const Standard_Boolean Sort)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape mainShape;
TopoDS_Shape mainTopo = GetTopoShape(shape);
CORBA::Short ShapeType)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
return SubShapesAll(shape, (TopAbs_ShapeEnum) ShapeType);
}
CORBA::Short ShapeType)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
return SubShapesAll(shape, (TopAbs_ShapeEnum) ShapeType, Standard_True);
}
throw (SALOME::SALOME_Exception)
{
/* List of sub shapes returned */
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Gen::ListOfGeomShapes_var listOfGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
listOfGeomShapes->length(0) ;
return listOfGeomShapes._retn() ;
}
-
//=================================================================================
// function : MakeBoolean()
// purpose : Boolean operation according to the type 'operation'
//=================================================================================
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeBoolean(GEOM::GEOM_Shape_ptr shape1,
- GEOM::GEOM_Shape_ptr shape2,
- CORBA::Long operation)
+ GEOM::GEOM_Shape_ptr shape2,
+ CORBA::Long operation)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape shape ;
TopoDS_Shape aShape1 ;
TopoDS_Shape aShape2 ;
-
+
try {
aShape1 = GetTopoShape(shape1) ;
aShape2 = GetTopoShape(shape2) ;
GEOM::GEOM_Shape_ptr shape2)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape aShape1 = GetTopoShape(shape1) ;
TopoDS_Shape aShape2 = GetTopoShape(shape2) ;
GEOM::DirStruct GEOM_Gen_i::MakeDirection(const GEOM::PointStruct& p)
{
GEOM::DirStruct d ;
- d.PS.x = p.x ; d.PS.y = p.y ; d.PS.z = p.z ;
- return d ;
- }
+ d.PS.x = p.x ; d.PS.y = p.y ; d.PS.z = p.z ;
+ return d ;
+}
//=================================================================================
// function : MakeBox()
CORBA::Double z2)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
gp_Pnt P1(x1,y1,z1);
gp_Pnt P2(x2,y2,z2);
GEOM::GEOM_Shape_var result ;
CORBA::Double height)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape tds ;
gp_Pnt p(pstruct.x, pstruct.y, pstruct.z) ;
CORBA::Double radius)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
try {
CORBA::Double minor_radius )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape tds ;
gp_Pnt p(pstruct.x, pstruct.y, pstruct.z) ;
CORBA::Double height)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape tds ;
gp_Pnt p(pstruct.x, pstruct.y, pstruct.z) ;
GEOM::GEOM_Shape_ptr GEOM_Gen_i::ImportIGES(const char* filename)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
//VRV: OCC 4.0 migration
IGESControl_Reader aReader;
THROW_SALOME_CORBA_EXCEPTION("Error in reading import file", SALOME::BAD_PARAM); }
MESSAGE("ImportIGES : all Geometry Transfer" << endl ) ;
+#if OCC_VERSION_MAJOR >= 5
+ aReader.ClearShapes();
+ aReader.TransferRoots();
+#else
aReader.Clear();
aReader.TransferRoots(false);
-
+#endif
MESSAGE("ImportIGES : count of shapes produced = " << aReader.NbShapes() << endl );
TopoDS_Shape shape = aReader.OneShape();
GEOM::GEOM_Shape_ptr GEOM_Gen_i::ImportSTEP(const char* filename)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
//VRV: OCC 4.0 migration
STEPControl_Reader aReader;
const CORBA::Short Limit)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var aResult;
TopoDS_Shape tds ;
//MESSAGE ("In Partition");
GEOM::GEOM_Shape_var aShape = GetIORFromString( ListTools[ind] );
TopoDS_Shape Shape = GetTopoShape(aShape);
if(Shape.IsNull() ) {
- //MESSAGE ( "In Partition a tool shape is null" );
THROW_SALOME_CORBA_EXCEPTION("In Partition a shape is null", SALOME::BAD_PARAM);
}
if ( !ShapesMap.Contains( Shape ) && ToolsMap.Add( Shape ))
PS.AddShape(Shape);
}
+ //MESSAGE ( "Partition::Compute() " );
PS.Compute ((TopAbs_ShapeEnum) Limit);
+ //MESSAGE ( "Partition::Compute() - END" );
// suppress result outside of shapes in KInsideMap
for (ind = 0; ind < ListKeepInside.length(); ind++) {
CORBA::Short maxdeg,
CORBA::Double tol3d,
CORBA::Double tol2d,
- CORBA::Short nbiter)
+ CORBA::Short nbiter,
+ CORBA::Boolean theApprox)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Face tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
THROW_SALOME_CORBA_EXCEPTION("Initial shape doesn't contain only edges !", SALOME::BAD_PARAM);
}
C = BRep_Tool::Curve(TopoDS::Edge(Scurrent), First, Last);
+ if (C.IsNull()) continue;
C = new Geom_TrimmedCurve(C, First, Last);
Section.AddCurve(C) ;
i++ ;
Handle(GeomFill_Line) Line = new GeomFill_Line(i) ;
GeomFill_AppSurf App(mindeg, maxdeg, tol3d, tol2d, nbiter) ; /* user parameters */
- App.Perform(Line, Section) ;
+ App.Perform(Line, Section, theApprox) ;
if (!App.IsDone()) {
THROW_SALOME_CORBA_EXCEPTION("Filling aborted : non valid shape result", SALOME::BAD_PARAM);
// appliquer BRepTools_SameParameter au compshell
// (rendre parametres 2D des edges identiques aux parametres 3D)
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
CORBA::Double precision )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
BRepOffsetAPI_Sewing aMethod ;
CORBA::Double precision )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds, S ;
BRepOffsetAPI_Sewing aMethod ;
GEOM::GEOM_Shape_ptr GEOM_Gen_i::OrientationChange(GEOM::GEOM_Shape_ptr aShape)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
BRep_Builder aBuilder;
Handle(TDataStd_Name) Att;
L.FindAttribute(TDataStd_Name::GetID(),Att);
TCollection_AsciiString nameIOR (Att->Get()) ;
- aList[i] = strdup( nameIOR.ToCString() );
+ aList[i] = CORBA::string_dup( nameIOR.ToCString() );
i++;
}
if (!Att->Get().IsEqual(TCollection_ExtendedString("Arguments")) ) {
TCollection_AsciiString nameIOR (Att->Get());
- aList[i] = strdup( nameIOR.ToCString() );
+ aList[i] = CORBA::string_dup( nameIOR.ToCString() );
i++;
}
ChildIterator1.Next();
GEOM::GEOM_Shape_ptr GEOM_Gen_i::ImportBREP(const char* filename)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
TopoDS_Shape tds ;
GEOM::GEOM_Shape_var result ;
try {
- BRep_Builder aBuilder;
- BRepTools::Read(tds, strdup(filename), aBuilder) ;
+ BRep_Builder aBuilder;
+ char* aCopyfilename = strdup(filename);
+ BRepTools::Read(tds, aCopyfilename, aBuilder) ;
+ free(aCopyfilename);
if (tds.IsNull()) {
THROW_SALOME_CORBA_EXCEPTION("Import BRep aborted", SALOME::BAD_PARAM);
}
CORBA::Double trimsize)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
CORBA::Double z)
throw (SALOME::SALOME_Exception)
{
-
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
gp_Pnt P(x,y,z);
TopoDS_Shape tds = BRepBuilderAPI_MakeVertex(P).Shape();
if (tds.IsNull()) {
THROW_SALOME_CORBA_EXCEPTION("Make Vertex/Point aborted", SALOME::BAD_PARAM);
}
+ tds.Infinite(true);
result = CreateObject(tds) ;
const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
result->ShapeId(entry);
CORBA::Boolean wantplanarface )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape aShape;
TopoDS_Shape tds;
FR.Perform();
if(FR.IsDone()) {
- for(; FR.More(); FR.Next())
- aBuilder.Add(C, FR.Current().Oriented(OriF));
- result = CreateObject(C);
- InsertInLabelMoreArguments(C, result, ListShapes, myCurrentOCAFDoc);
+ int k = 0;
+ TopoDS_Shape aFace;
+ for(; FR.More(); FR.Next()) {
+ aFace = FR.Current().Oriented(OriF);
+ aBuilder.Add(C, aFace);
+ k++;
+ }
+ if(k == 1) {
+ result = CreateObject(aFace);
+ InsertInLabelMoreArguments(aFace, result, ListShapes, myCurrentOCAFDoc);
+ }
+ else {
+ result = CreateObject(C);
+ InsertInLabelMoreArguments(C, result, ListShapes, myCurrentOCAFDoc);
+ }
}
}
}
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeShell( const GEOM::GEOM_Gen::ListOfIOR& ListShapes )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
BRepTools_Quilt Glue;
TopoDS_Shape C;
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeSolid( const GEOM::GEOM_Gen::ListOfIOR& ListShapes )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
Standard_Integer ish = 0;
TopoDS_Compound Res;
const GEOM::DirStruct& dstruct)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
gp_Pnt P1(pstruct.x, pstruct.y, pstruct.z);
gp_Pnt P2(dstruct.PS.x, dstruct.PS.y, dstruct.PS.z) ;
THROW_SALOME_CORBA_EXCEPTION("Make Line aborted : null shape", SALOME::BAD_PARAM);
}
else {
+ tds.Infinite(true);
result = CreateObject(tds) ;
const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
result->ShapeId(entry);
const GEOM::PointStruct& pstruct2)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
CORBA::Double radius)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape tds ;
CORBA::Double radius_minor )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape tds ;
const GEOM::PointStruct& pEnd)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
try {
gp_Pnt pI(pInit.x, pInit.y, pInit.z) ;
return result ;
}
+//=================================================================================
+// function : MakeSketcher()
+// purpose : Make a wire from a list containing many points
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeSketcher( const char *Cmd )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result ;
+ TopoDS_Shape tds ;
+ try {
+ Sketcher_Profile aProfile (Cmd);
+ if(aProfile.IsDone())
+ tds = aProfile.GetShape();
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeSketcher", SALOME::BAD_PARAM);
+ }
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeSketcher aborted : null shape", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds);
+ const char *entry = InsertInLabel(tds, result->Name(), myCurrentOCAFDoc) ;
+ result->ShapeId(entry) ;
+ }
+ return result;
+}
+
+
+
+//=================================================================================
+// function : MakeBezier()
+// purpose : Make a wire from a list containing many points
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeBezier( const GEOM::GEOM_Gen::ListOfIOR& ListShapes )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds, Shape;
+ TColgp_Array1OfPnt CurvePoints(1, ListShapes.length());
+
+ try {
+ for(unsigned int i = 0; i < ListShapes.length(); i++) {
+ GEOM::GEOM_Shape_var aShape = GetIORFromString(ListShapes[i]);
+ Shape = GetTopoShape(aShape);
+ if(Shape.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeBezier aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+ if(Shape.ShapeType() == TopAbs_VERTEX) {
+ const gp_Pnt& P = BRep_Tool::Pnt(TopoDS::Vertex(Shape));
+ CurvePoints.SetValue(i + 1, P);
+ }
+ }
+ Handle(Geom_BezierCurve) GBC = new Geom_BezierCurve(CurvePoints);
+ tds = BRepBuilderAPI_MakeEdge(GBC);
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeBezier", SALOME::BAD_PARAM);
+ }
+
+ if( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Bezier operation aborted : null result", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds);
+ InsertInLabelMoreArguments(tds, result, ListShapes, myCurrentOCAFDoc);
+ }
+ return result;
+}
+
+
+//=================================================================================
+// function : MakeInterpol()
+// purpose : Make a wire from a list containing many points
+//=================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeInterpol( const GEOM::GEOM_Gen::ListOfIOR& ListShapes )
+ throw (SALOME::SALOME_Exception)
+{
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds, Shape;
+ TColgp_Array1OfPnt CurvePoints(1, ListShapes.length());
+
+ try {
+ for(unsigned int i = 0; i < ListShapes.length(); i++) {
+ GEOM::GEOM_Shape_var aShape = GetIORFromString(ListShapes[i]);
+ Shape = GetTopoShape(aShape);
+ if(Shape.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("MakeBSpline aborted : null shape during operation", SALOME::BAD_PARAM);
+ }
+ if(Shape.ShapeType() == TopAbs_VERTEX) {
+ const gp_Pnt& P = BRep_Tool::Pnt(TopoDS::Vertex(Shape));
+ CurvePoints.SetValue(i + 1, P);
+ }
+ }
+ GeomAPI_PointsToBSpline GBC(CurvePoints);
+ tds = BRepBuilderAPI_MakeEdge(GBC);
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeBSpline", SALOME::BAD_PARAM);
+ }
+
+ if( tds.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Make BSpline operation aborted : null result", SALOME::BAD_PARAM);
+ }
+ else {
+ result = CreateObject(tds) ;
+ InsertInLabelMoreArguments(tds, result, ListShapes, myCurrentOCAFDoc) ;
+ }
+ return result;
+}
//=================================================================================
// function : MakeTranslation()
CORBA::Double z)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
if( aShape.IsNull() ) {
CORBA::Short nbtimes )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
CORBA::Short nbtimes2 )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
CORBA::Short nbtimes)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
CORBA::Short nbtimes2 )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCopy( GEOM::GEOM_Shape_ptr Shape)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(Shape) ;
GEOM::GEOM_Shape_ptr shapePlane)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
CORBA::Double angle)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
CORBA::Double factor)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCompound( const GEOM::GEOM_Gen::ListOfIOR& ListShapes )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Compound C;
BRep_Builder aBuilder;
const GEOM::PointStruct& pstruct2)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeWire( const GEOM::GEOM_Gen::ListOfIOR& ListShapes )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
BRepBuilderAPI_MakeWire MW ;
TopoDS_Shape tds, Shape ;
double angle)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
GEOM::GEOM_Shape_ptr baseShape )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Wire aWire ;
const GEOM::PointStruct& P2 )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(myShape) ;
GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeCDG(GEOM::GEOM_Shape_ptr aShape)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape shape = GetTopoShape(aShape) ;
CORBA::Double aMeshingDeflection)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
double cste = -1;
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape tds ;
fill.Add(E);
}
for (int i = 1;i<=fill.NbContours();i++) {
+#if OCC_VERSION_MAJOR >= 5
+ fill.SetRadius(radius,i,i);
+#else
fill.SetRadius(radius,i);
+#endif
}
tds = fill.Shape();
}
}
for (int i = 1;i<=fill.NbContours();i++) {
+#if OCC_VERSION_MAJOR >= 5
+ fill.SetRadius(radius,i,i);
+#else
fill.SetRadius(radius,i);
+#endif
}
tds = fill.Shape();
}
return result ;
}
+//================================================================================
+// function : MakeFilletR1R2()
+// purpose : Create a cylinder topology
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFilletR1R2( GEOM::GEOM_Shape_ptr shape,
+ CORBA::Double radius1,
+ CORBA::Double radius2,
+ CORBA::Short ShapeType,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID )
+ throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds ;
+
+ const TopoDS_Shape aShape = GetTopoShape(shape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM);
+ }
+
+ BRepFilletAPI_MakeFillet fill(aShape);
+
+ try {
+ /* case all */
+ if(ListOfID.length() == 0) {
+ TopExp_Explorer Exp ( aShape, TopAbs_EDGE );
+ for (Exp; Exp.More(); Exp.Next()) {
+ TopoDS_Edge E =TopoDS::Edge(Exp.Current());
+ fill.Add(E);
+ }
+ for (int i = 1;i<=fill.NbContours();i++) {
+#if OCC_VERSION_MAJOR >= 5
+ fill.SetRadius(radius1,radius2,i,i);
+#else
+ fill.SetRadius(radius1,radius2,i);
+#endif
+ }
+ tds = fill.Shape();
+
+ } else {
+
+ /* case selection */
+ for ( unsigned int ind = 0; ind < ListOfID.length(); ind++ ) {
+ TopoDS_Shape ss ;
+ if( GetShapeFromIndex( aShape, (TopAbs_ShapeEnum)ShapeType, ListOfID[ind], ss ) ) {
+ TopoDS_Edge E = TopoDS::Edge(ss) ;
+ fill.Add( E );
+ }
+ }
+ for (int i = 1;i<=fill.NbContours();i++) {
+#if OCC_VERSION_MAJOR >= 5
+ fill.SetRadius(radius1,radius2,i,i);
+#else
+ fill.SetRadius(radius1,radius2,i);
+#endif
+ }
+ tds = fill.Shape();
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeFilletR1R2", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make Fillet aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds);
+ InsertInLabelOneArgument(aShape, shape, tds, result, myCurrentOCAFDoc) ;
+
+ return result ;
+}
//================================================================================
// function : MakeChamfer
const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID )
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result;
TopoDS_Shape tds ;
return result ;
}
+//================================================================================
+// function : MakeChamferAD
+// purpose : Create a Chamfer topology by Lenght & Angle
+//================================================================================
+GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeChamferAD( GEOM::GEOM_Shape_ptr shape,
+ CORBA::Double d,
+ CORBA::Double angle,
+ CORBA::Short ShapeType,
+ const GEOM::GEOM_Shape::ListOfSubShapeID& ListOfID )
+ throw (SALOME::SALOME_Exception)
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ GEOM::GEOM_Shape_var result;
+ TopoDS_Shape tds ;
+
+ const TopoDS_Shape aShape = GetTopoShape(shape) ;
+ if( aShape.IsNull() ) {
+ THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM);
+ }
+
+ BRepFilletAPI_MakeChamfer MC(aShape);
+
+ try {
+ /* case all */
+ TopTools_IndexedDataMapOfShapeListOfShape M;
+ TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,M);
+ if(ListOfID.length() == 0) {
+ for (int i = 1;i<=M.Extent();i++) {
+ TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
+ TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
+ if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E))
+ MC.AddDA(d,angle,E,F);
+ }
+ tds = MC.Shape();
+
+ } else {
+
+ /* case selection */
+ for ( unsigned int ind = 0; ind < ListOfID.length(); ind++ ) {
+ TopoDS_Shape ss ;
+ if( GetShapeFromIndex( aShape, (TopAbs_ShapeEnum)ShapeType, ListOfID[ind], ss ) ) {
+ TopoDS_Edge E = TopoDS::Edge( ss ) ;
+ TopoDS_Face F = TopoDS::Face(M.FindFromKey(E).First());
+ if (!BRepTools::IsReallyClosed(E, F) && !BRep_Tool::Degenerated(E))
+ MC.AddDA(d,angle,E,F);
+ }
+ }
+ tds = MC.Shape();
+ }
+ }
+ catch(Standard_Failure) {
+ THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeChamferAD", SALOME::BAD_PARAM);
+ }
+
+ if (tds.IsNull()) {
+ THROW_SALOME_CORBA_EXCEPTION("Make ChamferAD aborted", SALOME::BAD_PARAM);
+ }
+ result = CreateObject(tds);
+ InsertInLabelOneArgument(aShape, shape, tds, result, myCurrentOCAFDoc) ;
+ return result ;
+}
+
//=================================================================================
// function : CheckShape()
// purpose :
CORBA::Boolean GEOM_Gen_i::CheckShape(GEOM::GEOM_Shape_ptr shape)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
TopoDS_Shape S = GetTopoShape(shape) ;
if( S.IsNull() ) {
THROW_SALOME_CORBA_EXCEPTION("Shape is null", SALOME::BAD_PARAM);
CORBA::Double delta1, CORBA::Double delta2, CORBA::Double delta3)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
CORBA::Double delta)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
GEOM::GEOM_Shape_var result ;
TopoDS_Shape tds ;
TopoDS_Shape aShape = GetTopoShape(shape) ;
GEOM::GEOM_Gen::ListOfIOR_var aList = new GEOM::GEOM_Gen::ListOfIOR;
aList->length(4);
- aList[0]=strdup(Edge1->Name());
- aList[1]=strdup(Edge2->Name());
- aList[2]=strdup(Edge3->Name());
- aList[3]=strdup(Edge4->Name());
+ aList[0]=CORBA::string_dup(Edge1->Name());
+ aList[1]=CORBA::string_dup(Edge2->Name());
+ aList[2]=CORBA::string_dup(Edge3->Name());
+ aList[3]=CORBA::string_dup(Edge4->Name());
GEOM::GEOM_Shape_ptr aWire = MakeWire( aList );
GEOM::GEOM_Shape_ptr aFace = MakeFace( aWire, true ) ;
void GEOM_Gen_i::ExportIGES(const char* filename,GEOM::GEOM_Shape_ptr theShape)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
if (theShape->_is_nil())
{
THROW_SALOME_CORBA_EXCEPTION("Export IGES aborted", SALOME::BAD_PARAM);
void GEOM_Gen_i::ExportBREP(const char* filename,GEOM::GEOM_Shape_ptr theShape)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
if (theShape->_is_nil())
{
THROW_SALOME_CORBA_EXCEPTION("Export BRep aborted", SALOME::BAD_PARAM);
void GEOM_Gen_i::ExportSTEP(const char* filename,GEOM::GEOM_Shape_ptr theShape)
throw (SALOME::SALOME_Exception)
{
+ Unexpect aCatch(SALOME_SalomeException);
if (theShape->_is_nil())
{
THROW_SALOME_CORBA_EXCEPTION("Export STEP aborted", SALOME::BAD_PARAM);