1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

145
src/StdSelect/StdSelect.cdl Executable file
View File

@@ -0,0 +1,145 @@
-- File: StdSelect.cdl
-- Created: Wed Mar 8 15:22:01 1995
-- Author: Mister rmi
-- <rmi@photon>
--Modified by ROB : Add ShapeFilters.
-- GG : 5/10/99 BUC60576 Add Cone to TypeOfFace enum
---Copyright: Matra Datavision 1995
package StdSelect
---Purpose: The StdSelect package provides the following services
-- - the definition of selection modes for topological shapes
-- - the definition of several concrete filtertandard
-- Selection2d.ap classes
-- - 2D and 3D viewer selectors.
-- Note that each new Interactive Object must have all
-- its selection modes defined.
-- Standard Classes is useful to build
-- 3D Selectable Objects, and to process
-- 3D Selections:
--
-- - Implementation of View Selector for dynamic selection
-- in Views from V3d.
--
-- - Implementation of Tool class to decompose 3D BRep Objects
-- into sensitive Primitives for every desired mode of selection
-- (selection of vertex,edges,wires,faces,...)
--
-- - Implementation of dedicated Sensitives Entities:
-- Text for 2D Views (linked to Specific 2D projectors.)
uses
MMgt,
Standard,
TCollection,
TopLoc,
TopoDS,
SelectMgr,
TopAbs,
TColStd,
gp,
Select3D,
Select2D,
Graphic2d,
Graphic3d,Visual3d,
Quantity,
Prs3d,
V2d,
V3d,
PrsMgr,
SelectBasics,
TopTools,
Bnd,
Geom,
TColgp
is
enumeration TypeOfResult is TOR_SIMPLE,TOR_MULTIPLE
end TypeOfResult;
---Purpose: Provides values for type of result.
-- These are used to specify whether the result is to
-- be simple or whether it may be multiple.
enumeration DisplayMode is DM_Wireframe,DM_Shading,DM_HLR
end DisplayMode;
-- enumeration TypeOfFace is AnyFace,Plane,Cylinder,Sphere,Torus,Revol;
enumeration TypeOfFace is AnyFace,Plane,Cylinder,Sphere,Torus,Revol,Cone;
---Purpose: Provides values for different types of faces. These
-- values are used to filter faces in frameworks inheriting
-- StdSelect_FaceFilter.
enumeration TypeOfEdge is AnyEdge,Line,Circle;
---Purpose: Provides values for different types of edges. These
-- values are used to filter edges in frameworks
-- inheriting StdSelect_EdgeFilter.
class ViewerSelector3d;
---Purpose: Viewer Selector for a view from V3d
-- Accepts Only Sensitive Entities inheriting Select3D entities...
class ViewerSelector2d;
---Purpose: Viewer Selector for a view from V2d
-- Accepts Only Sensitive Entities inheriting Select2D entities...
class BRepSelectionTool;
---Purpose: gives standard selections for Shapes
class BRepOwner;
---Purpose: Owner classes for BRep objects
-- used by BRepSelectionTool to know which entities
-- own the sensitive primitives created.
-- the hilight-unhilight methods are empty and
-- must be redefined by each User...
---Category: Some classes...
class BRepHilighter;
---Purpose: manages hilight of picked shapes in a ViewerSelector.
-- to be called after each pick of the selection...
class SensitiveText2d;
class TextProjector2d;
---Category: Shape Filters
class EdgeFilter;
class FaceFilter;
class ShapeTypeFilter;
---Category: Private Classes
private class Prs;
private class Shape;
private class IndexedDataMapOfOwnerPrs instantiates IndexedDataMap from TCollection
(EntityOwner from SelectBasics,Prs from StdSelect,MapTransientHasher from TColStd);
GetProjector (aView: View from V3d) returns Projector from Select3D;
---Purpose: Returns the 3D projector for the view aView.
SetDrawerForBRepOwner(aSelection: mutable Selection from SelectMgr;
aDrawer : Drawer from Prs3d);
---Purpose: puts The same drawer in every BRepOwner Of SensitivePrimitive
-- Used Only for hilight Of BRepOwner...
end StdSelect;

70
src/StdSelect/StdSelect.cxx Executable file
View File

@@ -0,0 +1,70 @@
// Copyright: Matra-Datavision 1995
// File: StdSelect.cxx
// Created: Mon Mar 27 17:07:10 1995
// Author: Robert COUBLANC
// <rob>
#include <StdSelect.ixx>
#include <SelectMgr_Selection.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_Group.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveFace.hxx>
#include <Graphic3d_AspectLine3d.hxx>
#include <Graphic3d_Structure.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Aspect_TypeOfLine.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax3.hxx>
#include <V3d_PerspectiveView.hxx>
#include <StdSelect_BRepOwner.hxx>
//#include <.hxx>
Select3D_Projector StdSelect::GetProjector(const Handle(V3d_View)& aViou)
{
Standard_Real Focale=0.,Xat,Yat,Zat,XUp,YUp,ZUp,DX,DY,DZ;
Standard_Boolean Pers=Standard_False;
// NKV - 31/07/07 - Fix for perspective view
if ( aViou->Type() == V3d_PERSPECTIVE ) {
Pers = Standard_True;
Focale = aViou->Focale();} // must be replaced by the method Focale
aViou->At(Xat,Yat,Zat);
aViou->Up(XUp,YUp,ZUp);
aViou->Proj(DX,DY,DZ);
gp_Pnt At (Xat,Yat,Zat);
gp_Dir Zpers (DX,DY,DZ);
gp_Dir Ypers (XUp,YUp,ZUp);
gp_Dir Xpers = Ypers.Crossed(Zpers);
gp_Ax3 Axe (At, Zpers, Xpers);
gp_Trsf T;
T.SetTransformation(Axe);
return Select3D_Projector(T,Pers,Focale);
}
//=======================================================================
//function : SetDrawerForBRepOwner
//purpose :
//=======================================================================
void StdSelect::SetDrawerForBRepOwner(const Handle(SelectMgr_Selection)& Sel,
const Handle(Prs3d_Drawer)& Drwr)
{
// Handle(StdSelect_BRepOwner) BROWN;
// for(Sel->Init();Sel->More();Sel->Next()){
// BROWN = Handle(StdSelect_BRepOwner)::DownCast(Sel->Sensitive()->OwnerId());
// if(!BROWN.IsNull())
// BROWN->SetDrawer(Drwr);
// }
}

View File

@@ -0,0 +1,93 @@
-- File: StdSelect_BRepHilighter.cdl
-- Created: Wed Mar 22 17:26:54 1995
-- Author: Robert COUBLANC
-- <rob@fidox>
---Copyright: Matra Datavision 1995
class BRepHilighter from StdSelect
---Purpose: Tool to manage hilight of BRepOwners during the selection process
-- -> Built with a ViewSelector3d.
-- -> Can hilight all the detected elements at the mouse position or
-- just the closest one.
-- How Use It:
-- TheSelector -> SelectPix (Xmouse,YMouse);
-- TheBRepHilighter->Process ();
--
-- When good choice
--
-- toto = TheSelector->LastPicked();
uses
NameOfColor from Quantity,
ViewerSelector3d from StdSelect,
Viewer from V3d,
View from V3d,
Drawer from Prs3d,
MapOfInteger from TColStd,
IndexedDataMapOfOwnerPrs,
TypeOfResult from StdSelect,
OStream,
TransientManager from Visual3d
is
Create returns BRepHilighter;
Create (aSelector : ViewerSelector3d from StdSelect;
aViewer : Viewer from V3d;
acolor : NameOfColor from Quantity = Quantity_NOC_INDIANRED3;
aType : TypeOfResult from StdSelect = StdSelect_TOR_SIMPLE)
returns BRepHilighter;
Set(me:in out; aSelector : ViewerSelector3d from StdSelect) is static;
Set(me:in out; aViewer : Viewer from V3d) is static;
Set(me:in out; acolor : NameOfColor from Quantity) is static;
Set(me:in out; atype : TypeOfResult from StdSelect) is static;
Process(me : in out) is static;
---Purpose: updates the viewer with the selection.
Process(me:in out; aView : View from V3d; DoubleBuffer: Boolean = Standard_False) is static;
---Purpose: updates only the view with the selection.
-- The updating will be made using immediate drawing which is far quicker.
Clear(me:in out ) is static;
---Level: Public
---Purpose: Clears the hilight structures
-- which were created during the selection action;
-- must me called after each selection loop;
--
Update(me:in out) is static private;
Update(me:in out; aView : View from V3d; DoubleBuffer: Boolean = Standard_False) is static private;
---Category: Internal Methods
--
--
Drawer(me)
---C++: return const &
returns any Drawer from Prs3d;
fields
myselector : ViewerSelector3d from StdSelect;
myviewer : Viewer from V3d;
mycolor : NameOfColor from Quantity;
mydrwr : Drawer from Prs3d;
mytype : TypeOfResult from StdSelect;
myold : MapOfInteger from TColStd;
mynew : MapOfInteger from TColStd;
myhimap : IndexedDataMapOfOwnerPrs;
mynbpick : Integer;
mylastindex : Integer;
myManager : TransientManager from Visual3d;
end BRepHilighter;

View File

