1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00

0024623: Visualization - improve selection mechanism

Redesign of selection mechanism:
- implemented 3-level BVH tree for selection;
- selection now calculates in 3D space;
- intersection tests were moved to SelectMgr_BaseFrustum descendants;
- removed .cdl files in Select3D and .cdl related to selection in MeshVS;
- SelectMgr_ViewerSelectors are now shared between local and global contexts;
- transformations of sensitive entities are now stored in SelectMgr_SelectableObject only. Sensitive entities are independent from transformations, it is applied to SelectMgr_SelectingVolumeManager instance only;
- connected and multiple connected interactive objects are now represented by their child objects only for SelectMgr_SelectionManager;
- if interactive object has child objects, they will be stored as separate objects in SelectMgr_SelectionManager now.
- test cases bugs/vis/bug24623_1, bug24623_2, bug24623_3, bug24623_4 to test performance and memory issues.
This commit is contained in:
vpa 2015-04-06 12:31:00 +03:00 committed by bugmaster
parent 7a91ad6e81
commit f751596e46
269 changed files with 12626 additions and 11723 deletions

View File

@ -33,15 +33,13 @@ set (Geometry_ISESSION2D_HEADER_FILES ${Geometry_ISESSION2D_DIR}/ISession_Curve.
${Geometry_ISESSION2D_DIR}/ISession_Point.h
${Geometry_ISESSION2D_DIR}/ISession_Surface.h
${Geometry_ISESSION2D_DIR}/ISession_Text.h
${Geometry_ISESSION2D_DIR}/ISession2D_Curve.h
${Geometry_ISESSION2D_DIR}/ISession2D_SensitiveCurve.h)
${Geometry_ISESSION2D_DIR}/ISession2D_Curve.h)
set (Geometry_ISESSION2D_SOURCE_FILES ${Geometry_ISESSION2D_DIR}/ISession_Curve.cpp
${Geometry_ISESSION2D_DIR}/ISession_Direction.cpp
${Geometry_ISESSION2D_DIR}/ISession_Point.cpp
${Geometry_ISESSION2D_DIR}/ISession_Surface.cpp
${Geometry_ISESSION2D_DIR}/ISession_Text.cpp
${Geometry_ISESSION2D_DIR}/ISession2D_Curve.cpp
${Geometry_ISESSION2D_DIR}/ISession2D_SensitiveCurve.cpp)
${Geometry_ISESSION2D_DIR}/ISession2D_Curve.cpp)
set (Geometry_RESOURCE_DIR ${MFC_STANDARD_SAMPLES_DIR}/01_Geometry/res)
set (Geometry_RESOURCE_HEADER ${Geometry_RESOURCE_DIR}/resource.h)

View File

@ -457,24 +457,6 @@
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="..\..\..\src\ISession2D\ISession2D_SensitiveCurve.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Disabled</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">EnableFastChecks</BasicRuntimeChecks>
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</BrowseInformation>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MaxSpeed</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="..\..\..\src\ISession2D\ISession_Curve.cpp">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -588,7 +570,6 @@
<ClInclude Include="..\..\..\src\GeometryView2D.h" />
<ClInclude Include="..\..\..\src\GeomSources.h" />
<ClInclude Include="..\..\..\src\ISession2D\ISession2D_Curve.h" />
<ClInclude Include="..\..\..\src\ISession2D\ISession2D_SensitiveCurve.h" />
<ClInclude Include="..\..\..\src\ISession2D\ISession_Curve.h" />
<ClInclude Include="..\..\..\src\ISession2D\ISession_Direction.h" />
<ClInclude Include="..\..\..\src\ISession2D\ISession_Point.h" />

View File

@ -54,9 +54,6 @@
<ClCompile Include="..\..\..\src\ISession2D\ISession2D_Curve.cpp">
<Filter>Source Files\ISession2d</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\ISession2D\ISession2D_SensitiveCurve.cpp">
<Filter>Source Files\ISession2d</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\ISession2D\ISession_Curve.cpp">
<Filter>Source Files\ISession2d</Filter>
</ClCompile>
@ -106,9 +103,6 @@
<ClInclude Include="..\..\..\src\ISession2D\ISession2D_Curve.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\ISession2D\ISession2D_SensitiveCurve.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\ISession2D\ISession_Curve.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -1,138 +0,0 @@
// Copyright: Matra-Datavision 1995
#include "stdafx.h"
#include <ISession2D_SensitiveCurve.h>
#include <GCPnts_TangentialDeflection.hxx>
#include <SelectBasics_BasicTool.hxx>
IMPLEMENT_STANDARD_HANDLE(ISession2D_SensitiveCurve,Select3D_SensitiveEntity)
IMPLEMENT_STANDARD_RTTIEXT(ISession2D_SensitiveCurve,Select3D_SensitiveEntity)
//=====================================================
// Function : Create
// Purpose :Constructor
//=====================================================
ISession2D_SensitiveCurve::
ISession2D_SensitiveCurve(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom2d_Curve)& C,
const Standard_Real CDeflect,
const Standard_Integer MaxRect):
Select3D_SensitiveEntity(OwnerId),
myMaxRect(MaxRect),
myCurve(C),
myCDeflect(CDeflect)
{
Compute();
}
void ISession2D_SensitiveCurve::Compute()
{
Geom2dAdaptor_Curve Curve (myCurve);
Standard_Real ADeflect = 180; //Angular deflection
GCPnts_TangentialDeflection PointsOnCurve;
PointsOnCurve.Initialize (Curve, ADeflect, myCDeflect,myMaxRect,1.0e-9);
myPolyP2d = new TColgp_HArray1OfPnt2d(1,PointsOnCurve.NbPoints());
gp_Pnt P;
for (Standard_Integer i=1; i<=PointsOnCurve.NbPoints();i++) {
P = PointsOnCurve.Value (i);
myPolyP2d->SetValue(i,gp_Pnt2d(P.X(),P.Y()));
}
}
//=====================================================
// Function : Areas
// Purpose : return the bounding boxes
//=====================================================
void ISession2D_SensitiveCurve::Areas(SelectBasics_ListOfBox2d& boxes)
{
// calcul des Areas --> le nombre voulu est myMaxRect
// mais il y a myPolyP2d->Length() segments
Standard_Integer NbSeg = myPolyP2d->Length()-1;
Standard_Integer nbPerBoxes= NbSeg/myMaxRect;
Standard_Integer CurrentPoint =1;
for (Standard_Integer i=1;i<=myMaxRect-1;i++)
{
Bnd_Box2d abox;
abox.Set(myPolyP2d->Value(CurrentPoint));
for(Standard_Integer j=1;j<=nbPerBoxes;j++)
{
CurrentPoint++;
abox.Add(myPolyP2d->Value(CurrentPoint));
}
boxes.Append(abox);
}
Bnd_Box2d abox;
abox.Set(myPolyP2d->Value(CurrentPoint));
for(Standard_Integer j=CurrentPoint;j<=myPolyP2d->Length()-1;j++)
{
CurrentPoint++;
abox.Add(myPolyP2d->Value(CurrentPoint));
}
boxes.Append(abox);
}
//=======================================================
// Function : Matches
// Purpose : test : segments in the bounding boxe
//=======================================================
Standard_Boolean ISession2D_SensitiveCurve::
Matches (const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
Bnd_Box2d BoundBox;
BoundBox.Update(XMin-aTol,YMin-aTol,XMax+aTol,YMax+aTol);
for(Standard_Integer j=1;j<=myPolyP2d->Length()-1;j++)
{
if(BoundBox.IsOut(myPolyP2d->Value(j))) return Standard_False;
}
return Standard_True;
}
//====================================================
// Function : Matches
// Purpose : test the real dist to the segments
//====================================================
Standard_Boolean ISession2D_SensitiveCurve::
Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
// VERY VERY IMPORTANT : set the selector sensibility !!! ( it's aTol !! )
Standard_Integer Rank=0; // New in 2.0
if (aTol == 0) {TRACE0("VERY VERY IMPORTANT : set the selector sensibility !!! ( it's aTol !! )");}
Standard_Boolean Result = SelectBasics_BasicTool::MatchPolyg2d(myPolyP2d->Array1(),
X,Y,
aTol,
DMin,
Rank); // new in 2.0
return Result;
}
Handle(TColgp_HArray1OfPnt2d) ISession2D_SensitiveCurve::
SensitivePolygon()
{
return myPolyP2d;
}

View File

@ -1,86 +0,0 @@
// File generated by CPPExt (Transient)
//
// Copyright (C) 1991,1995 by
//
// MATRA DATAVISION, FRANCE
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of the above copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any other person. No title to an ownership of the
// software is hereby transferred.
//
// At the termination of the contract, the software and all copies of this
// software must be deleted.
//
#ifndef _ISession2D_SensitiveCurve_HeaderFile
#define _ISession2D_SensitiveCurve_HeaderFile
#include <Standard_Macro.hxx>
#include <Standard_DefineHandle.hxx>
#include <Standard_Integer.hxx>
#include <gp_Pnt2d.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
class SelectBasics_EntityOwner;
class gp_Pnt2d;
#include <SelectBasics_ListOfBox2d.hxx>
#include "TColgp_HArray1OfPnt2d.hxx"
#include <Geom2d_Curve.hxx>
DEFINE_STANDARD_HANDLE(ISession2D_SensitiveCurve,Select3D_SensitiveEntity)
class ISession2D_SensitiveCurve : public Select3D_SensitiveEntity {
public:
// Methods PUBLIC
//
Standard_EXPORT ISession2D_SensitiveCurve(const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(Geom2d_Curve)& C,
const Standard_Real CDeflect,
const Standard_Integer MaxRect = 3);
inline void SetMaxBoxes(const Standard_Integer MaxRect) ;
inline virtual Standard_Integer MaxBoxes() const;
inline void SetCurve(const Handle(Geom2d_Curve) aCurve) ;
inline Handle(Geom2d_Curve) GetCurve() ;
void Compute();
Standard_EXPORT void Areas(SelectBasics_ListOfBox2d& aSeq) ;
Standard_EXPORT Standard_Boolean Matches(const Standard_Real XMin,const Standard_Real YMin,const Standard_Real XMax,const Standard_Real YMax,const Standard_Real aTol) ;
Standard_EXPORT Standard_Boolean Matches(const Standard_Real X,const Standard_Real Y,const Standard_Real aTol,Standard_Real& DMin) ;
Handle(TColgp_HArray1OfPnt2d) SensitivePolygon();
DEFINE_STANDARD_RTTI(ISession2D_SensitiveCurve)
private:
// Fields PRIVATE
//
Standard_Real myCDeflect;
Standard_Integer myMaxRect;
Handle(Geom2d_Curve) myCurve;
Handle(TColgp_HArray1OfPnt2d) myPolyP2d;
};
inline Standard_Integer ISession2D_SensitiveCurve::
MaxBoxes() const {return myMaxRect;}
inline void ISession2D_SensitiveCurve::
SetMaxBoxes(const Standard_Integer nbrect)
{myMaxRect = nbrect;}
inline void ISession2D_SensitiveCurve::
SetCurve(const Handle(Geom2d_Curve) aCurve)
{myCurve = aCurve;}
inline Handle(Geom2d_Curve) ISession2D_SensitiveCurve::
GetCurve()
{return myCurve;}
#endif

View File

@ -229,7 +229,6 @@
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_SelectionManager.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <ShapeFix_Shape.hxx>
#include <StdSelect_ViewerSelector3d.hxx>

View File

@ -127,8 +127,6 @@
#include <Quantity_Factor.hxx>
#include <Quantity_Length.hxx>
#include <Quantity_PlaneAngle.hxx>
#include <SelectBasics_ListOfBox2d.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_SelectableObject.hxx>

View File

