
Thu, 08/11/2011 - 12:23
hi. i make a edge object which structure is below.
Root
+ ------
|
+ -------- ----> TDataStd_Name : Edge1
| |
| + ---------- ------> TDataStd_Name : Vertex1
| | |
| | + -------> TDataStd_Real : X
| | |
| | + -------> TDataStd_Real : Y
| | |
| | + -------> TDataStd_Real : Z
| |
| |
| + ---------- ------> TDataStd_Name : Vertex2
| |
| + -------> TDataStd_Real : X
| |
| + -------> TDataStd_Real : Y
| |
| + -------> TDataStd_Real : Z
|
|
+ -------- ----> TDataStd_Name : Edge2
|
+ ---------- ------> TDataStd_Name : Vertex3
| |
| + -------> TDataStd_Real : X
| |
| + -------> TDataStd_Real : Y
| |
| + -------> TDataStd_Real : Z
|
|
+ ---------- ------> TDataStd_Name : Vertex4
|
+ -------> TDataStd_Real : X
|
+ -------> TDataStd_Real : Y
|
+ -------> TDataStd_Real : Z
it's no problem if i make edge which has independent vertex.
But i want to make a Edge which have same vertex.
+-------------+-------------+
but i don't know how to link the vertex in label and TFunction..
could you help me?
Thu, 08/11/2011 - 12:25
sorry, figure is broken
Edge1 tag is 0:1
Edge2 tag is 0:2
and Vertex1,2 is Child of Edge1. and Vertex3,4 is Child of Edge2. also X,Y,Z Attribute is child of each vertex.
thanks!
Thu, 08/11/2011 - 14:00
Dear yeon cheol,
I hope "Application Framework User’s Guide" and
"OPEN CASCADE APPLICATION FRAMEWORK FUNCTION MECHANISM USER’S GUIDE"
can help you to find the solution.
Regards
Tue, 08/16/2011 - 03:40
Hi. Supervisor. i'm sorry too late to reply your recommendation.
I already read that. But I can't understand about implementation relate to TDF_Reference.
But i sucess to apply my application. Of course, i can't sucess if there is no advice.
I appreciate your kinds.
I hope that if this guide is pressed at next time, there are more detail explain in
there. :-)
Have a nice day~
Tue, 08/16/2011 - 10:50
We are glad you have succeeded with your application. If you want to get a more detailed explanation (and professional assistance) you may contact us via the Contact Form http://www.opencascade.org/about/contacts/. We will be pleased to discuss all relevant details with you.
Regards...
Thu, 08/11/2011 - 14:18
Hi, you may set only coordinates of your point,
something like this:
TDF_Label level1 = L.FindChild(1,Standard_True);
TDataStd_Real::Set(level1.FindChild(1), x1);
TDataStd_Real::Set(level1.FindChild(2), y1);
TDataStd_Real::Set(level1.FindChild(3), z1);
TDataStd_Real::Set(level1.FindChild(4), x2);
TDataStd_Real::Set(level1.FindChild(5), y2);
TDataStd_Real::Set(level1.FindChild(6), z2);
Or you can add the geometry point in your shape with Brep::Add:
static uint aErrorCode;
TopoDS_Shape EdgeBuild::MakeEdge(const double &myX1 , const double &myY1 , const double &myZ1,
const double &myX2 , const double &myY2 , const double &myZ2)
{
aErrorCode = 0;
TopoDS_Shape ResultShape;
const double myDist = sqrt(pow(myX2-myX1,2.0)+pow(myY2-myY1,2.0)+pow(myZ2-myZ1,2.0));
if (myDist <= 0)
{
aErrorCode = 1;
return ResultShape;
}
gp_Pnt P1(myX1,myY1,myZ1);
gp_Pnt P2(myX2,myY2,myZ2);
gp_Lin Lin(P1,gp_Vec(P1,P2));
Handle(Geom_Line) GL = new Geom_Line(Lin);
TopoDS_Edge& E = TopoDS::Edge(ResultShape);
BRep_Builder Brep;
Brep.MakeEdge(E,GL,1.e-7);
Brep.Range(E,0,myDist); //limit length
//First and last
TopoDS_Vertex V1,V2;
Brep.MakeVertex(V1,P1,1.e-7);
Brep.MakeVertex(V2,P2,1.e-7);
V1.Orientation(TopAbs_FORWARD);
V2.Orientation(TopAbs_REVERSED);
Brep.Add(E,V1);
Brep.Add(E,V2);
return ResultShape;
}
Tue, 08/16/2011 - 04:11
Thanks!! your kind. I can success to make Edge object.
this is tip about how to use TDF_Reference.
when you use already existed object information, you use upper object.
TDF_Reference is descendant class of TDF_Attribute.
Some example is below code.
Assume there is a Vertex in your view. you want to use that like below.
Edge1
#-------------------------------+
Vertex1 Vertex2
# : Existed Object
+ : New object.
and Assume Vertex entry is 0:1 and Vertex have TDataStd_Real Attribute to store the position x,y,z. also Vertex1 is it's lable name. Each Entry is 0:1:1, 0:1:2, 0:1:3. and then, I make Edge Label have Reference information about Vertex1, new information about Vertex2.
TDF_Label EdgeLabel = TDF_TagSource(anyLabel);
TDF_Label VertexLabel1 = EdgeLabel.FindChild(1);
TDF_Label VertexLabel2 = EdgeLabel.FindChild(2);
and then You use the TDF_Reference to link between VertexLabel1 and Vertex1.
TDF_Reference::Set(VertexLabel1, Vertex1) // If you want to reference the Attribute about Vertex1
TDF_Reference::Set(VertexLabel1.FindChild(1), Vertex1.FindChild(1)) // reference the x
TDF_Reference::Set(VertexLabel1.FindChild(2), Vertex1.FindChild(2)) // reference the y
TDF_Reference::Set(VertexLabel1.FindChild(3), Vertex1.FindChild(3)) // reference the z
finally, In virtual method Excute() your descendant class of TFunction_Driver, You get Reference Value about Vertex1.
Handle(TDataStd_Real) TSR;
Handle(TDF_Reference) Ref;
Standard_Real x1,y1,z1,x2,y2,z2;
// Vertex 1;
if(Label().FindChild(1,Standard_False).FindChild(1,Standard_False).FindAttribute(TDataStd_Real::GetID(), TSR ))
{
x1=TSR->Get();
}
else if(Label().FindChild(1,Standard_False).FindChild(1,Standard_False).FindAttribute(TDF_Reference::GetID(), Ref))
{
if(Ref->Get().FindAttribute(TDataStd_Real::GetID(), TSR))
{
x1=TSR->Get();
}
}
else
return 1;
same procedure
.
.
.
.
this code is helpful your application.
YeonCheol
Tue, 08/16/2011 - 19:22
Hi, YeonCheol.
After any transformations of object you have only value that you input in TDF_Label... or you can modify this attribute on any transform operations, like translate, scale .... I'm use Brep::Add method to define this points like a part of geometrical object and after transformation this point is modified too.
Wed, 08/24/2011 - 07:55
Hi. I'm sorry too late to read your reply. I arrived my office last night.
i read your reply then find to check what does it function. (BRep::Add)
But i don't understand about exactly function of Add.
if you explain more detail about add, i'm really appriciate your kinds.
could you explain it and show some example code??
have a nice day :-)
Wed, 08/24/2011 - 11:39
Sorry, I find that in the end of your code.
But I have a question about mechanism of Your recommendation.