@@ -0,0 +1,304 @@
// Copyright: Matra-Datavision 1995
// File: StdSelect_BRepHilighter.cxx
// Created: Wed Mar 22 17:44:30 1995
// Author: Robert COUBLANC
// <rob>
#include <StdSelect_BRepHilighter.ixx>
#include <StdSelect_BRepOwner.hxx>
#include <StdSelect_Prs.hxx>
#include <Graphic3d_StructureManager.hxx>
#include <Graphic3d_Structure.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Prs3d_PointAspect.hxx>
#include <V3d_Viewer.hxx>
#include <V3d_View.hxx>
#include <Prs3d_Presentation.hxx>
#include <StdPrs_WFShape.hxx>
#include <OSD_Chronometer.hxx>
#include <Visual3d_TransientManager.hxx>
static TColStd_MapIteratorOfMapOfInteger it;
static Standard_Boolean ImmediateIsEnable;
static Standard_Boolean ImmediateIsEnableIsDef= Standard_False;
//==================================================
// Function:
// Purpose :
//==================================================
StdSelect_BRepHilighter::
StdSelect_BRepHilighter():mylastindex(0)
,myManager(new Visual3d_TransientManager){}
//==================================================
// Function:
// Purpose :
//==================================================
StdSelect_BRepHilighter::
StdSelect_BRepHilighter(const Handle(StdSelect_ViewerSelector3d)& aSelector,
const Handle(V3d_Viewer)& aViewer,
const Quantity_NameOfColor aColor,
const StdSelect_TypeOfResult aTOR):
myselector(aSelector),
myviewer(aViewer),
mycolor(aColor),
mydrwr(new Prs3d_Drawer()),
mytype(aTOR),
mylastindex(0),
myManager(new Visual3d_TransientManager)
{
Handle(Prs3d_PointAspect) PA = new Prs3d_PointAspect(Aspect_TOM_O,Quantity_NOC_INDIANRED3,3.);
mydrwr->SetPointAspect(PA);
}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_BRepHilighter::
Set(const Handle(StdSelect_ViewerSelector3d)& aSelector)
{myselector=aSelector;}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_BRepHilighter::
Set(const StdSelect_TypeOfResult aTOR)
{mytype =aTOR;}
//==================================================
// Function: Set
// Purpose :
//==================================================
void StdSelect_BRepHilighter::
Set(const Handle(V3d_Viewer)& aViewer)
{myviewer=aViewer;}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_BRepHilighter::
Set(const Quantity_NameOfColor aColor)
{mycolor=aColor;}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_BRepHilighter::
Process()
{
Update();
myviewer->Update();
}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_BRepHilighter::
Process(const Handle(V3d_View)& aViou,const Standard_Boolean DoubleBuffer)
{
if(aViou->Viewer() == myviewer){
Update(aViou,DoubleBuffer);
// aViou->Update();
}
}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_BRepHilighter::
Update()
{
myselector->Init();
switch(mytype){
case StdSelect_TOR_MULTIPLE:{
TColStd_MapIteratorOfMapOfInteger it;
if(!myselector->More())
{
for(it.Initialize(myold);it.More();it.Next())
{myhimap.FindFromIndex(it.Key())->UnHighlight();
myhimap.FindFromIndex(it.Key())->SetVisible(Standard_False);
}
myold.Clear();
mynew.Clear();
}
else{
for (;myselector->More();myselector->Next())
{
const Handle(SelectBasics_EntityOwner)& OO = myselector->Picked();
if (!myhimap.Contains(OO))
{
if(!Handle(StdSelect_BRepOwner)::DownCast(OO).IsNull()){
Handle(StdSelect_Prs) NiouPrs = new StdSelect_Prs
(myviewer->Viewer());
StdPrs_WFShape::Add(NiouPrs,
Handle(StdSelect_BRepOwner)::DownCast(OO)->Shape(),
mydrwr);
NiouPrs->Display();
myhimap.Add(OO,NiouPrs);
mynew.Add(myhimap.FindIndex(OO));
if(myold.Contains(myhimap.FindIndex(OO)))
myold.Remove(myhimap.FindIndex(OO));
}
}
}
for(it.Initialize(myold);it.More();it.Next()){
myhimap.FindFromIndex(it.Key())->UnHighlight();
myhimap.FindFromIndex(it.Key())->SetVisible(Standard_False);
}
myold = mynew;
mynew.Clear();
for(it.Initialize(myold);it.More();it.Next()){
myhimap.FindFromIndex(it.Key())->SetVisible(Standard_True);
myhimap.FindFromIndex(it.Key())->SetDisplayPriority(10);
myhimap.FindFromIndex(it.Key())->Color(mycolor);
}
}
break;
}
case StdSelect_TOR_SIMPLE:
{
if(myselector->More()){
const Handle(SelectBasics_EntityOwner)& OO = myselector->OnePicked();
if(!Handle(StdSelect_BRepOwner)::DownCast(OO).IsNull()){
if (!myhimap.Contains(OO)){
Handle(StdSelect_Prs) NiouPrs = new StdSelect_Prs
(myviewer->Viewer());
StdPrs_WFShape::Add(NiouPrs,
Handle(StdSelect_BRepOwner)::DownCast(OO)->Shape(),
mydrwr);
NiouPrs->Display();
myhimap.Add(OO,NiouPrs);
}
}
if(mylastindex!=myhimap.FindIndex(OO))
{
if(mylastindex!=0)
{
myhimap.FindFromIndex(mylastindex)->UnHighlight();
myhimap.FindFromIndex(mylastindex)->SetVisible(Standard_False);
}
mylastindex = myhimap.FindIndex(OO);
myhimap.FindFromIndex(mylastindex)->SetVisible(Standard_True);
myhimap.FindFromIndex(mylastindex)->SetDisplayPriority(10);
myhimap.FindFromIndex(mylastindex)->Color(mycolor);
}
}
else {
if(mylastindex!=0)
{
myhimap.FindFromIndex(mylastindex)->UnHighlight();
myhimap.FindFromIndex(mylastindex)->SetVisible(Standard_False);
mylastindex=0;
}
for (it.Initialize(myold);it.More();it.Next()){
myhimap.FindFromIndex(it.Key())->UnHighlight();
myhimap.FindFromIndex(it.Key())->SetVisible(Standard_False);}
myold.Clear();
}
}
}
}
void StdSelect_BRepHilighter::
Update(const Handle(V3d_View)& aView,const Standard_Boolean DoubleBuffer)
{
if(!ImmediateIsEnableIsDef) {
ImmediateIsEnable = aView->TransientManagerBeginDraw();
ImmediateIsEnableIsDef = Standard_True;
Visual3d_TransientManager::EndDraw();
}
if(!ImmediateIsEnable) {
Update();
}
else {
myselector->Init();
mynew.Clear();
switch(mytype){
case StdSelect_TOR_MULTIPLE:{
for (;myselector->More();myselector->Next()) {
const Handle(SelectBasics_EntityOwner)& OO = myselector->Picked();
if(!Handle(StdSelect_BRepOwner)::DownCast(OO).IsNull()){
if (!myhimap.Contains(OO)) {
Handle(StdSelect_Prs) NiouPrs = new StdSelect_Prs(myviewer->Viewer());
StdPrs_WFShape::Add(NiouPrs,Handle(StdSelect_BRepOwner)::DownCast(OO)->Shape(),mydrwr);
NiouPrs->Color(mycolor);
myhimap.Add(OO,NiouPrs);
}
mynew.Add(myhimap.FindIndex(OO));
}
}
break;
}
case StdSelect_TOR_SIMPLE: {
if(myselector->More()){
const Handle(SelectBasics_EntityOwner)& OO = myselector->OnePicked();
if(!Handle(StdSelect_BRepOwner)::DownCast(OO).IsNull()){
if (!myhimap.Contains(OO)){
Handle(StdSelect_Prs) NiouPrs = new StdSelect_Prs(myviewer->Viewer());
StdPrs_WFShape::Add(NiouPrs,Handle(StdSelect_BRepOwner)::DownCast(OO)->Shape(),mydrwr);
NiouPrs->Color(mycolor);
myhimap.Add(OO,NiouPrs);
}
mynew.Add(myhimap.FindIndex(OO));
}
}
}
break;
}
Standard_Boolean First = Standard_True; // pour eviter de faire le begindraw s'il n'y a
// rien (couteux ) rob 230996
for(it.Initialize(mynew);it.More();it.Next()){
if(First) {
aView->TransientManagerBeginDraw(DoubleBuffer);
First = Standard_False;
}
Visual3d_TransientManager::DrawStructure(myhimap.FindFromIndex(it.Key()));
}
if(!First)
Visual3d_TransientManager::EndDraw();
}
}
void StdSelect_BRepHilighter::Clear()
{
if(!myhimap.IsEmpty()){
for (Standard_Integer i=1;i<=myhimap.Extent();i++){
myhimap.FindFromIndex(i)->UnHighlight();
myhimap.FindFromIndex(i)->Erase();
myhimap.FindFromIndex(i)->Clear();
}
myold.Clear();
mynew.Clear();
mylastindex=0;
}
myhimap.Clear();
}
const Handle(Prs3d_Drawer)& StdSelect_BRepHilighter::Drawer() const
{
return mydrwr;
}

View File

@@ -0,0 +1,144 @@
-- File: StdSelect_BRepOwner.cdl
-- Created: Wed Mar 8 15:56:17 1995
-- Author: Mister rmi
-- <rmi@photon>
---Copyright: Matra Datavision 1995
class BRepOwner from StdSelect inherits EntityOwner from SelectMgr
---Purpose: Defines Specific Owners for Sensitive Primitives
-- (Sensitive Segments,Circles...).
-- Used in Dynamic Selection Mechanism.
-- A BRepOwner has an Owner (the shape it represents)
-- and Users (One or More Transient entities).
uses
Location from TopLoc,
Shape from TopoDS,
SelectableObject from SelectMgr,
EntityOwner from SelectMgr,
Presentation from Prs3d,
PresentationManager from PrsMgr,
PresentationManager3d from PrsMgr,
NameOfColor from Quantity,
Drawer from Prs3d,
Shape from StdSelect
is
Create(aPriority:Integer from Standard)
returns mutable BRepOwner from StdSelect;
---Purpose: Constructs an owner specification framework defined
-- by the priority aPriority.
Create (aShape : Shape from TopoDS;
aPriority : Integer = 0;
ComesFromDecomposition:Boolean from Standard = Standard_False)
returns mutable BRepOwner;
---Purpose: Constructs an owner specification framework defined
-- by the shape aShape and the priority aPriority.
-- aShape and aPriority are stored in this framework. If
-- more than one owner are detected during dynamic
-- selection, the one with the highest priority is the one stored.
Create (aShape : Shape from TopoDS;
theOrigin : SelectableObject from SelectMgr;
aPriority : Integer = 0;
FromDecomposition:Boolean from Standard = Standard_False)
returns mutable BRepOwner;
---Purpose: Constructs an owner specification framework defined
-- by the shape aShape, the selectable object theOrigin
-- and the priority aPriority.
-- aShape, theOrigin and aPriority are stored in this
-- framework. If more than one owner are detected
-- during dynamic selection, the one with the highest
-- priority is the one stored.
HasShape(me) returns Boolean from Standard;
---C++: inline
---Purpose: returns False if no shape was set
--
Set(me : mutable;
aShape : Shape from TopoDS;
FromDecomposition:Boolean from Standard=Standard_False);
---Purpose: <FromDecomposition> indicates whether <aShape>
-- comes from decomposition of a bigger shape.
ComesFromDecomposition(me) returns Boolean from Standard;
---C++: inline
Shape(me) returns Shape from TopoDS ;
---C++: inline
---C++: return const&
---Category: hilight of detected shapes...
HasHilightMode(me) returns Boolean from Standard;
---Purpose:
-- Returns true if this framework has a highlight mode defined for it.
---C++: inline
SetHilightMode(me:mutable;aMode : Integer from Standard);
---C++: inline
---Purpose: Sets the highlight mode for this framework.
-- This defines the type of display used to highlight the
-- owner of the shape when it is detected by the selector.
-- The default type of display is wireframe, defined by the index 0.
ResetHilightMode(me:mutable) ;
---Purpose: Resets the higlight mode for this framework.
-- This defines the type of display used to highlight the
-- owner of the shape when it is detected by the selector.
-- The default type of display is wireframe, defined by the index 0.
---C++: inline
HilightMode(me) returns Integer from Standard;
---Purpose: Returns the highlight mode for this framework.
-- This defines the type of display used to highlight the
-- owner of the shape when it is detected by the selector.
-- The default type of display is wireframe, defined by the index 0.
---C++: inline
IsHilighted (me ;
aPM : PresentationManager from PrsMgr;
aMode : Integer from Standard =0)
returns Boolean from Standard is redefined virtual;
---Purpose: Returns true if an object with the selection mode
-- aMode is highlighted in the presentation manager aPM.
Hilight(me:mutable) is redefined virtual;
Hilight(me : mutable;
aPM : PresentationManager from PrsMgr;
aMode : Integer from Standard =0) is redefined virtual;
--- Purpose: Returns the selection mode aMode defining the type
-- of shape highlighted in the presentation manager aPM.
HilightWithColor (me : mutable;
aPM : PresentationManager3d from PrsMgr;
aCol : NameOfColor from Quantity;
aMode : Integer from Standard =0) is redefined virtual;
Unhilight(me : mutable;
aPM : PresentationManager from PrsMgr;
aMode : Integer from Standard =0) is redefined virtual;
---Purpose: Removes highlighting from the type of shape
-- identified the selection mode aMode in the presentation manager aPM.
Clear(me: mutable;
aPM : PresentationManager from PrsMgr;
aMode : Integer from Standard =0) is redefined virtual;
---Purpose: Clears the presentation manager object aPM of all
-- shapes with the selection mode aMode.
SetLocation(me:mutable; aLoc : Location from TopLoc) is redefined;
ResetLocation(me:mutable) is redefined;
fields
myPrsSh : Shape from StdSelect;
myCurMode : Integer from Standard;
myFromDecomposition : Boolean from Standard is protected;
myShape : Shape from TopoDS is protected;
end BRepOwner;

View File