@ -846,10 +846,10 @@ void CViewer3dView::DrawRectangle(const Standard_Integer MinX ,
m_IsVisible = false;
}
StoredMinX = min ( MinX, MaxX );
StoredMinY = min ( MinY, MaxY );
StoredMaxX = max ( MinX, MaxX );
StoredMaxY = max ( MinY, MaxY);
StoredMinX = Min ( MinX, MaxX );
StoredMinY = Min ( MinY, MaxY );
StoredMaxX = Max ( MinX, MaxX );
StoredMaxY = Max ( MinY, MaxY);
if (Draw) // move : draw
{

View File

@ -99,8 +99,6 @@
#include <Quantity_PhysicalQuantity.hxx>
#include <Quantity_PlaneAngle.hxx>
#include <Quantity_TypeOfColor.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <SelectBasics_ListOfBox2d.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>

View File

@ -96,8 +96,6 @@
#include <Quantity_PhysicalQuantity.hxx>
#include <Quantity_PlaneAngle.hxx>
#include <Quantity_TypeOfColor.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <SelectBasics_ListOfBox2d.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>

View File

@ -153,8 +153,6 @@
#include <Quantity_PhysicalQuantity.hxx>
#include <Quantity_PlaneAngle.hxx>
#include <Quantity_TypeOfColor.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <SelectBasics_ListOfBox2d.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>

View File

@ -680,10 +680,10 @@ void CAnimationView3D::DrawRectangle(const Standard_Integer MinX ,
m_IsVisible = false;
}
StoredMinX = min ( MinX, MaxX );
StoredMinY = min ( MinY, MaxY );
StoredMaxX = max ( MinX, MaxX );
StoredMaxY = max ( MinY, MaxY);
StoredMinX = Min ( MinX, MaxX );
StoredMinY = Min ( MinY, MaxY );
StoredMaxX = Max ( MinX, MaxX );
StoredMaxY = Max ( MinY, MaxY);
if (Draw) // move : draw
{

View File

@ -164,8 +164,6 @@ enum CurrentAction3d {
#include <Quantity_PhysicalQuantity.hxx>
#include <Quantity_PlaneAngle.hxx>
#include <Quantity_TypeOfColor.hxx>
#include <SelectBasics_BasicTool.hxx>
#include <SelectBasics_ListOfBox2d.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>

View File

@ -450,10 +450,10 @@ void COCCDemoView::DrawRectangle(const Standard_Integer MinX,
m_IsVisible = false;
}
StoredMinX = min ( MinX, MaxX );
StoredMinY = min ( MinY, MaxY );
StoredMaxX = max ( MinX, MaxX );
StoredMaxY = max ( MinY, MaxY);
StoredMinX = Min ( MinX, MaxX );
StoredMinY = Min ( MinY, MaxY );
StoredMaxX = Max ( MinX, MaxX );
StoredMaxY = Max ( MinY, MaxY);
if (Draw) // move : draw
{

View File

@ -594,10 +594,10 @@ void OCC_2dView::DrawRectangle2D(const Standard_Integer MinX,
m_IsVisible = false;
}
StoredMinX = min ( MinX, MaxX );
StoredMinY = min ( MinY, MaxY );
StoredMaxX = max ( MinX, MaxX );
StoredMaxY = max ( MinY, MaxY);
StoredMinX = Min ( MinX, MaxX );
StoredMinY = Min ( MinY, MaxY );
StoredMaxX = Max ( MinX, MaxX );
StoredMaxY = Max ( MinY, MaxY);
if (Draw) // move : draw
{

View File

@ -542,10 +542,10 @@ void OCC_3dView::DrawRectangle(const Standard_Integer MinX ,
m_IsVisible = false;
}
StoredMinX = min ( MinX, MaxX );
StoredMinY = min ( MinY, MaxY );
StoredMaxX = max ( MinX, MaxX );
StoredMaxY = max ( MinY, MaxY);
StoredMinX = Min ( MinX, MaxX );
StoredMinY = Min ( MinY, MaxY );
StoredMaxX = Max ( MinX, MaxX );
StoredMaxY = Max ( MinY, MaxY);
if (Draw) // move : draw
{

View File

@ -83,7 +83,6 @@
#include <Prs3d_TextAspect.hxx>
#include <Prs3d_Text.hxx>
#include <Select3D_ListOfSensitive.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveGroup.hxx>

View File

@ -23,6 +23,7 @@
#include <Graphic3d_Structure.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <StdPrs_Curve.hxx>

View File

@ -25,6 +25,7 @@
#include <Prs3d_Drawer.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <TopoDS.hxx>

View File

@ -25,6 +25,7 @@
#include <Prs3d_Drawer.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <TopoDS.hxx>

View File

@ -22,6 +22,7 @@
#include <Graphic3d_Structure.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <StdPrs_DeflectionCurve.hxx>
#include <TopoDS.hxx>

View File

@ -19,6 +19,7 @@
#include <AIS_ConcentricRelation.ixx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitiveSegment.hxx>

View File

@ -18,6 +18,7 @@
#include <AIS_ConnectedInteractive.ixx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <Geom_Transformation.hxx>
@ -287,31 +288,30 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio
if (!myReference->HasSelection (theMode))
{
myReference->UpdateSelection (theMode);
myReference->RecomputePrimitives (theMode);
}
const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection (theMode);
Handle(SelectMgr_EntityOwner) anOwner = new SelectMgr_EntityOwner (this);
Handle(Select3D_SensitiveEntity) aSensitive, aNewSensitive;
TopLoc_Location aLocation (Transformation());
anOwner->SetLocation (aLocation);
if (TheRefSel->IsEmpty())
{
myReference->UpdateSelection (theMode);
myReference->RecomputePrimitives (theMode);
}
for (TheRefSel->Init(); TheRefSel->More(); TheRefSel->Next())
{
aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (TheRefSel->Sensitive());
aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (TheRefSel->Sensitive()->BaseSensitive());
if (!aSensitive.IsNull())
{
TopLoc_Location aLocation (Transformation());
// Get the copy of SE3D
aNewSensitive = aSensitive->GetConnected (aLocation);
aNewSensitive = aSensitive->GetConnected();
aNewSensitive->Set(anOwner);
// In case if SE3D caches some location-dependent data
// that must be updated after setting OWN
aNewSensitive->SetLocation (aLocation);
theSelection->Add (aNewSensitive);
}
@ -330,13 +330,13 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
Shapes2EntitiesMap;
if (!myReference->HasSelection (theMode))
myReference->UpdateSelection (theMode);
myReference->RecomputePrimitives (theMode);
const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode);
if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full)
{
myReference->UpdateSelection (theMode);
myReference->RecomputePrimitives (theMode);
}
Handle(StdSelect_BRepOwner) anOwner;
@ -352,7 +352,7 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
// sensitive entities associated with aMode
for (aRefSel->Init(); aRefSel->More(); aRefSel->Next())
{
aSE = Handle(Select3D_SensitiveEntity)::DownCast (aRefSel->Sensitive());
aSE = Handle(Select3D_SensitiveEntity)::DownCast (aRefSel->Sensitive()->BaseSensitive());
if(!aSE.IsNull())
{
anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId());
@ -376,17 +376,14 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_
this,
aSEList.First()->OwnerId()->Priority(),
Standard_True);
anOwner->SetLocation (Transformation());
for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next())
{
{
aSE = aListIt.Value();
TopLoc_Location aLocation (Transformation());
aNewSE = aSE->GetConnected (aDummyLoc);
aNewSE = aSE->GetConnected();
aNewSE->Set (anOwner);
// In case if aSE caches some location-dependent data
// that must be updated after setting anOwner
aNewSE->SetLocation (aLocation);
theSelection->Add (aNewSE);
}

View File

@ -50,8 +50,6 @@
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_SequenceOfOwner.hxx>
#include <Select3D_ListIteratorOfListOfSensitive.hxx>
#include <Select3D_ListOfSensitive.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitiveGroup.hxx>
#include <Select3D_SensitiveCurve.hxx>

View File

@ -32,7 +32,6 @@
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_TextAspect.hxx>
#include <Select3D_ListOfSensitive.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard.hxx>
#include <TCollection_ExtendedString.hxx>

View File

@ -26,6 +26,7 @@
#include <Geom_Circle.hxx>
#include <ElCLib.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Precision.hxx>

View File

@ -23,6 +23,7 @@
#include <TopAbs_ShapeEnum.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <BRep_Tool.hxx>

View File

@ -40,6 +40,7 @@
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <TColStd_ListIteratorOfListOfTransient.hxx>

View File

@ -427,43 +427,16 @@ is
---Purpose:
-- Removes selection mode from Interactive Objects.
-- aMode provides the selection mode index of the entity aniobj.
SetSensitivityMode(me : mutable;
aMode : SensitivityMode from StdSelect) is static;
---Level: Public
---Purpose: Sets the selection sensitivity mode. SM_WINDOW mode
-- uses the specified pixel tolerance to compute the sensitivity
-- value, SM_VIEW mode allows to define the sensitivity manually.
SensitivityMode(me) returns SensitivityMode from StdSelect;
---Level: Public
---Purpose: Returns the selection sensitivity mode.
SetSensitivity(me:mutable;
aPrecision: Real from Standard);
---Level: Public
---Purpose: Sets the sensitivity aPrecision
-- according to the view size for the current context or local
-- context if any is activated.
-- Sets the sensitivity aPrecision in pixels for the current context
-- or local context if any is activated. By default, this
-- sensitivity is equal to 4 pixels.
-- When a local context is open, the defined sensitivity applies to
-- this local context instead of the main context.
Sensitivity (me) returns Real from Standard;
---Level: Public
---Purpose: Returns the selection sensitivity value.
SetPixelTolerance(me:mutable;
aPrecision: Integer from Standard = 4);
aPrecision: Real from Standard = 4.0);
---Level: Public
---Purpose: Define the current selection pixel sensitivity
-- for this context or local context if any one is activated.
-- Warning: When a local context is open the sensitivity is apply on it
-- instead on the main context.
PixelTolerance(me) returns Integer from Standard;
PixelTolerance(me) returns Real from Standard;
---Level: Public
---Purpose: Returns the pixel tolerance.
@ -1668,9 +1641,10 @@ is
ZDetection(me) returns Boolean;
---Purpose: Retrieves the Z detection state.
Activate(me : mutable;
anIobj : InteractiveObject from AIS;
aMode : Integer from Standard = 0);
Activate(me : mutable;
anIobj : InteractiveObject from AIS;
aMode : Integer from Standard = 0;
theIsForce : Boolean from Standard = Standard_False);
---Purpose: Activates the selection mode aMode whose index is
-- given, for the given interactive entity anIobj.
@ -1947,10 +1921,10 @@ is
---C++: inline
---C++: return const &
MainSelector(me) returns any ViewerSelector3d from StdSelect;
MainSelector(me) returns ViewerSelector3d from StdSelect;
---C++: inline
---C++: return const &
LocalSelector(me) returns any ViewerSelector3d from StdSelect;
LocalSelector(me) returns ViewerSelector3d from StdSelect;
PurgeDisplay(me:mutable)
returns Integer from Standard;
@ -1962,12 +1936,6 @@ is
HighestIndex(me) returns Integer from Standard;
DisplayActiveAreas(me:mutable;aView:View from V3d) ;
ClearActiveAreas (me :mutable;
aView: View from V3d) is static;
---Level: Internal
DisplayActiveSensitive(me:mutable;aView : View from V3d) is static;
@ -1978,9 +1946,6 @@ is
DisplayActiveSensitive(me:mutable;
anObject: InteractiveObject from AIS;
aView : View from V3d) is static;
DisplayActiveAreas(me:mutable;
anObject: InteractiveObject from AIS;
aView : View from V3d) is static;
GetDefModes(me;
anIobj : InteractiveObject from AIS;
@ -2010,6 +1975,8 @@ is
---Purpose: returns if possible,
-- the first local context where the object is seen
RebuildSelectionStructs (me : mutable);
---Purpose: Rebuilds 1st level of BVH selection forcibly
SetViewAffinity (me : mutable;
theIObj : InteractiveObject from AIS;
theView : View from V3d;
@ -2017,6 +1984,12 @@ is
---Purpose: setup object visibility in specified view,
-- has no effect if object is not disaplyed in this context.
Disconnect (me : mutable;
theAssembly : InteractiveObject from AIS;
theObjToDisconnect : InteractiveObject from AIS = NULL)
is static;
---Purpose: Disconnects theObjToDisconnect from theAssembly and removes dependent selection structures
ObjectsForView (me;
theListOfIO : in out ListOfInteractive from AIS;
theView : View from V3d;

View File

@ -43,6 +43,7 @@
#include <Prs3d_PlaneAspect.hxx>
#include <PrsMgr_PresentableObject.hxx>
#include <Standard_Atomic.hxx>
#include <StdSelect_ViewerSelector3d.hxx>
#include <UnitsAPI.hxx>
#include <AIS_Trihedron.hxx>
@ -2364,6 +2365,9 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t
if (theIObj.IsNull()
|| !myObjects.IsBound (theIObj))
{
// for cases when reference shape of connected interactives was not displayed
// but its selection primitives were calculated
mgrSelector->Remove (theIObj);
return;
}
@ -2584,65 +2588,11 @@ void AIS_InteractiveContext::UnsetSelectionMode (const Handle(AIS_InteractiveObj
//
}
//=======================================================================
//function : SetSensitivityMode
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetSensitivityMode (const StdSelect_SensitivityMode theMode)
{
if (HasOpenedContext())
{
myLocalContexts (myCurLocalIndex)->SetSensitivityMode (theMode);
}
else
{
myMainSel->SetSensitivityMode (theMode);
}
}
//=======================================================================
//function : SensitivityMode
//purpose :
//=======================================================================
StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const
{
return HasOpenedContext()
? myLocalContexts (myCurLocalIndex)->SensitivityMode()
: myMainSel->SensitivityMode();
}
//=======================================================================
//function : SetSensitivity
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetSensitivity (const Standard_Real thePrecision)
{
if (HasOpenedContext())
{
myLocalContexts(myCurLocalIndex)->SetSensitivity (thePrecision);
}
else
{
myMainSel->SetSensitivity (thePrecision);
}
}
//=======================================================================
//function : Sensitivity
//purpose :
//=======================================================================
Standard_Real AIS_InteractiveContext::Sensitivity() const
{
return HasOpenedContext()
? myLocalContexts(myCurLocalIndex)->Sensitivity()
: myMainSel->Sensitivity();
}
//=======================================================================
//function : SetPixelTolerance
//purpose :
//=======================================================================
void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision)
void AIS_InteractiveContext::SetPixelTolerance (const Standard_Real thePrecision)
{
if (HasOpenedContext())
{
@ -2658,7 +2608,7 @@ void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecis
//function : PixelTolerance
//purpose :
//=======================================================================
Standard_Integer AIS_InteractiveContext::PixelTolerance() const
Standard_Real AIS_InteractiveContext::PixelTolerance() const
{
return HasOpenedContext()
? myLocalContexts (myCurLocalIndex)->PixelTolerance()
@ -2836,3 +2786,37 @@ Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_Interactive
? theIObj->ZLayer()
: Graphic3d_ZLayerId_UNKNOWN;
}
//=======================================================================
//function : RebuildSelectionStructs
//purpose : Rebuilds 1st level of BVH selection forcibly
//=======================================================================
void AIS_InteractiveContext::RebuildSelectionStructs()
{
myMainSel->RebuildObjectsTree (Standard_True);
}
//=======================================================================
//function : Disconnect
//purpose : Disconnects selectable object from an assembly and updates selection structures
//=======================================================================
void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly,
const Handle(AIS_InteractiveObject)& theObjToDisconnect)
{
if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive"))
{
const Handle(AIS_MultipleConnectedInteractive)& theObj =
Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly);
theObj->Disconnect (theObjToDisconnect);
mgrSelector->Remove (theObjToDisconnect);
}
else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect == NULL)
{
const Handle(AIS_ConnectedInteractive)& theObj =
Handle(AIS_ConnectedInteractive)::DownCast (theAssembly);
theObj->Disconnect();
mgrSelector->Remove (theObj);
}
else
return;
}

View File

@ -16,6 +16,7 @@
#include <AIS_InteractiveContext.jxx>
#include <SelectMgr_EntityOwner.hxx>
#include <StdSelect_ViewerSelector3d.hxx>
#include <AIS_Selection.hxx>
#include <AIS_StatusOfDetection.hxx>
#include <AIS_StatusOfPick.hxx>
@ -1098,11 +1099,11 @@ void AIS_InteractiveContext::EntityOwners(SelectMgr_IndexedMapOfOwner& theOwners
if ( !theIObj->HasSelection( aMode ) )
continue;
Handle(SelectMgr_Selection) aSel = theIObj->Selection( aMode );
Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
for ( aSel->Init(); aSel->More(); aSel->Next() )
{
Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive();
Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
if ( aEntity.IsNull() )
continue;

View File

@ -29,6 +29,8 @@
#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
#include <AIS_Selection.hxx>
#include <StdSelect_ViewerSelector3d.hxx>
//=======================================================================
//function : OpenLocalContext
//purpose :
@ -59,10 +61,6 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
myLastPicked.Nullify();
myWasLastMain = Standard_True;
Standard_Integer untilnow = myCurLocalIndex;
myCurLocalIndex = HighestIndex() + 1;
Handle(AIS_LocalContext) NewLocal= new AIS_LocalContext(this,myCurLocalIndex,
@ -72,12 +70,6 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
// the AIS_LocalContext bind itself to myLocalContexts
// because procedures performed in AIS_LocalContext constructor
// already may access myLocalContexts(myCurLocalIndex) (like methods AIS_LocalContext::IsSelected()).
//myLocalContexts.Bind (myCurLocalIndex, NewLocal);
NewLocal->MainSelector()->Set ((myLocalContexts.Extent() > 1)
? myLocalContexts (untilnow)->MainSelector()->Projector()
: myMainSel->Projector());
NewLocal->MainSelector()->UpdateConversion();
#ifdef OCCT_DEBUG
cout<<"\tOpen Local Context No "<<myCurLocalIndex<<endl;
@ -123,17 +115,11 @@ void AIS_InteractiveContext::CloseLocalContext(const Standard_Integer Index,
// the only open local context is closed...
if(myLocalContexts.Extent()==1 && GoodIndex == myCurLocalIndex){
Standard_Boolean updateproj = !(myLocalContexts(myCurLocalIndex)->HasSameProjector(myMainSel->Projector()));
myLocalContexts(myCurLocalIndex)->Terminate( updateviewer );
myLocalContexts.UnBind(myCurLocalIndex);
myCurLocalIndex = 0;
ResetOriginalState(Standard_False);
if(updateproj)
myMainSel->UpdateConversion();
else{
myMainSel->UpdateSort();
}
if(debugmode)
cout<<"No More Opened Local Context "<<endl;
}
@ -146,11 +132,6 @@ void AIS_InteractiveContext::CloseLocalContext(const Standard_Integer Index,
// the current is closed...
if(GoodIndex==myCurLocalIndex){
myCurLocalIndex = HighestIndex();
const Handle(AIS_LocalContext)& LocCtx = myLocalContexts(myCurLocalIndex);
if (!LocCtx->HasSameProjector (VS->Projector()))
{
LocCtx->MainSelector()->UpdateConversion();
}
}
else if(debugmode)
cout<<"a No Current Local Context WasClosed"<<endl;
@ -177,7 +158,6 @@ void AIS_InteractiveContext::CloseAllContexts(const Standard_Boolean updateviewe
ResetOriginalState(Standard_False);
myMainSel->UpdateSort();
if(updateviewer) myMainVwr->Update();
}
@ -226,12 +206,13 @@ Standard_Integer AIS_InteractiveContext::HighestIndex() const
void AIS_InteractiveContext::
Activate(const Handle(AIS_InteractiveObject)& anIObj,
const Standard_Integer aMode)
const Standard_Integer aMode,
const Standard_Boolean theIsForce)
{
if(!HasOpenedContext()){
if(!myObjects.IsBound(anIObj)) return;
const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
if(STAT->GraphicStatus()==AIS_DS_Displayed)
if(STAT->GraphicStatus()==AIS_DS_Displayed || theIsForce)
mgrSelector->Activate(anIObj,aMode,myMainSel);
STAT ->AddSelectionMode(aMode);
}
@ -570,31 +551,6 @@ const SelectMgr_ListOfFilter& AIS_InteractiveContext::Filters() const
return myFilters->StoredFilters();
}
//=======================================================================
//function : DisplayActiveAreas
//purpose :
//=======================================================================
void AIS_InteractiveContext::DisplayActiveAreas(const Handle(V3d_View)& aviou)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->DisplayAreas(aviou);
else
myMainSel->DisplayAreas(aviou);
}
//=======================================================================
//function : ClearActiveAreas
//purpose :
//=======================================================================
void AIS_InteractiveContext::ClearActiveAreas(const Handle(V3d_View)& aviou)
{
if(HasOpenedContext())
myLocalContexts(myCurLocalIndex)->ClearAreas(aviou);
else
myMainSel->ClearAreas(aviou);
}
//=======================================================================
//function : DisplayActiveSensitive
//purpose :
@ -631,41 +587,11 @@ void AIS_InteractiveContext::DisplayActiveSensitive(const Handle(AIS_Interactive
for(;It.More();It.Next()){
const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value());
VS->DisplaySensitive(Sel,aviou,Standard_False);
VS->DisplaySensitive(Sel,anIObj->Transformation(), aviou,Standard_False);
}
}
//=======================================================================
//function : DisplayActiveAreas
//purpose :
//=======================================================================
void AIS_InteractiveContext::DisplayActiveAreas(const Handle(AIS_InteractiveObject)& anIObj,
const Handle(V3d_View)& aviou)
{
TColStd_ListIteratorOfListOfInteger It;
Handle(StdSelect_ViewerSelector3d) VS;
if(HasOpenedContext()){
const Handle(AIS_LocalContext)& LC = myLocalContexts(myCurLocalIndex);
if(!LC->IsIn(anIObj)) return;
It.Initialize(LC->SelectionModes(anIObj));
VS = LC->MainSelector();
}
else{
if(!myObjects.IsBound(anIObj)) return;
It.Initialize(myObjects(anIObj)->SelectionModes());
VS = myMainSel;
}
for(;It.More();It.Next()){
const Handle(SelectMgr_Selection)& Sel = anIObj->Selection(It.Value());
VS->DisplayAreas(Sel,aviou,Standard_False);
}
}
//=======================================================================
//function : ClearActiveSensitive
//purpose :
@ -848,6 +774,7 @@ void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updatevie
{
Standard_Boolean upd_main(Standard_False);
TColStd_ListIteratorOfListOfInteger itl;
myMainSel->ResetSelectionActivationStatus();
for (AIS_DataMapIteratorOfDataMapOfIOStatus it(myObjects);it.More();it.Next()){
const Handle(AIS_InteractiveObject)& iobj = it.Key();

View File

@ -581,6 +581,12 @@ is
---Purpose: Retrieves current polygon offsets settings from <myDrawer>.
---Category: Inquire methods
BoundingBox (me : mutable;
theBndBox : out Box from Bnd)
is redefined;
---Level: Public
---Purpose: Returns bounding box of object correspondingly to its current display mode.
fields
myCTXPtr : PToContext from AIS;

View File

@ -33,6 +33,8 @@
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_BndBox4f.hxx>
#include <Graphic3d_CStructure.hxx>
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Structure.hxx>
@ -586,3 +588,62 @@ void AIS_InteractiveObject::PolygonOffsets(Standard_Integer& aMode,
if( HasPolygonOffsets() )
myDrawer->ShadingAspect()->Aspect()->PolygonOffsets( aMode, aFactor, aUnits );
}
//=======================================================================
//function : BoundingBox
//purpose : Returns bounding box of object correspondingly to its
// current display mode
//=======================================================================
void AIS_InteractiveObject::BoundingBox (Bnd_Box& theBndBox)
{
if (myDisplayMode == -1)
{
if (!myPresentations.IsEmpty())
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations.First().Presentation();
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
const Graphic3d_BndBox4f& aBndBox = aStruct->CStructure()->BoundingBox();
theBndBox.Update (static_cast<Standard_Real> (aBndBox.CornerMin().x()),
static_cast<Standard_Real> (aBndBox.CornerMin().y()),
static_cast<Standard_Real> (aBndBox.CornerMin().z()),
static_cast<Standard_Real> (aBndBox.CornerMax().x()),
static_cast<Standard_Real> (aBndBox.CornerMax().y()),
static_cast<Standard_Real> (aBndBox.CornerMax().z()));
return;
}
else
{
for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (Children()); aPrsIter.More(); aPrsIter.Next())
{
const Handle(AIS_InteractiveObject)& aChild = Handle(AIS_InteractiveObject)::DownCast (aPrsIter.Value());
if (aChild.IsNull())
{
continue;
}
Bnd_Box aBox;
aChild->BoundingBox (aBox);
theBndBox.Add (aBox);
}
return;
}
}
else
{
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)
{
if (myPresentations (aPrsIter).Mode() == myDisplayMode)
{
const Handle(PrsMgr_Presentation)& aPrs3d = myPresentations (aPrsIter).Presentation();
const Handle(Graphic3d_Structure)& aStruct = aPrs3d->Presentation();
const Graphic3d_BndBox4f& aBndBox = aStruct->CStructure()->BoundingBox();
theBndBox.Update (static_cast<Standard_Real> (aBndBox.CornerMin().x()),
static_cast<Standard_Real> (aBndBox.CornerMin().y()),
static_cast<Standard_Real> (aBndBox.CornerMin().z()),
static_cast<Standard_Real> (aBndBox.CornerMax().x()),
static_cast<Standard_Real> (aBndBox.CornerMax().y()),
static_cast<Standard_Real> (aBndBox.CornerMax().z()));
return;
}
}
}
}

View File

@ -23,6 +23,7 @@
#include <Graphic3d_Structure.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <StdPrs_Curve.hxx>
#include <Geom_Line.hxx>

View File

@ -51,7 +51,6 @@ uses
Shape from TopoDS,
View from V3d,
PresentationManager3d from PrsMgr,
Projector from Select3D,
IndexedMapOfOwner from SelectMgr,
EntityOwner from SelectMgr,
OrFilter from SelectMgr,
@ -105,14 +104,6 @@ is
Terminate(me: mutable; updateviewer : Boolean from Standard = Standard_True);
HasSameProjector(me;aPrj:Projector from Select3D)
returns Boolean from Standard;
---Purpose: compares the current projector of the localContext
-- with <aPrj>
-- returns True if the projectors are identical.
-- (no need to update projection of selection primitives
-- when closing the local context)....
Reactivate(me:mutable);
---Purpose: to be called when a upper local context was closed...
-- useful to put pack the right projector...
@ -445,35 +436,14 @@ is
WithColor : out Boolean from Standard;
HiCol : out NameOfColor from Quantity)
returns Boolean from Standard;
SetSensitivityMode(me : mutable;
aMode : SensitivityMode from StdSelect) is static;
---Level: Public
---Purpose: Sets the selection sensitivity mode. SM_WINDOW mode
-- uses the specified pixel tolerance to compute the sensitivity
-- value, SM_VIEW mode allows to define the sensitivity manually.
SensitivityMode(me) returns SensitivityMode from StdSelect;
---Level: Public
---Purpose: Returns the selection sensitivity mode.
SetSensitivity(me:mutable;
aPrecision: Real from Standard);
---Level: Public
---Purpose: Define the current selection sensitivity for
-- this local context according to the view size.
Sensitivity (me) returns Real from Standard;
---Level: Public
---Purpose: Returns the selection sensitivity value.
SetPixelTolerance(me:mutable;
aPrecision: Integer from Standard = 2);
aPrecision: Real from Standard = 2);
---Level: Public
---Purpose: Define the current selection sensitivity for
-- this local context according to the view size.
PixelTolerance(me) returns Integer from Standard;
PixelTolerance(me) returns Real from Standard;
---Level: Public
---Purpose: Returns the pixel tolerance.
@ -505,11 +475,6 @@ is
---Category: INTERNAL METHODS;
UpdateConversion(me:mutable);
UpdateSort(me:mutable);
Status(me) returns AsciiString from TCollection is private;
@ -524,15 +489,12 @@ is
UnloadContextObjects(me:mutable);
Process(me : mutable;
anObject : SelectableObject from SelectMgr;
WithProj: Boolean from Standard = Standard_True) is static private;
anObject : SelectableObject from SelectMgr) is static private;
Process(me:mutable;
WithProj: Boolean from Standard = Standard_True) is static private;
Process(me:mutable) is static private;
ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr;
WithProj: Boolean from Standard = Standard_True) is static private;
ActivateStandardModes(me:mutable;anObject: SelectableObject from SelectMgr) is static private;
manageDetected (me : mutable;
thePickOwner : EntityOwner from SelectMgr;
@ -566,13 +528,6 @@ is
ComesFromDecomposition(me; aPickedIndex : Integer from Standard)
returns Boolean from Standard is static private;
DisplayAreas(me:mutable;aviou:View from V3d);
ClearAreas (me:mutable;
aView: View from V3d) is static;
---Level: Internal
HasFilters(me;aType:ShapeEnum from TopAbs)
returns Boolean from Standard is private;
@ -580,7 +535,7 @@ is
ClearSensitive(me:mutable;aView:View from V3d) is static;
MainSelector(me) returns any ViewerSelector3d from StdSelect;
MainSelector(me) returns ViewerSelector3d from StdSelect;
---C++: inline
---C++: return const&

View File

@ -33,6 +33,7 @@
#include <Prs3d_Presentation.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <StdSelect_ShapeTypeFilter.hxx>
#include <StdSelect_ViewerSelector3d.hxx>
#include <AIS_Selection.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
@ -70,7 +71,7 @@ myLoadDisplayed(LoadDisplayed),
myAcceptStdMode(AcceptStandardModes),
myAcceptErase(AcceptEraseOfTemp),
mySM(aCtx->SelectionManager()),
myMainVS(new StdSelect_ViewerSelector3d(aCtx->MainSelector()->Projector())),
myMainVS(aCtx->MainSelector()),
myFilters(new SelectMgr_OrFilter()),
myAutoHilight(Standard_True),
mylastindex(0),
@ -84,13 +85,14 @@ myAISCurDetected(0)
// created and mapped.
aCtx->myLocalContexts.Bind (Index, this);
myMainVS->ResetSelectionActivationStatus();
myMainPM = aCtx->MainPrsMgr();
mySelName = AIS_Local_SelName(this, Index);
AIS_Selection::CreateSelection(mySelName.ToCString());
mySM->Add(myMainVS);
if(myLoadDisplayed) LoadContextObjects();
Process(Standard_False);
Process();
}
@ -195,7 +197,24 @@ Load(const Handle(AIS_InteractiveObject)& anInteractive,
const Standard_Boolean AllowShapeDecomposition,
const Standard_Integer ActivationMode)
{
if(myActiveObjects.IsBound(anInteractive)) return Standard_False;
if (myActiveObjects.IsBound (anInteractive))
{
if (anInteractive->HasSelection (ActivationMode))
{
const Handle(SelectMgr_Selection)& aSel = anInteractive->Selection (ActivationMode);
if (aSel->GetSelectionState() != SelectMgr_SOS_Activated)
{
if (!myMainVS->Contains (anInteractive))
{
mySM->Load (anInteractive, myMainVS);
}
mySM->Activate (anInteractive, ActivationMode, myMainVS);
return Standard_True;
}
}
return Standard_False;
}
Handle(AIS_LocalStatus) Att = new AIS_LocalStatus();
if(anInteractive->AcceptShapeDecomposition() && AllowShapeDecomposition)
@ -296,8 +315,6 @@ Erase(const Handle(AIS_InteractiveObject)& anInteractive)
}
}
UpdateSort();
ClearOutdatedSelection (anInteractive, Standard_True);
return status;
@ -353,7 +370,6 @@ void AIS_LocalContext::Clear(const AIS_ClearMode aType)
case AIS_CM_TemporaryShapePrs:
ClearDetected();
}
UpdateSort();
}
//=======================================================================
//function : ActivateMode
@ -370,7 +386,6 @@ void AIS_LocalContext::ActivateMode(const Handle(AIS_InteractiveObject)& aSelect
myActiveObjects(aSelectable)->AddSelectionMode(aMode);
mySM->Activate(aSelectable,aMode,myMainVS);
}
UpdateSort();
}
//=======================================================================
//function : ActivateMode
@ -386,8 +401,6 @@ void AIS_LocalContext::DeactivateMode(const Handle(AIS_InteractiveObject)& aSele
myActiveObjects(aSelectable)->RemoveSelectionMode(aMode);
mySM->Deactivate(aSelectable,aMode,myMainVS);
UpdateSort();
}
//=======================================================================
//function : ActivateMode
@ -398,9 +411,8 @@ void AIS_LocalContext::Deactivate(const Handle(AIS_InteractiveObject)& aSelectab
{
if(!myActiveObjects.IsBound(aSelectable)) return;
mySM->Deactivate(aSelectable,myMainVS);
mySM->Deactivate(aSelectable, -1, myMainVS);
myActiveObjects(aSelectable)->ClearSelectionModes();
UpdateSort();
}
//=======================================================================
@ -465,7 +477,6 @@ Standard_Boolean AIS_LocalContext::Remove(const Handle(AIS_InteractiveObject)& a
{
mySM->Remove (aSelectable);
}
UpdateSort();
ClearOutdatedSelection (aSelectable, Standard_True);
// This should be done at the very end because most methods use
@ -538,10 +549,8 @@ void AIS_LocalContext::DeactivateStandardMode(const TopAbs_ShapeEnum aType)
myListOfStandardMode.Remove(It);
if(myFilters->IsIn(myStdFilters[IMode]))
myFilters->Remove(myStdFilters[IMode]);
UpdateSort();
return;
}
UpdateSort();
}
//=======================================================================
@ -588,31 +597,6 @@ void AIS_LocalContext::RemoveFilter(const Handle(SelectMgr_Filter)& aFilter)
}
}
Standard_Boolean AIS_LocalContext::HasSameProjector(const Handle(Select3D_Projector)& thePrj) const
{
const Handle(Select3D_Projector)& aCurPrj = myMainVS->Projector();
if (aCurPrj->Perspective() != thePrj->Perspective())
return Standard_False;
if (aCurPrj->Perspective() && aCurPrj->Focus() != thePrj->Focus())
return Standard_False;
const gp_GTrsf& aCurTrsf = aCurPrj->Transformation();
const gp_GTrsf& aPrjTrsf = thePrj->Transformation();
for (Standard_Integer i = 1; i <= 3; ++i)
{
for (Standard_Integer j = 1; j <= 3 ; ++j)
{
if (aCurTrsf.Value (i, j) != aPrjTrsf.Value (i, j))
return Standard_False;
}
}
return Standard_True;
}
//=======================================================================
//function : Terminate
//purpose :
@ -627,7 +611,6 @@ void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate)
mylastindex=0;
// clear the selector...
myMainVS->Clear();
myCTX->SelectionManager()->Remove(myMainVS);
AIS_Selection::SetCurrentSelection(mySelName.ToCString());
@ -650,7 +633,6 @@ void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate)
}
Handle(V3d_View) aDummyView;
myMainVS->ClearAreas (aDummyView);
myMainVS->ClearSensitive (aDummyView);
if (theToUpdate)
@ -893,12 +875,17 @@ void AIS_LocalContext::LoadContextObjects()
myCTX->DisplayedObjects(LL,Standard_True);
Handle(AIS_LocalStatus) Att;
for (It.Initialize(LL);It.More();It.Next()){
const Handle(AIS_InteractiveObject)& anObj = It.Value();
Att= new AIS_LocalStatus();
Att->SetDecomposition((It.Value()->AcceptShapeDecomposition() && myAcceptStdMode));
Att->SetDecomposition((anObj->AcceptShapeDecomposition() && myAcceptStdMode));
Att->SetTemporary(Standard_False);
Att->SetHilightMode(It.Value()->HasHilightMode()? It.Value()->HilightMode(): 0);
myActiveObjects.Bind(It.Value(),Att);
Att->SetHilightMode(anObj->HasHilightMode()? anObj->HilightMode(): 0);
for (anObj->Init(); anObj->More(); anObj->Next())
{
const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection();
aSel->SetSelectionState (SelectMgr_SOS_Deactivated);
}
myActiveObjects.Bind(anObj,Att);
}
}
}
@ -922,17 +909,16 @@ void AIS_LocalContext::UnloadContextObjects()
//purpose :
//=======================================================================
void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject,
const Standard_Boolean WithProj)
void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObject)
{
if(!myActiveObjects.IsBound(anObject)) return;
if(myActiveObjects(anObject)->Decomposed())
ActivateStandardModes(anObject,WithProj);
ActivateStandardModes(anObject);
else
{
TColStd_ListIteratorOfListOfInteger It(myActiveObjects(anObject)->SelectionModes());
for(;It.More();It.Next())
myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS,WithProj);
myCTX->SelectionManager()->Activate(anObject,It.Value(),myMainVS);
}
}
@ -941,7 +927,7 @@ void AIS_LocalContext::Process(const Handle(SelectMgr_SelectableObject)& anObjec
//purpose :
//=======================================================================
void AIS_LocalContext::Process(const Standard_Boolean WithProj)
void AIS_LocalContext::Process()
{
myMainVS->Clear();
@ -951,11 +937,11 @@ void AIS_LocalContext::Process(const Standard_Boolean WithProj)
for(;It.More();It.Next()){
myCTX->SelectionManager()->Load(It.Key(),myMainVS);
if(It.Value()->Decomposed())
ActivateStandardModes(It.Key(),WithProj);
ActivateStandardModes(It.Key());
else if( myCTX->GetAutoActivateSelection() )
{
It.Value()->AddSelectionMode(0);
myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS,WithProj);
myCTX->SelectionManager()->Activate(It.Key(),0,myMainVS);
}
}
@ -966,8 +952,7 @@ void AIS_LocalContext::Process(const Standard_Boolean WithProj)
//purpose :
//=======================================================================
void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject,
const Standard_Boolean WithProj)
void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableObject)& anObject)
{
if(!myActiveObjects.IsBound(anObject)) return;
@ -976,7 +961,7 @@ void AIS_LocalContext::ActivateStandardModes(const Handle(SelectMgr_SelectableOb
const Handle(AIS_LocalStatus)& LS = myActiveObjects(anObject);
if(LS->Decomposed()){
for(;itl.More();itl.Next()){
myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS,WithProj);
myCTX->SelectionManager()->Activate(anObject,itl.Value(),myMainVS);
LS->AddSelectionMode(itl.Value());
}
}
@ -1023,13 +1008,13 @@ void AIS_LocalContext::ClearObjects()
myMainPM->Erase(SO,CurAtt->DisplayMode());
}
TColStd_ListIteratorOfListOfInteger ITL(CurAtt->SelectionModes());
for(;ITL.More();ITL.Next())
mySM->Deactivate(SO,ITL.Value(),myMainVS);
if(CurAtt->IsTemporary())
mySM->Remove(SO,myMainVS);
TColStd_ListIteratorOfListOfInteger aSelModeIter (CurAtt->SelectionModes());
for ( ; aSelModeIter.More(); aSelModeIter.Next())
{
Standard_Integer aSelMode = aSelModeIter.Value();
mySM->Deactivate (SO, aSelMode, myMainVS);
}
}
ClearSelected( Standard_False );
myActiveObjects.Clear();
@ -1082,16 +1067,6 @@ void AIS_LocalContext::ClearDetected()
}
}
void AIS_LocalContext::UpdateConversion()
{
myMainVS->UpdateConversion();
}
void AIS_LocalContext::UpdateSort()
{
myMainVS->UpdateSort();
}
//=======================================================================
//function : BeginImmediateDraw
//purpose :
@ -1155,32 +1130,12 @@ Standard_Boolean AIS_LocalContext::IsImmediateModeOn() const
return myMainPM->IsImmediateModeOn();
}
void AIS_LocalContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
myMainVS->SetSensitivityMode(aMode);
}
StdSelect_SensitivityMode AIS_LocalContext::SensitivityMode() const {
return myMainVS->SensitivityMode();
}
void AIS_LocalContext::SetSensitivity(const Standard_Real aPrecision) {
myMainVS->SetSensitivity(aPrecision);
}
Standard_Real AIS_LocalContext::Sensitivity() const {
return myMainVS->Sensitivity();
}
void AIS_LocalContext::SetPixelTolerance(const Standard_Integer aPrecision) {
void AIS_LocalContext::SetPixelTolerance(const Standard_Real aPrecision) {
myMainVS->SetPixelTolerance(aPrecision);
}
Standard_Integer AIS_LocalContext::PixelTolerance() const {
Standard_Real AIS_LocalContext::PixelTolerance() const {
return myMainVS->PixelTolerance();
}

View File

@ -31,12 +31,12 @@
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_Group.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
#include <StdSelect_ViewerSelector3d.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_Map.hxx>
#include <Visual3d_View.hxx>
#include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_SequenceOfOwner.hxx>
#include <OSD_Environment.hxx>
@ -855,7 +855,7 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec
continue;
}
if (toClearDeactivated && !mySM->IsActivated (theIO, myMainVS, aMode))
if (toClearDeactivated && !mySM->IsActivated(theIO, aMode, myMainVS))
{
continue;
}
@ -863,7 +863,7 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec
Handle(SelectMgr_Selection) aSelection = theIO->Selection(aMode);
for (aSelection->Init(); aSelection->More(); aSelection->Next())
{
Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive();
Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
if (anEntity.IsNull())
{
continue;
@ -1012,7 +1012,7 @@ void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,
const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
SIOBJ->Init();
if(SIOBJ->More()){
Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
}
}
@ -1049,10 +1049,9 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)&
{
const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
SIOBJ->Init();
if(SIOBJ->More())
{
Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
if(SIOBJ->More()){
Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
}
}
if(EO.IsNull())
@ -1272,27 +1271,6 @@ Standard_Boolean AIS_LocalContext::ComesFromDecomposition(const Standard_Integer
return Standard_False;
}
//=======================================================================
//function : DisplayAreas
//purpose :
//=======================================================================
void AIS_LocalContext::DisplayAreas(const Handle(V3d_View)& aviou)
{
myMainVS->DisplayAreas(aviou);
}
//=======================================================================
//function : ClearAreas
//purpose :
//=======================================================================
void AIS_LocalContext::ClearAreas(const Handle(V3d_View)& aviou)
{
myMainVS->ClearAreas(aviou);
}
//=======================================================================
//function : DisplaySensitive
//purpose :
@ -1475,9 +1453,9 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromShape(const
Standard_Boolean found(Standard_False);
if (!found) {
SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive aSensitiveIt (myMainVS->Primitives());
for (; aSensitiveIt.More(); aSensitiveIt.Next()) {
EO = Handle(SelectMgr_EntityOwner)::DownCast (aSensitiveIt.Value()->OwnerId());
NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (myMainVS->ActiveOwners());
for (; anOwnersIt.More(); anOwnersIt.Next()) {
EO = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
if (!BROwnr.IsNull() && BROwnr->HasShape() && BROwnr->Shape() == sh) {
found = Standard_True;

View File

@ -30,6 +30,7 @@
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>

View File

@ -38,6 +38,7 @@
#include <Geom_TrimmedCurve.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveCurve.hxx>

View File

@ -31,6 +31,7 @@
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <ElCLib.hxx>
#include <ElSLib.hxx>

View File

@ -159,6 +159,7 @@ AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive()
: AIS_InteractiveObject (PrsMgr_TOP_AllView)
{
myHasOwnPresentations = Standard_False;
myAssemblyOwner = NULL;
SetHilightMode (0);
}
@ -189,12 +190,16 @@ Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::Connect (const H
const Graphic3d_TransModeFlags& theTrsfPersFlag,
const gp_Pnt& theTrsfPersPoint)
{
if (myAssemblyOwner.IsNull())
myAssemblyOwner = new SelectMgr_EntityOwner (this);
Handle(AIS_InteractiveObject) anObjectToAdd;
Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj);
if (!aMultiConnected.IsNull())
{
Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive();
aNewMultiConnected->myAssemblyOwner = myAssemblyOwner;
aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformation());
// Perform deep copy of instance tree
@ -357,7 +362,7 @@ Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() co
//function : ComputeSelection
//purpose :
//=======================================================================
void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
const Standard_Integer theMode)
{
if (theMode != 0)
@ -370,67 +375,13 @@ void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_
continue;
}
if (!aChild->HasSelection(theMode))
if (!aChild->HasSelection (theMode))
{
aChild->UpdateSelection(theMode);
aChild->RecomputePrimitives (theMode);
}
aChild->ComputeSelection (theSelection, theMode);
}
return;
}
for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
{
Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
if (aChild.IsNull())
{
continue;
}
if (!aChild->HasSelection (theMode))
{
aChild->UpdateSelection (theMode);
}
const Handle(SelectMgr_Selection)& TheRefSel = aChild->Selection (theMode);
// To redirect selection we must replace owners in sensitives, but we don't want new owner for each SE.
// Only for each existing owner.
NCollection_DataMap <Handle(SelectMgr_EntityOwner), Handle(SelectMgr_EntityOwner)> anOwnerMap;
Handle(Select3D_SensitiveEntity) aSensitive, aNewSensitive;
if (TheRefSel->IsEmpty())
{
aChild->UpdateSelection(theMode);
}
for (TheRefSel->Init(); TheRefSel->More(); TheRefSel->Next())
{
aSensitive = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive());
if (!aSensitive.IsNull())
{
TopLoc_Location aLocation (Transformation());
// Get the copy of aSensitive
aNewSensitive = aSensitive->GetConnected (aLocation);
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aNewSensitive->OwnerId());
if (!anOwnerMap.IsBound (anOwner))
{
Handle(SelectMgr_EntityOwner) aNewOwner = new SelectMgr_AssemblyEntityOwner (anOwner, this);
anOwnerMap.Bind (anOwner, aNewOwner);
}
aNewSensitive->Set (anOwnerMap.Find (anOwner));
// In case if aSensitive caches some location-dependent data
// that must be updated after setting OWN
aNewSensitive->SetLocation (aLocation);
theSelection->Add (aNewSensitive);
}
Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode);
aChild->ComputeSelection (aSelection, theMode);
}
}
}

