mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
OCC22357 Hidden face selection
This commit is contained in:
@@ -305,12 +305,12 @@ void ViewerTest::SetAISContext (const Handle(AIS_InteractiveContext)& aCtx)
|
||||
|
||||
Handle(V3d_Viewer) ViewerTest::GetViewerFromContext()
|
||||
{
|
||||
return TheAISContext()->CurrentViewer();
|
||||
return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
|
||||
}
|
||||
|
||||
Handle(V3d_Viewer) ViewerTest::GetCollectorFromContext()
|
||||
{
|
||||
return TheAISContext()->CurrentViewer();
|
||||
return !TheAISContext().IsNull() ? TheAISContext()->CurrentViewer() : Handle(V3d_Viewer)();
|
||||
}
|
||||
|
||||
|
||||
@@ -2066,7 +2066,7 @@ static int VPerf(Draw_Interpretor& di, Standard_Integer , const char** argv) {
|
||||
// Function : VAnimation
|
||||
//==================================================================================
|
||||
static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char** argv) {
|
||||
if (argc != 5) {
|
||||
if (argc =! 5) {
|
||||
di<<"Use: "<<argv[0]<<" CrankArmFile CylinderHeadFile PropellerFile EngineBlockFile"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
@@ -2580,7 +2580,7 @@ Standard_Boolean ViewerTest::PickObjects(Handle(TColStd_HArray1OfTransient)& ar
|
||||
Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAISContext()->OpenLocalContext();
|
||||
|
||||
// step 1: prepare the data
|
||||
if(curindex != 0){
|
||||
if(curindex !=0){
|
||||
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
|
||||
TheAISContext()->AddFilter(F1);
|
||||
}
|
||||
@@ -2639,7 +2639,7 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
|
||||
|
||||
// step 1: prepare the data
|
||||
|
||||
if(curindex != 0){
|
||||
if(curindex !=0){
|
||||
Handle(AIS_SignatureFilter) F1 = new AIS_SignatureFilter(TheType,TheSignature);
|
||||
TheAISContext()->AddFilter(F1);
|
||||
}
|
||||
@@ -2666,7 +2666,7 @@ Handle(AIS_InteractiveObject) ViewerTest::PickObject(const AIS_KindOfInteractive
|
||||
IO = TheAISContext()->SelectedInteractive();
|
||||
}
|
||||
|
||||
if(curindex != 0)
|
||||
if(curindex!=0)
|
||||
TheAISContext()->CloseLocalContext(curindex);
|
||||
return IO;
|
||||
}
|
||||
@@ -3079,7 +3079,7 @@ static int VIOTypes( Draw_Interpretor& di, Standard_Integer , const char** )
|
||||
|
||||
static int VEraseType( Draw_Interpretor& , Standard_Integer argc, const char** argv)
|
||||
{
|
||||
if(argc != 2) return 1;
|
||||
if(argc!=2) return 1;
|
||||
|
||||
AIS_KindOfInteractive TheType;
|
||||
Standard_Integer TheSign(-1);
|
||||
|
@@ -26,8 +26,10 @@
|
||||
|
||||
#include <OSD_Chronometer.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <Visual3d_View.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <V3d_Plane.hxx>
|
||||
#include <V3d.hxx>
|
||||
|
||||
#include <AIS_Shape.hxx>
|
||||
@@ -2556,6 +2558,180 @@ static int VDrawSphere (Draw_Interpretor& di, Standard_Integer argc, const char*
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===============================================================================================
|
||||
//function : VClipPlane
|
||||
//purpose :
|
||||
//===============================================================================================
|
||||
static int VClipPlane (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
|
||||
Handle(V3d_View) aView = ViewerTest::CurrentView();
|
||||
Standard_Real coeffA, coeffB, coeffC, coeffD;
|
||||
if (aViewer.IsNull() || aView.IsNull())
|
||||
{
|
||||
std::cout << "Viewer not initialized!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// count an active planes count
|
||||
Standard_Integer aNewPlaneId = 1;
|
||||
Standard_Integer anActivePlanes = 0;
|
||||
for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aNewPlaneId)
|
||||
{
|
||||
Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
|
||||
if (aView->IsActivePlane (aPlaneV3d))
|
||||
{
|
||||
++anActivePlanes;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
// just show info about existing planes
|
||||
Standard_Integer aPlaneId = 1;
|
||||
std::cout << "Active planes: " << anActivePlanes << " from maximal " << aView->View()->PlaneLimit() << "\n";
|
||||
for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aPlaneId)
|
||||
{
|
||||
Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
|
||||
aPlaneV3d->Plane (coeffA, coeffB, coeffC, coeffD);
|
||||
gp_Pln aPlane (coeffA, coeffB, coeffC, coeffD);
|
||||
const gp_Pnt& aLoc = aPlane.Location();
|
||||
const gp_Dir& aNor = aPlane.Axis().Direction();
|
||||
Standard_Boolean isActive = aView->IsActivePlane (aPlaneV3d);
|
||||
std::cout << "Plane #" << aPlaneId
|
||||
<< " " << aLoc.X() << " " << aLoc.Y() << " " << aLoc.Z()
|
||||
<< " " << aNor.X() << " " << aNor.Y() << " " << aNor.Z()
|
||||
<< (isActive ? " on" : " off")
|
||||
<< (aPlaneV3d->IsDisplayed() ? ", displayed" : ", hidden")
|
||||
<< "\n";
|
||||
}
|
||||
if (aPlaneId == 1)
|
||||
{
|
||||
std::cout << "No defined clipping planes\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (argc == 2 || argc == 3)
|
||||
{
|
||||
Standard_Integer aPlaneIdToOff = (argc == 3) ? atoi (argv[1]) : 1;
|
||||
Standard_Boolean toIterateAll = (argc == 2);
|
||||
TCollection_AsciiString isOnOffStr ((argc == 3) ? argv[2] : argv[1]);
|
||||
isOnOffStr.LowerCase();
|
||||
Standard_Integer aPlaneId = 1;
|
||||
for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->NextDefinedPlanes(), ++aPlaneId)
|
||||
{
|
||||
if (aPlaneIdToOff == aPlaneId || toIterateAll)
|
||||
{
|
||||
Handle(V3d_Plane) aPlaneV3d = aViewer->DefinedPlane();
|
||||
if (isOnOffStr.Search ("off") >= 0)
|
||||
{
|
||||
aView->SetPlaneOff (aPlaneV3d);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was disabled\n";
|
||||
}
|
||||
else if (isOnOffStr.Search ("on") >= 0)
|
||||
{
|
||||
// avoid z-fighting glitches
|
||||
aPlaneV3d->Erase();
|
||||
if (!aView->IsActivePlane (aPlaneV3d))
|
||||
{
|
||||
if (anActivePlanes < aView->View()->PlaneLimit())
|
||||
{
|
||||
aView->SetPlaneOn (aPlaneV3d);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was enabled\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Maximal active planes limit exceeded (" << anActivePlanes << ")\n"
|
||||
<< "You should disable or remove some existing plane to activate this one\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was already enabled\n";
|
||||
}
|
||||
}
|
||||
else if (isOnOffStr.Search ("del") >= 0 || isOnOffStr.Search ("rem") >= 0)
|
||||
{
|
||||
aPlaneV3d->Erase(); // not performed on destructor!!!
|
||||
aView->SetPlaneOff (aPlaneV3d);
|
||||
aViewer->DelPlane (aPlaneV3d);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was removed\n";
|
||||
if (toIterateAll)
|
||||
{
|
||||
for (aViewer->InitDefinedPlanes(); aViewer->MoreDefinedPlanes(); aViewer->InitDefinedPlanes(), ++aPlaneId)
|
||||
{
|
||||
aPlaneV3d = aViewer->DefinedPlane();
|
||||
aPlaneV3d->Erase(); // not performed on destructor!!!
|
||||
aView->SetPlaneOff (aPlaneV3d);
|
||||
aViewer->DelPlane (aPlaneV3d);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was removed\n";
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (isOnOffStr.Search ("disp") >= 0 || isOnOffStr.Search ("show") >= 0)
|
||||
{
|
||||
// avoid z-fighting glitches
|
||||
aView->SetPlaneOff (aPlaneV3d);
|
||||
aPlaneV3d->Display (aView);
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was shown and disabled\n";
|
||||
}
|
||||
else if (isOnOffStr.Search ("hide") >= 0)
|
||||
{
|
||||
aPlaneV3d->Erase();
|
||||
std::cout << "Clipping plane #" << aPlaneId << " was hidden\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Usage: " << argv[0] << " [x y z dx dy dz] [planeId {on/off/del/display/hide}]\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (aPlaneIdToOff >= aPlaneId && !toIterateAll)
|
||||
{
|
||||
std::cout << "Clipping plane with id " << aPlaneIdToOff << " not found!\n";
|
||||
return 1;
|
||||
}
|
||||
aView->Update();
|
||||
return 0;
|
||||
}
|
||||
else if (argc != 7)
|
||||
{
|
||||
std::cout << "Usage: " << argv[0] << " [x y z dx dy dz] [planeId {on/off/del/display/hide}]\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Standard_Real aLocX = atof (argv[1]);
|
||||
Standard_Real aLocY = atof (argv[2]);
|
||||
Standard_Real aLocZ = atof (argv[3]);
|
||||
Standard_Real aNormDX = atof (argv[4]);
|
||||
Standard_Real aNormDY = atof (argv[5]);
|
||||
Standard_Real aNormDZ = atof (argv[6]);
|
||||
|
||||
Handle(V3d_Plane) aPlaneV3d = new V3d_Plane();
|
||||
gp_Pln aPlane (gp_Pnt (aLocX, aLocY, aLocZ), gp_Dir (aNormDX, aNormDY, aNormDZ));
|
||||
aPlane.Coefficients (coeffA, coeffB, coeffC, coeffD);
|
||||
aPlaneV3d->SetPlane(coeffA, coeffB, coeffC, coeffD);
|
||||
|
||||
aViewer->AddPlane (aPlaneV3d); // add to defined planes list
|
||||
std::cout << "Added clipping plane #" << aNewPlaneId << "\n";
|
||||
if (anActivePlanes < aView->View()->PlaneLimit())
|
||||
{
|
||||
aView->SetPlaneOn (aPlaneV3d); // add to enabled planes list
|
||||
aView->Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Maximal active planes limit exceeded (" << anActivePlanes << ")\n"
|
||||
<< "You should disable or remove some existing plane to activate the new one\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ObjectsCommands
|
||||
@@ -2625,4 +2801,8 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
|
||||
"vdrawsphere: vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]\n",
|
||||
__FILE__,VDrawSphere,group);
|
||||
|
||||
theCommands.Add("vclipplane",
|
||||
"vclipplane : vclipplane [x y z dx dy dz] [planeId {on/off/del/display/hide}]",
|
||||
__FILE__,VClipPlane,group);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user