@@ -0,0 +1,163 @@
// Copyright: Matra-Datavision 1995
// File: StdSelect_BRepOwner.cxx
// Created: Wed Mar 8 16:13:35 1995
// Author: Mister rmi
// <rmi>
#define BUC60876 //GG_050401 Enable to highlight something
// with a specific hilight mode
//
#include <StdSelect_BRepOwner.ixx>
#include <SelectBasics_EntityOwner.hxx>
#include <StdPrs_WFShape.hxx>
#include <Graphic3d_StructureManager.hxx>
//==================================================
// Function:
// Purpose :
//==================================================
StdSelect_BRepOwner::StdSelect_BRepOwner(const Standard_Integer aPriority):
SelectMgr_EntityOwner(aPriority),
myFromDecomposition(Standard_False),
myCurMode(0)
{
}
StdSelect_BRepOwner::StdSelect_BRepOwner(const TopoDS_Shape& aShape,
const Standard_Integer aPriority,
const Standard_Boolean ComesFromDecomposition):
SelectMgr_EntityOwner(aPriority),
myFromDecomposition(ComesFromDecomposition),
myShape(aShape),
myCurMode(0)
{
}
StdSelect_BRepOwner::StdSelect_BRepOwner(const TopoDS_Shape& aShape,
const Handle (SelectMgr_SelectableObject)& theOrigin,
const Standard_Integer aPriority,
const Standard_Boolean ComesFromDecomposition):
SelectMgr_EntityOwner(theOrigin,aPriority),
myFromDecomposition(ComesFromDecomposition),
myShape(aShape),
myCurMode(0)
{
}
//=======================================================================
//function : IsHilighted
//purpose :
//=======================================================================
Standard_Boolean StdSelect_BRepOwner::
IsHilighted(const Handle(PrsMgr_PresentationManager)& PM,
const Standard_Integer aMode) const
{
#ifdef BUC60876
Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
if(myPrsSh.IsNull())
return PM->IsHighlighted(Selectable(),M);
return PM->IsHighlighted(myPrsSh,M);
}
//=======================================================================
//function : Hilight/Unhilight Methods...
//purpose :
//=======================================================================
void StdSelect_BRepOwner::Hilight(const Handle(PrsMgr_PresentationManager)& PM,
const Standard_Integer aMode)
{
#ifdef BUC60876
Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
if(myFromDecomposition)
if(myPrsSh.IsNull())
myPrsSh = new StdSelect_Shape(myShape);
if(myPrsSh.IsNull())
PM->Highlight(Selectable(),M);
else
PM->Highlight(myPrsSh,M);
}
void StdSelect_BRepOwner::Hilight()
{}
void StdSelect_BRepOwner::HilightWithColor(const Handle(PrsMgr_PresentationManager3d)& PM,
const Quantity_NameOfColor aCol,
const Standard_Integer aMode)
{
#ifdef BUC60876
Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
if(myFromDecomposition){
if(myPrsSh.IsNull()){
if(HasLocation()){
TopLoc_Location lbid = Location() * myShape.Location();
TopoDS_Shape ShBis = myShape.Located(lbid);
myPrsSh = new StdSelect_Shape(ShBis);
}
else
myPrsSh = new StdSelect_Shape(myShape);
}
}
if(myPrsSh.IsNull())
PM->Color(Selectable(),aCol,M);
else
PM->Color(myPrsSh,aCol,M);
}
void StdSelect_BRepOwner::Unhilight(const Handle(PrsMgr_PresentationManager)& PM,
const Standard_Integer aMode)
{
#ifdef BUC60876
Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
if(myPrsSh.IsNull() || !myFromDecomposition)
PM->Unhighlight(Selectable(),M);
else
PM->Unhighlight(myPrsSh,M);
}
void StdSelect_BRepOwner::Clear(const Handle(PrsMgr_PresentationManager)& PM,
const Standard_Integer aMode)
{
#ifdef BUC60876
Standard_Integer M = (aMode < 0) ? myCurMode : aMode;
#else
Standard_Integer M = (myCurMode==-1) ? aMode:myCurMode;
#endif
if(myPrsSh.IsNull())
PM->Clear(myPrsSh,M);
myPrsSh.Nullify();
}
void StdSelect_BRepOwner::SetLocation(const TopLoc_Location& aLoc)
{
SelectMgr_EntityOwner::SetLocation(aLoc);
if(!myPrsSh.IsNull())
myPrsSh.Nullify();
}
void StdSelect_BRepOwner::ResetLocation()
{
SelectMgr_EntityOwner::ResetLocation();
if(!myPrsSh.IsNull())
myPrsSh.Nullify();
}

View File

@@ -0,0 +1,22 @@
#include <StdSelect_Shape.hxx>
inline Standard_Boolean StdSelect_BRepOwner::HasHilightMode() const
{return myCurMode == -1;}
inline void StdSelect_BRepOwner::SetHilightMode(const Standard_Integer HiMod)
{myCurMode=HiMod;}
inline void StdSelect_BRepOwner::ResetHilightMode()
{myCurMode =-1;}
inline Standard_Integer StdSelect_BRepOwner::HilightMode() const
{return myCurMode;}
inline const TopoDS_Shape& StdSelect_BRepOwner::Shape() const
{return myShape;}
inline Standard_Boolean StdSelect_BRepOwner::HasShape() const
{return !myShape.IsNull();}
inline Standard_Boolean StdSelect_BRepOwner::ComesFromDecomposition() const
{return myFromDecomposition;}

View File

@@ -0,0 +1,179 @@
-- File: StdSelect_BRepSelectionTool.cdl
-- Created: Wed Mar 8 16:20:52 1995
-- Author: Mister rmi
-- <rmi@photon>
--
-- Fri Apr 10 98 : rob : Add Boolean for automatic
-- Triangulation on faces...
--
---Copyright: Matra Datavision 1995
class BRepSelectionTool from StdSelect
---Purpose: Tool to create specific selections (sets of primitives)
-- for Shapes from Topology.
-- These Selections may be used in dynamic selection
-- Mechanism
-- Given a Shape and a mode of selection
-- (selection of vertices,
-- edges,faces ...) , This Tool Computes corresponding sensitive primitives,
-- puts them in an entity called Selection (see package SelectMgr) and returns it.
--
--
-- A Priority for the decomposed pickable objects can be given ;
-- by default There is A Preset Hierachy:
-- Vertex priority : 5
-- Edge priority : 4
-- Wire priority : 3
-- Face priority : 2
-- Shell,solid,shape priority : 1
-- the default priority in the following methods has no sense - it's only taken in account
-- when the user gives a value between 0 and 10.
-- IMPORTANT : This decomposition creates BRepEntityOwner instances (from StdSelect).
-- which are stored in the Sensitive Entities coming from The Decomposition.
--
-- the result of picking in a ViewerSelector return EntityOwner from SelectMgr;
-- to know what kind of object was picked :
--
-- ENTITY_OWNER -> Selectable() gives the selectableobject which
-- was decomposed into pickable elements.
-- Handle(StdSelect_BRepOwner)::DownCast(ENTITY_OWNER) -> Shape()
-- gives the real picked shape (edge,vertex,shape...)
--
uses
Selection from SelectMgr,
Shape from TopoDS,
Face from TopoDS,
ShapeEnum from TopAbs,
SelectableObject from SelectMgr,
BRepOwner from StdSelect,
SensitiveEntity from Select3D,
ListOfSensitive from Select3D
is
Load(myclass;
aSelection : mutable Selection from SelectMgr;
aShape : Shape from TopoDS;
aType : ShapeEnum from TopAbs;
theDeflection : Real from Standard;
theDeviationAngle : Real from Standard;
AutoTriangulation : Boolean from Standard = Standard_True;
aPriority : Integer =-1;
NbPOnEdge : Integer = 9;
MaximalParameter : Real from Standard = 500);
---Level: Public
---Purpose: Decomposition of <aShape> into sensitive entities following
-- a mode of decomposition <aType>. These entities are stored in <aSelection>.
-- BrepOwners are created to store the identity of the picked shapes
-- during the selection process.
-- In those BRepOwners is also stored the original shape.
-- But One can't get the selectable object which was decomposed to give
-- the sensitive entities.
-- maximal parameter is used for infinite objects, to limit the sensitive Domain....
-- If AutoTriangulation = True, a Triangulation will be
-- computed for faces which have no existing one.
-- if AutoTriangulation = False the old algorithm will be
-- called to compute sensitive entities on faces.
Load(myclass;
aSelection : mutable Selection from SelectMgr;
Origin : SelectableObject from SelectMgr;
aShape : Shape from TopoDS;
aType : ShapeEnum from TopAbs;
theDeflection : Real from Standard;
theDeviationAngle : Real from Standard;
AutoTriangulation : Boolean from Standard = Standard_True;
aPriority : Integer =-1;
NbPOnEdge : Integer = 9;
MaximalParameter : Real from Standard = 500);
---Purpose: Same functionnalities ; the only
-- difference is that the selectable object from which the
-- selection comes is stored in each Sensitive EntityOwner;
-- Load(myclass;
-- aSelection : mutable Selection from SelectMgr;
-- Users : SequenceOfAddress from SelectBasics;
-- aShape : Shape from TopoDS;
-- aType : ShapeEnum from TopAbs;
-- AutoTriangulation : Boolean from Standard = Standard_True;
-- aPriority : Integer =-1;
-- NbPOnEdge : Integer = 9;
-- MaximalParameter : Real from Standard = 500);
---Level: Public
---Purpose:decomposition of <aShape> into sensitive entities following
-- a mode of decomposition <aType>. These entities are stored in <aSelection>
-- The Major difference is that the known users are first inserted in the
-- BRepOwners. the original shape is the last user...
-- (see EntityOwner from SelectBasics and BrepOwner)...
GetStandardPriority(myclass;
aShap: Shape from TopoDS;
aType: ShapeEnum from TopAbs)
returns Integer from Standard;
---Purpose: Returns the standard priority of the shape aShap having the type aType.
-- This priority is passed to a StdSelect_BRepOwner object.
-- You can use the function Load to modify the
-- selection priority of an owner to make one entity
-- more selectable than another one.
ComputeSensitive(myclass;
aShape : Shape from TopoDS;
anOwner : BRepOwner from StdSelect;
aSelection : mutable Selection from SelectMgr;
theDeflection : Real from Standard;
theDeviationAngle : Real from Standard;
NbPOnEdge : Integer;
MaximalParameter : Real from Standard;
AutoTriangulation : Boolean from Standard = Standard_True) ;
---Purpose: Computes the sensitive primitives corresponding to
-- the subshape aShape with the owner anOwner.
-- Stores them in the SelectMgr_Selection object, and returns this object.
-- The number NbPOnEdge is used to define edges and wires.
-- In the case of infinite objects, the value
-- MaximalParameter serves to limit computation time
-- by limiting the sensitive area. The default value is 500.
-- If AutoTriangulation is true, triangulation will be
-- computed for the faces which have none. If it is false,
-- sensitive entities on these faces will be calculated.
GetEdgeSensitive(myclass;
aShape : Shape from TopoDS;
anOwner : BRepOwner from StdSelect;
aSelection : mutable Selection from SelectMgr;
theDeflection : Real from Standard;
theDeflectionAngle : Real from Standard;
NbPOnEdge : Integer;
MaximalParameter : Real from Standard;
aSensitive : in out SensitiveEntity from Select3D)
is private;
---Level: Internal
---Purpose:
GetSensitiveForFace(myclass;
aFace : Face from TopoDS;
anOwner : BRepOwner from StdSelect;
OutList : in out ListOfSensitive from Select3D;
AutoTriangulation : Boolean from Standard = Standard_True;
NbPOnEdge : Integer = 9;
MaxiParam : Real from Standard =500;
InteriorFlag : Boolean from Standard = Standard_True)
returns Boolean from Standard;
---Purpose: appends to <OutList> the 3D
-- sensitive entities created for selection of <aFace>
-- if<InteriorFlag> = False the face will be sensitive only on its boundary
end BRepSelectionTool;

View File