View File

@ -35,6 +35,7 @@
#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <TCollection_ExtendedString.hxx>

View File

@ -33,6 +33,7 @@
#include <AIS.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>

View File

@ -41,6 +41,7 @@
#include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>

View File

@ -50,7 +50,7 @@ inline Select3D_TypeOfSensitivity AIS_Plane::TypeOfSensitivity() const
return myTypeOfSensitivity;
}
inline void AIS_Plane::SetTypeOfSensitivity (const Select3D_TypeOfSensitivity theTypeOfSensitivity)
inline void AIS_Plane::SetTypeOfSensitivity (const Select3D_TypeOfSensitivity& theTypeOfSensitivity)
{
myTypeOfSensitivity = theTypeOfSensitivity;
}

View File

@ -26,6 +26,7 @@
#include <DsgPrs_DatumPrs.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitivePoint.hxx>
#include <Geom_Axis1Placement.hxx>

View File

@ -21,6 +21,7 @@
#include <gce_MakeLin.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Precision.hxx>

View File

@ -21,6 +21,7 @@
#include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>

View File

@ -45,7 +45,8 @@ public:
//! Creates binned SAH BVH builder.
BVH_BinnedBuilder (const Standard_Integer theLeafNodeSize = 5,
const Standard_Integer theMaxTreeDepth = 32);
const Standard_Integer theMaxTreeDepth = 32,
const Standard_Boolean theToUseMainAxis = Standard_False);
//! Releases resources of binned SAH BVH builder.
virtual ~BVH_BinnedBuilder();
@ -64,6 +65,10 @@ protected:
BVH_BinVector& theBins,
const Standard_Integer theAxis);
private:
Standard_Boolean myUseMainAxis; //!< Defines whether to search for the best split or use the widest axis
};
#include <BVH_BinnedBuilder.lxx>

View File

@ -19,9 +19,11 @@
// =======================================================================
template<class T, int N, int Bins>
BVH_BinnedBuilder<T, N, Bins>::BVH_BinnedBuilder (const Standard_Integer theLeafNodeSize,
const Standard_Integer theMaxTreeDepth)
const Standard_Integer theMaxTreeDepth,
const Standard_Boolean theToUseMainAxis)
: BVH_QueueBuilder<T, N> (theLeafNodeSize,
theMaxTreeDepth)
theMaxTreeDepth),
myUseMainAxis (theToUseMainAxis)
{
//
}
@ -129,6 +131,46 @@ namespace BVH
#include <limits>
namespace BVH
{
template<class T, int N>
struct BVH_AxisSelector
{
typedef typename BVH::VectorType<T, N>::Type BVH_VecNt;
// =======================================================================
// function : MainAxis
// purpose :
// =======================================================================
static Standard_Integer MainAxis (const BVH_VecNt& theSize)
{
if (theSize.y() > theSize.x())
{
return theSize.y() > theSize.z() ? 1 : 2;
}
else
{
return theSize.z() > theSize.x() ? 2 : 0;
}
}
};
template<class T>
struct BVH_AxisSelector<T, 2>
{
typedef typename BVH::VectorType<T, 2>::Type BVH_VecNt;
// =======================================================================
// function : MainAxis
// purpose :
// =======================================================================
static Standard_Integer MainAxis (const BVH_VecNt& theSize)
{
return theSize.x() > theSize.y() ? 0 : 1;
}
};
}
// =======================================================================
// function : BuildNode
// purpose :
@ -162,8 +204,10 @@ void BVH_BinnedBuilder<T, N, Bins>::BuildNode (BVH_Set<T, N>* theSet,
Standard_Real aMinSplitCost = std::numeric_limits<Standard_Real>::max();
Standard_Integer aMainAxis = BVH::BVH_AxisSelector<T, N>::MainAxis (aSize);
// Find best split
for (Standard_Integer anAxis = 0; anAxis < (N < 4 ? N : 3); ++anAxis)
for (Standard_Integer anAxis = myUseMainAxis ? aMainAxis : 0; anAxis <= (myUseMainAxis ? aMainAxis : Min (N - 1, 2)); ++anAxis)
{
if (BVH::VecComp<T, N>::Get (aSize, anAxis) <= BVH::THE_NODE_MIN_SIZE)
continue;

View File

@ -26,7 +26,8 @@ public:
//! Creates spatial median split builder.
BVH_SpatialMedianBuilder (const Standard_Integer theLeafNodeSize = 5,
const Standard_Integer theMaxTreeDepth = 32);
const Standard_Integer theMaxTreeDepth = 32,
const Standard_Boolean theToUseMainAxis = Standard_False);
//! Releases resources of spatial median split builder.
virtual ~BVH_SpatialMedianBuilder();

View File

@ -21,9 +21,11 @@
// =======================================================================
template<class T, int N>
BVH_SpatialMedianBuilder<T, N>::BVH_SpatialMedianBuilder (const Standard_Integer theLeafNodeSize,
const Standard_Integer theMaxTreeDepth)
const Standard_Integer theMaxTreeDepth,
const Standard_Boolean theToUseMainAxis)
: BVH_BinnedBuilder<T, N, 2> (theLeafNodeSize,
theMaxTreeDepth)
theMaxTreeDepth,
theToUseMainAxis)
{
//
}

View File

@ -33,7 +33,6 @@ public:
DEFINE_STANDARD_RTTI( IVtk_IShapePickerAlgo )
virtual void SetView (const IVtk_IView::Handle& theView) = 0;
virtual void Modified() = 0;
virtual int NbPicked() = 0;
//! Get activated selection modes for a shape.

View File

@ -19,6 +19,8 @@
#include <IVtk_Interface.hxx>
#include <gp_XY.hxx>
#include <gp_XYZ.hxx>
#include <gp_Pnt.hxx>
#include <Graphic3d_Mat4d.hxx>
DEFINE_STANDARD_HANDLE( IVtk_IView, IVtk_Interface )
@ -65,12 +67,26 @@ public:
//! @return Two doubles containing the display coordinates of the view window center
virtual void GetViewCenter (double& theX, double& theY) const = 0;
//! Gets window size in screen coordinates in pixels
virtual void GetWindowSize (int& theX, int& theY) const = 0;
//! Gets camera projection and orientation matrices
virtual void GetCamera (Graphic3d_Mat4d& theProj,
Graphic3d_Mat4d& theOrient,
Standard_Boolean& theIsOrtho) const = 0;
//! Converts 3D display coordinates into 3D world coordinates.
//! @param [in] theDisplayPnt 2d point of display coordinates
//! @param [out] theWorldPnt 3d point of world coordinates
//! @return true if conversion was successful, false otherwise
virtual bool DisplayToWorld (const gp_XY& theDisplayPnt, gp_XYZ& theWorldPnt) const = 0;
//! Gets viewport coordinates
virtual void GetViewport (Standard_Real& theX,
Standard_Real& theY,
Standard_Real& theWidth,
Standard_Real& theHeight) const = 0;
DEFINE_STANDARD_RTTI( IVtk_IView )
};

View File

@ -170,3 +170,13 @@ const Bnd_Box& IVtkOCC_SelectableObject::BoundingBox()
return myBndBox;
}
//============================================================================
// Method: BoundingBox
// Purpose:
//============================================================================
void IVtkOCC_SelectableObject::BoundingBox (Bnd_Box& theBndBox)
{
BoundingBox();
theBndBox = myBndBox;
}

View File

@ -43,6 +43,9 @@ public:
const IVtkOCC_Shape::Handle& GetShape() const { return myShape; };
//! Returns bounding box of object
Standard_EXPORT virtual void BoundingBox (Bnd_Box& theBndBox) Standard_OVERRIDE;
DEFINE_STANDARD_RTTI( IVtkOCC_SelectableObject )
private:

