Wed, 02/09/2011 - 12:38
Forums:
Hi. i have some question about object of AIS_Shape.
In my case, I make a object using TopoDS_Shape and then generate Handle(AIS_Shape) for displaying. it's no problem to make a object.
But i really want to know that where does AIS_Shape object store?
Generally, User approach each object to operate some work like searching intersection or trimming the Seleted edge.
Also, Selection problem is like upper case.
So, my question is
If I make a AIS_Shape, Where does it store? If it store somewhere, what is the name of class and data structure?
Does anyone help me? please answer my question in details.
Wed, 02/09/2011 - 23:06
Its stored in the AIS_InteractiveContext when you send the Handle to the AIS_Shape into the Display() method of AIS_InteractiveContext. You can query for the selected object from the AIS_InteractiveContext itself. For selecting Topological sub-shapes of the AIS_Shape, you need to open a Local Interactive Context by calling the method OpenLocalContext() and set the selection filters accordingly using ActivateStandardMode(). Check out the MFC sample code for AIS_Select.
Thu, 02/10/2011 - 05:39
Thanks Sharjith!
I understand what you say to me. But exactly not.
In general, there are many object in screen like Edge or Face or Vertex...
You say they are stored in AIS_InteractiveContext. Also It is controlled by LocalContext. If so, When I open the LocalContext? MFC sample use the toolbar icon.
it's not better way i think. for example, As I cut the object, It's obviously to select the another object. In this case, User already Open the Localcontext before select.
Could you explain more detail? Alread I check the MFC sample, But It's hard to understand.
Thanks your reply
- Yeon Cheol
Thu, 02/10/2011 - 05:53
I'm sorry that i forgot this question
what is differece between Select() and Openning the LocalContext after Select()?
Have a nice day
Thu, 02/10/2011 - 07:41
Did you check out the example code?
Thu, 02/10/2011 - 13:16
hi Sharjith
Yes, I already check the AIS_Select sample.
sample procedure is below
1. Select the ToolBar Icon for OpenLocal context, If there is already OpenLocalContext, Close all Local Context.
2. Using the mouse, InputEvent occur in AIS_Select document.cpp
3. and then Close the Local context
So, I try to catch the error in my code, but i can't.
For Cutting the object, Selection problem must be solved.
Could you help me??
-Yoen Cheol
Thu, 02/10/2011 - 18:23
I think I am not getting your requirement exactly. What do you want to select and what do you want to cut. Can you please explain little more?
Fri, 02/11/2011 - 06:58
Sorry Sharjith~ . My comunication skill is not good. I'm really sorry.
Todays, I work to make a TopoDS_Face result in BRepAlgoAPI_Cut. It's my requirement.
So, Explain my precedure using my code. i'm sorry.
1. Make a TopoDS_Edge object like a rectangle using 4 segment of Edge. Otherwise, Cirlce is made of TopoDS_Edge object . and then, Make a Handle(AIS_Shape) using by upper obejct. Of Course, I make a class for making these object(GeomSources class)
2. As You know, BRepAlgoAPI_Cut function act on 2D or 3D object. So I change the upper object in 2D like TopoDS_Face. In this procedure, I think it is very complicate for me
2-1. Select the object using mouse event (In mfc, OnMouseMove function). below is my code in OnMouseMove
// this function is to make a Rectangle during drag
DrawRectangle(DrawRectangleFirstPoint.x, DrawRectangleFirstPoint.y, point.x, point.y, Standard_False);
// if i put down Shift key, act
if(nFlags & MK_SHIFT)
{
GetDocument()->myAISContext->ShiftSelect(DrawRectangleFirstPoint.x, DrawRectangleFirstPoint.y, point.x, point.y, myView);
GetDocument()->myAISContext->InitSelected();
}
else
{
GetDocument()->myAISContext->Select(DrawRectangleFirstPoint.x,DrawRectangleFirstPoint.y, point.x, point.y, myView);
GetDocument()->myAISContext->InitSelected();
}
DrawRectangle(DrawRectangleFirstPoint.x, DrawRectangleFirstPoint.y, point.x, point.y,
Standard_True);
2-2 and then, Select object change for TopoDS_Face. it operate in GeomSources class below is my code.
void GeomSources::OnShapeFill(CProjectDoc* aDoc)
{
// make a object to store the selected Object
TopoDS_Shape SelectedTopoDSShape;
// make a List to make a wire
TopTools_ListOfShape ListOfShape;
for(aDoc->myAISContext->InitSelected();aDoc->myAISContext->MoreSelected();aDoc->myAISContext->NextSelected())
{
// if selected shape type is TopoDS_Edge, Append a list
if(aDoc->myAISContext->SelectedShape().ShapeType() == TopAbs_EDGE)
{
ListOfShape.Append(aDoc->myAISContext->SelectedShape());
}
}
// make a wire
BRepBuilderAPI_MakeWire BRepMakeWire;
BRepMakeWire.Add(ListOfShape);
// make a face
TopoDS_Face TopoDSFace = BRepBuilderAPI_MakeFace(BRepMakeWire.Wire());
Handle(AIS_Shape) AISCurrentShape = new AIS_Shape(TopoDSFace);
// As a results, CurrentObject is set by AIS_Shape
aDoc->myAISContext->SetCurrentObject(AISCurrentShape);
}
2-3 then, Store the object in TopTools_HSequenceOfShape Using Mouse LButton click. The reason why I make a TopTools_HSequenceOfShape is to check the Mouse click order and to save the shape date. of couse, I write the it in OnLButtonDown.
// Save the status of pick for preventing error
AIS_StatusOfPick StatusOfPick = GetDocument()->myAISContext->Select();
GetDocument()->myAISContext->InitSelected();
// If i click the object, excute this line
if(StatusOfPick != AIS_SOP_NothingSelected && StatusOfPick != AIS_SOP_Error)
{
TopoDS_Shape TempStoreTopoDSShape = GetDocument()->myAISContext->SelectedShape();
// Store the object if selected object type is TopAbs_Face
//
if(TempStoreTopoDSShape.ShapeType() == TopAbs_FACE)
{ FirstSelectedShape->Append(GetDocument()->myAISContext->SelectedShape());
}
}
4. Last, BRepAlgoAPI_Cut. my code is below.
void GeomSources::OperatorCut(CObjectDoc* aDoc, Handle(TopTools_HSequenceOfShape) FirstSelectedShape)
{
DisplayType TheDisplayType = No2D3D;
// excute this line if TopTools_HSequenceOfShape have data
if(FirstSelectedShape->Length() != 0)
{
// excute if first selected shape type is face
if(FirstSelectedShape->Value(1).ShapeType() == TopAbs_FACE)
{
Handle(AIS_Shape) FirstAISShape = new AIS_Shape(FirstSelectedShape->Value(1));
TopoDS_Shape LastSelectedShape = aDoc->myAISContext->SelectedShape();
if(LastSelectedShape.ShapeType() == TopAbs_FACE)
{
// BRepAlgoAPI_Cut
TopoDS_Shape ResultTopoDSShape = BRepAlgoAPI_Cut(FirstSelectedShape->Value(1), LastSelectedShape);
Handle(AIS_Shape) ResultAISShape = new AIS_Shape(ResultTopoDSShape);
// this line don't excute. I can't find why does it happen.
aDoc->myAISContext->Erase( FirstAISShape);
// this line also.
aDoc->myAISContext->Display(ResultAISShape);
}
FirstSelectedShape->Clear();
}
}
// this line is to update a view
PostProcess(aDoc,ID_GEOMETRY_BSPLINE,TheDisplayType /*0.02*/);
}
I'm sorry . It's very important job to me.. Do you get my requirement?
-Yeoncheol
Fri, 02/11/2011 - 22:34
I think I am roughly getting your requirement. You see there is an example for the OCAF application where a cylinder is cut from a box using the pop-up menu after selecting both the objects. The selected objects are obtained by the for loop and then the second object is used as a tool to cut the first one. I think the only problem that you are facing is in designing the command flow to subsequently select the tool to cut the first object. Hope the OCAF sample helps.
Wed, 02/16/2011 - 05:19
Hi Sharjith
I'm sorry to reply too late.
I find the way to solve this. First, I erase the Edge object in Facing. Because of this, I can't get the right results. And then, I make a SequenceOfInteractive data in CObjectView at LMouseButton. This means when i click the object, it store in SequeceOfInteractive if Selected object is Face. because, It's very curious that AIS_Shape object in my OperatorCut function doesn't act the specific function as Erase. So Selected object is get by upper data structure.
I appreciate your kind. Have a nice day
PS) Do you know why Erase function in my OperatorCut doesn't act?