@@ -0,0 +1,857 @@
// Copyright: Matra-Datavision 1995
// File: StdSelect_BRepSelectionTool.cxx
// Created: Tue Mar 14 14:09:28 1995
// Author: Robert COUBLANC
// <rob>
#define OCC232 //GG_15/03/02 Enable to compute selection also
// for COMPSOLID shape type.
// Origin: TELCO Smart70563 (jbz)
#define OCC294 // SAV 22/10/02 catching exception from BRepAdaptor_Curve::Initialize
#define OCC872 // SAV 23/10/02 checking if TopoDS_Wire is null or not to avoid "access violation" exception.
#include <StdSelect_BRepSelectionTool.ixx>
#include <GeomAdaptor_Curve.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <Select3D_SensitivePoint.hxx>
#include <StdSelect_BRepOwner.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Circle.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitiveCurve.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveWire.hxx>
#include <Select3D_SensitiveFace.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
#include <Select3D_SensitiveTriangle.hxx>
#include <Select3D_SensitiveGroup.hxx>
#include <Select3D_ListIteratorOfListOfSensitive.hxx>
#include <Select3D_ListOfSensitiveTriangle.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <Select3D_TypeOfSensitivity.hxx>
#include <Precision.hxx>
#include <gp_Circ.hxx>
#include <GCPnts_TangentialDeflection.hxx>
#include <TopoDS_Wire.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <Standard_NullObject.hxx>
#include <Standard_ErrorHandler.hxx>
//static Standard_Integer myArraySize = 2,myN=2;
static Standard_Integer myN=2;
static Standard_Boolean first = Standard_True;
//==================================================
// Function: Load
// Purpose : Version debuggee....
//==================================================
void StdSelect_BRepSelectionTool
::Load (const Handle(SelectMgr_Selection)& aSelection,
const TopoDS_Shape& aShap,
const TopAbs_ShapeEnum aType,
const Standard_Real theDeflection,
const Standard_Real theDeviationAngle,
const Standard_Boolean AutoTriangulation,
const Standard_Integer aPriority,
const Standard_Integer NbPOnEdge,
const Standard_Real MaxParam)
{
Standard_Integer Prior = (aPriority==-1)? GetStandardPriority(aShap,aType): aPriority;
switch(aType) {
case TopAbs_VERTEX:
case TopAbs_EDGE:
case TopAbs_WIRE:
case TopAbs_FACE:
case TopAbs_SHELL:
case TopAbs_SOLID:
#ifdef OCC232
case TopAbs_COMPSOLID:
#endif
{
TopTools_IndexedMapOfShape subshaps;
TopExp::MapShapes(aShap,aType,subshaps);
Standard_Boolean ComesFromDecomposition(Standard_True);
if(subshaps.Extent()==1)
if(aShap==subshaps(1))
ComesFromDecomposition = Standard_False;
Handle(StdSelect_BRepOwner) BOwn;
for (Standard_Integer I = 1;I<=subshaps.Extent();I++){
BOwn = new StdSelect_BRepOwner(subshaps(I),Prior,ComesFromDecomposition);
// BOwn->SetHilightMode(1);
ComputeSensitive (subshaps(I),
BOwn,
aSelection,
theDeflection,
theDeviationAngle,
NbPOnEdge,
MaxParam,
AutoTriangulation);
}
break;
}
default:
{
Handle(StdSelect_BRepOwner) BOwn;
BOwn = new StdSelect_BRepOwner(aShap,Prior);
// BOwn->SetHilightMode(1);
ComputeSensitive(aShap,
BOwn,
aSelection,
theDeflection,
theDeviationAngle,
NbPOnEdge,
MaxParam,
AutoTriangulation);
}
}
}
void StdSelect_BRepSelectionTool
::Load (const Handle(SelectMgr_Selection)& aSelection,
const Handle(SelectMgr_SelectableObject)& aSO,
const TopoDS_Shape& aShap,
const TopAbs_ShapeEnum aType,
const Standard_Real theDeflection,
const Standard_Real theDeviationAngle,
const Standard_Boolean AutoTriangulation,
const Standard_Integer aPriority,
const Standard_Integer NbPOnEdge,
const Standard_Real MaxParam)
{
Load (aSelection,
aShap,
aType,
theDeflection,
theDeviationAngle,
AutoTriangulation,
aPriority,
NbPOnEdge);
//chargement des selectables...
for (aSelection->Init();aSelection->More();aSelection->Next()) {
Handle(SelectBasics_EntityOwner) BOwn = aSelection->Sensitive()->OwnerId();
Handle(SelectMgr_EntityOwner) Own = *((Handle(SelectMgr_EntityOwner)*) &BOwn);
Own->Set(aSO);
}
}
/*void StdSelect_BRepSelectionTool
::Load (const Handle(SelectMgr_Selection)& aSelection,
const SelectBasics_SequenceOfAddress& Users,
const TopoDS_Shape& aShap,
const TopAbs_ShapeEnum aType,
const Standard_Boolean AutoTriangulation,
const Standard_Integer aPriority,
const Standard_Integer NbPOnEdge,
const Standard_Real MaxParam)
{
Load(aSelection,aShap,aType,AutoTriangulation,aPriority,NbPOnEdge);
for (aSelection->Init();aSelection->More();aSelection->Next())
{
for(Standard_Integer i=1;i<=Users.Length();i++)
{aSelection->Sensitive()->OwnerId()->Add(Users(i));}
}
}*/
void StdSelect_BRepSelectionTool
::ComputeSensitive(const TopoDS_Shape& shap,
const Handle(StdSelect_BRepOwner)& Owner ,
const Handle(SelectMgr_Selection)& aSelection,
const Standard_Real theDeflection,
const Standard_Real theDeviationAngle,
const Standard_Integer NbPOnEdge,
const Standard_Real MaxParam,
const Standard_Boolean AutoTriangulation)
{
TopAbs_ShapeEnum TheShapeType = shap.ShapeType();
switch (TheShapeType) {
case TopAbs_VERTEX:
{
aSelection->Add(new Select3D_SensitivePoint
(Owner , BRep_Tool::Pnt(TopoDS::Vertex(shap))));
break;
}
case TopAbs_EDGE:
{
Handle (Select3D_SensitiveEntity) aSensitive;
GetEdgeSensitive (shap, Owner, aSelection, theDeflection, theDeviationAngle, NbPOnEdge, MaxParam, aSensitive);
if(!aSensitive.IsNull())
aSelection->Add(aSensitive);
break;
}
case TopAbs_WIRE:
{
BRepTools_WireExplorer Exp(TopoDS::Wire(shap));
Handle (Select3D_SensitiveEntity) aSensitive;
Handle (Select3D_SensitiveWire) aWireSensitive = new Select3D_SensitiveWire(Owner);
aSelection->Add(aWireSensitive);
while(Exp.More()){
GetEdgeSensitive (Exp.Current(), Owner, aSelection, theDeflection, theDeviationAngle, NbPOnEdge, MaxParam, aSensitive);
aWireSensitive->Add(aSensitive);
Exp.Next();
}
break;
}
case TopAbs_FACE:
{
const TopoDS_Face& F = TopoDS::Face(shap);
Select3D_ListOfSensitive LL;
GetSensitiveForFace(F,Owner,LL,AutoTriangulation,NbPOnEdge,MaxParam);
for(Select3D_ListIteratorOfListOfSensitive It(LL);It.More();It.Next())
aSelection->Add(It.Value());
break;
}
case TopAbs_SHELL:{
TopTools_IndexedMapOfShape subshaps;
TopExp::MapShapes(shap,TopAbs_FACE,subshaps);
Handle(Select3D_SensitiveGroup) SG = new Select3D_SensitiveGroup(Owner);
Select3D_ListOfSensitive LL;
TopExp::MapShapes(shap,TopAbs_FACE,subshaps);
for (Standard_Integer I = 1;I<=subshaps.Extent();I++) {
GetSensitiveForFace(TopoDS::Face(subshaps(I)),
Owner,LL,AutoTriangulation,NbPOnEdge,MaxParam);
}
if(!LL.IsEmpty()){
SG->Add(LL);
aSelection->Add(SG);
}
break;
}
case TopAbs_SOLID:
case TopAbs_COMPSOLID:
{
TopTools_IndexedMapOfShape subshaps;
TopExp::MapShapes(shap,TopAbs_FACE,subshaps);
for (Standard_Integer I = 1;I<=subshaps.Extent();I++)
{
ComputeSensitive (subshaps(I), Owner, aSelection, theDeflection, theDeviationAngle, NbPOnEdge, MaxParam, AutoTriangulation);}
break;
}
case TopAbs_COMPOUND:
default:
{
TopExp_Explorer Exp;
Standard_Boolean Ilibre = 0;
for(Exp.Init(shap,TopAbs_VERTEX,TopAbs_EDGE);Exp.More();Exp.Next()){
Ilibre++;
ComputeSensitive (Exp.Current(), Owner, aSelection, theDeflection, theDeviationAngle, NbPOnEdge, MaxParam, AutoTriangulation);}
Ilibre = 0;
for(Exp.Init(shap,TopAbs_EDGE,TopAbs_FACE);Exp.More();Exp.Next()){
Ilibre++;
ComputeSensitive (Exp.Current(), Owner, aSelection, theDeflection, theDeviationAngle, NbPOnEdge, MaxParam, AutoTriangulation);}
Ilibre = 0;
for(Exp.Init(shap,TopAbs_WIRE,TopAbs_FACE);Exp.More();Exp.Next()){
Ilibre++;
ComputeSensitive (Exp.Current(), Owner, aSelection, theDeflection, theDeviationAngle, NbPOnEdge, MaxParam, AutoTriangulation);}
// Standard_Integer Iface = 0;
TopTools_IndexedMapOfShape subshaps;
TopExp::MapShapes(shap,TopAbs_FACE,subshaps);
for (Standard_Integer I = 1;I<=subshaps.Extent();I++)
{
ComputeSensitive (subshaps(I), Owner, aSelection, theDeflection, theDeviationAngle, NbPOnEdge, MaxParam, AutoTriangulation);
}
}
}
}
static Handle(TColgp_HArray1OfPnt) GetPointsFromPolygon (const TopoDS_Edge& theEdge,
const Standard_Real theDeflection)
{
Handle(TColgp_HArray1OfPnt) aResultPoints;
Standard_Real fi, la;
Handle(Geom_Curve) CC3d = BRep_Tool::Curve (theEdge, fi, la);
TopLoc_Location aLocation;
Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (theEdge, aLocation);
if (!aPolygon.IsNull())
{
Standard_Boolean isOK = aPolygon->Deflection() <= theDeflection;
isOK = isOK || (CC3d.IsNull());
if (isOK)
{
const TColgp_Array1OfPnt& aNodes = aPolygon->Nodes();
aResultPoints = new TColgp_HArray1OfPnt (1, aNodes.Length());
if (aLocation.IsIdentity())
{
for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
{
aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId));
}
}
else
{
for (Standard_Integer aNodeId (aNodes.Lower()), aPntId (1); aNodeId <= aNodes.Upper(); ++aNodeId, ++aPntId)
{
aResultPoints->SetValue (aPntId, aNodes.Value (aNodeId).Transformed (aLocation));
}
}
return aResultPoints;
}
}
Handle(Poly_Triangulation) aTriangulation;
Handle(Poly_PolygonOnTriangulation) anHIndices;
BRep_Tool::PolygonOnTriangulation (theEdge, anHIndices, aTriangulation, aLocation);
if (!anHIndices.IsNull())
{
Standard_Boolean isOK = anHIndices->Deflection() <= theDeflection;
isOK = isOK || (CC3d.IsNull());
if (isOK)
{
const TColStd_Array1OfInteger& anIndices = anHIndices->Nodes();
const TColgp_Array1OfPnt& aNodes = aTriangulation->Nodes();
aResultPoints = new TColgp_HArray1OfPnt (1, anIndices.Length());
if (aLocation.IsIdentity())
{
for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
{
aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)));
}
}
else
{
for (Standard_Integer anIndex (anIndices.Lower()), aPntId (1); anIndex <= anIndices.Upper(); ++anIndex, ++aPntId)
{
aResultPoints->SetValue (aPntId, aNodes (anIndices (anIndex)).Transformed (aLocation));
}
}
return aResultPoints;
}
}
return aResultPoints;
}
static Standard_Boolean FindLimits(const Adaptor3d_Curve& aCurve,
const Standard_Real aLimit,
Standard_Real& First,
Standard_Real& Last)
{
First = aCurve.FirstParameter();
Last = aCurve.LastParameter();
Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
Standard_Boolean lastInf = Precision::IsPositiveInfinite(Last);
if (firstInf || lastInf) {
gp_Pnt P1,P2;
Standard_Real delta = 1;
Standard_Integer count = 0;
if (firstInf && lastInf) {
do {
if (count++ == 100000) return Standard_False;
delta *= 2;
First = - delta;
Last = delta;
aCurve.D0(First,P1);
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
else if (firstInf) {
aCurve.D0(Last,P2);
do {
if (count++ == 100000) return Standard_False;
delta *= 2;
First = Last - delta;
aCurve.D0(First,P1);
} while (P1.Distance(P2) < aLimit);
}
else if (lastInf) {
aCurve.D0(First,P1);
do {
if (count++ == 100000) return Standard_False;
delta *= 2;
Last = First + delta;
aCurve.D0(Last,P2);
} while (P1.Distance(P2) < aLimit);
}
}
return Standard_True;
}
//=====================================================
// Function : GetEdgeSensitive
// Purpose : cree un edge sensible pour pouvoir l'ajouter
// dans computeselection a "aselection" (cas d'une selection d'un edge)
// ou a "aSensitiveWire" (cas d'une selection d'un wire; dans ce cas la,
// c'est le sensitive wire qui est ajoute a "aselection" )
// odl - pour la selection par rectangle -
//=====================================================
void StdSelect_BRepSelectionTool
::GetEdgeSensitive (const TopoDS_Shape& shap,
const Handle(StdSelect_BRepOwner)& Owner ,
const Handle(SelectMgr_Selection)& aSelection,
const Standard_Real theDeflection,
const Standard_Real theDeviationAngle,
const Standard_Integer NbPOnEdge,
const Standard_Real MaxParam,
Handle(Select3D_SensitiveEntity)& aSensitive)
{
BRepAdaptor_Curve cu3d;
#ifdef OCC294
try {
OCC_CATCH_SIGNALS
cu3d.Initialize (TopoDS::Edge(shap));
} catch ( Standard_NullObject ) {
return;
}
#else
cu3d.Initialize (TopoDS::Edge(shap));
#endif
// try to get points from existing polygons
Handle(TColgp_HArray1OfPnt) aPoints = GetPointsFromPolygon (TopoDS::Edge(shap), theDeflection);
if (!aPoints.IsNull() && aPoints->Length() > 0)
{
aSensitive = new Select3D_SensitiveCurve (Owner, aPoints);
return;
}
Standard_Real wf,wl;
BRep_Tool::Range(TopoDS::Edge(shap), wf, wl);
switch(cu3d.GetType()){
case GeomAbs_Line:
{
aSensitive = new Select3D_SensitiveSegment
(Owner,
cu3d.Value(wf),cu3d.Value(wl));
break;
}
case GeomAbs_Circle:
{
Handle (Geom_Circle) TheCircle =new Geom_Circle(cu3d.Circle());
Standard_Real TheStart = cu3d.FirstParameter();
Standard_Real TheEnd = cu3d.LastParameter();
if(TheCircle->Radius()<=Precision::Confusion())
aSelection->Add(new Select3D_SensitivePoint(Owner,TheCircle->Location()));
else
aSensitive = new Select3D_SensitiveCircle(Owner,TheCircle,TheStart,TheEnd,Standard_False,16);
break;
}
default:
{
// modif-rob : on prend le meme deroulement que dans StdPrs_Curve
// nb de points...
//============================================
//aLimit = myDrawer->MaximalParameterValue(); ??
Standard_Real aLimit = 200.; // TODO (kgv) - do we need set MaxParam here?
Standard_Real V1 = cu3d.FirstParameter();
Standard_Real V2 = cu3d.LastParameter();
Standard_Boolean firstInf = Precision::IsNegativeInfinite(V1);
Standard_Boolean lastInf = Precision::IsPositiveInfinite(V2);
if (firstInf || lastInf) {
gp_Pnt P1,P2;
Standard_Real delta = 1;
if (firstInf && lastInf) {
do {
delta *= 2;
V1 = - delta;
V2 = delta;
cu3d.D0(V1,P1);
cu3d.D0(V2,P2);
} while (P1.Distance(P2) < aLimit);
}
else if (firstInf) {
cu3d.D0(V2,P2);
do {
delta *= 2;
V1 = V2 - delta;
cu3d.D0(V1,P1);
} while (P1.Distance(P2) < aLimit);
}
else if (lastInf) {
cu3d.D0(V1,P1);
do {
delta *= 2;
V2 = V1 + delta;
cu3d.D0(V2,P2);
} while (P1.Distance(P2) < aLimit);
}
}
Standard_Real aLimitV1, aLimitV2;
Standard_Boolean isOK = FindLimits (cu3d, aLimit, aLimitV1, aLimitV2);
//aLimitV1 = cu3d.FirstParameter();
//aLimitV2 = cu3d.LastParameter();
// reproduce drawing behavour
// TODO (kgv) - remove copy-paste
if (isOK)
{
Standard_Integer aNbIntervals = cu3d.NbIntervals (GeomAbs_C1);
TColStd_Array1OfReal anIntervals (1, aNbIntervals + 1);
cu3d.Intervals (anIntervals, GeomAbs_C1);
Standard_Real aV1, aV2;
Standard_Integer aNumberOfPoints;
TColgp_SequenceOfPnt aPointsSeq;
for (Standard_Integer anIntervalId = 1; anIntervalId <= aNbIntervals; ++anIntervalId)
{
aV1 = anIntervals (anIntervalId); aV2 = anIntervals (anIntervalId + 1);
if (aV2 > aLimitV1 && aV1 < aLimitV2)
{
aV1 = Max (aV1, aLimitV1);
aV2 = Min (aV2, aLimitV2);
GCPnts_TangentialDeflection anAlgo (cu3d, aV1, aV2, theDeviationAngle, theDeflection);
aNumberOfPoints = anAlgo.NbPoints();
if (aNumberOfPoints > 0)
{
for (Standard_Integer i = 1; i < aNumberOfPoints; ++i)
{
aPointsSeq.Append (anAlgo.Value (i));
}
if (anIntervalId == aNbIntervals)
{
aPointsSeq.Append (anAlgo.Value (aNumberOfPoints));
}
}
}
}
aPoints = new TColgp_HArray1OfPnt (1, aPointsSeq.Length());
for (Standard_Integer aPntId = 1; aPntId <= aPointsSeq.Length(); ++aPntId)
{
aPoints->SetValue (aPntId, aPointsSeq.Value (aPntId));
}
aSensitive = new Select3D_SensitiveCurve (Owner, aPoints);
break;
}
// simple subdivisions
Standard_Integer nbintervals = 1;
if (cu3d.GetType() == GeomAbs_BSplineCurve) {
nbintervals = cu3d.NbKnots() - 1;
nbintervals = Max(1, nbintervals/3);}
Standard_Real V;
Standard_Integer N = Max(2, NbPOnEdge*nbintervals);
Standard_Real DV = (V2-V1) / (N-1);
gp_Pnt p;
if (first) {
myN = N;
first = Standard_False;
}
if (myN == N) {
Handle(TColgp_HArray1OfPnt) points = new TColgp_HArray1OfPnt(1, N);
for (Standard_Integer i = 1; i <= N;i++)
{
V = V1 + (i-1)*DV;
p = cu3d.Value(V);
points->SetValue(i,p);
}
aSensitive = new Select3D_SensitiveCurve(Owner,points);
}
else {
Handle(TColgp_HArray1OfPnt) pointsbis = new TColgp_HArray1OfPnt(1, N);
for (Standard_Integer i = 1; i <= N;i++)
{
V = V1 + (i-1)*DV;
p = cu3d.Value(V);
pointsbis->SetValue(i,p);
}
aSensitive = new Select3D_SensitiveCurve(Owner,pointsbis);
}
}
break;
}
}
Standard_Integer StdSelect_BRepSelectionTool::GetStandardPriority (const TopoDS_Shape& SH,
const TopAbs_ShapeEnum aType)
{
switch(aType) {
case TopAbs_VERTEX:
return 8;
case TopAbs_EDGE:
return 7;
case TopAbs_WIRE:
return 6;
case TopAbs_FACE:
return 5;
case TopAbs_SHAPE:
default:
switch(SH.ShapeType())
{
case TopAbs_VERTEX:
return 9;
case TopAbs_EDGE:
return 8;
case TopAbs_WIRE:
return 7;
case TopAbs_FACE:
return 6;
case TopAbs_SHELL:
return 5;
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID:
case TopAbs_SOLID:
case TopAbs_SHAPE:
default:
return 4;
}
}
return 0;
}
//=======================================================================
//function : GetSensitiveEntityForFace
//purpose :
//=======================================================================
Standard_Boolean StdSelect_BRepSelectionTool::GetSensitiveForFace(const TopoDS_Face& F,
const Handle(StdSelect_BRepOwner)& Owner,
Select3D_ListOfSensitive& LL,
const Standard_Boolean AutoTriangulation,
const Standard_Integer NbPOnEdge,
const Standard_Real MaxParam,
const Standard_Boolean InteriorFlag)
{
// voyons s y a une triangulation de la face...
BRepAdaptor_Curve cu3d;
Handle(Poly_Triangulation) T;
TopLoc_Location loc;
T = BRep_Tool::Triangulation(F,loc);
if(T.IsNull() && AutoTriangulation){
Standard_Real Defl=.2,Ang=30*PI/180.;
BRepMesh_IncrementalMesh(F,Defl,Standard_True,Ang);
T = BRep_Tool::Triangulation(F,loc);
}
if(!T.IsNull()){
Handle(Select3D_SensitiveTriangulation) STG =
new Select3D_SensitiveTriangulation(Owner,T,loc,InteriorFlag);
LL.Append(STG);
return Standard_True;
}
// pour les faces a bugs de triangulation ou sans autotriangulation ....
// tres laid et ne devrait meme plus exister ...
BRepAdaptor_Surface BS;
BS.Initialize (F);
Standard_Real FirstU = BS.FirstUParameter()<=-Precision::Infinite()? -MaxParam:BS.FirstUParameter();
Standard_Real LastU = BS.LastUParameter() >=Precision::Infinite()? MaxParam:BS.LastUParameter();
Standard_Real FirstV = BS.FirstVParameter()<=-Precision::Infinite()? -MaxParam:BS.FirstVParameter();
Standard_Real LastV = BS.LastVParameter()>=Precision::Infinite()? MaxParam:BS.LastVParameter();
if(BS.GetType()==GeomAbs_Plane){
gp_Pnt pcur;
Handle(TColgp_HArray1OfPnt) P = new TColgp_HArray1OfPnt(1,5);
BS.D0(FirstU,FirstV,pcur);
P->SetValue(1,pcur);
BS.D0(LastU,FirstV,pcur);
P->SetValue(2,pcur);
BS.D0(LastU,LastV,pcur);
P->SetValue(3,pcur);
BS.D0(FirstU,LastV,pcur);
P->SetValue(4,pcur);
P->SetValue(5,P->Value(1));
// si le plan est "infini", on ne le rend sensible que sur sa frontiere delimitee par MaxParam
if(FirstU ==-MaxParam && LastU==MaxParam && FirstV ==-MaxParam && LastV==MaxParam)
LL.Append(new Select3D_SensitiveFace
(Owner, P, Select3D_TOS_BOUNDARY));
else{
Select3D_TypeOfSensitivity TS = InteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
LL.Append(new Select3D_SensitiveFace
(Owner, P, TS));
}
return Standard_True;
}
// IL S'AGIT DE CONSTRUIRE UN POLYGONE "SENSIBLE" A PARTIR DU CONTOUR EXTERIEUR DE LA FACE...
// CA N'EST PAS BEAU DU TOUT MAIS...
TopoDS_Wire aWire;
// Standard_Integer NbEdges=1;
// Standard_Integer NbPoints(0);
TopExp_Explorer EW(F,TopAbs_WIRE);
if(EW.More())
aWire = TopoDS::Wire(EW.Current()); // en esperant que c'est le premier... a voir
#ifdef OCC872
if ( aWire.IsNull() )
return Standard_False;
#endif
BRepTools_WireExplorer Exp;
Exp.Init(aWire);
TColgp_SequenceOfPnt WirePoints;
Standard_Boolean FirstExp = Standard_True;
Standard_Real wf,wl;
for(;Exp.More();Exp.Next()){
cu3d.Initialize (Exp.Current());
BRep_Tool::Range(Exp.Current(), wf, wl);
if(Abs(wf-wl)<=Precision::Confusion()){
#ifdef DEB
cout<<" StdSelect_BRepSelectionTool : Curve where ufirst = ulast ...."<<endl;
#endif
}
else{
if(FirstExp){
if(Exp.Orientation()==TopAbs_FORWARD ){
WirePoints.Append(cu3d.Value(wf));
}
else{
WirePoints.Append(cu3d.Value(wl));}
FirstExp = Standard_False;}
switch(cu3d.GetType()){
case GeomAbs_Line:{
if(Exp.Orientation()==TopAbs_FORWARD){
WirePoints.Append(cu3d.Value(wl));}
else{
WirePoints.Append(cu3d.Value(wf));}
break;}
case GeomAbs_Circle:{
if (2*PI - Abs(wl-wf) <= Precision::Confusion()) {
if(BS.GetType()==GeomAbs_Cylinder ||
BS.GetType()==GeomAbs_Torus ||
BS.GetType()==GeomAbs_Cone ||
BS.GetType()==GeomAbs_BSplineSurface) // beuurkk pour l'instant...
{
Standard_Real ff= wf ,ll= wl ;
Standard_Real dw
=(Max(wf, wl)-Min(wf,wl))/(Standard_Real)Max(2, NbPOnEdge-1);
if (Exp.Orientation()==TopAbs_FORWARD){
for (Standard_Real wc=wf+dw; wc <= wl; wc+=dw){
WirePoints.Append(cu3d.Value(wc));
}
} else if (Exp.Orientation()==TopAbs_REVERSED){
for (Standard_Real wc=ll-dw; wc >= ff; wc-=dw){
WirePoints.Append(cu3d.Value(wc));
}
}
}
else {
if(cu3d.Circle().Radius() <= Precision::Confusion())
LL.Append(new Select3D_SensitivePoint(Owner,cu3d.Circle().Location()));
else
LL.Append(new Select3D_SensitiveCircle(Owner,new Geom_Circle(cu3d.Circle()),InteriorFlag,16));
}
}
else {
Standard_Real ff= wf ,ll= wl ;
Standard_Real dw
=(Max(wf, wl)-Min(wf,wl))/(Standard_Real)Max(2, NbPOnEdge-1);
if (Exp.Orientation()==TopAbs_FORWARD){
for (Standard_Real wc=wf+dw; wc <= wl; wc+=dw){
WirePoints.Append(cu3d.Value(wc));
}
} else if (Exp.Orientation()==TopAbs_REVERSED){
for (Standard_Real wc=ll-dw; wc >= ff; wc-=dw){
WirePoints.Append(cu3d.Value(wc));
}
}
}
break;
}
default:
{
Standard_Real ff= wf ,ll= wl ;
Standard_Real dw
=(Max(wf, wl)-Min(wf,wl))/(Standard_Real)Max(2, NbPOnEdge-1);
if (Exp.Orientation()==TopAbs_FORWARD){
for (Standard_Real wc=wf+dw; wc <= wl; wc+=dw){
WirePoints.Append(cu3d.Value(wc));
}
} else if (Exp.Orientation()==TopAbs_REVERSED) {
for (Standard_Real wc=ll-dw; wc >= ff; wc-=dw){
WirePoints.Append(cu3d.Value(wc));
}
}
}
}
}
}
Standard_Integer ArrayPosition = WirePoints.Length();
Handle(TColgp_HArray1OfPnt) facepoints = new TColgp_HArray1OfPnt(1,ArrayPosition);
// beurk beurk beurk...
for(Standard_Integer I=1 ;I<=ArrayPosition;I++)
{facepoints->SetValue (I, WirePoints.Value(I));}
if ((facepoints->Array1()).Length() > 1) { // 1 si un seul edge circulaire plein.
Select3D_TypeOfSensitivity TS = InteriorFlag ? Select3D_TOS_INTERIOR : Select3D_TOS_BOUNDARY;
LL.Append(new Select3D_SensitiveFace
(Owner, facepoints, TS));
}
return Standard_True;
}

View File

@@ -0,0 +1,41 @@
-- File: StdSelect_EdgeFilter.cdl
-- Created: Mon Mar 11 10:55:07 1996
-- Author: Robert COUBLANC
-- <rob@fidox>
---Copyright: Matra Datavision 1996
class EdgeFilter from StdSelect inherits Filter from SelectMgr
---Purpose: A framework to define a filter to select a specific type of edge.
-- The types available include:
-- - any edge
-- - a linear edge
-- - a circular edge.
uses
TypeOfEdge from StdSelect,
Shape from TopoDS,
EntityOwner from SelectMgr,
ShapeEnum from TopAbs
is
Create (Edge: TypeOfEdge from StdSelect)
returns mutable EdgeFilter from StdSelect;
---Purpose: Constructs an edge filter object defined by the type of edge Edge.
SetType(me:mutable;aNewType : TypeOfEdge from StdSelect);
---Purpose: Sets the type of edge aNewType. aNewType is to be highlighted in selection.
Type(me) returns TypeOfEdge from StdSelect;
---Purpose: Returns the type of edge to be highlighted in selection.
IsOk (me;anobj : EntityOwner from SelectMgr)
returns Boolean from Standard is redefined virtual;
ActsOn(me; aStandardMode : ShapeEnum from TopAbs)
returns Boolean from Standard is redefined virtual;
fields
mytype : TypeOfEdge from StdSelect;
end EdgeFilter;

View File

@@ -0,0 +1,80 @@
// Copyright: Matra-Datavision 1996
// File: StdSelect_EdgeFilter.cxx
// Created: Wed Mar 13 16:52:25 1996
// Author: Robert COUBLANC
// <rob>
#include <StdSelect_EdgeFilter.ixx>
#include <BRepAdaptor_Curve.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
#include <StdSelect_BRepOwner.hxx>
/*#include <.hxx>
#include <.hxx>
#include <.hxx>
#include <.hxx>
#include <.hxx>
*/
//==================================================
// Function:
// Purpose :
//==================================================
StdSelect_EdgeFilter
::StdSelect_EdgeFilter (const StdSelect_TypeOfEdge Edge):
mytype(Edge){}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_EdgeFilter
::SetType(const StdSelect_TypeOfEdge aNewType)
{
mytype=aNewType;
}
//==================================================
// Function:
// Purpose :
//==================================================
StdSelect_TypeOfEdge StdSelect_EdgeFilter::Type() const
{
return mytype;
}
//==================================================
// Function:
// Purpose :
//==================================================
Standard_Boolean StdSelect_EdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull()) return Standard_False;
const TopoDS_Shape& sh = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
if(sh.ShapeType()!= TopAbs_EDGE) return Standard_False;
switch(mytype){
case StdSelect_AnyEdge:
return Standard_True;
case StdSelect_Line:
{
BRepAdaptor_Curve curv(TopoDS::Edge(sh));
return (curv.GetType() == GeomAbs_Line);
}
break;
case StdSelect_Circle:
BRepAdaptor_Curve curv(TopoDS::Edge(sh));
return (curv.GetType() == GeomAbs_Circle);
}
return Standard_False ;
}
Standard_Boolean StdSelect_EdgeFilter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const
{return aStandardMode==TopAbs_EDGE;}