View File

@ -47,16 +47,6 @@ IVtkOCC_ShapePickerAlgo::~IVtkOCC_ShapePickerAlgo()
void IVtkOCC_ShapePickerAlgo::SetView (const IVtk_IView::Handle& theView)
{
myView = theView;
Modified();
}
//================================================================
// Function : Modified
// Purpose :
//================================================================
void IVtkOCC_ShapePickerAlgo::Modified()
{
myViewerSelector->Update (myView);
}
//================================================================
@ -132,6 +122,7 @@ void IVtkOCC_ShapePickerAlgo::SetSelectionMode (const IVtk_IShape::Handle& theSh
// then create a new selection in the given mode for this object (shape).
Handle(SelectMgr_Selection) aNewSelection = new SelectMgr_Selection (theMode);
aSelObj->AddSelection (aNewSelection, theMode);
myViewerSelector->AddSelectionToObject (aSelObj, aNewSelection);
}
// Update the selection for the given mode according to its status.
@ -141,14 +132,16 @@ void IVtkOCC_ShapePickerAlgo::SetSelectionMode (const IVtk_IShape::Handle& theSh
{
case SelectMgr_TOU_Full:
// Recompute the sensitive primitives which correspond to the mode.
aSelObj->UpdateSelection (theMode);
myViewerSelector->RemoveSelectionOfObject (aSelObj, aSelObj->Selection (theMode));
aSelObj->RecomputePrimitives (theMode);
myViewerSelector->AddSelectionToObject (aSelObj, aSelObj->Selection (theMode));
myViewerSelector->RebuildObjectsTree();
myViewerSelector->RebuildSensitivesTree (aSelObj);
case SelectMgr_TOU_Partial:
{
if (aSelObj->HasTransformation())
{
// Updates locations in all sensitive entities from the Selection and
// corresponding entity owners (shapes).
aSelObj->UpdateTransformations (aSel);
myViewerSelector->RebuildObjectsTree();
}
break;
}

View File

@ -39,12 +39,6 @@ public:
//! the 3D view projection.
Standard_EXPORT virtual void SetView (const IVtk_IView::Handle& theView);
//! Informs the picker that some parameters of the view
//! has been modified so it is necessary to recompute internal selection data.
//! It makes sense to call this method automatically as soon as
//! the underlying VTK object emits its ModifiedEvent.
Standard_EXPORT virtual void Modified();
//! Get number of picked entities.
Standard_EXPORT virtual int NbPicked();

View File

@ -29,33 +29,7 @@ IMPLEMENT_STANDARD_RTTIEXT( IVtkOCC_ViewerSelector, SelectMgr_ViewerSelector )
IVtkOCC_ViewerSelector::IVtkOCC_ViewerSelector()
: SelectMgr_ViewerSelector(),
myPixTol(2),
myToUpdateTol(Standard_True)
{
for (Standard_Integer i=0;i<=13;i++) {myCoeff [i] = 0.;myPrevCoeff[i]=0.0;}
for (Standard_Integer j=0;j<2;j++) {myCenter [j] = 0.;myPrevCenter[j]=0.0;}
}
//============================================================================
// Method: Convert
// Purpose: Projects all sensitive entities from the given selection container
// to 2D space
//============================================================================
void IVtkOCC_ViewerSelector::Convert (const Handle(SelectMgr_Selection)& theSelection)
{
for (theSelection->Init(); theSelection->More(); theSelection->Next())
{
if(theSelection->Sensitive()->NeedsConversion())
{
Handle(Select3D_SensitiveEntity) aSensEntity =
*((Handle(Select3D_SensitiveEntity)*) &(theSelection->Sensitive()));
aSensEntity->Project (myPrj);
if (!tosort)
{
tosort = Standard_True;
}
}
}
}
myToUpdateTol(Standard_True) {}
//============================================================================
// Method: Pick
@ -65,14 +39,38 @@ void IVtkOCC_ViewerSelector::Pick (const Standard_Integer theXPix,
const Standard_Integer theYPix,
const IVtk_IView::Handle& theView)
{
myclip.SetVoid();
Update (theView);
gp_XY aDispPnt (theXPix, theYPix);
gp_XYZ aWorldPnt;
gp_Pnt2d aP2d;
theView->DisplayToWorld (aDispPnt, aWorldPnt);
myPrj->Project (gp_Pnt (aWorldPnt), aP2d);
InitSelect (aP2d.X(), aP2d.Y());
if (myToUpdateTol)
{
// Compute and set a sensitivity tolerance according to the renderer (viewport).
// TODO: Think if this works well in perspective view...'cause result depends
// on position on the screen, but we always use the point close to the
// screen's origin...
mySelectingVolumeMgr.SetPixelTolerance (myPixTol);
myToUpdateTol = Standard_False;
}
Standard_Integer aWidth = 0, aHeight = 0;
Graphic3d_Mat4d aProj, anOrient;
Standard_Boolean isOrthographic = Standard_False;
Standard_Real aX = RealLast(), aY = RealLast();
Standard_Real aVpWidth = RealLast(), aVpHeight = RealLast();
mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Point);
theView->GetCamera (aProj, anOrient, isOrthographic);
mySelectingVolumeMgr.SetCamera (aProj, anOrient, isOrthographic);
theView->GetWindowSize (aWidth, aHeight);
mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight);
theView->GetViewport (aX, aY, aVpWidth, aVpHeight);
mySelectingVolumeMgr.SetViewport (aX, aY, aVpWidth, aVpHeight);
gp_Pnt2d aMousePos (static_cast<Standard_Real> (theXPix),
static_cast<Standard_Real> (theYPix));
mySelectingVolumeMgr.BuildSelectingVolume (aMousePos);
TraverseSensitives();
}
//============================================================================
@ -91,33 +89,36 @@ void IVtkOCC_ViewerSelector::Pick (const Standard_Integer theXMin,
// TODO: Think if this works well in perspective view...'cause result depends
// on position on the screen, but we always use the point close to the
// screen's origin...
gp_XYZ aWorldPnt1, aWorldPnt2;
gp_XY aDispPnt1 (0.0, 0.0);
gp_XY aDispPnt2 (myPixTol, 0.0);
theView->DisplayToWorld (aDispPnt1, aWorldPnt1);
theView->DisplayToWorld (aDispPnt2, aWorldPnt2);
gp_Pnt aPnt1 (aWorldPnt1);
gp_Pnt aPnt2 (aWorldPnt2);
SetSensitivity (aPnt2.Distance (aPnt1));
mySelectingVolumeMgr.SetPixelTolerance (myPixTol);
myToUpdateTol = Standard_False;
}
Update (theView);
gp_XY aDispPnt1 (theXMin, theYMin);
gp_XY aDispPnt2 (theXMax, theYMax);
gp_XYZ aWorldPnt1, aWorldPnt2;
Standard_Integer aWidth = 0, aHeight = 0;
Graphic3d_Mat4d aProj, anOrient;
Standard_Boolean isOrthographic = Standard_False;
Standard_Real aX = RealLast(), aY = RealLast();
Standard_Real aVpWidth = RealLast(), aVpHeight = RealLast();
gp_Pnt2d aP2d_1, aP2d_2;
theView->DisplayToWorld (aDispPnt1, aWorldPnt1);
theView->DisplayToWorld (aDispPnt2, aWorldPnt2);
mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Box);
theView->GetCamera (aProj, anOrient, isOrthographic);
mySelectingVolumeMgr.SetCamera (aProj, anOrient, isOrthographic);
myPrj->Project (gp_Pnt (aWorldPnt1), aP2d_1);
myPrj->Project (gp_Pnt (aWorldPnt2), aP2d_2);
theView->GetWindowSize (aWidth, aHeight);
mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight);
InitSelect (Min (aP2d_1.X(), aP2d_2.X()),
Min (aP2d_1.Y(), aP2d_2.Y()),
Max (aP2d_1.X(), aP2d_2.X()),
Max (aP2d_1.Y(), aP2d_2.Y()));
theView->GetViewport (aX, aY, aVpWidth, aVpHeight);
mySelectingVolumeMgr.SetViewport (aX, aY, aVpWidth, aVpHeight);
gp_Pnt2d aMinMousePos (static_cast<Standard_Real> (theXMin),
static_cast<Standard_Real> (theYMin));
gp_Pnt2d aMaxMousePos (static_cast<Standard_Real> (theXMax),
static_cast<Standard_Real> (theYMax));
mySelectingVolumeMgr.BuildSelectingVolume (aMinMousePos,
aMaxMousePos);
TraverseSensitives();
}
//============================================================================
@ -136,19 +137,11 @@ void IVtkOCC_ViewerSelector::Pick (double** thePoly,
// TODO: Think if this works well in perspective view...'cause result depends
// on position on the screen, but we always use the point close to the
// screen's origin...
gp_XYZ aWorldPnt1, aWorldPnt2;
gp_XY aDispPnt1 (0.0, 0.0);
gp_XY aDispPnt2 (myPixTol, 0.0);
theView->DisplayToWorld (aDispPnt1, aWorldPnt1);
theView->DisplayToWorld (aDispPnt2, aWorldPnt2);
gp_Pnt aPnt1 (aWorldPnt1);
gp_Pnt aPnt2 (aWorldPnt2);
SetSensitivity (aPnt2.Distance (aPnt1));
mySelectingVolumeMgr.SetPixelTolerance (myPixTol);
myToUpdateTol = Standard_False;
}
Update (theView);
// Build TColgp_Array1OfPnt2d from input array of doubles
gp_XYZ aWorldPnt;
@ -156,149 +149,46 @@ void IVtkOCC_ViewerSelector::Pick (double** thePoly,
{
gp_XY aDispPnt = thePoly[anIt][2] != 0 ? gp_XY (thePoly[anIt][0] / thePoly[anIt][2], thePoly[anIt][1] / thePoly[anIt][2])
: gp_XY (thePoly[anIt][0], thePoly[anIt][1]);
gp_Pnt2d aP2d;
theView->DisplayToWorld (aDispPnt, aWorldPnt);
myPrj->Project (gp_Pnt (aWorldPnt), aP2d);
aPolyline.SetValue (anIt + 1, aP2d);
aPolyline.SetValue (anIt + 1, aDispPnt);
}
InitSelect (aPolyline);
}
Standard_Integer aWidth = 0, aHeight = 0;
Graphic3d_Mat4d aProj, anOrient;
Standard_Boolean isOrthographic = Standard_False;
Standard_Real aX = RealLast(), aY = RealLast();
Standard_Real aVpWidth = RealLast(), aVpHeight = RealLast();
//============================================================================
// Method: Update
// Purpose: Checks if some projection parameters have changed,
// and updates the 2D projections of all sensitive entities if necessary.
//============================================================================
Standard_Boolean IVtkOCC_ViewerSelector::Update (const IVtk_IView::Handle& theView)
{
static Standard_Real aZoom (0.0);
mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Polyline);
theView->GetCamera (aProj, anOrient, isOrthographic);
mySelectingVolumeMgr.SetCamera (aProj, anOrient, isOrthographic);
// No focal distance by default
myPrevCoeff[9] = 0.0;
// Parallel projection by default
myPrevCoeff[10] = 0.0;
theView->GetWindowSize (aWidth, aHeight);
mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight);
// Flag related to perspective or parallel projection
Standard_Boolean isPerspective = theView->IsPerspective();
theView->GetViewport (aX, aY, aVpWidth, aVpHeight);
mySelectingVolumeMgr.SetViewport (aX, aY, aVpWidth, aVpHeight);
// For perspective projections only
if (isPerspective)
{
// Flag = 1 if perspective projection
myPrevCoeff[10] = 1.0;
// Focal distance
myPrevCoeff[9] = theView->GetDistance();
}
// View point
// Use (0,0,0) as a view reference point:
mySelectingVolumeMgr.BuildSelectingVolume (aPolyline);
theView->GetPosition (myPrevCoeff[0], myPrevCoeff[1], myPrevCoeff[2]);
// Orientation
theView->GetViewUp (myPrevCoeff[3], myPrevCoeff[4], myPrevCoeff[5]);
// Projection direction vector
theView->GetDirectionOfProjection (myPrevCoeff[6], myPrevCoeff[7], myPrevCoeff[8]);
// 3D Scale
theView->GetScale (myPrevCoeff[11], myPrevCoeff[12], myPrevCoeff[13]);
// Return the center of this viewport in display coordinates.
theView->GetViewCenter (myPrevCenter[0], myPrevCenter[1]);
Standard_Integer anIt;
for (anIt=0; anIt <= 13 && (myPrevCoeff[anIt] == myCoeff[anIt]); anIt++) { }
if (anIt <= 13 || (myPrevCenter[0] != myCenter[0]) || (myPrevCenter[1] != myCenter[1]))
{
toupdate = Standard_True;
myToUpdateTol = Standard_True;
for (Standard_Integer anI = anIt; anI <= 13; anI++)
{
myCoeff[anI] = myPrevCoeff[anI];
}
for (Standard_Integer aJ = 0; aJ < 2; aJ++)
{
myCenter[aJ] = myPrevCenter[aJ];
}
// For orthographic view use only direction of projection and up vector
// Panning, and zooming has no effect on 2D selection sensitives.
Handle (Graphic3d_Camera) aCamera = new Graphic3d_Camera();
aCamera->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
aCamera->SetCenter (gp::Origin());
aCamera->SetDirection (gp_Dir (-myCoeff[6], -myCoeff[7], -myCoeff[8]));
aCamera->SetUp (gp_Dir (myCoeff[3], myCoeff[4], myCoeff[5]));
aCamera->SetDistance (1.0);
aCamera->SetAxialScale (gp_XYZ (myCoeff[11], myCoeff[12], myCoeff[13]));
myPrj = new Select3D_Projector (aCamera->OrientationMatrix(), Graphic3d_Mat4d());
}
if (isPerspective)
{
if (Abs(theView->GetViewAngle() - aZoom) > 1.e-3)
{
myToUpdateTol = Standard_True;
aZoom = theView->GetViewAngle();
}
}
else
{
if (Abs (theView->GetParallelScale() - aZoom) > 1.e-3)
{
myToUpdateTol = Standard_True;
aZoom = theView->GetParallelScale();
}
}
if(myToUpdateTol)
{
// Compute and set a sensitivity tolerance according to the view
gp_XYZ aWorldPnt1, aWorldPnt2;
gp_XY aDispPnt1 (0.0, 0.0);
gp_XY aDispPnt2 (myPixTol, 0.0);
theView->DisplayToWorld (aDispPnt1, aWorldPnt1);
theView->DisplayToWorld (aDispPnt2, aWorldPnt2);
gp_Pnt aPnt1 (aWorldPnt1);
gp_Pnt aPnt2 (aWorldPnt2);
SetSensitivity (aPnt2.Distance (aPnt1));
myToUpdateTol = Standard_False;
}
if(toupdate) UpdateConversion();
if(tosort) UpdateSort();
return Standard_True;
TraverseSensitives();
}
//============================================================================
// Method: Activate
// Purpose: Activates the given selection
//============================================================================
void IVtkOCC_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Boolean theIsAutomaticProj)
void IVtkOCC_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSelection)
{
tosort = Standard_True;
for (theSelection->Init(); theSelection->More(); theSelection->Next())
{
theSelection->Sensitive()->SetActiveForSelection();
}
if (!myselections.IsBound (theSelection))
{
myselections.Bind (theSelection, 0);
}
else if (myselections (theSelection) != 0)
{
myselections (theSelection) = 0;
}
if (theIsAutomaticProj)
{
Convert (theSelection);
}
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
myTolerances.Add (theSelection->Sensitivity());
mytolerance = myTolerances.Largest();
myToUpdateTolerance = Standard_True;
}
//============================================================================
@ -307,18 +197,14 @@ void IVtkOCC_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSel
//============================================================================
void IVtkOCC_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theSelection)
{
if (myselections.IsBound (theSelection))
for (theSelection->Init(); theSelection->More(); theSelection->Next())
{
myselections (theSelection) = 1;
tosort = Standard_True;
theSelection->Sensitive()->ResetSelectionActiveStatus();
}
}
//============================================================================
// Method: PickingLine
// Purpose: Deactivate the given selection
//============================================================================
gp_Lin IVtkOCC_ViewerSelector::PickingLine (const Standard_Real theX,const Standard_Real theY) const
{
return myPrj->Shoot (theX, theY);
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
myTolerances.Decrement (theSelection->Sensitivity());
mytolerance = myTolerances.Largest();
myToUpdateTolerance = Standard_True;
}

View File

@ -17,7 +17,6 @@
#define __IVTKOCC_VIEWERSELECTOR_H__
#include <IVtk_IView.hxx>
#include <Select3D_Projector.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_ViewerSelector.hxx>
@ -32,10 +31,6 @@ class IVtkOCC_ViewerSelector : public SelectMgr_ViewerSelector
public:
IVtkOCC_ViewerSelector();
//! Projects all sensitive entities from the given selection container to 2D space
//! param [in] theSelection Container with sensitive entities to project
void Convert (const Handle(SelectMgr_Selection)& theSelection);
//! Implements point picking
//! @param [in] theXPix, theYPix Display coordinates of the point
//! @param [in] theView ICamera interface to update the projection parameters.
@ -56,32 +51,15 @@ public:
void Pick (double** thePoly, const int theNbPoints, const IVtk_IView::Handle& theView);
//! Activates the given selection
void Activate (const Handle(SelectMgr_Selection)& theSelection,
const Standard_Boolean isAutomaticProj = Standard_True);
void Activate (const Handle(SelectMgr_Selection)& theSelection);
//! Deactivate the given selection
void Deactivate (const Handle(SelectMgr_Selection)& theSelection);
//! Checks if some projection parameters have changed,
//! and updates the 2D projections of all sensitive entities if necessary.
//! @param [in] theView Interface to VTK renderer to access projection parameters
Standard_Boolean Update (const IVtk_IView::Handle& theView);
//! Returns picking line.
//! @param theX direction X.
//! @param theX direction Y.
//! @return picking direction.
virtual gp_Lin PickingLine (const Standard_Real theX, const Standard_Real theY) const;
DEFINE_STANDARD_RTTI( IVtkOCC_ViewerSelector )
private:
Standard_Real myCoeff[14];
Standard_Real myPrevCoeff[14];
Standard_Real myCenter[2];
Standard_Real myPrevCenter[2];
Standard_Integer myPixTol;
Handle(Select3D_Projector) myPrj;
Standard_Boolean myToUpdateTol;
};

View File

@ -18,6 +18,7 @@
#include <vtkAutoInit.h>
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkTransform.h>
// Initialization of VTK object factories.
@ -159,3 +160,56 @@ bool IVtkVTK_View::DisplayToWorld (const gp_XY& theDisplayPnt, gp_XYZ& theWorldP
return true;
}
//================================================================
// Function : GetWindowSize
// Purpose :
//================================================================
void IVtkVTK_View::GetWindowSize (int& theX, int& theY) const
{
int* aSize = myRenderer->GetRenderWindow()->GetSize();
theX = aSize[0];
theY = aSize[1];
}
//================================================================
// Function : GetCamera
// Purpose :
//================================================================
void IVtkVTK_View::GetCamera (Graphic3d_Mat4d& theProj,
Graphic3d_Mat4d& theOrient,
Standard_Boolean& theIsOrtho) const
{
theIsOrtho = !IsPerspective();
vtkMatrix4x4* aCompositeProj =
myRenderer->GetActiveCamera()->GetCompositeProjectionTransformMatrix (myRenderer->GetTiledAspectRatio(),
0,
1);
for (Standard_Integer aRow = 0; aRow < 4; ++aRow)
{
for (Standard_Integer aCol = 0; aCol < 4; ++aCol)
{
theProj.SetValue (aRow, aCol, aCompositeProj->GetElement (aRow, aCol));
}
}
theOrient.InitIdentity();
}
//================================================================
// Function : GetViewport
// Purpose :
//================================================================
void IVtkVTK_View::GetViewport (Standard_Real& theX,
Standard_Real& theY,
Standard_Real& theWidth,
Standard_Real& theHeight) const
{
Standard_Real aViewport[4];
myRenderer->GetViewport (aViewport);
theX = aViewport[0];
theY = aViewport[1];
theWidth = aViewport[2];
theHeight = aViewport[3];
}

View File

@ -68,6 +68,20 @@ public:
//! @return Two doubles containing the display coordinates of the view window center
Standard_EXPORT virtual void GetViewCenter (double& theX, double& theY) const;
//! Gets window size in screen coordinates in pixels
Standard_EXPORT virtual void GetWindowSize (int& theX, int& theY) const Standard_OVERRIDE;
//! Gets camera projection and orientation matrices
Standard_EXPORT virtual void GetCamera (Graphic3d_Mat4d& theProj,
Graphic3d_Mat4d& theOrient,
Standard_Boolean& theIsOrtho) const Standard_OVERRIDE;
//! Gets viewport coordinates
Standard_EXPORT virtual void GetViewport (Standard_Real& theX,
Standard_Real& theY,
Standard_Real& theWidth,
Standard_Real& theHeight) const Standard_OVERRIDE;
//! Converts 3D display coordinates into 3D world coordinates.
//! @param [in] theDisplayPnt 2d point of display coordinates
//! @param [out] theWorldPnt 3d point of world coordinates

View File

