DCQ : Debug Open/Save for Kinematic.

This commit is contained in:
dcq 2004-02-23 10:04:17 +00:00
parent eeb3c18d16
commit 749f61ead9
9 changed files with 630 additions and 173 deletions

View File

@ -339,6 +339,12 @@ module GEOM
in short NbSeq,
in boolean IsInLoop) raises (SALOME::SALOME_Exception) ;
void SetPosition(in GEOM_Contact Contact) raises (SALOME::SALOME_Exception) ;
void SetRotation(in GEOM_Contact Contact) raises (SALOME::SALOME_Exception) ;
void SetTranslation(in GEOM_Contact Contact) raises (SALOME::SALOME_Exception) ;
};
};

View File

@ -55,17 +55,30 @@ GEOM_Contact_i::GEOM_Contact_i(Kinematic_Contact* Contact,
_Shape1 = GEOM::GEOM_Shape::_duplicate(Shape1);
_Shape2 = GEOM::GEOM_Shape::_duplicate(Shape2);
GEOM::PointStruct p0 = engine->MakePointStruct(0, 0, 0);
GEOM::PointStruct pX = engine->MakePointStruct(1, 0, 0);
GEOM::PointStruct pY = engine->MakePointStruct(0, 1, 0);
GEOM::PointStruct pZ = engine->MakePointStruct(0, 0, 1);
GEOM::PointStruct p0 = engine->MakePointStruct(Contact->Position().Origin().X(),
Contact->Position().Origin().Y(),
Contact->Position().Origin().Z());
GEOM::PointStruct pX = engine->MakePointStruct(Contact->Position().DirX().X(),
Contact->Position().DirX().Y(),
Contact->Position().DirX().Z());
GEOM::PointStruct pY = engine->MakePointStruct(Contact->Position().DirY().X(),
Contact->Position().DirY().Y(),
Contact->Position().DirY().Z());
GEOM::PointStruct pZ = engine->MakePointStruct(Contact->Position().DirZ().X(),
Contact->Position().DirZ().Y(),
Contact->Position().DirZ().Z());
GEOM::DirStruct VX = engine->MakeDirection(pX);
GEOM::DirStruct VY = engine->MakeDirection(pY);
GEOM::DirStruct VZ = engine->MakeDirection(pZ);
GEOM_Position_i * Position_servant = new GEOM_Position_i(p0, VX, VY, VZ);
_Position = GEOM::GEOM_Position::_narrow(Position_servant->_this());
GEOM_Rotation_i * Rotation_servant = new GEOM_Rotation_i(1, 2, 3, 0, 0, 0);
GEOM_Rotation_i * Rotation_servant = new GEOM_Rotation_i(Contact->Rotation().Rot1(),
Contact->Rotation().Rot2(),
Contact->Rotation().Rot3(),
Contact->Rotation().ValX(),
Contact->Rotation().ValY(),
Contact->Rotation().ValZ());
_Rotation = GEOM::GEOM_Rotation::_narrow(Rotation_servant->_this());
GEOM_Translation_i * Translation_servant = new GEOM_Translation_i(0, 0, 0);
_Translation = GEOM::GEOM_Translation::_narrow(Translation_servant->_this());

View File

@ -212,6 +212,18 @@ char* GEOM_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
if (!CORBA::is_nil(aShape)) {
return strdup(aShape->ShapeId());
}
GEOM::GEOM_Assembly_var aAssembly = GEOM::GEOM_Assembly::_narrow(_orb->string_to_object(IORString));
if (!CORBA::is_nil(aAssembly)) {
return strdup(aAssembly->ShapeId());
}
GEOM::GEOM_Contact_var aContact = GEOM::GEOM_Contact::_narrow(_orb->string_to_object(IORString));
if (!CORBA::is_nil(aContact)) {
return strdup(aContact->ShapeId());
}
GEOM::GEOM_Animation_var aAnimation = GEOM::GEOM_Animation::_narrow(_orb->string_to_object(IORString));
if (!CORBA::is_nil(aAnimation)) {
return strdup(aAnimation->ShapeId());
}
return 0;
}
@ -236,112 +248,228 @@ char* GEOM_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
TCollection_ExtendedString MainIOR;
TDF_Label Lab;
TDF_Tool::Label(aDoc->GetData(), aPersRefString, Lab );
Handle(TNaming_NamedShape) NS;
Lab.FindAttribute( TNaming_NamedShape::GetID(), NS );
TopoDS_Shape S = TNaming_Tool::GetShape(NS);
/* shapetype, index=0, topo, orb, shapetype, ismain=true and name are setted and modified later ? */
GEOM::GEOM_Shape_var result = CreateObject(S);
GEOMDS_Commands GC( aDoc->Main() ) ;
if ( GC.HasIOR(Lab) ) { /* shape already created/loaded */
return 0 ;
}
/******************* Dependent object (not a main shape) *********************/
if( GC.IsDependentShape(Lab) ) {
TDF_Label mainLabel ;
Standard_Boolean mainShapeOk = GC.GetMainShapeLabel(Lab, mainLabel) ;
/* Main object not yet loaded we load/create it */
if( !GC.HasIOR(mainLabel) ) {
TCollection_AsciiString entry;
TDF_Tool::Entry(mainLabel,entry);
CORBA::String_var ent = strdup(entry.ToCString());
/* Create the main object recursively */
MainIOR = LocalPersistentIDToIOR(theSObject, ent, isMultiFile, isASCII) ;
} else {
GC.ReturnNameIOR( mainLabel, MainIOR );
}
result->MainName( TCollection_AsciiString(MainIOR).ToCString() ) ;
result->IsMainShape(false) ;
result->ShapeId(aPersRefString);
Handle(TDF_Reference) aRef;
Lab.FindAttribute( TDF_Reference::GetID(), aRef );
TDF_Label myL = aRef->Get() ;
Handle(TNaming_NamedShape) NN;
myL.FindAttribute( TNaming_NamedShape::GetID(), NN );
TopoDS_Shape mainTopo = TNaming_Tool::GetShape(NN);
TopoDS_Shape S;
Kinematic_Assembly* Assembly = new Kinematic_Assembly();
Kinematic_Contact* Contact = new Kinematic_Contact();
Kinematic_Animation* Animation = new Kinematic_Animation();
GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
if(GC.GetShape(Lab, S)) {
GEOM::GEOM_Shape_var result = CreateObject(S);
if(S.ShapeType() != TopAbs_COMPOUND) {
/* to set the index of a unique sub shape (Explode All ONLY for the moment !) */
ListOfID->length(1);
int index = 1;
TopTools_MapOfShape M;
TopExp_Explorer Exp ;
for( Exp.Init(mainTopo, TopAbs_ShapeEnum( result->ShapeType() )) ; Exp.More(); Exp.Next() ) {
if ( M.Add(Exp.Current()) ) {
if(Exp.Current().IsSame(S) ) {
ListOfID[0] = index;
break;
}
index++ ;
}
/******************* Dependent object (not a main shape) *********************/
if( GC.IsDependentShape(Lab) ) {
TDF_Label mainLabel ;
Standard_Boolean mainShapeOk = GC.GetMainShapeLabel(Lab, mainLabel) ;
/* Main object not yet loaded we load/create it */
if( !GC.HasIOR(mainLabel) ) {
TCollection_AsciiString entry;
TDF_Tool::Entry(mainLabel,entry);
CORBA::String_var ent = strdup(entry.ToCString());
/* Create the main object recursively */
MainIOR = LocalPersistentIDToIOR(theSObject, ent, isMultiFile, isASCII) ;
} else {
GC.ReturnNameIOR( mainLabel, MainIOR );
}
result->Index(ListOfID) ;
result->MainName( TCollection_AsciiString(MainIOR).ToCString() ) ;
result->IsMainShape(false) ;
result->ShapeId(aPersRefString);
Handle(TDF_Reference) aRef;
Lab.FindAttribute( TDF_Reference::GetID(), aRef );
TDF_Label myL = aRef->Get() ;
Handle(TNaming_NamedShape) NN;
myL.FindAttribute( TNaming_NamedShape::GetID(), NN );
TopoDS_Shape mainTopo = TNaming_Tool::GetShape(NN);
GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
if(S.ShapeType() != TopAbs_COMPOUND) {
/* to set the index of a unique sub shape (Explode All ONLY for the moment !) */
ListOfID->length(1);
int index = 1;
TopTools_MapOfShape M;
TopExp_Explorer Exp ;
for( Exp.Init(mainTopo, TopAbs_ShapeEnum( result->ShapeType() )) ; Exp.More(); Exp.Next() ) {
if ( M.Add(Exp.Current()) ) {
if(Exp.Current().IsSame(S) ) {
ListOfID[0] = index;
break;
}
index++ ;
}
}
result->Index(ListOfID) ;
return result->Name();
}
else {
/* Here is a TopAbs_COMPOUND : we set the list/index for a compound : containing two or more sub shapes */
/* Warning : the Corba shape has a shapetype Compound : in GEOMDS_Client we have to retrieve the kind of */
/* subshapes contained in this compound ! */
TopTools_SequenceOfShape SS;
TopoDS_Iterator it ;
TopExp_Explorer exp ;
TopAbs_ShapeEnum subType ;
/* Set all sub shapes in a sequence of shapes */
for ( it.Initialize( S, true, true ) ; it.More(); it.Next() ) {
subType = it.Value().ShapeType() ;
SS.Append( it.Value() ) ;
}
ListOfID->length( SS.Length() ) ;
int j, k ; /* in TopTools_SequenceOfShape index start at 1 */
for( k=1; k<=SS.Length(); k++ ) {
j = 1 ;
for( exp.Init( mainTopo, subType ); exp.More(); exp.Next() ) {
if( exp.Current().IsSame( SS.Value(k) ) ) {
ListOfID[k-1] = j ;
}
j++ ;
}
}
result->Index(ListOfID) ;
return result->Name();
}
}
/******************* Independent object (not a sub shape) *********************/
else {
result->IsMainShape(true) ;
if( !GC.AddIORNameAttribute(Lab, result->Name() ) ) {
MESSAGE("in LocalPersistentIDToIOR, NAME/IOR attribute already exist." << endl ) ;
}
Handle(TNaming_NamedShape) NamedShape ;
bool notTested = Lab.FindAttribute(TNaming_NamedShape::GetID(), NamedShape) ;
result->ShapeId(aPersRefString);
return result->Name();
}
else {
/* Here is a TopAbs_COMPOUND : we set the list/index for a compound : containing two or more sub shapes */
/* Warning : the Corba shape has a shapetype Compound : in GEOMDS_Client we have to retrieve the kind of */
/* subshapes contained in this compound ! */
TopTools_SequenceOfShape SS;
TopoDS_Iterator it ;
TopExp_Explorer exp ;
TopAbs_ShapeEnum subType ;
/* Set all sub shapes in a sequence of shapes */
for ( it.Initialize( S, true, true ) ; it.More(); it.Next() ) {
subType = it.Value().ShapeType() ;
SS.Append( it.Value() ) ;
}
ListOfID->length( SS.Length() ) ;
int j, k ; /* in TopTools_SequenceOfShape index start at 1 */
for( k=1; k<=SS.Length(); k++ ) {
j = 1 ;
for( exp.Init( mainTopo, subType ); exp.More(); exp.Next() ) {
if( exp.Current().IsSame( SS.Value(k) ) ) {
ListOfID[k-1] = j ;
}
j++ ;
}
}
result->Index(ListOfID) ;
return result->Name();
}
}
/******************* Independent object (not a sub shape) *********************/
else {
result->IsMainShape(true) ;
if( !GC.AddIORNameAttribute(Lab, result->Name() ) ) {
else if(GC.GetAssembly(Lab, *Assembly)) {
/* Create the CORBA servant holding the TopoDS_Shape */
GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this();
GEOM_Assembly_i * Assembly_servant = new GEOM_Assembly_i(Assembly, _orb, engine);
GEOM::GEOM_Assembly_var result = GEOM::GEOM_Assembly::_narrow(Assembly_servant->_this());
/* Create and set the name (IOR of shape converted into a string) */
string name_ior = _orb->object_to_string(result);
result->Name(name_ior.c_str());
if( !GC.AddIORNameAttribute(Lab, result->Name())) {
MESSAGE("in LocalPersistentIDToIOR, NAME/IOR attribute already exist." << endl ) ;
}
Handle(TNaming_NamedShape) NamedShape ;
bool notTested = Lab.FindAttribute(TNaming_NamedShape::GetID(), NamedShape) ;
result->ShapeId(aPersRefString);
return result->Name();
return result->Name();
}
else if(GC.GetContact(Lab, *Contact)) {
TDF_ChildIterator it;
int i = 1;
GEOM::GEOM_Shape_var aShape1;
GEOM::GEOM_Shape_var aShape2;
TCollection_ExtendedString str;
Handle(TDF_Reference) aRef;
for(it.Initialize(Lab, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
if(i == 3) {
L.FindAttribute(TDF_Reference::GetID(), aRef);
TDF_Label myL = aRef->Get();
GC.ReturnNameIOR(myL, str);
aShape1 = GetIORFromString(TCollection_AsciiString(str).ToCString());
}
if(i == 4) {
L.FindAttribute(TDF_Reference::GetID(), aRef);
TDF_Label myL = aRef->Get();
GC.ReturnNameIOR(myL, str);
aShape2 = GetIORFromString(TCollection_AsciiString(str).ToCString());
}
i++;
}
/* Create the CORBA servant holding the TopoDS_Shape */
GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this();
GEOM_Contact_i * Contact_servant = new GEOM_Contact_i(Contact, aShape1, aShape2, _orb, engine);
GEOM::GEOM_Contact_var result = GEOM::GEOM_Contact::_narrow(Contact_servant->_this());
/* Create and set the name (IOR of shape converted into a string) */
string name_ior = _orb->object_to_string(result);
result->Name(name_ior.c_str());
if( !GC.AddIORNameAttribute(Lab, result->Name())) {
MESSAGE("in LocalPersistentIDToIOR, NAME/IOR attribute already exist." << endl ) ;
}
result->ShapeId(aPersRefString);
GEOM::GEOM_Assembly_var aAssPtr;
TDF_Label AssLab = Lab.Father();
GC.ReturnNameIOR(AssLab, str);
if(strcmp(TCollection_AsciiString(str).ToCString(),"") != 0) {
CORBA::Object_var anObject = _orb->string_to_object(TCollection_AsciiString(str).ToCString());
if(!CORBA::is_nil(anObject))
aAssPtr = GEOM::GEOM_Assembly::_narrow(anObject.in());
}
aAssPtr->AddContact(result);
return result->Name();
}
else if(GC.GetAnimation(Lab, *Animation)) {
TDF_ChildIterator it;
int i = 1;
GEOM::GEOM_Assembly_var aAssPtr;
GEOM::GEOM_Shape_var aFramePtr;
TCollection_ExtendedString str;
Handle(TDF_Reference) aRef;
for(it.Initialize(Lab, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
if(i == 2) {
L.FindAttribute(TDF_Reference::GetID(), aRef);
TDF_Label myL = aRef->Get();
GC.ReturnNameIOR(myL, str);
if(strcmp(TCollection_AsciiString(str).ToCString(),"") != 0) {
CORBA::Object_var anObject = _orb->string_to_object(TCollection_AsciiString(str).ToCString());
if(!CORBA::is_nil(anObject))
aAssPtr = GEOM::GEOM_Assembly::_narrow(anObject.in());
}
}
if(i == 3) {
L.FindAttribute(TDF_Reference::GetID(), aRef);
TDF_Label myL = aRef->Get();
GC.ReturnNameIOR(myL, str);
aFramePtr = GetIORFromString(TCollection_AsciiString(str).ToCString());
}
i++;
}
/* Create the CORBA servant holding the TopoDS_Shape */
GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this();
GEOM_Animation_i * Animation_servant = new GEOM_Animation_i(Animation, aAssPtr, aFramePtr, _orb, engine);
GEOM::GEOM_Animation_var result = GEOM::GEOM_Animation::_narrow(Animation_servant->_this());
/* Create and set the name (IOR of shape converted into a string) */
string name_ior = _orb->object_to_string(result);
result->Name(name_ior.c_str());
if( !GC.AddIORNameAttribute(Lab, result->Name())) {
MESSAGE("in LocalPersistentIDToIOR, NAME/IOR attribute already exist." << endl ) ;
}
result->ShapeId(aPersRefString);
return result->Name();
}
cout<<"GEOM_Gen_i::LocalPersistentIDToIOR : end"<<endl;
}
//============================================================================
@ -5140,14 +5268,14 @@ GEOM::GEOM_Animation_ptr GEOM_Gen_i::AddAnimation(GEOM::GEOM_Assembly_ptr Ass,
/* Create the CORBA servant holding the TopoDS_Shape */
GEOM::GEOM_Gen_ptr engine = POA_GEOM::GEOM_Gen::_this();
GEOM_Animation_i * Animation_servant = new GEOM_Animation_i(tds, Ass, Shape1, _orb, engine);
GEOM::GEOM_Animation_var Animation = GEOM::GEOM_Animation::_narrow(Animation_servant->_this());
GEOM::GEOM_Animation_var Animation = GEOM::GEOM_Animation::_narrow(Animation_servant->_this());
/* Create and set the name (IOR of shape converted into a string) */
string name_ior = _orb->object_to_string(Animation);
Animation->Name(name_ior.c_str());
/* add attributs S and mystr in a new label */
TDF_Label Lab = GC.AddAnimation(*tds, Animation->Name());
TDF_Label Lab = GC.AddAnimation(*tds, mainRefLab, Animation->Name());
TCollection_AsciiString entry;
TDF_Tool::Entry(Lab, entry);
@ -5158,6 +5286,91 @@ GEOM::GEOM_Animation_ptr GEOM_Gen_i::AddAnimation(GEOM::GEOM_Assembly_ptr Ass,
}
//=================================================================================
// function : SetPosition()
// purpose :
//=================================================================================
void GEOM_Gen_i::SetPosition(GEOM::GEOM_Contact_ptr Contact)
throw (SALOME::SALOME_Exception)
{
try {
TDF_Label mainRefLab;
TDF_Tool::Label(myCurrentOCAFDoc->GetData(), Contact->ShapeId(), mainRefLab);
GEOMDS_Commands GC(myCurrentOCAFDoc->Main());
GEOM::GEOM_Position_var myGeomPosition = GEOM::GEOM_Position::_narrow(Contact->GetPosition());
GEOM::PointStruct P0 = myGeomPosition->GetOrigin();
GEOM::DirStruct VX = myGeomPosition->GetVX();
GEOM::DirStruct VY = myGeomPosition->GetVY();
GEOM::DirStruct VZ = myGeomPosition->GetVZ();
GC.SetPosition(mainRefLab, P0.x, P0.y, P0.z,
VX.PS.x, VX.PS.y, VX.PS.z,
VY.PS.x, VY.PS.y, VY.PS.z,
VZ.PS.x, VZ.PS.y, VZ.PS.z);
}
catch(Standard_Failure)
THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::SetPosition", SALOME::BAD_PARAM);
return;
}
//=================================================================================
// function : SetRotation()
// purpose :
//=================================================================================
void GEOM_Gen_i::SetRotation(GEOM::GEOM_Contact_ptr Contact)
throw (SALOME::SALOME_Exception)
{
try {
TDF_Label mainRefLab;
TDF_Tool::Label(myCurrentOCAFDoc->GetData(), Contact->ShapeId(), mainRefLab);
GEOMDS_Commands GC(myCurrentOCAFDoc->Main());
GEOM::GEOM_Rotation_var myGeomRotation = GEOM::GEOM_Rotation::_narrow(Contact->GetRotation());
int aRot1 = myGeomRotation->GetRot1();
int aRot2 = myGeomRotation->GetRot2();
int aRot3 = myGeomRotation->GetRot3();
double aVal1 = myGeomRotation->GetVal1();
double aVal2 = myGeomRotation->GetVal2();
double aVal3 = myGeomRotation->GetVal3();
GC.SetRotation(mainRefLab, aRot1, aRot2, aRot3, aVal1, aVal2, aVal3);
}
catch(Standard_Failure)
THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::SetRotation", SALOME::BAD_PARAM);
return;
}
//=================================================================================
// function : SetTranslation()
// purpose :
//=================================================================================
void GEOM_Gen_i::SetTranslation(GEOM::GEOM_Contact_ptr Contact)
throw (SALOME::SALOME_Exception)
{
try {
TDF_Label mainRefLab;
TDF_Tool::Label(myCurrentOCAFDoc->GetData(), Contact->ShapeId(), mainRefLab);
GEOMDS_Commands GC(myCurrentOCAFDoc->Main());
GEOM::GEOM_Translation_var myGeomTranslation = GEOM::GEOM_Translation::_narrow(Contact->GetTranslation());
double aVal1 = myGeomTranslation->GetVal1();
double aVal2 = myGeomTranslation->GetVal2();
double aVal3 = myGeomTranslation->GetVal3();
GC.SetTranslation(mainRefLab, aVal1, aVal2, aVal3);
}
catch(Standard_Failure)
THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::SetTranslation", SALOME::BAD_PARAM);
return;
}
//=====================================================================================
// EXPORTED METHODS
//=====================================================================================

View File

@ -622,6 +622,12 @@ class GEOM_Gen_i: public POA_GEOM::GEOM_Gen,
const short NbSeq,
CORBA::Boolean IsInLoop)
throw (SALOME::SALOME_Exception) ;
void SetPosition(GEOM::GEOM_Contact_ptr Contact)
throw (SALOME::SALOME_Exception) ;
void SetRotation(GEOM::GEOM_Contact_ptr Contact)
throw (SALOME::SALOME_Exception) ;
void SetTranslation(GEOM::GEOM_Contact_ptr Contact)
throw (SALOME::SALOME_Exception) ;
};

View File

@ -271,9 +271,10 @@ Standard_Boolean GEOMDS_Commands::ClearAllIOR(const TDF_Label& aLabel)
TDF_Label L = it.Value() ;
if( L.FindAttribute(TDataStd_Name::GetID(), anAttName) ) {
notTested = L.ForgetAttribute(TDataStd_Name::GetID()) ;
if(notTested)
MESSAGE("in GEOMDS_Commands::ClearAllIOR : IOR CLEARED" )
ClearAllIOR(L);
}
if(notTested)
MESSAGE("in GEOMDS_Commands::ClearAllIOR : IOR CLEARED" )
}
return true ;
}
@ -318,6 +319,10 @@ TDF_Label GEOMDS_Commands::AddAssembly(Kinematic_Assembly& KAss,
{
TDF_Label LabAssembly = myLab.NewChild();
TDataStd_Name::Set(LabAssembly, Name);
TDF_Label LabType = LabAssembly.NewChild();
TDataStd_Integer::Set(LabType, 1);
return LabAssembly;
}
@ -333,20 +338,24 @@ TDF_Label GEOMDS_Commands::AddContact(Kinematic_Contact& KContact,
TDF_Label LabContact = mainRefLab.NewChild();
TDataStd_Name::Set(LabContact, Name);
TDF_Label LabContactType = LabContact.NewChild();
TDataStd_Integer::Set(LabContactType, 2);
TDF_Label LabType = LabContact.NewChild();
TDataStd_Integer::Set(LabType, KContact.Type());
int ret;
TDF_Label NewLab1 = LabContact.NewChild();
TNaming_Builder B1(NewLab1);
B1.Select(KContact.Shape1(), KContact.Shape1());
// TDF_Label RefLab1 = TNaming_Tool::Label(myLab, KContact.Shape1());
// TDF_Reference::Set(NewLab1, RefLab1);
TDF_Label RefLab1 = TNaming_Tool::Label(myLab, KContact.Shape1(), ret);
TDF_Reference::Set(NewLab1, RefLab1);
TDF_Label NewLab2 = LabContact.NewChild();
TNaming_Builder B2(NewLab2);
B2.Select(KContact.Shape2(), KContact.Shape2());
// TDF_Label RefLab2 = TNaming_Tool::Label(myLab, KContact.Shape2());
// TDF_Reference::Set(NewLab2, RefLab2);
TDF_Label RefLab2 = TNaming_Tool::Label(myLab, KContact.Shape2(), ret);
TDF_Reference::Set(NewLab2, RefLab2);
TDF_Label LabPosition = LabContact.NewChild();
Handle(TDataStd_RealArray) RealArrayP = TDataStd_RealArray::Set(LabPosition, 1, 12);
@ -393,14 +402,27 @@ TDF_Label GEOMDS_Commands::AddContact(Kinematic_Contact& KContact,
// purpose :
//=======================================================================
TDF_Label GEOMDS_Commands::AddAnimation(Kinematic_Animation& KAnimation,
const TDF_Label& AssLab,
const TCollection_ExtendedString& Name)
{
TDF_Label LabAnimation = myLab.NewChild();
TDataStd_Name::Set(LabAnimation, Name);
Standard_Real duration = double(KAnimation.Duration());
TDF_Label LabType = LabAnimation.NewChild();
TDataStd_Integer::Set(LabType, 3);
TDF_Label LabAssembly = LabAnimation.NewChild();
TDF_Reference::Set(LabAssembly, AssLab);
int ret;
TDF_Label LabFrame = LabAnimation.NewChild();
TNaming_Builder B1(LabFrame);
B1.Select(KAnimation.Frame(), KAnimation.Frame());
TDF_Label RefLab = TNaming_Tool::Label(myLab, KAnimation.Frame(), ret);
TDF_Reference::Set(LabFrame, RefLab);
TDF_Label LabDuration = LabAnimation.NewChild();
Standard_Real duration = double(KAnimation.Duration());
TDataStd_Real::Set(LabDuration, duration);
TDF_Label LabNbSeq = LabAnimation.NewChild();
@ -421,20 +443,25 @@ Standard_Boolean GEOMDS_Commands::GetAssembly(const TDF_Label& aLabel,
Kinematic_Assembly& returnAss)
{
Kinematic_Assembly* Ass = new Kinematic_Assembly();
Handle(TDataStd_Name) anAttName;
if(!aLabel.FindAttribute(TDataStd_Name::GetID(), anAttName))
return false;
else {
TDF_ChildIterator it;
for(it.Initialize(aLabel, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
Kinematic_Contact* aContact = new Kinematic_Contact();
Standard_Boolean test = GetContact(L, *aContact);
Ass->AddContact(aContact);
TDF_ChildIterator it;
for(it.Initialize(aLabel, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
Handle(TDataStd_Integer) anAttInteger;
if(L.FindAttribute(TDataStd_Integer::GetID(), anAttInteger)) {
if(anAttInteger->Get() != 1) {
returnAss = *Ass;
return false;
}
}
else {
Kinematic_Contact* aContact = new Kinematic_Contact();
if(GetContact(L, *aContact))
Ass->AddContact(aContact);
}
returnAss = *Ass;
return true;
}
returnAss = *Ass;
return true;
}
@ -446,63 +473,209 @@ Standard_Boolean GEOMDS_Commands::GetContact(const TDF_Label& aLabel,
Kinematic_Contact& returnContact)
{
Kinematic_Contact* Contact = new Kinematic_Contact();
Handle(TDataStd_Name) anAttName;
if(!aLabel.FindAttribute(TDataStd_Name::GetID(), anAttName))
return false;
else {
TDF_ChildIterator it;
int i = 1;
for(it.Initialize(aLabel, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
Handle(TNaming_NamedShape) anAttTopo1;
Handle(TNaming_NamedShape) anAttTopo2;
Handle(TDataStd_Integer) anAttInteger;
Handle(TDataStd_Real) anAttReal;
Handle(TDataStd_IntegerArray) anAttIntegerArrayR;
Handle(TDataStd_RealArray) anAttRealArrayP;
Handle(TDataStd_RealArray) anAttRealArrayR;
Handle(TDataStd_RealArray) anAttRealArrayT;
if(i == 1 && L.FindAttribute(TDataStd_Integer::GetID(), anAttInteger)) {
Contact->Type(anAttInteger->Get());
TDF_ChildIterator it;
int i = 1;
for(it.Initialize(aLabel, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
Handle(TNaming_NamedShape) anAttTopo1;
Handle(TNaming_NamedShape) anAttTopo2;
Handle(TDataStd_Integer) anAttInteger1;
Handle(TDataStd_Integer) anAttInteger2;
Handle(TDataStd_Real) anAttReal;
Handle(TDataStd_IntegerArray) anAttIntegerArrayR;
Handle(TDataStd_RealArray) anAttRealArrayP;
Handle(TDataStd_RealArray) anAttRealArrayR;
Handle(TDataStd_RealArray) anAttRealArrayT;
if(i == 1 && L.FindAttribute(TDataStd_Integer::GetID(), anAttInteger1)) {
if(anAttInteger1->Get() != 2) {
returnContact = *Contact;
return false;
}
if(i == 2 && L.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo1)) {
Contact->Shape1(TNaming_Tool::GetShape(anAttTopo1));
}
if(i == 3 && L.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo2)) {
Contact->Shape2(TNaming_Tool::GetShape(anAttTopo2));
}
if(i == 4 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayP)) {
gp_Pnt Center(anAttRealArrayP->Value(1), anAttRealArrayP->Value(2), anAttRealArrayP->Value(3));
gp_Dir aDirX(anAttRealArrayP->Value(4), anAttRealArrayP->Value(5), anAttRealArrayP->Value(6));
gp_Dir aDirY(anAttRealArrayP->Value(7), anAttRealArrayP->Value(8), anAttRealArrayP->Value(9));
gp_Dir aDirZ(anAttRealArrayP->Value(10), anAttRealArrayP->Value(11), anAttRealArrayP->Value(12));
Contact->Position().Origin(Center);
Contact->Position().DirX(aDirX);
Contact->Position().DirY(aDirY);
Contact->Position().DirZ(aDirZ);
}
if(i == 5 && L.FindAttribute(TDataStd_IntegerArray::GetID(), anAttIntegerArrayR)) {
Contact->Rotation().Rot1(anAttIntegerArrayR->Value(1));
Contact->Rotation().Rot2(anAttIntegerArrayR->Value(2));
Contact->Rotation().Rot3(anAttIntegerArrayR->Value(3));
}
if(i == 6 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayR)) {
Contact->Rotation().ValX(anAttRealArrayR->Value(1));
Contact->Rotation().ValY(anAttRealArrayR->Value(2));
Contact->Rotation().ValZ(anAttRealArrayR->Value(3));
}
if(i == 7 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayT)) {
Contact->Translation().ValX(anAttRealArrayT->Value(1));
Contact->Translation().ValY(anAttRealArrayT->Value(2));
Contact->Translation().ValZ(anAttRealArrayT->Value(3));
}
if(i == 8 && L.FindAttribute(TDataStd_Real::GetID(), anAttReal)) {
Contact->Step(anAttReal->Get());
}
i++;
}
returnContact = *Contact;
return true;
if(i == 2 && L.FindAttribute(TDataStd_Integer::GetID(), anAttInteger2)) {
Contact->Type(anAttInteger2->Get());
}
if(i == 3 && L.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo1)) {
Contact->Shape1(TNaming_Tool::GetShape(anAttTopo1));
}
if(i == 4 && L.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo2)) {
Contact->Shape2(TNaming_Tool::GetShape(anAttTopo2));
}
if(i == 5 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayP)) {
gp_Pnt Center(anAttRealArrayP->Value(1), anAttRealArrayP->Value(2), anAttRealArrayP->Value(3));
gp_Dir aDirX(anAttRealArrayP->Value(4), anAttRealArrayP->Value(5), anAttRealArrayP->Value(6));
gp_Dir aDirY(anAttRealArrayP->Value(7), anAttRealArrayP->Value(8), anAttRealArrayP->Value(9));
gp_Dir aDirZ(anAttRealArrayP->Value(10), anAttRealArrayP->Value(11), anAttRealArrayP->Value(12));
Contact->Position().Origin(Center);
Contact->Position().DirX(aDirX);
Contact->Position().DirY(aDirY);
Contact->Position().DirZ(aDirZ);
}
if(i == 6 && L.FindAttribute(TDataStd_IntegerArray::GetID(), anAttIntegerArrayR)) {
Contact->Rotation().Rot1(anAttIntegerArrayR->Value(1));
Contact->Rotation().Rot2(anAttIntegerArrayR->Value(2));
Contact->Rotation().Rot3(anAttIntegerArrayR->Value(3));
}
if(i == 7 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayR)) {
Contact->Rotation().ValX(anAttRealArrayR->Value(1));
Contact->Rotation().ValY(anAttRealArrayR->Value(2));
Contact->Rotation().ValZ(anAttRealArrayR->Value(3));
}
if(i == 8 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayT)) {
Contact->Translation().ValX(anAttRealArrayT->Value(1));
Contact->Translation().ValY(anAttRealArrayT->Value(2));
Contact->Translation().ValZ(anAttRealArrayT->Value(3));
}
if(i == 9 && L.FindAttribute(TDataStd_Real::GetID(), anAttReal)) {
Contact->Step(anAttReal->Get());
}
i++;
}
returnContact = *Contact;
return true;
}
//=======================================================================
// function : GetAnimation()
// purpose :
//=======================================================================
Standard_Boolean GEOMDS_Commands::GetAnimation(const TDF_Label& aLabel,
Kinematic_Animation& returnAnim)
{
Kinematic_Animation* Anim = new Kinematic_Animation();
TDF_ChildIterator it;
int i = 1;
for(it.Initialize(aLabel, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
Handle(TNaming_NamedShape) anAttTopo;
Handle(TDataStd_Real) anAttReal;
Handle(TDataStd_Integer) anAttInteger;
Handle(TDataStd_Integer) anAttInteger1;
Handle(TDataStd_Integer) anAttInteger2;
if(i == 1 && L.FindAttribute(TDataStd_Integer::GetID(), anAttInteger)) {
if(anAttInteger->Get() != 3) {
returnAnim = *Anim;
return false;
}
}
if(i == 2) {
Kinematic_Assembly aAss;
Standard_Boolean test = GetAssembly(L, aAss);
Anim->Assembly(aAss);
}
if(i == 3 && L.FindAttribute(TNaming_NamedShape::GetID(), anAttTopo)) {
Anim->Frame(TNaming_Tool::GetShape(anAttTopo));
}
if(i == 4 && L.FindAttribute(TDataStd_Real::GetID(), anAttReal)) {
Anim->Duration(anAttReal->Get());
}
if(i == 5 && L.FindAttribute(TDataStd_Integer::GetID(), anAttInteger1)) {
Anim->NbSeq(anAttInteger1->Get());
}
if(i == 6 && L.FindAttribute(TDataStd_Integer::GetID(), anAttInteger2)) {
Anim->IsInLoop(anAttInteger2->Get());
}
i++;
}
returnAnim = *Anim;
return true;
}
//=======================================================================
// function : SetPosition()
// purpose :
//=======================================================================
void GEOMDS_Commands::SetPosition(const TDF_Label& aLabel,
double P0x, double P0y, double P0z,
double VXx, double VXy, double VXz,
double VYx, double VYy, double VYz,
double VZx, double VZy, double VZz)
{
TDF_ChildIterator it;
int i = 1;
for(it.Initialize(aLabel, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
Handle(TDataStd_RealArray) anAttRealArrayP;
if(i == 5 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayP)) {
anAttRealArrayP->SetValue(1, P0x);
anAttRealArrayP->SetValue(2, P0y);
anAttRealArrayP->SetValue(3, P0z);
anAttRealArrayP->SetValue(4, VXx);
anAttRealArrayP->SetValue(5, VXy);
anAttRealArrayP->SetValue(6, VXz);
anAttRealArrayP->SetValue(7, VYx);
anAttRealArrayP->SetValue(8, VYy);
anAttRealArrayP->SetValue(9, VYz);
anAttRealArrayP->SetValue(10, VZx);
anAttRealArrayP->SetValue(11, VZy);
anAttRealArrayP->SetValue(12, VZz);
return;
}
i++;
}
return;
}
//=======================================================================
// function : SetRotation()
// purpose :
//=======================================================================
void GEOMDS_Commands::SetRotation(const TDF_Label& aLabel,
int Rot1, int Rot2, int Rot3,
double Val1, double Val2, double Val3)
{
TDF_ChildIterator it;
int i = 1;
for(it.Initialize(aLabel, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
Handle(TDataStd_IntegerArray) anAttIntegerArrayR;
Handle(TDataStd_RealArray) anAttRealArrayR;
if(i == 6 && L.FindAttribute(TDataStd_IntegerArray::GetID(), anAttIntegerArrayR)) {
anAttIntegerArrayR->SetValue(1, Rot1);
anAttIntegerArrayR->SetValue(2, Rot2);
anAttIntegerArrayR->SetValue(3, Rot3);
}
if(i == 7 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayR)) {
anAttRealArrayR->SetValue(1, Val1);
anAttRealArrayR->SetValue(2, Val2);
anAttRealArrayR->SetValue(3, Val3);
return;
}
i++;
}
return;
}
//=======================================================================
// function : SetTranslation()
// purpose :
//=======================================================================
void GEOMDS_Commands::SetTranslation(const TDF_Label& aLabel,
double Val1, double Val2, double Val3)
{
TDF_ChildIterator it;
int i = 1;
for(it.Initialize(aLabel, Standard_False); it.More(); it.Next()) {
TDF_Label L = it.Value();
Handle(TDataStd_RealArray) anAttRealArrayT;
if(i == 8 && L.FindAttribute(TDataStd_RealArray::GetID(), anAttRealArrayT)) {
anAttRealArrayT->SetValue(1, Val1);
anAttRealArrayT->SetValue(2, Val2);
anAttRealArrayT->SetValue(3, Val3);
return;
}
i++;
}
return;
}

View File

@ -133,11 +133,23 @@ public:
const TDF_Label& mainRefLab,
const TCollection_ExtendedString& Name) ;
Standard_EXPORT TDF_Label AddAnimation(Kinematic_Animation& KAnimation,
const TCollection_ExtendedString& Name) ;
const TDF_Label& AssLab,
const TCollection_ExtendedString& Name) ;
Standard_EXPORT Standard_Boolean GetAssembly(const TDF_Label& aLabel,
Kinematic_Assembly& returnAss) ;
Standard_EXPORT Standard_Boolean GetContact(const TDF_Label& aLabel,
Kinematic_Contact& returnContact) ;
Standard_EXPORT Standard_Boolean GetAnimation(const TDF_Label& aLabel,
Kinematic_Animation& returnAnimation) ;
Standard_EXPORT void SetPosition(const TDF_Label& aLabel,
double P0x, double P0y, double P0z,
double VXx, double VXy, double VXz,
double VYx, double VYy, double VYz,
double VZx, double VZy, double VZz) ;
Standard_EXPORT void SetRotation(const TDF_Label& aLabel, int Rot1, int Rot2, int Rot3,
double Val1, double Val2, double Val3) ;
Standard_EXPORT void SetTranslation(const TDF_Label& aLabel,
double Val1, double Val2, double Val3) ;
protected:

View File

@ -70,6 +70,13 @@ public:
gp_Trsf& aLoc, Kinematic_Contact* aContact,
double Step);
void Assembly(Kinematic_Assembly& Assembly){myAss = &Assembly;};
void Frame(TopoDS_Shape Frame){myFrame = Frame;};
void Duration(double Duration){myDuration = Duration;};
void NbSeq(int NbSeq){myNbSeq = NbSeq;};
void IsInLoop(bool IsInLoop){myIsInLoop = IsInLoop;};
Kinematic_Assembly* Assembly(){return myAss;};
TopoDS_Shape& Frame(){return myFrame;};
double& Duration(){return myDuration;};
int& NbSeq(){return myNbSeq;};

View File

@ -484,6 +484,8 @@ void KinematicGUI::SetPosition(GEOM::GEOM_Contact_ptr aContact, GEOM::PointStruc
myGeomPosition->SetVX(VX);
myGeomPosition->SetVY(VY);
myGeomPosition->SetVZ(VZ);
myGeom->SetPosition(aContact);
}
catch(const SALOME::SALOME_Exception& S_ex) {
QtCatchCorbaException(S_ex);
@ -512,6 +514,7 @@ void KinematicGUI::SetRotation(GEOM::GEOM_Contact_ptr aContact,
double aVal1 = aStep * Val1 / 360;
myGeomTranslation->SetTranslation(aVal1, aVal2, aVal3);
}
myGeom->SetRotation(aContact);
}
catch(const SALOME::SALOME_Exception& S_ex) {
QtCatchCorbaException(S_ex);
@ -542,6 +545,7 @@ void KinematicGUI::SetTranslation(GEOM::GEOM_Contact_ptr aContact,
double aVal1 = 360 * Val1 / aStep;
myGeomRotation->SetRotation(aRot1, aRot2, aRot3, aVal1, aVal2, aVal3);
}
myGeom->SetTranslation(aContact);
}
catch(const SALOME::SALOME_Exception& S_ex) {
QtCatchCorbaException(S_ex);

View File

@ -185,7 +185,30 @@ void KinematicGUI_PositionDlg::SetEnabledValues()
{
int type = myGeomContact->GetType();
if(type == 1 || type == 3 || type == 5 || type == 9) { //PIVOT || SLIDING PIVOT || PLANE || HELICOIDAL
if(type == 0) { //EMBEDDING
Group1->SpinBox_21->setEnabled(false);
Group1->SpinBox_22->setEnabled(false);
Group1->SpinBox_23->setEnabled(false);
Group1->SpinBox_31->setEnabled(false);
Group1->SpinBox_32->setEnabled(false);
Group1->SpinBox_33->setEnabled(false);
Group1->SpinBox_41->setEnabled(false);
Group1->SpinBox_42->setEnabled(false);
Group1->SpinBox_43->setEnabled(false);
Group1->TextLabel5->setEnabled(false);
Group1->TextLabel6->setEnabled(false);
Group1->TextLabel7->setEnabled(false);
Group1->TextLabel8->setEnabled(false);
Group1->TextLabel9->setEnabled(false);
Group1->TextLabel10->setEnabled(false);
Group1->TextLabel11->setEnabled(false);
Group1->TextLabel12->setEnabled(false);
Group1->TextLabel13->setEnabled(false);
Group1->TextLabel14->setEnabled(false);
Group1->TextLabel15->setEnabled(false);
Group1->TextLabel16->setEnabled(false);
}
else if(type == 1 || type == 3 || type == 5 || type == 9) { //PIVOT || SLIDING PIVOT || PLANE || HELICOIDAL
Group1->SpinBox_31->setEnabled(false);
Group1->SpinBox_32->setEnabled(false);
Group1->SpinBox_33->setEnabled(false);