View File

@@ -0,0 +1,44 @@
-- File: StdSelect_FaceFilter.cdl
-- Created: Fri Mar 8 17:04:18 1996
-- Author: Robert COUBLANC
-- <rob@fidox>
---Copyright: Matra Datavision 1996
class FaceFilter from StdSelect inherits Filter from SelectMgr
---Purpose: A framework to define a filter to select a specific type of face.
-- The types available include:
-- - any face
-- - a planar face
-- - a cylindrical face
-- - a spherical face
-- - a toroidal face
-- - a revol face.
uses
TypeOfFace from StdSelect,
Shape from TopoDS,
EntityOwner from SelectMgr,
ShapeEnum from TopAbs
is
Create (aTypeOfFace: TypeOfFace from StdSelect)
returns mutable FaceFilter from StdSelect;
---Purpose: Constructs a face filter object defined by the type of face aTypeOfFace.
SetType(me:mutable;aNewType : TypeOfFace from StdSelect);
--- Purpose: Sets the type of face aNewType. aNewType is to be highlighted in selection.
Type(me) returns TypeOfFace from StdSelect;
--- Purpose: Returns the type of face to be highlighted in selection.
IsOk (me;anobj : EntityOwner from SelectMgr)
returns Boolean from Standard is redefined virtual;
ActsOn(me; aStandardMode : ShapeEnum from TopAbs)
returns Boolean from Standard is redefined virtual;
fields
mytype : TypeOfFace from StdSelect;
end FaceFilter;