@ -1,10 +1,20 @@
MeshVS_Buffer.hxx
MeshVS_EntityType.hxx
MeshVS_DisplayModeFlags.hxx
MeshVS_DummySensitiveEntity.hxx
MeshVS_DummySensitiveEntity.cxx
MeshVS_BuilderPriority.hxx
MeshVS_MeshPrsBuilder.lxx
MeshVS_TwoColors.hxx
MeshVS_TwoColors.cxx
MeshVS_TwoNodes.hxx
MeshVS_SelectionModeFlags.hxx
MeshVS_SensitiveFace.hxx
MeshVS_SensitiveFace.cxx
MeshVS_SensitiveMesh.hxx
MeshVS_SensitiveMesh.cxx
MeshVS_SensitiveSegment.hxx
MeshVS_SensitiveSegment.cxx
MeshVS_SensitivePolyhedron.hxx
MeshVS_SensitivePolyhedron.cxx
MeshVS_SymmetricPairHasher.hxx

View File

@ -141,12 +141,6 @@ is
class MeshOwner;
class MeshEntityOwner;
class DummySensitiveEntity;
class SensitiveMesh;
class SensitiveFace;
class SensitiveSegment;
class SensitivePolyhedron;
---Category: miscellaneous types: data maps, enumerations and other
imported EntityType;
@ -156,6 +150,11 @@ is
imported BuilderPriority;
imported TwoNodes;
imported Buffer;
imported SensitiveFace;
imported SensitiveMesh;
imported SensitiveSegment;
imported SensitivePolyhedron;
imported DummySensitiveEntity;
class Tool;

View File

@ -1,55 +0,0 @@
-- Created on: 2003-09-29
-- Created by: Alexander SOLOVYOV and Sergey LITONIN
-- Copyright (c) 2003-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class DummySensitiveEntity from MeshVS inherits SensitiveEntity from SelectBasics
---Purpose: This class allows to create owners to all elements or nodes,
-- both hidden and shown, but these owners user cannot select "by hands"
-- in viewer. They means for internal application tasks, for example, receiving
-- all owners, both for hidden and shown entities.
uses
EntityOwner from SelectBasics,
ListOfBox2d from SelectBasics,
PickArgs from SelectBasics,
Array1OfPnt2d from TColgp,
Box2d from Bnd
is
Create ( OwnerId : EntityOwner from SelectBasics ) returns DummySensitiveEntity from MeshVS;
Areas ( me: mutable;
aresult: in out ListOfBox2d from SelectBasics ) is redefined;
Matches (me : mutable;
thePickArgs : PickArgs from SelectBasics;
theMatchDMin, theMatchDepth : out Real from Standard)
returns Boolean is redefined;
Matches ( me: mutable;
XMin, YMin, XMax, YMax, aTol: Real ) returns Boolean is redefined;
Matches ( me: mutable;
Polyline : Array1OfPnt2d from TColgp;
aBox : Box2d from Bnd;
aTol : Real ) returns Boolean is redefined;
Is3D ( me ) returns Boolean is redefined;
NeedsConversion ( me ) returns Boolean is redefined;
MaxBoxes ( me ) returns Integer is redefined;
end DummySensitiveEntity;

View File

@ -13,84 +13,61 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <MeshVS_DummySensitiveEntity.ixx>
#include <MeshVS_DummySensitiveEntity.hxx>
#include <Bnd_Box2d.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
IMPLEMENT_STANDARD_HANDLE (MeshVS_DummySensitiveEntity, SelectBasics_SensitiveEntity)
IMPLEMENT_STANDARD_RTTIEXT(MeshVS_DummySensitiveEntity, SelectBasics_SensitiveEntity)
//================================================================
// Function : Constructor MeshVS_DummySensitiveEntity
// Purpose :
//================================================================
MeshVS_DummySensitiveEntity::MeshVS_DummySensitiveEntity
( const Handle(SelectBasics_EntityOwner)& OwnerId )
: SelectBasics_SensitiveEntity( OwnerId )
{
}
MeshVS_DummySensitiveEntity::MeshVS_DummySensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwnerId)
: SelectBasics_SensitiveEntity (theOwnerId)
{}
//================================================================
// Function : Areas
// Function : NbSubElements
// Purpose :
//================================================================
void MeshVS_DummySensitiveEntity::Areas( SelectBasics_ListOfBox2d& )
Standard_Integer MeshVS_DummySensitiveEntity::NbSubElements()
{
return -1;
}
//================================================================
// Function : Matches
// Purpose :
//================================================================
Standard_Boolean MeshVS_DummySensitiveEntity::Matches( const SelectBasics_PickArgs&,
Standard_Real&,
Standard_Real& )
Standard_Boolean MeshVS_DummySensitiveEntity::Matches (SelectBasics_SelectingVolumeManager& /*theMgr*/,
SelectBasics_PickResult& /*thePickResult*/)
{
return Standard_False;
}
//================================================================
// Function : Matches
// Function : BoundingBox
// Purpose :
//================================================================
Standard_Boolean MeshVS_DummySensitiveEntity::Matches( const Standard_Real,
const Standard_Real,
const Standard_Real,
const Standard_Real,
const Standard_Real )
Select3D_BndBox3d MeshVS_DummySensitiveEntity::BoundingBox()
{
return Standard_False;
return Select3D_BndBox3d();
}
//================================================================
// Function : Matches
// Function : ElementsNb
// Purpose :
//================================================================
Standard_Boolean MeshVS_DummySensitiveEntity::Matches( const TColgp_Array1OfPnt2d&,
const Bnd_Box2d&,
const Standard_Real )
{
return Standard_False;
}
void MeshVS_DummySensitiveEntity::BVH()
{}
//================================================================
// Function : NeedsConversion
// Function : Clear
// Purpose :
//================================================================
Standard_Boolean MeshVS_DummySensitiveEntity::NeedsConversion() const
{
return Standard_False;
}
//================================================================
// Function : Is3D
// Purpose :
//================================================================
Standard_Boolean MeshVS_DummySensitiveEntity::Is3D() const
{
return Standard_True;
}
//================================================================
// Function : MaxBoxes
// Purpose :
//================================================================
Standard_Integer MeshVS_DummySensitiveEntity::MaxBoxes() const
{
return 0;
}
void MeshVS_DummySensitiveEntity::Clear()
{}

View File

@ -0,0 +1,56 @@
// Created on: 2003-09-29
// Created by: Alexander SOLOVYOV and Sergey LITONIN
// Copyright (c) 2003-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _MeshVS_DummySensitiveEntity_HeaderFile
#define _MeshVS_DummySensitiveEntity_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <Select3D_BndBox3d.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <SelectBasics_SelectingVolumeManager.hxx>
class SelectBasics_EntityOwner;
//! This class allows to create owners to all elements or nodes,
//! both hidden and shown, but these owners user cannot select "by hands"
//! in viewer. They means for internal application tasks, for example, receiving
//! all owners, both for hidden and shown entities.
class MeshVS_DummySensitiveEntity : public SelectBasics_SensitiveEntity
{
public:
Standard_EXPORT MeshVS_DummySensitiveEntity (const Handle(SelectBasics_EntityOwner)& theOwnerId);
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
Standard_EXPORT virtual void Clear() Standard_OVERRIDE;
DEFINE_STANDARD_RTTI(MeshVS_DummySensitiveEntity)
};
DEFINE_STANDARD_HANDLE(MeshVS_DummySensitiveEntity, SelectBasics_SensitiveEntity)
#endif // _MeshVS_DummySensitiveEntity_HeaderFile

View File

@ -29,9 +29,9 @@ uses
NameOfColor from Quantity,
Selection from SelectMgr,
EntityOwner from SelectMgr,
SequenceOfOwner from SelectMgr,
Selection from SelectMgr,
EntityOwner from SelectMgr,
SequenceOfOwner from SelectMgr,
Boolean from Standard,
CString from Standard,

View File

@ -1,54 +0,0 @@
-- Created on: 2003-09-29
-- Created by: Alexander SOLOVYOV and Sergey LITONIN
-- Copyright (c) 2003-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class SensitiveFace from MeshVS inherits SensitiveFace from Select3D
---Purpose: This class provides custom sensitive face, which will be selected if it center is in rectangle.
uses
EntityOwner from SelectBasics,
Array1OfPnt from TColgp,
TypeOfSensitivity from Select3D,
Projector from Select3D,
Pnt from gp,
Pnt2d from gp,
Array1OfPnt2d from TColgp,
Box2d from Bnd
is
Create ( theOwner : EntityOwner from SelectBasics;
thePoints : Array1OfPnt from TColgp;
theSensType : TypeOfSensitivity from Select3D = Select3D_TOS_INTERIOR )
returns SensitiveFace from MeshVS;
Project( me: mutable; aProjector : Projector from Select3D ) is redefined;
Matches ( me: mutable; XMin, YMin, XMax, YMax: Real;
aTol: Real ) returns Boolean is redefined;
Matches ( me: mutable; Polyline: Array1OfPnt2d from TColgp;
aBox:Box2d; aTol: Real ) returns Boolean is redefined;
fields
myCentre : Pnt from gp is protected;
myProjCentre : Pnt2d from gp is protected;
end SensitiveFace;

View File

@ -13,70 +13,26 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <MeshVS_SensitiveFace.ixx>
#include <MeshVS_SensitiveFace.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <Select3D_Projector.hxx>
#include <CSLib_Class2d.hxx>
#include <TopLoc_Location.hxx>
IMPLEMENT_STANDARD_HANDLE (MeshVS_SensitiveFace, Select3D_SensitiveEntity)
IMPLEMENT_STANDARD_RTTIEXT(MeshVS_SensitiveFace, Select3D_SensitiveEntity)
//=======================================================================
// name : MeshVS_SensitiveFace::MeshVS_SensitiveFace
// Purpose :
//=======================================================================
MeshVS_SensitiveFace::MeshVS_SensitiveFace (
const Handle(SelectBasics_EntityOwner)& theOwnerId,
const TColgp_Array1OfPnt& thePnts,
const Select3D_TypeOfSensitivity theSensitivity )
: Select3D_SensitiveFace( theOwnerId, thePnts, theSensitivity )
MeshVS_SensitiveFace::MeshVS_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const TColgp_Array1OfPnt& thePnts,
const Select3D_TypeOfSensitivity theSensitivity)
: Select3D_SensitiveFace (theOwnerId, thePnts, theSensitivity)
{
gp_XYZ c( 0, 0, 0 );
Standard_Integer nbPnts = thePnts.Upper() - thePnts.Lower() + 1;
for ( Standard_Integer i = thePnts.Lower(); i <= thePnts.Upper(); i++ )
c += thePnts( i ).XYZ();
myCentre.SetXYZ( c / nbPnts );
}
gp_XYZ aCenter (0.0, 0.0, 0.0);
Standard_Integer aNbPnts = thePnts.Upper() - thePnts.Lower() + 1;
for (Standard_Integer aPntIdx = thePnts.Lower(); aPntIdx <= thePnts.Upper(); aPntIdx++)
aCenter += thePnts (aPntIdx).XYZ();
//=======================================================================
// name : MeshVS_SensitiveFace::Project
// Purpose :
//=======================================================================
void MeshVS_SensitiveFace::Project( const Handle(Select3D_Projector)& aProj )
{
Select3D_SensitiveFace::Project( aProj );
if ( HasLocation() )
aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
else
aProj->Project( myCentre, myProjCentre );
}
//=======================================================================
// name : MeshVS_SensitiveFace::Matches
// Purpose :
//=======================================================================
Standard_Boolean MeshVS_SensitiveFace::Matches( const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol )
{
Bnd_Box2d aBox;
aBox.Update( XMin-aTol, YMin-aTol, XMax+aTol, YMax+aTol );
return !aBox.IsOut( myProjCentre );
}
//=======================================================================
// name : MeshVS_SensitiveFace::Matches
// Purpose :
//=======================================================================
Standard_Boolean MeshVS_SensitiveFace::Matches( const TColgp_Array1OfPnt2d& Polyline,
const Bnd_Box2d& aBox,
const Standard_Real aTol )
{
Standard_Real Umin, Vmin, Umax, Vmax;
aBox.Get ( Umin,Vmin,Umax,Vmax );
CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
Standard_Integer aRes = aClassifier2d.SiDans( myProjCentre );
return ( aRes == 1) ;
myCenter.SetXYZ (aCenter / aNbPnts);
}

View File

@ -0,0 +1,49 @@
// Created on: 2003-09-29
// Created by: Alexander SOLOVYOV and Sergey LITONIN
// Copyright (c) 2003-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _MeshVS_SensitiveFace_HeaderFile
#define _MeshVS_SensitiveFace_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <gp_Pnt.hxx>
#include <Select3D_SensitiveFace.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Select3D_TypeOfSensitivity.hxx>
class SelectBasics_EntityOwner;
class TColgp_Array1OfPnt;
//! This class provides custom sensitive face, which will be selected if it center is in rectangle.
class MeshVS_SensitiveFace : public Select3D_SensitiveFace
{
public:
Standard_EXPORT MeshVS_SensitiveFace (const Handle(SelectBasics_EntityOwner)& theOwner,
const TColgp_Array1OfPnt& thePoints,
const Select3D_TypeOfSensitivity theSensType = Select3D_TOS_INTERIOR);
DEFINE_STANDARD_RTTI(MeshVS_SensitiveFace)
protected:
gp_Pnt myCenter;
};
DEFINE_STANDARD_HANDLE(MeshVS_SensitiveFace, Select3D_SensitiveFace)
#endif // _MeshVS_SensitiveFace_HeaderFile

View File

@ -1,69 +0,0 @@
-- Created on: 2007-01-25
-- Created by: Sergey KOCHETKOV
-- Copyright (c) 2007-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class SensitiveMesh from MeshVS inherits SensitiveEntity from Select3D
---Purpose: This class provides custom mesh sensitive entity used in advanced mesh selection.
---It provides detection of mesh entities accordingly to activated selection mode
uses
EntityOwner from SelectBasics,
Array1OfPnt2d from TColgp,
Box from Bnd,
Box2d from Bnd,
Location from TopLoc,
Lin from gp,
ListOfBox2d from SelectBasics,
PickArgs from SelectBasics,
Projector from Select3D
is
Create ( theOwner : EntityOwner from SelectBasics;
theMode : Integer = 0 )
returns SensitiveMesh from MeshVS;
GetMode( me ) returns Integer from Standard;
GetConnected( me: mutable; aLocation : Location from TopLoc )
returns SensitiveEntity from Select3D is redefined;
Matches (me : mutable;
thePickArgs : PickArgs from SelectBasics;
theMatchDMin, theMatchDepth : out Real from Standard)
returns Boolean is redefined;
Matches ( me: mutable; XMin, YMin, XMax, YMax : Real;
aTol : Real ) returns Boolean
is redefined;
Matches ( me: mutable; Polyline : Array1OfPnt2d from TColgp;
aBox : Box2d;
aTol : Real ) returns Boolean
is redefined;
Project ( me:mutable; aProjector : Projector from Select3D ) is redefined static;
Areas ( me: mutable ; boxes : in out ListOfBox2d from SelectBasics ) is redefined static;
ProjectOneCorner( me: mutable; aProjector : Projector from Select3D;
X,Y,Z : Real from Standard ) is private;
fields
myMode : Integer from Standard;
mybox : Box from Bnd;
mybox2d : Box2d from Bnd;
end SensitiveMesh;

View File