View File

@@ -0,0 +1,112 @@
// File: StdSelect_FaceFilter.cxx
// Created: Fri Mar 8 17:16:47 1996
// Author: Robert COUBLANC
// <rob@fidox>
// Modifie par jmi le 21/9/96
// Utilisation des termes StdSelect_Sphere pour StdSelect_Cone
// StdSelect_Torus pour StdSelect_PlaneOrCone
// StdSelect_Revol pour StdSelect_CylinderOrCone
// en attendant la possibilite de modifier du CDL.
// mettre a jour alors Placement-menu.ccl de DsgFront
// et Part-placement.ccl de AssemblyScripts
#define BUC60576 //GG_5/10/99 Adds Cone to enum TypeOfFace
#include <StdSelect_FaceFilter.ixx>
#include <BRepAdaptor_Surface.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
#include <StdSelect_BRepOwner.hxx>
/*#include <.hxx>
#include <.hxx>
#include <.hxx>
#include <.hxx>
#include <.hxx>
#include <.hxx>
*/
StdSelect_FaceFilter::
StdSelect_FaceFilter(const StdSelect_TypeOfFace aTypeOfFace):
mytype(aTypeOfFace){}
void StdSelect_FaceFilter::
SetType(const StdSelect_TypeOfFace aTypeOfFace)
{mytype = aTypeOfFace;}
//==================================================
// Function:
// Purpose :
//==================================================
StdSelect_TypeOfFace StdSelect_FaceFilter::Type() const
{
return mytype;
}
Standard_Boolean StdSelect_FaceFilter::
IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull()) return Standard_False;
const TopoDS_Shape& anobj= ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
if(anobj.ShapeType()!= TopAbs_FACE)return Standard_False;
switch(mytype) {
case StdSelect_AnyFace:
return Standard_True;
case StdSelect_Plane:
{
BRepAdaptor_Surface surf(TopoDS::Face(anobj));
return (surf.GetType() == GeomAbs_Plane);
}
case StdSelect_Cylinder:
{
BRepAdaptor_Surface surf(TopoDS::Face(anobj));
return (surf.GetType() == GeomAbs_Cylinder);
}
case StdSelect_Sphere:
{
BRepAdaptor_Surface surf(TopoDS::Face(anobj));
#ifdef BUC60576
return (surf.GetType() == GeomAbs_Sphere);
#else
return (surf.GetType() == GeomAbs_Cone);
#endif
}
case StdSelect_Torus:
{
BRepAdaptor_Surface surf(TopoDS::Face(anobj));
#ifdef BUC60576
return ( surf.GetType() == GeomAbs_Torus);
#else
return ( surf.GetType() == GeomAbs_Plane || surf.GetType() == GeomAbs_Cone);
#endif
}
case StdSelect_Revol:
{
BRepAdaptor_Surface surf(TopoDS::Face(anobj));
return ( surf.GetType() == GeomAbs_Cylinder ||
surf.GetType() == GeomAbs_Cone ||
surf.GetType() == GeomAbs_Torus
#ifdef BUC60576
||
surf.GetType() == GeomAbs_Sphere ||
surf.GetType() == GeomAbs_SurfaceOfRevolution
#endif
);
}
#ifdef BUC60576
case StdSelect_Cone: // en attendant la liberation du cdl, on l'utilise pour Cone
{
BRepAdaptor_Surface surf(TopoDS::Face(anobj));
return (surf.GetType() == GeomAbs_Cone);
}
#endif
}
return Standard_False;
}
Standard_Boolean StdSelect_FaceFilter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const
{return aStandardMode==TopAbs_FACE;}

30
src/StdSelect/StdSelect_Prs.cdl Executable file
View File

@@ -0,0 +1,30 @@
-- File: StdSelect_Prs.cdl
-- Created: Fri Mar 17 13:42:13 1995
-- Author: Robert COUBLANC
-- <rob@photon>
---Copyright: Matra Datavision 1995
private class Prs from StdSelect inherits Presentation from Prs3d
---Purpose: allows entities owners to be hilighted
-- independantly from PresentableObjects
uses
StructureManager from Graphic3d
is
Create(aStructureManager: StructureManager from Graphic3d)
returns mutable Prs;
Manager(me) returns any StructureManager from Graphic3d;
---C++: inline
---C++: return const&
fields
myManager : StructureManager from Graphic3d;
end Prs;

15
src/StdSelect/StdSelect_Prs.cxx Executable file
View File

@@ -0,0 +1,15 @@
// Copyright: Matra-Datavision 1995
// File: StdSelect_Prs.cxx
// Created: Fri Mar 17 13:45:56 1995
// Author: Robert COUBLANC
// <rob>
#include <StdSelect_Prs.ixx>
StdSelect_Prs::
StdSelect_Prs(const Handle(Graphic3d_StructureManager)& aStructureManager):
Prs3d_Presentation(aStructureManager),
myManager(aStructureManager){}

View File

@@ -0,0 +1,2 @@
inline const Handle(Graphic3d_StructureManager)& StdSelect_Prs::
Manager() const {return myManager;}

View File

@@ -0,0 +1,81 @@
-- File: StdSelect_SensitiveText2d.cdl
-- Created: Fri Apr 21 10:53:42 1995x
-- Author: Robert COUBLANC
-- <rob@photon>
---Copyright: Matra Datavision 1995
class SensitiveText2d from StdSelect inherits SensitiveEntity from
Select2D
---Purpose: A framework to define a sensitive text entity for 2D views.
uses
ExtendedString from TCollection,
EntityOwner from SelectBasics,
ListOfBox2d from SelectBasics,
Projector from Select2D,
Array1OfPnt2d from TColgp,
Box2d from Bnd
is
Create(anOwnerId : EntityOwner from SelectBasics;
aString : ExtendedString from TCollection;
XPox,YPos : Real from Standard;
Angle : Real = 0;
aFontIndex: Integer = -1)
returns mutable SensitiveText2d from StdSelect;
---Purpose: Constructs a sensitive 2D text object defined by the
-- owner anOwnerId, the string aString, the point
-- defined by the parameters XPos and YPos, the angle
-- Angle and the font index aFontIndex.
NeedsConversion (me) returns Boolean is redefined static;
---Purpose: returns Standard_True
---Level: Public
---C++: inline
Convert(me:mutable; aTextProj : Projector from Select2D) is redefined virtual;
---Purpose: gets the size of the text in the 2d view
---Level: Public
Areas(me:mutable; aresult : in out ListOfBox2d from SelectBasics) is redefined static;
---Level: Public
---Purpose: to be implemented specifically by each type of
-- sensitive primitive .
--
Matches (me :mutable;
X,Y : Real from Standard;
aTol: Real from Standard;
DMin: out Real from Standard)
returns Boolean
is redefined static;
Matches (me :mutable;
XMin,YMin,XMax,YMax : Real from Standard;
aTol: Real from Standard)
returns Boolean
is redefined static;
Matches (me :mutable;
Polyline:Array1OfPnt2d from TColgp;
aBox:Box2d from Bnd;
aTol: Real from Standard)
returns Boolean
is redefined static;
fields
mytext : ExtendedString from TCollection;
myxpos : Real;
myypos : Real;
myangle: Real;
myfont : Integer;
myinitbox: Box2d from Bnd; --box before rotation...
end SensitiveText2d;