@ -13,15 +13,20 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <MeshVS_SensitiveMesh.ixx>
#include <MeshVS_SensitiveMesh.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HPackedMapOfInteger.hxx>
#include <Select3D_Projector.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <TopLoc_Location.hxx>
#include <MeshVS_DataSource.hxx>
#include <MeshVS_MeshOwner.hxx>
#include <NCollection_Vec4.hxx>
IMPLEMENT_STANDARD_HANDLE (MeshVS_SensitiveMesh, Select3D_SensitiveEntity)
IMPLEMENT_STANDARD_RTTIEXT(MeshVS_SensitiveMesh, Select3D_SensitiveEntity)
//=======================================================================
// name : MeshVS_SensitiveMesh::MeshVS_SensitiveMesh
@ -29,16 +34,24 @@
//=======================================================================
MeshVS_SensitiveMesh::MeshVS_SensitiveMesh (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const Standard_Integer theMode)
: Select3D_SensitiveEntity( theOwnerId )
: Select3D_SensitiveEntity (theOwnerId)
{
myMode = theMode;
mybox.SetVoid();
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast (OwnerId());
if( !anOwner.IsNull() )
{
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
if( !aDS.IsNull() )
mybox = aDS->GetBoundingBox();
if (!aDS.IsNull())
{
Bnd_Box aBox = aDS->GetBoundingBox();
Standard_Real aXMin, aYMin, aZMin;
Standard_Real aXMax, aYMax, aZMax;
aBox.Get (aXMin, aYMin, aZMin,
aXMax, aYMax, aZMax);
Select3D_Vec3 aMinPnt (aXMin, aYMin, aZMin);
Select3D_Vec3 aMaxPnt (aXMax, aYMax, aZMax);
myBndBox = Select3D_BndBox3d (aMinPnt, aMaxPnt);
}
}
}
@ -46,159 +59,54 @@ MeshVS_SensitiveMesh::MeshVS_SensitiveMesh (const Handle(SelectBasics_EntityOwne
// Function : GetMode
// Purpose :
//================================================================
Standard_Integer MeshVS_SensitiveMesh::GetMode () const
Standard_Integer MeshVS_SensitiveMesh::GetMode() const
{
return myMode;
}
//=======================================================================
// name : Matches
// Purpose :
//=======================================================================
Standard_Boolean MeshVS_SensitiveMesh::Matches (const SelectBasics_PickArgs& thePickArgs,
Standard_Real& theMatchDMin,
Standard_Real& theMatchDepth)
{
theMatchDMin = 0.0;
theMatchDepth = Precision::Infinite();
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
if( anOwner.IsNull() ) return Standard_False;
Handle(MeshVS_Mesh) aMeshPrs = Handle(MeshVS_Mesh)::DownCast( anOwner->Selectable() );
if( aMeshPrs.IsNull() ) return Standard_False;
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
if( aDS.IsNull() ) return Standard_False;
Handle(TColStd_HPackedMapOfInteger) NodesMap;
Handle(TColStd_HPackedMapOfInteger) ElemsMap;
// Mesh data source should provide the algorithm for computation
// of detected entities from 2D point
Standard_Boolean isDetected =
aDS->GetDetectedEntities (aMeshPrs, thePickArgs.X(), thePickArgs.Y(),
thePickArgs.Tolerance(), NodesMap,
ElemsMap, theMatchDMin);
// The detected entites will be available from mesh owner
anOwner->SetDetectedEntities( NodesMap, ElemsMap );
return isDetected;
}
//=======================================================================
// name : Matches
// Purpose :
//=======================================================================
Standard_Boolean MeshVS_SensitiveMesh::Matches(const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol)
{
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
if( anOwner.IsNull() ) return Standard_False;
Handle(MeshVS_Mesh) aMeshPrs = Handle(MeshVS_Mesh)::DownCast( anOwner->Selectable() );
if( aMeshPrs.IsNull() ) return Standard_False;
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
if( aDS.IsNull() ) return Standard_False;
Handle(TColStd_HPackedMapOfInteger) NodesMap;
Handle(TColStd_HPackedMapOfInteger) ElemsMap;
// Mesh data source should provide the algorithm for computation
// of detected entities from 2D box area
Standard_Boolean isDetected = aDS->GetDetectedEntities( aMeshPrs, XMin, YMin, XMax, YMax, aTol, NodesMap, ElemsMap );
// The detected entites will be available from mesh owner
anOwner->SetDetectedEntities( NodesMap, ElemsMap );
return isDetected;
}
//=======================================================================
// name : Matches
// Purpose :
//=======================================================================
Standard_Boolean MeshVS_SensitiveMesh::Matches(const TColgp_Array1OfPnt2d& Polyline,
const Bnd_Box2d& aBox,
const Standard_Real aTol)
{
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
if( anOwner.IsNull() ) return Standard_False;
Handle(MeshVS_Mesh) aMeshPrs = Handle(MeshVS_Mesh)::DownCast( anOwner->Selectable() );
if( aMeshPrs.IsNull() ) return Standard_False;
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
if( aDS.IsNull() ) return Standard_False;
Handle(TColStd_HPackedMapOfInteger) NodesMap;
Handle(TColStd_HPackedMapOfInteger) ElemsMap;
// Mesh data source should provide the algorithm for computation
// of detected entities from 2D polyline
Standard_Boolean isDetected = aDS->GetDetectedEntities( aMeshPrs, Polyline, aBox, aTol, NodesMap, ElemsMap );
// The detected entites will be available from mesh owner
anOwner->SetDetectedEntities( NodesMap, ElemsMap );
return isDetected;
}
//=======================================================================
// name : GetConnected
// Purpose :
//=======================================================================
Handle(Select3D_SensitiveEntity) MeshVS_SensitiveMesh::GetConnected( const TopLoc_Location& aLoc )
Handle(Select3D_SensitiveEntity) MeshVS_SensitiveMesh::GetConnected()
{
Handle(MeshVS_SensitiveMesh) aMeshEnt = new MeshVS_SensitiveMesh( myOwnerId );
if(HasLocation()) aMeshEnt->SetLocation( Location() );
aMeshEnt->UpdateLocation( aLoc );
Handle(MeshVS_SensitiveMesh) aMeshEnt = new MeshVS_SensitiveMesh (myOwnerId);
return aMeshEnt;
}
//==================================================
// Function: ProjectOneCorner
// Purpose :
//==================================================
void MeshVS_SensitiveMesh::ProjectOneCorner(const Handle(Select3D_Projector)& theProj,
const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theZ)
//=======================================================================
// function : NbSubElements
// purpose : Returns the amount of mesh nodes
//=======================================================================
Standard_Integer MeshVS_SensitiveMesh::NbSubElements()
{
gp_Pnt aPnt( theX, theY, theZ );
gp_Pnt2d aProjPnt;
if( HasLocation() )
theProj->Project( aPnt.Transformed(Location().Transformation()), aProjPnt );
else
theProj->Project( aPnt, aProjPnt );
mybox2d.Add( aProjPnt );
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast (OwnerId());
if (anOwner.IsNull())
return -1;
Handle(MeshVS_DataSource) aDataSource = anOwner->GetDataSource();
if (aDataSource.IsNull())
return -1;
return aDataSource->GetAllNodes().Extent();
}
//==================================================
// Function: Project
// Purpose :
//==================================================
void MeshVS_SensitiveMesh::Project(const Handle(Select3D_Projector)& aProj)
//=======================================================================
// function : BoundingBox
// purpose : Returns bounding box of mesh
//=======================================================================
Select3D_BndBox3d MeshVS_SensitiveMesh::BoundingBox()
{
mybox2d.SetVoid();
if (mybox.IsVoid())
return;
// Compute the 2D bounding box - projection of mesh bounding box
Handle(MeshVS_MeshOwner) anOwner = Handle(MeshVS_MeshOwner)::DownCast( OwnerId() );
if( anOwner.IsNull() ) return;
Handle(MeshVS_DataSource) aDS = anOwner->GetDataSource();
if( aDS.IsNull() ) return;
Standard_Real XMin, YMin, ZMin, XMax, YMax, ZMax;
mybox.Get( XMin, YMin, ZMin, XMax, YMax, ZMax );
ProjectOneCorner (aProj, XMin, YMin, ZMin);
ProjectOneCorner (aProj, XMin, YMin, ZMax);
ProjectOneCorner (aProj, XMin, YMax, ZMin);
ProjectOneCorner (aProj, XMin, YMax, ZMax);
ProjectOneCorner (aProj, XMax, YMin, ZMin);
ProjectOneCorner (aProj, XMax, YMin, ZMax);
ProjectOneCorner (aProj, XMax, YMax, ZMin);
ProjectOneCorner (aProj, XMax, YMax, ZMax);
return myBndBox;
}
//==================================================
// Function: Areas
// Purpose :
//==================================================
void MeshVS_SensitiveMesh::Areas( SelectBasics_ListOfBox2d& aSeq )
//=======================================================================
// function : CenterOfGeometry
// purpose : Returns center of mesh
//=======================================================================
gp_Pnt MeshVS_SensitiveMesh::CenterOfGeometry() const
{
aSeq.Append(mybox2d);
if (!myBndBox.IsValid())
return gp_Pnt (0.0, 0.0, 0.0);
SelectMgr_Vec3 aCenter = (myBndBox.CornerMax() + myBndBox.CornerMin()) * 0.5;
return gp_Pnt (aCenter.x(), aCenter.y(), aCenter.z());
}

View File

@ -0,0 +1,63 @@
// Created on: 2007-01-29
// Created by: Sergey KOCHETKOV
// Copyright (c) 2007-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _MeshVS_SensitiveMesh_HeaderFile
#define _MeshVS_SensitiveMesh_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <Bnd_Box.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <Select3D_BndBox3d.hxx>
class SelectBasics_EntityOwner;
class Select3D_SensitiveEntity;
//! This class provides custom mesh sensitive entity used in advanced mesh selection.
class MeshVS_SensitiveMesh : public Select3D_SensitiveEntity
{
public:
Standard_EXPORT MeshVS_SensitiveMesh (const Handle(SelectBasics_EntityOwner)& theOwner,
const Standard_Integer theMode = 0);
Standard_EXPORT Standard_Integer GetMode() const;
Standard_EXPORT virtual Handle(Select3D_SensitiveEntity) GetConnected() Standard_OVERRIDE;
//! Returns the amount of mesh nodes
Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
//! Returns bounding box of mesh
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
//! Returns center of mesh
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTI(MeshVS_SensitiveMesh)
private:
Standard_Integer myMode;
Select3D_BndBox3d myBndBox;
};
DEFINE_STANDARD_HANDLE(MeshVS_SensitiveMesh, Select3D_SensitiveEntity)
#endif // _MeshVS_SensitiveMesh_HeaderFile

View File

@ -1,78 +0,0 @@
-- Created on: 2005-01-21
-- Created by: Alexander SOLOVYOV
-- Copyright (c) 2005-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class SensitivePolyhedron from MeshVS inherits SensitiveEntity from Select3D
uses
EntityOwner from SelectBasics,
Projector from Select3D,
Location from TopLoc,
Real from Standard,
Boolean from Standard,
Array1OfPnt2d from TColgp,
SequenceOfInteger from TColStd,
Box2d from Bnd,
Lin from gp,
ListOfBox2d from SelectBasics,
PickArgs from SelectBasics,
Array1OfPnt from TColgp,
HArray1OfPnt from TColgp,
HArray1OfPnt2d from TColgp,
HArray1OfSequenceOfInteger from MeshVS,
XY from gp
is
Create( Owner : EntityOwner from SelectBasics;
Nodes : Array1OfPnt from TColgp;
Topo : HArray1OfSequenceOfInteger from MeshVS ) returns SensitivePolyhedron from MeshVS;
Project( me:mutable; aProjector: Projector from Select3D ) is redefined;
GetConnected( me:mutable; aLocation: Location from TopLoc ) returns SensitiveEntity from Select3D
is redefined;
Matches (me : mutable;
thePickArgs : PickArgs from SelectBasics;
theMatchDMin, theMatchDepth : out Real from Standard)
returns Boolean is redefined;
Matches( me : mutable;
XMin,YMin,XMax,YMax : Real from Standard;
aTol : Real from Standard ) returns Boolean from Standard is redefined;
Matches( me : mutable;
Polyline : Array1OfPnt2d from TColgp;
aBox : Box2d from Bnd;
aTol : Real from Standard ) returns Boolean from Standard is redefined;
GetBox2d( me; aBox : out Box2d from Bnd ) is protected;
FindIntersection( me; NodesIndices : SequenceOfInteger from TColStd;
EyeLine : Lin from gp ) returns Real is protected;
ComputeDepth( me; EyeLine: Lin from gp ) returns Real from Standard is virtual;
-- ComputeSize( me ) returns Real from Standard is redefined;
Areas( me: mutable; aResult : in out ListOfBox2d from SelectBasics ) is redefined;
fields
myNodes : HArray1OfPnt from TColgp;
myNodes2d : HArray1OfPnt2d from TColgp;
myTopo : HArray1OfSequenceOfInteger from MeshVS;
myCenter : XY from gp;
end SensitiveEntity;

View File

@ -13,289 +13,118 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <MeshVS_SensitivePolyhedron.ixx>
#include <MeshVS_SensitivePolyhedron.hxx>
#include <gp_Lin.hxx>
#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
#include <MeshVS_Tool.hxx>
#include <CSLib_Class2d.hxx>
#include <ElCLib.hxx>
#include <NCollection_Vec4.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_SequenceOfInteger.hxx>
IMPLEMENT_STANDARD_HANDLE (MeshVS_SensitivePolyhedron, Select3D_SensitiveEntity)
IMPLEMENT_STANDARD_RTTIEXT(MeshVS_SensitivePolyhedron, Select3D_SensitiveEntity)
//================================================================
// Function : Constructor MeshVS_SensitivePolyhedron
// Purpose :
//================================================================
MeshVS_SensitivePolyhedron::
MeshVS_SensitivePolyhedron( const Handle( SelectBasics_EntityOwner )& Owner,
const TColgp_Array1OfPnt& Nodes,
const Handle( MeshVS_HArray1OfSequenceOfInteger )& Topo )
: Select3D_SensitiveEntity( Owner ),
myTopo( Topo )
MeshVS_SensitivePolyhedron::MeshVS_SensitivePolyhedron (const Handle(SelectBasics_EntityOwner)& theOwner,
const TColgp_Array1OfPnt& theNodes,
const Handle(MeshVS_HArray1OfSequenceOfInteger)& theTopo)
: Select3D_SensitiveEntity (theOwner),
myTopo (theTopo)
{
Standard_Integer low = Nodes.Lower(), up = Nodes.Upper(), i;
Standard_Integer aPlaneLowIdx = theTopo->Lower();
Standard_Integer aPlaneUpIdx = theTopo->Upper();
Standard_Integer aNodesLowerIdx = theNodes.Lower();
myNodes = new TColgp_HArray1OfPnt (aNodesLowerIdx, theNodes.Upper());
myCenter = gp_XYZ (0.0, 0.0, 0.0);
myNodes = new TColgp_HArray1OfPnt ( low, up );
for( i=low; i<=up; i++ )
myNodes->SetValue( i, Nodes.Value( i ) );
myNodes2d = new TColgp_HArray1OfPnt2d( low, up );
}
//================================================================
// Function : Project
// Purpose :
//================================================================
void MeshVS_SensitivePolyhedron::Project( const Handle(Select3D_Projector)& aProjector )
{
if( myNodes.IsNull() || myNodes2d.IsNull() )
return;
Standard_Integer low = myNodes->Lower(),
up = myNodes->Upper();
gp_Pnt pnt;
gp_Pnt2d proj;
Standard_Boolean hasLoc = HasLocation();
myCenter = gp_XY( 0, 0 );
for( Standard_Integer i=low; i<=up; i++ )
for (Standard_Integer aPlaneIdx = aPlaneLowIdx; aPlaneIdx <= aPlaneUpIdx; ++aPlaneIdx)
{
pnt = myNodes->Value( i );
if( !hasLoc )
aProjector->Project( pnt, proj );
else
aProjector->Project( pnt.Transformed( Location().Transformation() ), proj );
Standard_Integer aVertNb = theTopo->Value (aPlaneIdx).Length();
Handle(TColgp_HArray1OfPnt) aVertArray = new TColgp_HArray1OfPnt (0, aVertNb - 1);
for (Standard_Integer aVertIdx = 1; aVertIdx <= aVertNb; ++aVertIdx)
{
Standard_Integer aNodeIdx = theTopo->Value (aPlaneIdx).Value (aVertIdx);
const gp_Pnt& aVert = theNodes.Value (aNodeIdx + aNodesLowerIdx);
aVertArray->SetValue (aVertIdx - 1, aVert);
myNodes->SetValue (aNodeIdx + aNodesLowerIdx, aVert);
myBndBox.Add (SelectMgr_Vec3 (aVert.X(), aVert.Y(), aVert.Z()));
myCenter += aVert.XYZ();
}
myNodes2d->SetValue( i, proj.XY() );
myCenter += proj.XY();
myTopology.Append (aVertArray);
}
myCenter /= ( up-low+1 );
myCenter.Divide (theNodes.Length());
}
//================================================================
// Function : GetConnected
// Purpose :
//================================================================
Handle( Select3D_SensitiveEntity ) MeshVS_SensitivePolyhedron::GetConnected
( const TopLoc_Location& aLocation )
Handle(Select3D_SensitiveEntity) MeshVS_SensitivePolyhedron::GetConnected()
{
Handle( MeshVS_SensitivePolyhedron ) NewEnt = new
MeshVS_SensitivePolyhedron( myOwnerId, myNodes->Array1(), myTopo );
Handle(MeshVS_SensitivePolyhedron) aNewEnt = new
MeshVS_SensitivePolyhedron (myOwnerId, myNodes->Array1(), myTopo);
if( HasLocation() )
NewEnt->SetLocation( Location() );
NewEnt->UpdateLocation( aLocation );
return NewEnt;
return aNewEnt;
}
//================================================================
// Function : sort
// Purpose :
//================================================================
void sort( Standard_Real& a, Standard_Real& b )
//=======================================================================
// function : Matches
// purpose :
//=======================================================================
Standard_Boolean MeshVS_SensitivePolyhedron::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
if( a>b )
Standard_Real aDepthMin = RealLast();
Standard_Real aDistToCOG = RealLast();
for (MeshVS_PolyhedronVertsIter aIter (myTopology); aIter.More(); aIter.Next())
{
Standard_Real temp = a; a = b; b = temp;
}
}
//================================================================
// Function : Matches
// Purpose :
//================================================================
Standard_Boolean MeshVS_SensitivePolyhedron::Matches( const SelectBasics_PickArgs& thePickArgs,
Standard_Real& /*theMatchDMin*/,
Standard_Real& theMatchDepth )
{
if( myNodes2d.IsNull() || myTopo.IsNull() )
return Standard_False;
Standard_Integer R1 = myTopo->Lower(),
R2 = myTopo->Upper(),
low = myNodes2d->Lower();
Standard_Real rTol = thePickArgs.Tolerance() * SensitivityFactor();
Standard_Boolean inside = Standard_False;
// "odd-even" algorithm: with ray parallel axis of absciss and toward positive
for( Standard_Integer i=R1; i<=R2 && !inside; i++ )
{
Standard_Integer intersect = 0, cur, next, C1 = 1, C2 = myTopo->Value( i ).Length();
Standard_Real k, b, // y=kx+b -- equation of polygon's edge
x1, y1, x2, y2, xp; // auxiliary points
for( Standard_Integer j=C1; j<=C2; j++ )
Standard_Real aDepth = RealLast();
if (theMgr.Overlaps (aIter.Value(), Select3D_TOS_INTERIOR, aDepth))
{
cur = myTopo->Value( i ).Value( j );
next = myTopo->Value( i ).Value( j<C2 ? j+1 : C1 );
x1 = myNodes2d->Value( low+cur ).X(),
y1 = myNodes2d->Value( low+cur ).Y(),
x2 = myNodes2d->Value( low+next ).X(),
y2 = myNodes2d->Value( low+next ).Y();
if( Abs( x2-x1 )<Precision::Confusion() )
{
//vertical edge!!!
sort( y1, y2 );
if ( thePickArgs.Y() >= y1 - rTol && thePickArgs.Y() <= y2 + rTol && x1 > thePickArgs.X() - rTol )
intersect++;
}
else
{
//inclined edge!!!
k = ( y2-y1 ) / ( x2-x1 );
b = y1 - k*x1;
if( Abs( k )>Precision::Confusion() )
{
xp = ( thePickArgs.Y() - b ) / k; // absciss of point of intersection
sort( x1, x2 );
if( xp >= x1 && xp <= x2 && xp > thePickArgs.X() - rTol )
intersect++;
}
}
}
inside = ( intersect%2 ) == 1;
}
if( inside )
{
theMatchDepth = ComputeDepth (thePickArgs.PickLine());
return !thePickArgs.IsClipped(theMatchDepth);
}
return Standard_False;
}
//================================================================
// Function : Matches
// Purpose :
//================================================================
Standard_Boolean MeshVS_SensitivePolyhedron::Matches( const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol )
{
Standard_Real rTol = aTol*SensitivityFactor();
return myCenter.X()>=XMin-rTol && myCenter.X()<=XMax+rTol &&
myCenter.Y()>=YMin-rTol && myCenter.Y()<=YMax+rTol;
}
//================================================================
// Function : Matches
// Purpose :
//================================================================
Standard_Boolean MeshVS_SensitivePolyhedron::Matches
( const TColgp_Array1OfPnt2d& Polyline,
const Bnd_Box2d& aBox,
const Standard_Real aTol )
{
Standard_Real Umin, Vmin, Umax, Vmax;
aBox.Get( Umin, Vmin, Umax, Vmax );
CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
Standard_Integer res = aClassifier2d.SiDans( myCenter );
return( res==1 );
}
//================================================================
// Function : FindIntersection
// Purpose :
//================================================================
Standard_Real MeshVS_SensitivePolyhedron::FindIntersection
( const TColStd_SequenceOfInteger& NodesIndices,
const gp_Lin& EyeLine) const
{
Standard_Real val( Precision::Infinite() );
for( Standard_Integer i=1, n=NodesIndices.Length(); i<=n; i++ )
val = Min( val, ElCLib::Parameter(
EyeLine, myNodes->Value( myNodes->Lower()+NodesIndices.Value( i ) ) ) );
return val;
}
//================================================================
// Function : ComputeDepth
// Purpose :
//================================================================
Standard_Real MeshVS_SensitivePolyhedron::ComputeDepth( const gp_Lin& EyeLine ) const
{
Standard_Real val = Precision::Infinite();
if( !myTopo.IsNull() )
for( Standard_Integer i=myTopo->Lower(), up=myTopo->Upper(); i<=up; i++ )
val = Min( val, FindIntersection( myTopo->Value( i ), EyeLine ) );
return val;
}
//================================================================
// Function : ComputeSize
// Purpose :
//================================================================
/*Standard_Real MeshVS_SensitivePolyhedron::ComputeSize() const
{
Bnd_Box2d aBox;
GetBox2d( aBox );
Standard_Real aXmin, aYmin, aXmax, aYmax;
aBox.Get( aXmin, aYmin, aXmax, aYmax );
return Abs( ( aXmax-aXmin ) * ( aYmax-aYmin ) );
} */
//================================================================
// Function : Areas
// Purpose :
//================================================================
void MeshVS_SensitivePolyhedron::Areas( SelectBasics_ListOfBox2d& aResult )
{
Bnd_Box2d aBox;
GetBox2d( aBox );
aResult.Append( aBox );
}
//================================================================
// Function : GetBox2d
// Purpose :
//================================================================
void MeshVS_SensitivePolyhedron::GetBox2d( Bnd_Box2d& aBox ) const
{
aBox.SetVoid();
Standard_Real xmin = 0., ymin = 0., xmax = 0., ymax = 0., x, y;
Standard_Integer low = myNodes2d->Lower(),
up = myNodes2d->Upper();
if( !myNodes2d.IsNull() )
{
xmin = xmax = myNodes2d->Value( low ).X();
ymin = ymax = myNodes2d->Value( low ).Y();
for( Standard_Integer i=low+1; i<=up; i++ )
{
x = myNodes2d->Value( i ).X();
y = myNodes2d->Value( i ).Y();
if( x>xmax )
xmax = x;
else if( x<xmin )
xmin = x;
if( y>ymax )
ymax = y;
else if( y<ymin )
ymin = y;
aDepthMin = Min (aDepth, aDepthMin);
}
}
aBox.Update( xmin, ymin, xmax, ymax );
aDistToCOG = aDepthMin == RealLast() ? RealLast() : theMgr.DistToGeometryCenter (myCenter);
thePickResult = SelectBasics_PickResult (aDepthMin, aDistToCOG);
return aDepthMin != RealLast();
}
//=======================================================================
// function : NbSubElements
// purpose : Returns the amount of nodes of polyhedron
//=======================================================================
Standard_Integer MeshVS_SensitivePolyhedron::NbSubElements()
{
return myNodes->Length();
}
//=======================================================================
// function : BoundingBox
// purpose :
//=======================================================================
Select3D_BndBox3d MeshVS_SensitivePolyhedron::BoundingBox()
{
return myBndBox;
}
//=======================================================================
// function : CenterOfGeometry
// purpose :
//=======================================================================
gp_Pnt MeshVS_SensitivePolyhedron::CenterOfGeometry() const
{
return myCenter;
}

View File

@ -0,0 +1,85 @@
// Created on: 2005-01-21
// Created by: Alexander SOLOVYOV
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _MeshVS_SensitivePolyhedron_HeaderFile
#define _MeshVS_SensitivePolyhedron_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <Handle_TColgp_HArray1OfPnt.hxx>
#include <Handle_TColgp_HArray1OfPnt2d.hxx>
#include <Handle_MeshVS_HArray1OfSequenceOfInteger.hxx>
#include <gp_XY.hxx>
#include <NCollection_List.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <Select3D_BndBox3d.hxx>
class TColgp_HArray1OfPnt;
class TColgp_HArray1OfPnt2d;
class MeshVS_HArray1OfSequenceOfInteger;
class SelectBasics_EntityOwner;
class TColgp_Array1OfPnt;
class Select3D_SensitiveEntity;
class TopLoc_Location;
class TColgp_Array1OfPnt2d;
class Bnd_Box2d;
class TColStd_SequenceOfInteger;
class gp_Lin;
class SelectBasics_ListOfBox2d;
typedef NCollection_List<Handle(TColgp_HArray1OfPnt)> MeshVS_PolyhedronVerts;
typedef NCollection_List<Handle(TColgp_HArray1OfPnt)>::Iterator MeshVS_PolyhedronVertsIter;
//! This class is used to detect selection of a polyhedron. The main
//! principle of detection algorithm is to search for overlap with
//! each polyhedron's face separately, treating them as planar convex
//! polygons.
class MeshVS_SensitivePolyhedron : public Select3D_SensitiveEntity
{
public:
Standard_EXPORT MeshVS_SensitivePolyhedron (const Handle(SelectBasics_EntityOwner)& theOwner,
const TColgp_Array1OfPnt& theNodes,
const Handle(MeshVS_HArray1OfSequenceOfInteger)& theTopo);
Standard_EXPORT virtual Handle_Select3D_SensitiveEntity GetConnected() Standard_OVERRIDE;
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Returns the amount of nodes of polyhedron
Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
DEFINE_STANDARD_RTTI(MeshVS_SensitivePolyhedron)
private:
MeshVS_PolyhedronVerts myTopology;
gp_XYZ myCenter;
Select3D_BndBox3d myBndBox;
Handle(TColgp_HArray1OfPnt) myNodes;
Handle(MeshVS_HArray1OfSequenceOfInteger) myTopo;
};
DEFINE_STANDARD_HANDLE(MeshVS_SensitivePolyhedron, Select3D_SensitiveEntity)
#endif // _MeshVS_SensitivePolyhedron_HeaderFile

View File

@ -1,53 +0,0 @@
-- Created on: 2003-09-29
-- Created by: Alexander SOLOVYOV and Sergey LITONIN
-- Copyright (c) 2003-2014 OPEN CASCADE SAS
--
-- This file is part of Open CASCADE Technology software library.
--
-- This library is free software; you can redistribute it and/or modify it under
-- the terms of the GNU Lesser General Public License version 2.1 as published
-- by the Free Software Foundation, with special exception defined in the file
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-- distribution for complete text of the license and disclaimer of any warranty.
--
-- Alternatively, this file may be used under the terms of Open CASCADE
-- commercial license or contractual agreement.
class SensitiveSegment from MeshVS inherits SensitiveSegment from Select3D
---Purpose: This class provides custom sensitive face, which will be selected if it center is in rectangle.
uses
EntityOwner from SelectBasics,
Array1OfPnt from TColgp,
TypeOfSensitivity from Select3D,
Projector from Select3D,
Pnt from gp,
Pnt2d from gp,
Array1OfPnt2d from TColgp,
Box2d from Bnd
is
Create ( theOwner : EntityOwner from SelectBasics;
theFirstP, theLastP : Pnt from gp;
theMaxRect : Integer = 1 ) returns SensitiveSegment from MeshVS;
Project( me: mutable; aProjector : Projector from Select3D ) is redefined;
Matches ( me: mutable; XMin, YMin, XMax, YMax: Real;
aTol: Real ) returns Boolean is redefined;
Matches ( me: mutable; Polyline: Array1OfPnt2d from TColgp;
aBox: Box2d; aTol: Real ) returns Boolean is redefined;
fields
myCentre : Pnt from gp is protected;
myProjCentre : Pnt2d from gp is protected;
end SensitiveSegment;

View File

@ -13,66 +13,19 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <MeshVS_SensitiveSegment.ixx>
#include <Select3D_Projector.hxx>
#include <Bnd_Box2d.hxx>
#include <CSLib_Class2d.hxx>
#include <TopLoc_Location.hxx>
#include <MeshVS_SensitiveSegment.hxx>
#include <SelectBasics_EntityOwner.hxx>
IMPLEMENT_STANDARD_HANDLE (MeshVS_SensitiveSegment, Select3D_SensitiveSegment)
IMPLEMENT_STANDARD_RTTIEXT(MeshVS_SensitiveSegment, Select3D_SensitiveSegment)
//=======================================================================
// name : MeshVS_SensitiveSegment::MeshVS_SensitiveSegment
// Purpose :
//=======================================================================
MeshVS_SensitiveSegment::MeshVS_SensitiveSegment (
const Handle(SelectBasics_EntityOwner)& theOwnerId,
const gp_Pnt& theFirstP,
const gp_Pnt& theLastP,
const Standard_Integer theMaxRect )
: Select3D_SensitiveSegment( theOwnerId, theFirstP, theLastP, theMaxRect )
{
myCentre.SetXYZ( ( theFirstP.XYZ() + theLastP.XYZ() ) / 2 );
}
//=======================================================================
// name : MeshVS_SensitiveSegment::Project
// Purpose :
//=======================================================================
void MeshVS_SensitiveSegment::Project( const Handle(Select3D_Projector)& aProj )
{
Select3D_SensitiveSegment::Project( aProj );
if ( HasLocation() )
aProj->Project( myCentre.Transformed( Location().Transformation() ), myProjCentre );
else
aProj->Project( myCentre, myProjCentre );
}
//=======================================================================
// name : MeshVS_SensitiveSegment::Matches
// Purpose :
//=======================================================================
Standard_Boolean MeshVS_SensitiveSegment::Matches( const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol )
{
Bnd_Box2d aBox;
aBox.Update( XMin-aTol, YMin-aTol, XMax+aTol, YMax+aTol );
return !aBox.IsOut( myProjCentre );
}
//=======================================================================
// name : MeshVS_SensitiveSegment::Matches
// Purpose :
//=======================================================================
Standard_Boolean MeshVS_SensitiveSegment::Matches( const TColgp_Array1OfPnt2d& Polyline,
const Bnd_Box2d& aBox,
const Standard_Real aTol )
{
Standard_Real Umin, Vmin, Umax, Vmax;
aBox.Get ( Umin,Vmin,Umax,Vmax );
CSLib_Class2d aClassifier2d( Polyline, aTol, aTol, Umin, Vmin, Umax, Vmax );
Standard_Integer aRes = aClassifier2d.SiDans( myProjCentre );
return ( aRes == 1) ;
}
MeshVS_SensitiveSegment::MeshVS_SensitiveSegment (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const gp_Pnt& theFirstPnt,
const gp_Pnt& theLastPnt)
: Select3D_SensitiveSegment (theOwnerId, theFirstPnt, theLastPnt)
{}

View File

@ -0,0 +1,44 @@
// Created on: 2003-09-29
// Created by: Alexander SOLOVYOV and Sergey LITONIN
// Copyright (c) 2003-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _MeshVS_SensitiveSegment_HeaderFile
#define _MeshVS_SensitiveSegment_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineHandle.hxx>
#include <gp_Pnt.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
class SelectBasics_EntityOwner;
class gp_Pnt;
//! This class provides custom sensitive face, which will be selected if it center is in rectangle.
class MeshVS_SensitiveSegment : public Select3D_SensitiveSegment
{
public:
Standard_EXPORT MeshVS_SensitiveSegment (const Handle(SelectBasics_EntityOwner)& theOwner,
const gp_Pnt& theFirstPnt,
const gp_Pnt& theLastPnt);
DEFINE_STANDARD_RTTI(MeshVS_SensitiveSegment)
};
DEFINE_STANDARD_HANDLE(MeshVS_SensitiveSegment, Select3D_SensitiveSegment)
#endif // _MeshVS_SensitiveSegment_HeaderFile

View File

@ -234,6 +234,10 @@ is
Transformation(me) returns any Trsf from gp;
---C++: inline
---C++: return const&
InversedTransformation(me) returns any Trsf from gp;
---C++: inline
---C++: return const&
ResetTransformation(me:mutable) is virtual;
---Purpose: resets local transformation to identity.
@ -330,6 +334,7 @@ fields
myLocalTransformation : Trsf from gp; -- Own transformation of presentable object.
myTransformation : Trsf from gp; -- Combined transformation of presentable object.
myInvTransformation : Trsf from gp; -- Inverted combined transformation of presentable object.
myCombinedParentTransform : Trsf from gp; -- Combined transformation of presentable object excepting local transformation.
myChildren : ListOfPresentableObjects from PrsMgr; -- Child objects in scene hierarchy.

View File

@ -269,6 +269,7 @@ void PrsMgr_PresentableObject::SetCombinedParentTransform (const gp_Trsf& theTra
void PrsMgr_PresentableObject::UpdateTransformation()
{
myTransformation = myCombinedParentTransform * myLocalTransformation;
myInvTransformation = myTransformation.Inverted();
Handle(Geom_Transformation) aTrsf = new Geom_Transformation (myTransformation);
for (Standard_Integer aPrsIter = 1; aPrsIter <= myPresentations.Length(); ++aPrsIter)

View File

@ -28,6 +28,11 @@ inline const gp_Trsf& PrsMgr_PresentableObject::Transformation() const
return myTransformation;
}
inline const gp_Trsf& PrsMgr_PresentableObject::InversedTransformation() const
{
return myInvTransformation;
}
inline const PrsMgr_ListOfPresentableObjects& PrsMgr_PresentableObject::Children() const
{
return myChildren;

View File

@ -5270,7 +5270,7 @@ Standard_Integer CR23234 (Draw_Interpretor& di, Standard_Integer argc, const cha
aisContext->OpenLocalContext();
//aisContext->ActivateStandardMode(TopAbs_ShapeEnum::TopAbs_EDGE);
aisContext->ActivateStandardMode(TopAbs_EDGE);
aisContext->SetSensitivity(8);
aisContext->SetPixelTolerance(8);
return 0; //TCL_OK
}

View File

@ -117,7 +117,7 @@ static Standard_Integer OCC137 (Draw_Interpretor& di, Standard_Integer argc, con
const Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4);
if(!aSelection.IsNull()) {
for(aSelection->Init();aSelection->More();aSelection->Next()) {
Handle(StdSelect_BRepOwner) aO = Handle(StdSelect_BRepOwner)::DownCast(aSelection->Sensitive()->OwnerId());
Handle(StdSelect_BRepOwner) aO = Handle(StdSelect_BRepOwner)::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
aO->SetHilightMode(Draw::Atoi(argv[1]));
}
}

View File

@ -20,16 +20,12 @@ uses
PresentationManager3d from PrsMgr,
Presentation from Prs3d,
NameOfColor from Quantity,
Selection from SelectMgr
Selection from SelectMgr
is
Create(aText :ExtendedString from TCollection;aPosition : Pnt from gp)
returns MyText from QABugs;
Create(aText :ExtendedString from TCollection;aPosition : Pnt from gp;aFont : CString from Standard; aColor : NameOfColor from Quantity; aHeight :Real from Standard)
returns MyText from QABugs;
NbPossibleSelection(me)
returns Integer from Standard
is redefined virtual protected;
Compute(me:mutable;
aPresentationManager: PresentationManager3d from PrsMgr;

View File

@ -77,10 +77,3 @@ void QABugs_MyText::ComputeSelection(const Handle(SelectMgr_Selection)& aSelecti
myPosition.Z() + 20);
aSelection->Add(box);
}
Standard_Integer QABugs_MyText::NbPossibleSelection() const
{
return 1;
}

View File

@ -1,5 +1,43 @@
Select3D_Pnt.hxx
Select3D_Pnt2d.hxx
Select3D_Box2d.hxx
Select3D_Macro.hxx
Select3D_PointData.hxx
Select3D_PointData.hxx
Select3D_BoundarySensitivePointSet.hxx
Select3D_BoundarySensitivePointSet.cxx
Select3D_BndBox3d.hxx
Select3D_BVHPrimitiveContent.hxx
Select3D_BVHPrimitiveContent.cxx
Select3D_InteriorSensitivePointSet.hxx
Select3D_InteriorSensitivePointSet.cxx
Select3D_ISensitivePointSet.hxx
Select3D_EntitySequence.hxx
Select3D_SensitiveBox.hxx
Select3D_SensitiveBox.cxx
Select3D_SensitiveCircle.hxx
Select3D_SensitiveCircle.cxx
Select3D_SensitiveCurve.hxx
Select3D_SensitiveCurve.cxx
Select3D_SensitiveEntity.hxx
Select3D_SensitiveEntity.cxx
Select3D_SensitiveFace.hxx
Select3D_SensitiveFace.cxx
Select3D_SensitiveGroup.hxx
Select3D_SensitiveGroup.cxx
Select3D_SensitiveGroup.lxx
Select3D_SensitivePoint.hxx
Select3D_SensitivePoint.cxx
Select3D_SensitivePoly.hxx
Select3D_SensitivePoly.cxx
Select3D_SensitivePoly.lxx
Select3D_SensitiveSegment.hxx
Select3D_SensitiveSegment.cxx
Select3D_SensitiveSegment.lxx
Select3D_SensitiveSet.hxx
Select3D_SensitiveSet.cxx
Select3D_SensitiveTriangle.hxx
Select3D_SensitiveTriangle.cxx
Select3D_SensitiveTriangulation.hxx
Select3D_SensitiveTriangulation.cxx
Select3D_SensitiveTriangulation.lxx
Select3D_SensitiveWire.hxx
Select3D_SensitiveWire.cxx
Select3D_TypeOfSensitivity.hxx

View File

@ -37,60 +37,34 @@ uses
TopLoc,
Geom,
SelectBasics,
SelectMgr,
V3d,
Graphic3d
is
---Category: sensitive entities
enumeration TypeOfSensitivity is TOS_INTERIOR,TOS_BOUNDARY
end TypeOfSensitivity;
---Purpose: Provides values for type of sensitivity in 3D.
-- These are used to specify whether it is the interior,
-- the boundary, or the exterior of a 3D sensitive entity which is sensitive.
deferred class SensitiveEntity;
deferred class SensitivePoly;
class SensitivePoint;
class SensitiveSegment;
class SensitiveCircle;
class SensitiveCurve;
class SensitiveTriangle;
class SensitiveTriangulation;
class SensitiveFace;
class SensitiveBox;
class SensitiveWire;
class SensitiveGroup;
class SensitiveEntitySequence instantiates Sequence from TCollection
(SensitiveEntity from Select3D);
---Category: selectors/projectors
class Projector;
class ListOfSensitiveTriangle instantiates List from TCollection
(SensitiveTriangle from Select3D);
class ListOfSensitive instantiates List from TCollection
(SensitiveEntity from Select3D);
imported BndBox3d;
imported BoundarySensitivePointSet;
imported BVHPrimitiveContent;
imported InteriorSensitivePointSet;
imported ISensitivePointSet;
imported EntitySequence;
imported Pnt;
imported Pnt2d;
imported Box2d;
imported PointData;
imported SelectingVolumeManager;
imported SensitiveBox;
imported SensitiveCircle;
imported SensitiveCurve;
imported transient class SensitiveEntity;
imported SensitiveFace;
imported SensitiveGroup;
imported SensitivePoint;
imported SensitivePoly;
imported SensitiveSegment;
imported SensitiveSet;
imported SensitiveTriangle;
imported SensitiveTriangulation;
imported SensitiveWire;
imported TypeOfSensitivity;
end Select3D;

View File

@ -0,0 +1,80 @@
// Created on: 2014-05-30
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <BVH_LinearBuilder.hxx>
#include <Select3D_SensitiveSet.hxx>
#include <Select3D_BVHPrimitiveContent.hxx>
//=======================================================================
// function : Select3D_BVHPrimitiveContent
// purpose : Initializes new linear BVH builder for the set of sensitives
// theSensitiveSet given
//=======================================================================
Select3D_BVHPrimitiveContent::Select3D_BVHPrimitiveContent (const Handle(Select3D_SensitiveSet)& theSensitiveSet)
{
mySensitiveSet = theSensitiveSet;
myBuilder = new BVH_LinearBuilder<Standard_Real, 3> (8, 32);
MarkDirty();
}
//=======================================================================
// function : Size
// purpose : Returns the length of set of sensitives
//=======================================================================
Standard_Integer Select3D_BVHPrimitiveContent::Size() const
{
return mySensitiveSet->Size();
}
//=======================================================================
// function : Box
// purpose : Returns bounding box of sensitive with index theIdx
//=======================================================================
Select3D_BndBox3d Select3D_BVHPrimitiveContent::Box (const Standard_Integer theIdx) const
{
return mySensitiveSet->Box (theIdx);
}
//=======================================================================
// function : Center
// purpose : Returns center of sensitive with index theIdx in the set
// along the given axis theAxis
//=======================================================================
Standard_Real Select3D_BVHPrimitiveContent::Center (const Standard_Integer theIdx,
const Standard_Integer theAxis) const
{
return mySensitiveSet->Center (theIdx, theAxis);
}
//=======================================================================
// function : Swap
// purpose : Swaps items with indexes theIdx1 and theIdx2 in the set
//=======================================================================
void Select3D_BVHPrimitiveContent::Swap (const Standard_Integer theIdx1,
const Standard_Integer theIdx2)
{
mySensitiveSet->Swap (theIdx1, theIdx2);
}
//=======================================================================
// function : GetBVH
// purpose : Returns the tree built for set of sensitives
//=======================================================================
const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& Select3D_BVHPrimitiveContent::GetBVH()
{
return BVH();
}

View File

@ -0,0 +1,57 @@
// Created on: 2014-05-30
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Select3D_BVHPrimitiveContent_Header
#define _Select3D_BVHPrimitiveContent_Header
#include <BVH_PrimitiveSet.hxx>
class Select3D_SensitiveSet;
//! The purpose of this class is to provide a link between BVH_PrimitiveSet
//! and Select3D_SensitiveSet instance to build BVH tree for set of sensitives
class Select3D_BVHPrimitiveContent : public BVH_PrimitiveSet<Standard_Real, 3>
{
public:
//! Initializes new linear BVH builder for the set of sensitives
//! theSensitiveSet given
Select3D_BVHPrimitiveContent (const Handle(Select3D_SensitiveSet)& theSensitiveSet);
~Select3D_BVHPrimitiveContent() {};
//! Returns the length of set of sensitives
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
//! Returns bounding box of sensitive with index theIdx
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
//! Returns center of sensitive with index theIdx in the set along the
//! given axis theAxis
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
const Standard_Integer theAxis) const Standard_OVERRIDE;
//! Swaps items with indexes theIdx1 and theIdx2 in the set
Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
const Standard_Integer theIdx2) Standard_OVERRIDE;
//! Returns the tree built for set of sensitives
Standard_EXPORT const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& GetBVH();
protected:
Handle(Select3D_SensitiveSet) mySensitiveSet; //!< Set of sensitive entities
};
#endif // _Select3D_BVHPrimitiveContent_Header

View File

@ -1,7 +1,6 @@
// Created on: 1997-07-16
// Created by: Robert COUBLANC
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
// Created on: 2014-29-05
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
@ -14,5 +13,17 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
inline const Bnd_Box& Select3D_SensitiveBox::Box() const
{return mybox3d;}
#ifndef _Select3D_BndBox3d_Header
#define _Select3D_BndBox3d_Header
#include <BVH_Box.hxx>
#include <BVH_Types.hxx>
#include <gp_Trsf.hxx>
#include <NCollection_Vector.hxx>
typedef BVH_Box<Standard_Real, 3> Select3D_BndBox3d;
typedef NCollection_Vec3<Standard_Real> Select3D_Vec3;
#endif // _Select3D_BndBox3d_Header

View File

@ -0,0 +1,95 @@
// Created on: 2014-11-10
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Select3D_BoundarySensitivePointSet.hxx>
//=======================================================================
// function : Select3D_BoundarySensitivePointSet
// purpose : Creates new instance of Select3D_SensitivePoly with BVH tree
// required and initializes it with the given array of points
//=======================================================================
Select3D_BoundarySensitivePointSet::Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId,
const TColgp_Array1OfPnt& ThePoints)
: Select3D_SensitivePoly (OwnerId, ThePoints, Standard_True)
{}
//=======================================================================
// function : Select3D_BoundarySensitivePointSet
// purpose : Creates new instance of Select3D_SensitivePoly with BVH tree
// required and initializes it with the given array of points
//=======================================================================
Select3D_BoundarySensitivePointSet::Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(TColgp_HArray1OfPnt)& ThePoints)
: Select3D_SensitivePoly (OwnerId, ThePoints, Standard_True)
{}
//=======================================================================
// function : Matches
// purpose : Checks whether the point set overlaps current selecting
// volume
//=======================================================================
Standard_Boolean Select3D_BoundarySensitivePointSet::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
return Select3D_SensitivePoly::Matches (theMgr, thePickResult);
}
//=======================================================================
// function : GetPoints
// purpose : Initializes the given array theHArrayOfPnt by 3d
// coordinates of vertices of the point set
//=======================================================================
void Select3D_BoundarySensitivePointSet::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
{
Points3D (theHArrayOfPnt);
}
//=======================================================================
// function : BoundingBox
// purpose : Returns bounding box of the point set. If location transformation
// is set, it will be applied
//=======================================================================
Select3D_BndBox3d Select3D_BoundarySensitivePointSet::BoundingBox()
{
return Select3D_SensitivePoly::BoundingBox();
}
//=======================================================================
// function : CenterOfGeometry
// purpose : Returns center of the point set. If location transformation
// is set, it will be applied
//=======================================================================
gp_Pnt Select3D_BoundarySensitivePointSet::CenterOfGeometry() const
{
return Select3D_SensitivePoly::CenterOfGeometry();
}
//=======================================================================
// function : BVH
// purpose : Builds BVH tree for the point set
//=======================================================================
void Select3D_BoundarySensitivePointSet::BVH()
{
Select3D_SensitivePoly::BVH();
}
//=======================================================================
// function : NbSubElements
// purpose : Returns the amount of points in set
//=======================================================================
Standard_Integer Select3D_BoundarySensitivePointSet::NbSubElements()
{
return Select3D_SensitivePoly::NbSubElements();
}