View File

@@ -0,0 +1,75 @@
// File: StdSelect_SensitiveText2d.cxx
// Created: Fri Apr 21 15:15:02 1995
// Author: Robert COUBLANC
// <rob@fidox>
#include <StdSelect_SensitiveText2d.ixx>
#include <StdSelect_TextProjector2d.hxx>
#include <gp_Pnt2d.hxx>
StdSelect_SensitiveText2d::
StdSelect_SensitiveText2d (const Handle(SelectBasics_EntityOwner)& anOwnerId,
const TCollection_ExtendedString& aString,
const Standard_Real XPos,
const Standard_Real YPos,
const Standard_Real Angle,
const Standard_Integer aFontIndex):
Select2D_SensitiveEntity(anOwnerId),
mytext(aString),
myxpos(XPos),
myypos(YPos),
myangle(Angle),
myfont(aFontIndex) {}
void StdSelect_SensitiveText2d::Convert(const Handle(Select2D_Projector)& aPrj)
{
if(!(Handle(StdSelect_TextProjector2d)::DownCast(aPrj)).IsNull())
{
gp_Pnt2d FirstP,LastP;
Handle(StdSelect_TextProjector2d)::DownCast(aPrj)
->Convert(mytext,myxpos,myypos,FirstP,LastP,myfont);
myinitbox.Set(FirstP);
myinitbox.Add(LastP);
}
}
void StdSelect_SensitiveText2d::Areas(SelectBasics_ListOfBox2d& aresult)
{
if(myangle==0.) aresult.Append(myinitbox);
else {
gp_Trsf2d T; T.SetRotation(gp_Pnt2d(myxpos,myypos),myangle);
aresult.Append(myinitbox.Transformed(T));
}
}
Standard_Boolean StdSelect_SensitiveText2d::Matches(const Standard_Real X,
const Standard_Real Y,
const Standard_Real aTol,
Standard_Real& DMin)
{
return Standard_True;
}
Standard_Boolean StdSelect_SensitiveText2d::Matches
(const Standard_Real XMin,
const Standard_Real YMin,
const Standard_Real XMax,
const Standard_Real YMax,
const Standard_Real aTol) {
return Standard_True;
}
Standard_Boolean StdSelect_SensitiveText2d::Matches
(const TColgp_Array1OfPnt2d& aPoly,
const Bnd_Box2d& aBox,
const Standard_Real aTol) {
return Standard_True;
}

View File

@@ -0,0 +1,12 @@
// File: StdSelect_SensitiveText2d.lxx
// Created: Fri Apr 21 15:45:25 1995
// Author: Robert COUBLANC
// <rob@fidox>
inline Standard_Boolean StdSelect_SensitiveText2d::NeedsConversion() const
{
return Standard_True;
}

View File

@@ -0,0 +1,63 @@
-- File: StdSelect_Shape.cdl
-- Created: Fri Mar 27 14:46:27 1998
-- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
private class Shape from StdSelect inherits PresentableObject from PrsMgr
---Purpose: Presentable shape only for purpose of display for BRepOwner...
uses
Projector from Prs3d,
Transformation from Geom,
PresentationManager2d from PrsMgr,
GraphicObject from Graphic2d,
Shape from TopoDS,
PresentationManager3d from PrsMgr,
Presentation from Prs3d
is
Create(Sh:Shape from TopoDS) returns mutable Shape from StdSelect;
Compute(me:mutable;
aPresentationManager: PresentationManager3d from PrsMgr;
aPresentation: mutable Presentation from Prs3d;
aMode: Integer from Standard = 0)
is redefined static;
Compute(me:mutable;
aProjector: Projector from Prs3d;
aPresentation: mutable Presentation from Prs3d)
is redefined static private;
Compute(me:mutable;
aPresentationManager: PresentationManager2d from PrsMgr;
aPresentation: mutable GraphicObject from Graphic2d;
aMode: Integer from Standard = 0)
is redefined static private;
Compute(me : mutable;
aProjector : Projector from Prs3d;
aTrsf : Transformation from Geom;
aPresentation : mutable Presentation from Prs3d)
is redefined;
---Purpose: computes the presentation according to a point of view
-- given by <aProjector>.
-- To be Used when the associated degenerated Presentations
-- have been transformed by <aTrsf> which is not a Pure
-- Translation. The HLR Prs can't be deducted automatically
-- WARNING :<aTrsf> must be applied
-- to the object to display before computation !!!
Shape(me) returns Shape from TopoDS;
---C++: inline
---C++: return const&
Shape(me:mutable;sh : Shape from TopoDS);
---C++: inline
fields
mysh : Shape from TopoDS;
end Shape;

View File

@@ -0,0 +1,70 @@
// File: StdSelect_Shape.cxx
// Created: Fri Mar 27 14:53:29 1998
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#include <StdSelect_Shape.ixx>
#include <StdPrs_WFShape.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Aspect_TypeOfMarker.hxx>
#include <Prs3d_PlaneAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <StdPrs_ShadedShape.hxx>
#include <TopAbs_ShapeEnum.hxx>
StdSelect_Shape::StdSelect_Shape(const TopoDS_Shape& sh):
mysh(sh)
{}
void StdSelect_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& PM,
const Handle(Prs3d_Presentation)& P,
const Standard_Integer aMode)
{
if(mysh.IsNull()) return;
static Handle(Prs3d_Drawer) DRWR;
if(DRWR.IsNull()){
DRWR = new Prs3d_Drawer();
DRWR->WireAspect()->SetWidth(2);
DRWR->LineAspect()->SetWidth(2.);
DRWR->PlaneAspect()->EdgesAspect()->SetWidth(2.);
DRWR->FreeBoundaryAspect()->SetWidth(2.);
DRWR->UnFreeBoundaryAspect()->SetWidth(2.);
Standard_Integer I = 5;//pour tests...
DRWR->PointAspect()->SetTypeOfMarker((Aspect_TypeOfMarker)I);
DRWR->PointAspect()->SetScale(2.);
}
Standard_Boolean CanShade = (mysh.ShapeType()<5 || mysh.ShapeType()==8);
if(aMode==1){
if(CanShade)
StdPrs_ShadedShape::Add(P,mysh,DRWR);
else
StdPrs_WFShape::Add(P,mysh,DRWR);
}
else if (aMode==0)
StdPrs_WFShape::Add(P,mysh,DRWR);
}
void StdSelect_Shape::Compute(const Handle_Prs3d_Projector& aProjector ,
const Handle_Geom_Transformation& aGeomTrans,
const Handle_Prs3d_Presentation& aPresentation )
{
PrsMgr_PresentableObject::Compute(aProjector,aGeomTrans,aPresentation);
}
void StdSelect_Shape::Compute(const Handle_PrsMgr_PresentationManager2d& aPrsMgr,
const Handle_Graphic2d_GraphicObject& aGO,
const int anInt)
{
PrsMgr_PresentableObject::Compute(aPrsMgr,aGO,anInt);
}
void StdSelect_Shape::Compute(const Handle_Prs3d_Projector& aProjector,
const Handle_Prs3d_Presentation& aPresentation)
{
PrsMgr_PresentableObject::Compute(aProjector,aPresentation);
}

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,46 @@
-- File: StdSelect_ShapeTypeFilter.cdl
-- Created: Tue Sep 17 10:02:44 1996
-- Author: Odile Olivier
-- <g_design@robox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class ShapeTypeFilter from StdSelect inherits Filter from SelectMgr
--- Purpose: A filter framework which allows you to define a filter
-- for a specific shape type. The types available include:
-- - compound
-- - compsolid
-- - solid
-- - shell
-- - face
-- - wire
-- - edge
-- - vertex.
uses
Shape from TopoDS,
EntityOwner from SelectMgr,
ShapeEnum from TopAbs
is
Create (aType: ShapeEnum from TopAbs)
returns mutable ShapeTypeFilter from StdSelect;
---Purpose: Constructs a filter object defined by the shape type aType.
IsOk (me;anobj : EntityOwner from SelectMgr)
returns Boolean from Standard is redefined virtual;
Type(me) returns ShapeEnum from TopAbs;
---Purpose: Returns the type of shape selected by the filter.
---C++: inline
ActsOn(me; aStandardMode : ShapeEnum from TopAbs)
returns Boolean from Standard is redefined virtual;
fields
myType : ShapeEnum from TopAbs;
end ShapeTypeFilter;

View File

@@ -0,0 +1,34 @@
//Copyright: Matra Datavision 1996
// File: StdSelect_ShapeTypeFilter.cxx
// Created: Tue Sep 17 10:02:44 1996
// Author: Odile Olivier
// <g_design@robox.paris1.matra-dtv.fr>
#include <StdSelect_ShapeTypeFilter.ixx>
#include <StdSelect_BRepOwner.hxx>
//==================================================
// Function: StdSelect_ShapeTypeFilter
// Purpose : Constructeur
//==================================================
StdSelect_ShapeTypeFilter::StdSelect_ShapeTypeFilter(const TopAbs_ShapeEnum aType):
myType(aType){}
//==================================================
// Function: IsOk
// Purpose : Renvoie True si la shape est du type defini a la construction
//==================================================
Standard_Boolean StdSelect_ShapeTypeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast( EO );
if( BRO.IsNull() || !BRO->HasShape() ) return Standard_False;
const TopoDS_Shape& anobj= BRO->Shape();
return anobj.ShapeType() == myType;
}
Standard_Boolean StdSelect_ShapeTypeFilter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const
{return aStandardMode==myType;}

View File

@@ -0,0 +1,7 @@
// File: StdSelect_ShapeTypeFilter.lxx
// Created: Thu Mar 6 14:07:18 1997
// Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
inline TopAbs_ShapeEnum StdSelect_ShapeTypeFilter::Type() const
{return myType;}

View File

@@ -0,0 +1,58 @@
-- File: StdSelect_TextProjector2d.cdl
-- Created: Fri Apr 21 16:54:14 1995
-- Author: Robert COUBLANC
-- <rob@fidox>
---Copyright: Matra Datavision 1995
class TextProjector2d from StdSelect inherits Projector from Select2D
---Purpose: A projector framework specific to texts in 2D views.
-- For a string of text, an insertion point and a font, it
-- calculates the minimum and maximum points of the text box in the view.
uses
View from V2d,
Trsf2d from gp,
Pnt2d from gp,
ExtendedString from TCollection
is
Create(aView: View from V2d) returns mutable TextProjector2d;
---Purpose: Constructs a 2D text projector framework defined by the 2D view aView.
Set(me:mutable; aView:View from V2d) is static;
---Purpose: Sets the view aView.
---C++: inline
Set(me:mutable;atrsf:Trsf2d from gp)is static;
---Purpose: Sets the transformation atrsf.
-- This transformation is applied to the attachment point
-- of the text, and takes the size and length of the text
-- into account to give the upper right hand point of the text box.
---C++: inline
Convert(me;aPointIn : Pnt2d from gp;
aPointOut : out Pnt2d from gp) is redefined virtual;
---Level: Public
---Purpose: applies the stored trsf to aPointIn to get aPointOut
Convert(me;aText: ExtendedString from TCollection;
XPos,YPos: Real;
MinPoint,MaxPoint: out Pnt2d from gp;
afont : Integer=-1) is virtual;
---Level: Public
---Purpose:XPos,YPos is the AttachPoint for the text.First, the stored Trsf is
-- applied to this point, then we get the size and length of text to
-- give the upper point
fields
myview : View from V2d; --to be replaced by a pointer...
end TextProjector2d;

View File

@@ -0,0 +1,57 @@
// File: StdSelect_TextProjector2d.cxx
// Created: Fri Apr 21 17:17:45 1995
// Author: Robert COUBLANC
// <rob@fidox>
#include <StdSelect_TextProjector2d.ixx>
#include <Aspect_WindowDriver.hxx>
//==================================================
// Function:
// Purpose :
//==================================================
StdSelect_TextProjector2d::
StdSelect_TextProjector2d(const Handle(V2d_View)& aView):
myview(aView)
{
}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_TextProjector2d::
Convert(const gp_Pnt2d& aPointIn, gp_Pnt2d& aPointOut) const
{
aPointOut = aPointIn.Transformed(mytrsf);
}
//==================================================
// Function:
// Purpose :
//==================================================
void StdSelect_TextProjector2d
::Convert(const TCollection_ExtendedString& aText,
const Standard_Real XPos,
const Standard_Real YPos,
gp_Pnt2d& MinPoint,
gp_Pnt2d& MaxPoint,
const Standard_Integer afont) const
{
Standard_ShortReal myL,myH;
MinPoint = gp_Pnt2d(XPos,YPos).Transformed(mytrsf);
myview->Driver()->TextSize(aText,myL,myH,afont);
Standard_Real myWinL=myview->Convert(myL);
Standard_Real myWinH=myview->Convert(myH);
MaxPoint.SetCoord(XPos+myWinL,YPos+myWinH);
MaxPoint.Transform(mytrsf);
}