View File

@ -0,0 +1,67 @@
// Created on: 2014-08-15
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Select3D_BoundarySensitivePointSet_HeaderFile
#define _Select3D_BoundarySensitivePointSet_HeaderFile
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Handle_TColgp_HArray1OfPnt.hxx>
#include <Select3D_ISensitivePointSet.hxx>
#include <Select3D_SensitivePoly.hxx>
class SelectBasics_EntityOwner;
class TColgp_Array1OfPnt;
class TColgp_HArray1OfPnt;
//! This class handles the selection of arbitrary point set with boundary type of sensitivity.
class Select3D_BoundarySensitivePointSet : public Select3D_ISensitivePointSet, public Select3D_SensitivePoly
{
public:
//! Creates new instance of Select3D_SensitivePoly with BVH tree
//! required and initializes it with the given array of points
Standard_EXPORT Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId,
const TColgp_Array1OfPnt& ThePoints);
//! Creates new instance of Select3D_SensitivePoly with BVH tree
//! required and initializes it with the given array of points
Standard_EXPORT Select3D_BoundarySensitivePointSet (const Handle(SelectBasics_EntityOwner)& OwnerId,
const Handle(TColgp_HArray1OfPnt)& ThePoints);
//! Checks whether the point set overlaps current selecting volume
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Initializes the given array theHArrayOfPnt by 3d coordinates
//! of vertices of the point set
Standard_EXPORT virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt) Standard_OVERRIDE;
//! Returns bounding box of the point set. If there is a
//! location transformation set, it will be applied
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
//! Returns center of the point set. If there is a
//! location transformation set, it will be applied
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
//! Builds BVH tree for the point set
Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
//! Returns the amount of points in set
Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
};
#endif // _Select3D_BoundarySensitivePointSet_HeaderFile

View File