View File

@@ -0,0 +1,16 @@
// Copyright: Matra-Datavision 1995
// File: StdSelect_TextProjector2d.lxx
// Created: Tue May 2 17:06:22 1995
// Author: Robert COUBLANC
// <rob>
inline void StdSelect_TextProjector2d::Set(const Handle(V2d_View)& aView)
{
myview = aView;
}
inline void StdSelect_TextProjector2d::Set(const gp_Trsf2d& atrsf)
{
mytrsf = atrsf;
}

View File

@@ -0,0 +1,78 @@
-- File: StdSelect_ViewerSelector2d.cdl
-- Created: Thu Feb 23 17:08:17 1995
-- Author: Mister rmi
-- <rmi@photon>
---Copyright: Matra Datavision 1995
class ViewerSelector2d from StdSelect inherits ViewerSelector from SelectMgr
---Purpose: A viewer selection framework.
-- The objects defined in this framework can be passed to a selection manager.
uses
View from V2d,
Projector from Select2D,
Selection from SelectMgr,
GraphicObject from Graphic2d
is
Create returns mutable ViewerSelector2d from StdSelect;
--- Purpose: Constructs an empty viewer selection framework.
Create (aProjector: Projector from Select2D)
returns mutable ViewerSelector2d from StdSelect;
---Purpose: Constructs the viewer selection framework defined by
-- the projector aProjector.
Set(me:mutable; aSensitivity : Integer) is static;
---Level: Public
---Purpose: Sets a pixel tolerance for the selection.
-- will be converted for picking in a view.
Set(me:mutable; aProjector: Projector from Select2D) is static;
---Purpose: Sets the new projector aProjector.
Convert(me:mutable;aSelection:mutable Selection from SelectMgr)
is redefined static;
Pick (me : mutable;XPix,YPix:Integer;
aView : View from V2d) is static;
---Purpose: Returns the pixel coordinates of the mouse Xpix, Ypix
-- in the view aView.
Pick (me:mutable;XPMin,YPMin,XPMax,YPMax:Integer;aView:View from V2d) is static;
---Purpose: Returns the minimum and maximum pixel coordinates
-- XPMin, YPMin and XPMax, YPMax defining a 2D area in the view aView.
Projector (me) returns any Projector from Select2D;
---Purpose: Returns the projector which defines this framework.
---C++: inline
DisplayAreas (me:mutable;aView:View from V2d) is static;
---Purpose: Displays the active areas in the given view;
ClearAreas(me:mutable) is static;
---Purpose: Clear the displayed sensitive areas from this framework..
fields
myprj : Projector from Select2D;
mypixtol : Integer;
mygo : GraphicObject from Graphic2d;
end ViewerSelector2d;

View File

@@ -0,0 +1,158 @@
// Copyright: Matra-Datavision 1995
// File: StdSelect_ViewerSelector2d.cxx
// Created: Thu Feb 23 17:10:14 1995
// Author: Mister rmi
// <rmi>
#include <StdSelect_ViewerSelector2d.ixx>
#include <Graphic2d_Array1OfVertex.hxx>
#include <Graphic2d_GraphicObject.hxx>
#include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
#include <Select2D_SensitiveEntity.hxx>
#include <StdSelect_TextProjector2d.hxx>
#include <SelectBasics_ListOfBox2d.hxx>
#include <Bnd_Box2d.hxx>
#include <Graphic2d_Vertex.hxx>
#include <Graphic2d_Polyline.hxx>
#include <Graphic2d_Array1OfVertex.hxx>
#include <SelectBasics_ListIteratorOfListOfBox2d.hxx>
//==================================================
// Function:
// Purpose :
//==================================================
StdSelect_ViewerSelector2d::StdSelect_ViewerSelector2d():
mypixtol(2)
{}
StdSelect_ViewerSelector2d::StdSelect_ViewerSelector2d(const Handle(Select2D_Projector)& aPrj):
myprj(aPrj),
mypixtol(2)
{}
//==================================================
// Function: Set
// Purpose :
//==================================================
void StdSelect_ViewerSelector2d::Set(const Standard_Integer apixtol)
{mypixtol = apixtol;
tosort = Standard_True;
}
//==================================================
// Function: Set
// Purpose :
//==================================================
void StdSelect_ViewerSelector2d::Set(const Handle(Select2D_Projector)& aPrj)
{myprj = aPrj;
UpdateConversion();
}
//==================================================
// Function: Convert
// Purpose :
//==================================================
void StdSelect_ViewerSelector2d::Convert(const Handle(SelectMgr_Selection)& aSel)
{
for(aSel->Init();aSel->More();aSel->Next())
{
if(aSel->Sensitive()->NeedsConversion())
Handle(Select2D_SensitiveEntity)::
DownCast(aSel->Sensitive())->Convert(myprj);
}
tosort = Standard_True;
}
void StdSelect_ViewerSelector2d::Pick(const Standard_Integer XPix,
const Standard_Integer YPix,
const Handle(V2d_View)& aViou)
{
Standard_Real Xr,Yr;
aViou->Convert(XPix,YPix,Xr,Yr);
InitSelect(Xr,Yr);
}
void StdSelect_ViewerSelector2d::Pick(const Standard_Integer XPMin,
const Standard_Integer YPMin,
const Standard_Integer XPMax,
const Standard_Integer YPMax,
const Handle(V2d_View)& aViou)
{
if(mypixtol!=0) mytolerance = aViou->Convert(mypixtol);
Standard_Real X1,Y1,X2,Y2;
aViou->Convert(XPMin,YPMin,X1,Y1);
aViou->Convert(XPMax,YPMax,X2,Y2);
InitSelect(Min(X1,X2),
Min(Y1,Y2),
Max(X1,X2),
Max(Y1,Y2));
}
//==================================================
// Function: DisplayAreas
// Purpose :
//==================================================
void StdSelect_ViewerSelector2d::
DisplayAreas(const Handle(V2d_View)& aViou)
{
mygo = new Graphic2d_GraphicObject(aViou->View());
Graphic2d_Array1OfVertex Av1 (1,5);
SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive It(myentities);
SelectBasics_ListOfBox2d BoxList;
Standard_Real xmin,ymin,xmax,ymax;
Handle(Graphic2d_Polyline) pol;
for(;It.More();It.Next())
{
It.Value()->Areas(BoxList);
// DEN
SelectBasics_ListIteratorOfListOfBox2d anIterator(BoxList);
for (;anIterator.More();anIterator.Next())
{
anIterator.Value().Get(xmin,ymin,xmax,ymax);
// FIN DEN
// BY DEN BoxList.Last().Get(xmin,ymin,xmax,ymax);
// construction des vertex graphiques
Av1.SetValue(1,Graphic2d_Vertex(xmin-mytolerance,ymin-mytolerance));
Av1.SetValue(2,Graphic2d_Vertex(xmax+mytolerance,ymin-mytolerance));
Av1.SetValue(3,Graphic2d_Vertex(xmax+mytolerance,ymax+mytolerance));
Av1.SetValue(4,Graphic2d_Vertex(xmin-mytolerance,ymax+mytolerance));
Av1.SetValue(5,Graphic2d_Vertex(xmin-mytolerance,ymin-mytolerance));
pol = new Graphic2d_Polyline(mygo,Av1);
pol ->SetColorIndex(4); //vert
pol->SetTypeIndex(2);
// DEN
}
// FIN DEN
}
mygo->Display();
aViou->Update();
}
//================================================
// function : ClearAreas
// purpose :
//================================================
void StdSelect_ViewerSelector2d::ClearAreas ()
{
if (mygo.IsNull()) return;
mygo->RemovePrimitives();
mygo->Display();
mygo->Remove();
}

View File

@@ -0,0 +1,3 @@
inline Handle(Select2D_Projector) StdSelect_ViewerSelector2d
::Projector () const
{return myprj;}

View File

@@ -0,0 +1,149 @@
-- File: StdSelect_ViewerSelector3d.cdl
-- Created: Wed Mar 15 10:17:24 1995
-- Author: Robert COUBLANC
-- <rob@photon>
-- Modified by rob jun 25 98 : Add Method : Reactivate projector...
---Copyright: Matra Datavision 1995
class ViewerSelector3d from StdSelect inherits ViewerSelector from SelectMgr
---Purpose: Selector Usable by Viewers from V3d
--
uses
View from V3d,
Selection from SelectMgr,
Projector from Select3D,
Group from Graphic3d,
Structure from Graphic3d,
Array1OfReal from TColStd,
Array1OfPnt2d from TColgp
is
Create returns mutable ViewerSelector3d from StdSelect;
---Purpose: Constructs an empty 3D selector object.
Create(aProj : Projector from Select3D) returns mutable ViewerSelector3d from StdSelect;
---Purpose: Constructs a 3D selector object defined by the projector aProj.
Convert(me:mutable;aSelection:mutable Selection from SelectMgr)
is redefined static;
---Level: Public
---Purpose: Processes the projection of the sensitive primitives
-- in the active view ; to be done before the selection action...
Set(me:mutable; aSensitivity : Integer) is static;
---Purpose: Sets the sensitivity aSensitivity.
Set(me:mutable; aProj: Projector from Select3D) is static;
---Purpose: Sets the new projector aProj to replace the one used at construction time.
Pick (me : mutable;XPix,YPix:Integer;
aView : View from V3d) is static;
---Level: Public
---Purpose: Picks the sensitive entity at the pixel coordinates of
-- the mouse Xpix and Ypix. The selector looks for touched areas and owners.
Pick (me:mutable;XPMin,YPMin,XPMax,YPMax:Integer;aView:View from V3d) is static;
---Purpose: Picks the sensitive entity according to the minimum
-- and maximum pixel values XPMin, YPMin, XPMax
-- and YPMax defining a 2D area for selection in the 3D view aView.
Pick (me:mutable;Polyline:Array1OfPnt2d from TColgp;aView:View from V3d) is static;
---Level: Public
---Purpose: pick action - input pixel values for polyline selection for selection.
---Category: Inquire Methods
Projector (me) returns Projector from Select3D;
---Level: Public
---Purpose: Returns the current Projector.
---C++: inline
---C++: return const&
---Category: Internal Methods
-- -----------------
ReactivateProjector(me:mutable);
---Level: Internal
---Purpose: Puts back the address of the current projector in sensitive primitives...
UpdateProj(me :mutable;
aView: View from V3d) returns Boolean is static private;
---Level: Internal
DisplayAreas(me :mutable;
aView: View from V3d) is static;
---Purpose: Displays sensitive areas found in the view aView.
ClearAreas (me :mutable;
aView: View from V3d) is static;
---Purpose: Clears the view aView of sensitive areas found in it.
DisplaySensitive(me:mutable;aView : View from V3d) is static;
--- Purpose: Displays the selection aSel found in the view aView.
ClearSensitive(me:mutable;aView:View from V3d) is static;
DisplaySensitive(me:mutable;
aSel : Selection from SelectMgr;
aView : View from V3d;
ClearOthers : Boolean from Standard = Standard_True)
is static;
DisplayAreas(me:mutable;
aSel :Selection from SelectMgr;
aView : View from V3d;
ClearOthers : Boolean from Standard = Standard_True)
is static;
ComputeSensitivePrs(me:mutable;aSel: Selection from SelectMgr)
is static private;
---Level: Internal
ComputeAreasPrs(me:mutable;aSel:Selection from SelectMgr)
is static private;
---Level: Internal
fields
myprj : Projector from Select3D;
mycoeff : Real from Standard[14];
myprevcoeff : Real from Standard[14];
mycenter : Real from Standard[2];
myprevcenter : Real from Standard[2];
mylastzoom : Real from Standard;
mypixtol : Integer ;
myupdatetol : Boolean;
--areas verification...
myareagroup : Group from Graphic3d;
mysensgroup : Group from Graphic3d;
mystruct: Structure from Graphic3d;
end ViewerSelector3d;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
inline const Select3D_Projector& StdSelect_ViewerSelector3d::
Projector() const {return myprj;}