@ -1,95 +0,0 @@
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Select3D_Box2d_HeaderFile
#define _Select3D_Box2d_HeaderFile
#include<Bnd_Box2d.hxx>
#include<Standard_ShortReal.hxx>
#include<Select3D_Macro.hxx>
struct Select3D_Box2d
{
Standard_ShortReal xmin, ymin, xmax, ymax;
Select3D_Box2d()
: xmin( ShortRealLast() ),
ymin( ShortRealLast() ),
xmax( ShortRealFirst() ),
ymax( ShortRealFirst() )
{
}
Select3D_Box2d(const Bnd_Box2d& theBox)
{
SetField(theBox);
}
inline operator Bnd_Box2d() const
{
Bnd_Box2d aBox;
aBox.SetVoid();
if( !IsVoid() )
aBox.Update(xmin, ymin, xmax, ymax);
return aBox;
}
inline Select3D_Box2d operator = ( const Bnd_Box2d& theBox)
{
SetField(theBox);
return *this;
}
inline void Update(const gp_Pnt2d& thePnt)
{
Bnd_Box2d aBox;
aBox.Set(thePnt);
if( !IsVoid() )
aBox.Update(xmin, ymin, xmax, ymax);
SetField(aBox);
}
inline void SetVoid()
{
xmin = ymin = ShortRealLast();
xmax = ymax = ShortRealFirst();
}
inline Standard_Boolean IsVoid() const
{
return ( xmin == ShortRealLast() && ymin == ShortRealLast() && xmax == ShortRealFirst() && ymax == ShortRealFirst() );
}
private:
inline void SetField(const Bnd_Box2d& theBox)
{
if( theBox.IsVoid() )
SetVoid();
else {
Standard_Real x, y, x1, y1;
theBox.Get(x, y, x1, y1);
xmin = DToF(x);
ymin = DToF(y);
xmax = DToF(x1);
ymax = DToF(y1);
}
}
};
#endif

View File

@ -0,0 +1,11 @@
#ifndef _Select3D_EntitySequence_Header
#define _Select3D_EntitySequence_Header
#include <NCollection_Sequence.hxx>
class Handle(Select3D_SensitiveEntity);
typedef NCollection_Sequence<Handle(Select3D_SensitiveEntity)> Select3D_EntitySequence;
typedef NCollection_Sequence<Handle(Select3D_SensitiveEntity)>::Iterator Select3D_EntitySequenceIter;
#endif // _Select3D_EntitySequence_Header

View File

@ -0,0 +1,70 @@
// Created on: 2014-08-15
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Select3D_ISensitivePointSet_HeaderFile
#define _Select3D_ISensitivePointSet_HeaderFile
#include <Standard.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_OStream.hxx>
#include <Standard_Real.hxx>
#include <Select3D_BndBox3d.hxx>
#include <Select3D_SensitiveEntity.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <SelectBasics_PickResult.hxx>
#include <SelectBasics_SelectingVolumeManager.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Handle_TColgp_HArray1OfPnt.hxx>
class gp_Pnt;
class Standard_ConstructionError;
class Standard_OutOfRange;
class TColgp_Array1OfPnt;
class TColgp_HArray1OfPnt;
class TColgp_Array1OfPnt2d;
class TopLoc_Location;
//! Interface class to unify the work with both internal and boundary
//! sensitive sets of points.
class Select3D_ISensitivePointSet
{
public:
//! Checks whether the point set overlaps current selecting volume
virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) = 0;
//! Initializes the given array theHArrayOfPnt by 3d coordinates
//! of vertices of the point set
virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt) = 0;
//! Returns bounding box of the point set. If location
//! transformation is set, it will be applied
virtual Select3D_BndBox3d BoundingBox() = 0;
//! Returns center of the point set. If location
//! transformation is set, it will be applied
virtual gp_Pnt CenterOfGeometry() const = 0;
//! Builds BVH tree for the point set
virtual void BVH() = 0;
//! Returns the amount of points in set
virtual Standard_Integer NbSubElements() = 0;
};
#endif // _Select3D_ISensitivePointSet_HeaderFile

View File

@ -0,0 +1,418 @@
// Created on: 2014-08-15
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <gp_Pnt.hxx>
#include <gp_XYZ.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <Select3D_InteriorSensitivePointSet.hxx>
// Internal class for creation of planar polygons
class Select3D_Plane
{
public:
Select3D_Plane()
: myPlane (0.0),
myIsInitialized (Standard_False)
{}
Standard_Boolean Contains (const gp_Pnt& thePnt) const
{
if (!myIsInitialized)
return Standard_False;
Standard_Real aRes = myPlane.x() * thePnt.X() +
myPlane.y() * thePnt.Y() +
myPlane.z() * thePnt.Z() +
myPlane.w();
if (aRes < Precision::Confusion())
return Standard_True;
return Standard_False;
}
void MakePlane (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
const gp_Pnt& thePnt3)
{
const gp_XYZ& aVec1 = thePnt2.XYZ() - thePnt1.XYZ();
const gp_XYZ& aVec2 = thePnt3.XYZ() - thePnt1.XYZ();
const gp_XYZ& aDir = aVec1.Crossed (aVec2);
Standard_Real aD = aDir.Dot (thePnt1.XYZ().Reversed());
myPlane = NCollection_Vec4<Standard_Real> (aDir.X(), aDir.Y(), aDir.Z(), aD);
myIsInitialized = Standard_True;
}
void Invalidate()
{
myIsInitialized = Standard_False;
}
Standard_Boolean IsValid() const
{
return myIsInitialized;
}
private:
NCollection_Vec4<Standard_Real> myPlane;
Standard_Boolean myIsInitialized;
};
// =======================================================================
// function : Select3D_InteriorSensitivePointSet
// purpose : Splits the given point set thePoints onto planar convex
// polygons
// =======================================================================
Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const TColgp_Array1OfPnt& thePoints)
: Select3D_SensitiveSet (theOwnerId)
{
Select3D_Plane aPlane;
Standard_Integer aStartIdx = 1, anEndIdx = 0;
Standard_Integer aLowerIdx = thePoints.Lower();
Standard_Integer anUpperIdx = thePoints.Upper();
Select3D_BndBox3d aBndBox;
gp_XYZ aPntSum (0.0, 0.0, 0.0);
if (thePoints.Length() > 3)
{
for (Standard_Integer aPntIter = aLowerIdx; aPntIter <= anUpperIdx; ++aPntIter)
{
gp_Pnt aPnt1, aPnt2;
const gp_Pnt& aPnt3 = thePoints.Value (aPntIter);
aBndBox.Add (SelectMgr_Vec3 (aPnt3.X(), aPnt3.Y(), aPnt3.Z()));
aPntSum += aPnt3.XYZ();
if (aPntIter - aLowerIdx >= 2)
{
aPnt1 = thePoints.Value (aPntIter - 2);
aPnt2 = thePoints.Value (aPntIter - 1);
}
if (aPntIter - aStartIdx == 2 && !aPlane.IsValid())
{
aPlane.MakePlane (aPnt1, aPnt2, aPnt3);
aStartIdx = aPntIter - 2;
anEndIdx = aPntIter;
}
else if (aPlane.IsValid())
{
const gp_XYZ& aVec1 = aPnt1.XYZ() - aPnt2.XYZ();
const gp_XYZ& aVec2 = aPnt3.XYZ() - aPnt2.XYZ();
Standard_Real anAngle = aVec1.Dot (aVec2);
if (!aPlane.Contains (thePoints.Value (aPntIter)) || anAngle > Precision::Confusion())
{
Standard_Integer anUpperBound = aPntIter - aStartIdx;
Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anUpperBound);
for (Standard_Integer aIdx = aStartIdx; aIdx <= aStartIdx + anUpperBound; ++aIdx)
{
aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value (aIdx));
}
Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId,
aPointsArray,
Standard_False);
myPlanarPolygons.Append (aPlanarPolyg);
aStartIdx = aPntIter;
anEndIdx = aPntIter;
aPlane.Invalidate();
}
else
{
if (anEndIdx == anUpperIdx)
{
Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anEndIdx - aStartIdx);
for (Standard_Integer aIdx = aStartIdx; aIdx <= anEndIdx; ++aIdx)
{
aPointsArray->SetValue (aIdx - aStartIdx, thePoints.Value (aIdx));
}
Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId,
aPointsArray,
Standard_False);
myPlanarPolygons.Append (aPlanarPolyg);
}
anEndIdx++;
}
}
}
}
else
{
Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, 2);
const gp_Pnt& aPnt1 = thePoints.Value (aLowerIdx);
const gp_Pnt& aPnt2 = thePoints.Value (aLowerIdx + 1);
const gp_Pnt& aPnt3 = thePoints.Value (aLowerIdx + 2);
aPointsArray->SetValue (0, aPnt1);
aPointsArray->SetValue (1, aPnt2);
aPointsArray->SetValue (2, aPnt3);
aBndBox.Add (SelectMgr_Vec3 (aPnt1.X(), aPnt1.Y(), aPnt1.Z()));
aBndBox.Add (SelectMgr_Vec3 (aPnt2.X(), aPnt2.Y(), aPnt2.Z()));
aBndBox.Add (SelectMgr_Vec3 (aPnt3.X(), aPnt3.Y(), aPnt3.Z()));
aPntSum += aPnt1.XYZ() + aPnt2.XYZ() + aPnt3.XYZ();
Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId,
aPointsArray,
Standard_False);
myPlanarPolygons.Append (aPlanarPolyg);
}
myPolygonsIdxs = new TColStd_HArray1OfInteger (0, myPlanarPolygons.Length() - 1);
for (Standard_Integer aIdx = 0; aIdx < myPlanarPolygons.Length(); ++aIdx)
{
myPolygonsIdxs->SetValue (aIdx, aIdx);
}
myCOG = aPntSum / thePoints.Length();
myBndBox = aBndBox;
}
// =======================================================================
// function : Select3D_InteriorSensitivePointSet
// purpose : Splits the given point set thePoints onto planar convex
// polygons
// =======================================================================
Select3D_InteriorSensitivePointSet::Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const Handle(TColgp_HArray1OfPnt)& thePoints)
: Select3D_SensitiveSet (theOwnerId)
{
Select3D_Plane aPlane;
Standard_Integer aLowerIdx = thePoints->Lower();
Standard_Integer anUpperIdx = thePoints->Upper();
Standard_Integer aStartIdx = aLowerIdx, anEndIdx = 0;
Select3D_BndBox3d aBndBox;
gp_XYZ aPntSum (0.0, 0.0, 0.0);
for (Standard_Integer aPntIter = aLowerIdx; aPntIter <= anUpperIdx; ++aPntIter)
{
gp_Pnt aPnt1, aPnt2;
const gp_Pnt& aPnt3 = thePoints->Value (aPntIter);
aPntSum += aPnt3.XYZ();
SelectMgr_Vec3 aCurrPnt (aPnt3.X(), aPnt3.Y(), aPnt3.Z());
aBndBox.Add (aCurrPnt);
if (aPntIter - aLowerIdx >= 2)
{
aPnt1 = thePoints->Value (aPntIter - 2);
aPnt2 = thePoints->Value (aPntIter - 1);
}
if (aPntIter - aStartIdx == 2 && !aPlane.IsValid())
{
aPlane.MakePlane (aPnt1, aPnt2, aPnt3);
aStartIdx = aPntIter - 2;
anEndIdx = aPntIter;
}
else if (aPlane.IsValid())
{
const gp_XYZ& aVec1 = aPnt1.XYZ() - aPnt2.XYZ();
const gp_XYZ& aVec2 = aPnt3.XYZ() - aPnt2.XYZ();
Standard_Real anAngle = aVec1.Dot (aVec2);
if (!aPlane.Contains (thePoints->Value (aPntIter)) || anAngle > Precision::Confusion())
{
Standard_Integer anUpperBound = aPntIter - aStartIdx;
Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anUpperBound);
for (Standard_Integer aIdx = aStartIdx; aIdx <= aStartIdx + anUpperBound; ++aIdx)
{
aPointsArray->SetValue (aIdx - aStartIdx, thePoints->Value (aIdx));
}
Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId,
aPointsArray,
Standard_False);
myPlanarPolygons.Append (aPlanarPolyg);
aStartIdx = aPntIter;
anEndIdx = aPntIter;
aPlane.Invalidate();
}
else
{
anEndIdx++;
if (anEndIdx == anUpperIdx)
{
Handle (TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt (0, anEndIdx - aStartIdx);
for (Standard_Integer aIdx = aStartIdx; aIdx <= anEndIdx; ++aIdx)
{
aPointsArray->SetValue (aIdx - aStartIdx, thePoints->Value (aIdx));
}
Handle(Select3D_SensitivePoly) aPlanarPolyg = new Select3D_SensitivePoly (theOwnerId,
aPointsArray,
Standard_False);
myPlanarPolygons.Append (aPlanarPolyg);
}
}
}
}
myPolygonsIdxs = new TColStd_HArray1OfInteger (0, myPlanarPolygons.Length() - 1);
for (Standard_Integer aIdx = 0; aIdx < myPlanarPolygons.Length(); ++aIdx)
{
myPolygonsIdxs->SetValue (aIdx, aIdx);
}
myCOG = aPntSum / thePoints->Length();
myBndBox = aBndBox;
}
// =======================================================================
// function : Matches
// purpose : Checks whether the point set overlaps current selecting
// volume
// =======================================================================
Standard_Boolean Select3D_InteriorSensitivePointSet::Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult)
{
return Select3D_SensitiveSet::Matches (theMgr, thePickResult);
}
// =======================================================================
// function : GetPoints
// purpose : Initializes the given array theHArrayOfPnt by 3d
// coordinates of vertices of the whole point set
// =======================================================================
void Select3D_InteriorSensitivePointSet::GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt)
{
Standard_Integer aSize = 0;
for (Standard_Integer anIdx = 0; anIdx < myPlanarPolygons.Length(); ++anIdx)
{
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (anIdx);
aSize += aPolygon->NbSubElements();
}
aSize -= (myPlanarPolygons.Length() - 1) * 2;
theHArrayOfPnt = new TColgp_HArray1OfPnt (1, aSize);
Standard_Integer anOutputPntArrayIdx = 1;
for (Standard_Integer aPolygIdx = 0; aPolygIdx < myPlanarPolygons.Length(); ++aPolygIdx)
{
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx);
Handle(TColgp_HArray1OfPnt) aPoints;
aPolygon->Points3D (aPoints);
Standard_Integer anUpper = aPolygIdx < myPlanarPolygons.Length() - 1 ? aPoints->Upper() : aPoints->Upper() + 1;
for (Standard_Integer aPntIter = 1; aPntIter < anUpper; ++aPntIter)
{
theHArrayOfPnt->SetValue (anOutputPntArrayIdx, aPoints->Value (aPntIter));
anOutputPntArrayIdx++;
}
aPoints.Nullify();
}
}
//=======================================================================
// function : Size
// purpose : Returns the length of vector of planar convex polygons
//=======================================================================
Standard_Integer Select3D_InteriorSensitivePointSet::Size() const
{
return myPlanarPolygons.Length();
}
//=======================================================================
// function : Box
// purpose : Returns bounding box of planar convex polygon with index
// theIdx
//=======================================================================
Select3D_BndBox3d Select3D_InteriorSensitivePointSet::Box (const Standard_Integer theIdx) const
{
Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theIdx);
return myPlanarPolygons.Value (aPolygIdx)->BoundingBox();
}
//=======================================================================
// function : Center
// purpose : Returns geometry center of planar convex polygon with index
// theIdx in the vector along the given axis theAxis
//=======================================================================
Standard_Real Select3D_InteriorSensitivePointSet::Center (const Standard_Integer theIdx,
const Standard_Integer theAxis) const
{
Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theIdx);
const gp_XYZ& aCOG = myPlanarPolygons.Value (aPolygIdx)->CenterOfGeometry().XYZ();
Standard_Real aCenter = theAxis == 0 ? aCOG.X() : (theAxis == 1 ? aCOG.Y() : aCOG.Z());
return aCenter;
}
//=======================================================================
// function : Swap
// purpose : Swaps items with indexes theIdx1 and theIdx2 in the vector
//=======================================================================
void Select3D_InteriorSensitivePointSet::Swap (const Standard_Integer theIdx1,
const Standard_Integer theIdx2)
{
Standard_Integer aPolygIdx1 = myPolygonsIdxs->Value (theIdx1);
Standard_Integer aPolygIdx2 = myPolygonsIdxs->Value (theIdx2);
myPolygonsIdxs->ChangeValue (theIdx1) = aPolygIdx2;
myPolygonsIdxs->ChangeValue (theIdx2) = aPolygIdx1;
}
// =======================================================================
// function : overlapsElement
// purpose : Checks whether the planar convex polygon with index theIdx
// in myPlanarPolygons overlaps the current selecting volume
// =======================================================================
Standard_Boolean Select3D_InteriorSensitivePointSet::overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
Standard_Real& theMatchDepth)
{
Standard_Integer aPolygIdx = myPolygonsIdxs->Value (theElemIdx);
const Handle(Select3D_SensitivePoly)& aPolygon = myPlanarPolygons.Value (aPolygIdx);
Handle(TColgp_HArray1OfPnt) aPoints;
aPolygon->Points3D (aPoints);
return theMgr.Overlaps (aPoints, Select3D_TOS_INTERIOR, theMatchDepth);
}
// =======================================================================
// function : distanceToCOG
// purpose : Calculates distance from the 3d projection of used-picked
// screen point to center of the geometry
// =======================================================================
Standard_Real Select3D_InteriorSensitivePointSet::distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr)
{
return theMgr.DistToGeometryCenter (myCOG);
}
//=======================================================================
// function : BoundingBox
// purpose : Returns bounding box of the point set. If location
// transformation is set, it will be applied
//=======================================================================
Select3D_BndBox3d Select3D_InteriorSensitivePointSet::BoundingBox()
{
return myBndBox;
}
//=======================================================================
// function : CenterOfGeometry
// purpose : Returns center of the point set. If location transformation
// is set, it will be applied
//=======================================================================
gp_Pnt Select3D_InteriorSensitivePointSet::CenterOfGeometry() const
{
return myCOG;
}
//=======================================================================
// function : BVH
// purpose : Builds BVH tree for the point set
//=======================================================================
void Select3D_InteriorSensitivePointSet::BVH()
{
BVH();
}
//=======================================================================
// function : NbSubElements
// purpose : Returns the amount of points in set
//=======================================================================
Standard_Integer Select3D_InteriorSensitivePointSet::NbSubElements()
{
return myPlanarPolygons.Length();
}

View File

@ -0,0 +1,109 @@
// Created on: 2014-08-15
// Created by: Varvara POSKONINA
// Copyright (c) 2005-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Select3D_InteriorSensitivePointSet_HeaderFile
#define _Select3D_InteriorSensitivePointSet_HeaderFile
#include <NCollection_Vector.hxx>
#include <Handle_SelectBasics_EntityOwner.hxx>
#include <Handle_TColgp_HArray1OfPnt.hxx>
#include <Handle_TColStd_HArray1OfInteger.hxx>
#include <Select3D_ISensitivePointSet.hxx>
#include <Select3D_SensitivePoly.hxx>
#include <Select3D_SensitiveSet.hxx>
class gp_Pnt;
class SelectBasics_EntityOwner;
class TColgp_Array1OfPnt;
class TColgp_HArray1OfPnt;
class TColStd_HArray1OfInteger;
typedef NCollection_Vector<Handle(Select3D_SensitivePoly)> Select3D_VectorOfHPoly;
//! This class handles the selection of arbitrary point set with internal type of sensitivity.
//! The main principle is to split the point set given onto planar convex polygons and search
//! for the overlap with one or more of them through traverse of BVH tree.
class Select3D_InteriorSensitivePointSet : public Select3D_ISensitivePointSet, public Select3D_SensitiveSet
{
public:
//! Splits the given point set thePoints onto planar convex polygons
Standard_EXPORT Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const TColgp_Array1OfPnt& thePoints);
//! Splits the given point set thePoints onto planar convex polygons
Standard_EXPORT Select3D_InteriorSensitivePointSet (const Handle(SelectBasics_EntityOwner)& theOwnerId,
const Handle(TColgp_HArray1OfPnt)& thePoints);
//! Checks whether the point set overlaps current selecting volume
Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
//! Initializes the given array theHArrayOfPnt by 3d coordinates of vertices of the
//! whole point set
Standard_EXPORT virtual void GetPoints (Handle(TColgp_HArray1OfPnt)& theHArrayOfPnt) Standard_OVERRIDE;
//! Returns the length of vector of planar convex polygons
Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE;
//! Returns bounding box of planar convex polygon with index theIdx
Standard_EXPORT virtual Select3D_BndBox3d Box (const Standard_Integer theIdx) const Standard_OVERRIDE;
//! Returns geometry center of planar convex polygon with index
//! theIdx in the vector along the given axis theAxis
Standard_EXPORT virtual Standard_Real Center (const Standard_Integer theIdx,
const Standard_Integer theAxis) const Standard_OVERRIDE;
//! Swaps items with indexes theIdx1 and theIdx2 in the vector
Standard_EXPORT virtual void Swap (const Standard_Integer theIdx1,
const Standard_Integer theIdx2) Standard_OVERRIDE;
//! Returns bounding box of the point set. If location
//! transformation is set, it will be applied
Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE;
//! Returns center of the point set. If location
//! transformation is set, it will be applied
Standard_EXPORT virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE;
//! Builds BVH tree for the point set
Standard_EXPORT virtual void BVH() Standard_OVERRIDE;
//! Returns the amount of points in set
Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE;
protected:
//! Checks whether the planar convex polygon with index theIdx
//! in myPlanarPolygons overlaps the current selecting volume
Standard_EXPORT virtual Standard_Boolean overlapsElement (SelectBasics_SelectingVolumeManager& theMgr,
Standard_Integer theElemIdx,
Standard_Real& theMatchDepth) Standard_OVERRIDE;
//! Calculates distance from the 3d projection of used-picked
//! screen point to center of the geometry
Standard_EXPORT virtual Standard_Real distanceToCOG (SelectBasics_SelectingVolumeManager& theMgr) Standard_OVERRIDE;
protected:
Select3D_VectorOfHPoly myPlanarPolygons; //!< Vector of planar polygons
Handle_TColStd_HArray1OfInteger myPolygonsIdxs; //!< Indexes array for BVH calculation
gp_Pnt myCOG; //!< Center of the point set
Select3D_BndBox3d myBndBox; //!< Bounding box of the point set
};
#endif // _Select3D_InteriorSensitivePointSet_HeaderFile

Some files were not shown because too many files have changed in this diff Show More