Fix for Bug NPAL12883

This commit is contained in:
enk 2007-10-18 05:19:08 +00:00
parent faef7428c3
commit f20c2e1db2
20 changed files with 2153 additions and 385 deletions

View File

@ -327,7 +327,13 @@ void DisplayGUI::Erase()
listIO.Append( anIObject );
}
}
GEOM_Displayer(anActiveStudy).Erase( listIO, true );
SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow();
bool aIsForced = true;
if(viewWindow->getViewManager()->getType() == SVTK_Viewer::Type())
aIsForced = false;
GEOM_Displayer(anActiveStudy).Erase( listIO, aIsForced);
getGeometryGUI()->getApp()->selectionMgr()->clearSelected();
}

View File

@ -1125,7 +1125,7 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->insert( action( 8033 ), -1, -1 ); // transparency
mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, true );
mgr->insert( action( 8034 ), -1, -1 ); // isos
mgr->setRule( action( 8034 ), "client='OCCViewer' and selcount>0 and isVisible", true );
mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", true );
mgr->insert( separator(), -1, -1 ); // -----------
@ -1419,7 +1419,7 @@ bool GeometryGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QStr
}
else {
////// VTK viewer only
popup->removeItem( 8034 ); // "Isos"
//popup->removeItem( 8034 ); // "Isos"
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
if ( vtkPrs && !vtkPrs->IsNull() ) {
vtkActorCollection* actorList = vtkPrs->GetObjects();
@ -1542,7 +1542,7 @@ bool GeometryGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QStr
popup->removeItem( QAD_Display_Popup_ID );
if ( !needErase )
popup->removeItem( QAD_Erase_Popup_ID );
if ( !isOCCViewer )
if ( !isOCCViewer && !isVTKViewer)
popup->removeItem( 8034 ); // "Isos"
}
}
@ -1587,7 +1587,7 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
return;
const bool ViewOCC = ( win->getViewManager()->getType() == OCCViewer_Viewer::Type() );
// const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
const bool ViewVTK = ( win->getViewManager()->getType() == SVTK_Viewer::Type() );
// disable non-OCC viewframe menu commands
// action( 404 )->setEnabled( ViewOCC ); // SKETCHER
@ -1598,6 +1598,7 @@ void GeometryGUI::onWindowActivated( SUIT_ViewWindow* win )
action( 608 )->setEnabled( ViewOCC ); // AddPointOnEdge
// action( 609 )->setEnabled( ViewOCC ); // Free boundaries
action( 413 )->setEnabled( ViewOCC ); // Isos Settings
action( 413 )->setEnabled( ViewVTK ); // Isos Settings
action( 800 )->setEnabled( ViewOCC ); // Create Group
action( 801 )->setEnabled( ViewOCC ); // Edit Group
@ -1674,14 +1675,9 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
QString GeometryGUI::engineIOR() const
{
QString anIOR = QString::null;
if ( !CORBA::is_nil( GetGeomGen() ) )
{
CORBA::String_var objStr = getApp()->orb()->object_to_string( GetGeomGen() );
anIOR = QString( objStr.in() );
// free( objStr ); ASV : 26.07.06 : commented out because it raises exception and blocks application
}
return anIOR;
return QString( getApp()->orb()->object_to_string( GetGeomGen() ) );
return QString( "" );
}
LightApp_Selection* GeometryGUI::createSelection() const

View File

@ -245,7 +245,7 @@ void GEOMToolsGUI::OnColor()
return;
SVTK_View* aView = vtkVW->getView();
QColor initcolor = aView->GetColor( selected.First() );
QColor c = QColorDialog::getColor( QColor(), app->desktop() );
QColor c = QColorDialog::getColor( initcolor, app->desktop() );
if ( c.isValid() ) {
SUIT_OverrideCursor();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
@ -304,45 +304,107 @@ void GEOMToolsGUI::OnTransparency()
void GEOMToolsGUI::OnNbIsos()
{
SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
const bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
if ( !isOCC )
return;
// if is OCCViewer
if(isOCC){
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
ic->InitCurrent();
if ( ic->MoreCurrent() ) {
Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
int UIso = CurDrawer->UIsoAspect()->Number();
int VIso = CurDrawer->VIsoAspect()->Number();
GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
NbIsosDlg->setU( UIso );
NbIsosDlg->setV( VIso );
if ( NbIsosDlg->exec() ) {
SUIT_OverrideCursor();
for(; ic->MoreCurrent(); ic->NextCurrent()) {
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
int nbUIso = NbIsosDlg->getU();
int nbVIso = NbIsosDlg->getV();
CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) );
CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) );
ic->SetLocalAttributes(CurObject, CurDrawer);
ic->Redisplay(CurObject);
ic->InitCurrent();
if ( ic->MoreCurrent() ) {
Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
int UIso = CurDrawer->UIsoAspect()->Number();
int VIso = CurDrawer->VIsoAspect()->Number();
GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
NbIsosDlg->setU( UIso );
NbIsosDlg->setV( VIso );
if ( NbIsosDlg->exec() ) {
SUIT_OverrideCursor();
for(; ic->MoreCurrent(); ic->NextCurrent()) {
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
int nbUIso = NbIsosDlg->getU();
int nbVIso = NbIsosDlg->getV();
CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) );
CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) );
ic->SetLocalAttributes(CurObject, CurDrawer);
ic->Redisplay(CurObject);
}
}
}
}
} else if(isVTK){ // if is VTKViewer
//
// Warning. It's works incorrect. must be recheked.
//
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app )
return;
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( !aSelMgr )
return;
SALOME_ListIO selected;
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() )
return;
Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
if ( FirstIOS.IsNull() )
return;
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
if ( !vtkVW )
return;
SVTK_View* aView = vtkVW->getView();
vtkActorCollection* aCollection = aView->getRenderer()->GetActors();
int UIso = 0;
int VIso = 0;
if(aCollection){
aCollection->InitTraversal();
}
vtkActor *anAct = aCollection->GetNextActor();
if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
anActor->GetNbIsos(UIso,VIso);
}
GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
NbIsosDlg->setU( UIso );
NbIsosDlg->setV( VIso );
if ( NbIsosDlg->exec() ) {
SUIT_OverrideCursor();
while(anAct = aCollection->GetNextActor()) {
if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
// There are no casting to needed actor.
UIso = NbIsosDlg->getU();
VIso = NbIsosDlg->getV();
int aIsos[2]={UIso,VIso};
anActor->SetNbIsos(aIsos);
}
}
}
} // end vtkviewer
}
void GEOMToolsGUI::OnOpen()

File diff suppressed because it is too large Load Diff

View File

@ -32,58 +32,89 @@
#include "GEOM_OBJECT_defs.hxx"
#include "SALOME_Actor.h"
//OpenCASCADE
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include "GEOM_SmartPtr.h"
#include <vtkSmartPointer.h>
class GEOM_VertexSource;
typedef GEOM_SmartPtr<GEOM_VertexSource> PVertexSource;
class GEOM_EdgeSource;
typedef GEOM_SmartPtr<GEOM_EdgeSource> PEdgeSource;
class GEOM_WireframeFace;
typedef GEOM_SmartPtr<GEOM_WireframeFace> PWFaceSource;
class GEOM_ShadingFace;
typedef GEOM_SmartPtr<GEOM_ShadingFace> PSFaceSource;
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
class vtkRenderer;
class vtkAppendPolyData;
typedef GEOM_SmartPtr<vtkAppendPolyData> PAppendFilter;
class vtkCamera;
class TopoDS_Shape;
class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor
{
public:
vtkTypeMacro(GEOM_Actor,SALOME_Actor);
static GEOM_Actor* New();
void SetShape(const TopoDS_Shape& theShape,
float theDeflection,
bool theIsRelative);
void SetDeflection(float theDeflection, bool theIsRelative);
float GetDeflection() const{ return myDeflection;}
bool GetIsRelative() const{ return myIsRelative;}
void AddToRender(vtkRenderer* theRenderer);
void RemoveFromRender(vtkRenderer* theRenderer);
class GEOM_OBJECT_EXPORT GEOM_Actor : public SALOME_Actor {
public:
vtkTypeMacro(GEOM_Actor,SALOME_Actor);
enum EDisplayMode{ eWireframe, eShading};
/* void SetDisplayMode(EDisplayMode theMode); */
/* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */
void SetSelected(bool theIsSelected);
bool IsSelected() const { return myIsSelected;}
static GEOM_Actor* New();
// OLD METHODS
// Properties
void SetHighlightProperty(vtkProperty* Prop);
void SetWireframeProperty(vtkProperty* Prop);
void SetShadingProperty(vtkProperty* Prop);
void setDeflection(double adef);
virtual void setDisplayMode(int thenewmode);
// Description:
// This causes the actor to be rendered. It, in turn, will render the actor's
// property and then mapper.
virtual void Render(vtkRenderer *, vtkMapper *);
// Description:
// Release any graphics resources that are being consumed by this actor.
// The parameter window could be used to determine which graphic
// resources to release.
void ReleaseGraphicsResources(vtkWindow *);
const TopoDS_Shape& getTopo();
void setInputShape(const TopoDS_Shape& ashape, double adef1,
int imode, bool isVector = false);
double getDeflection();
void setDeflection(double adefl);
double isVector() { return myIsVector; }
double isVector();
// SubShape
void SubShapeOn();
void SubShapeOff();
// Display Mode
virtual void setDisplayMode(int);
// Highlight
virtual void highlight(bool theHighlight);
virtual bool hasHighlight() { return true; }
void ShallowCopy(vtkProp *prop);
// Properties
void SetHighlightProperty(vtkProperty* Prop);
void SetWireframeProperty(vtkProperty* Prop);
void SetShadingProperty(vtkProperty* Prop);
// Opacity
void SetOpacity(vtkFloatingPointType opa);
vtkFloatingPointType GetOpacity();
@ -92,37 +123,97 @@ class GEOM_OBJECT_EXPORT GEOM_Actor : public SALOME_Actor {
void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b);
void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b);
virtual bool IsInfinite() {return myIsInfinite;}
protected:
virtual bool IsInfinite();
GEOM_Actor();
~GEOM_Actor();
GEOM_Actor(const GEOM_Actor&) {};
void operator=(const GEOM_Actor&) {};
// overloaded functions
//! To map current selection to VTK representation
virtual
void
Highlight(bool theHighlight);
//----------------------------------------------------------------------------
//! To process prehighlight (called from #SVTK_InteractorStyle)
virtual
bool
PreHighlight(vtkInteractorStyle* theInteractorStyle,
SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight);
//! To process highlight (called from #SVTK_InteractorStyle)
virtual
bool
Highlight(vtkInteractorStyle* theInteractorStyle,
SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight);
//! Visibility management
virtual
void
SetVisibility( int );
//! IsoLines management
// theNb[0] - number of U lines
// theNb[1] - number of V lines
virtual
void
SetNbIsos(const int theNb[2]);
virtual
void
GetNbIsos(int &theNbU,int &theNbV);
protected:
void SetShape(const TopoDS_Shape& theShape,
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap);
void SetModified();
void CreateWireframeMapper();
void CreateShadingMapper();
void CreateMapper(int theMode);
void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
private:
bool subshape;
bool myIsInfinite;
GEOM_Actor();
~GEOM_Actor();
private:
TopoDS_Shape myShape;
double deflection;
bool myIsVector;
vtkMapper* ShadingMapper;
vtkMapper* WireframeMapper;
vtkProperty* ShadingProperty;
vtkProperty* WireframeProperty;
vtkProperty* HighlightProperty;
};
#endif //GEOM_ACTOR_H
int myNbIsos[2];
float myDeflection;
bool myIsRelative;
bool myIsForced;
// EDisplayMode myDisplayMode;
bool myIsSelected;
PDeviceActor myVertexActor;
PVertexSource myVertexSource;
PDeviceActor myIsolatedEdgeActor;
PEdgeSource myIsolatedEdgeSource;
PDeviceActor myOneFaceEdgeActor;
PEdgeSource myOneFaceEdgeSource;
PDeviceActor mySharedEdgeActor;
PEdgeSource mySharedEdgeSource;
PDeviceActor myWireframeFaceActor;
PWFaceSource myWireframeFaceSource;
PDeviceActor myShadingFaceActor;
PSFaceSource myShadingFaceSource;
PDeviceActor myHighlightActor;
vtkSmartPointer<vtkProperty> myHighlightProp;
vtkSmartPointer<vtkProperty> myPreHighlightProp;
vtkSmartPointer<vtkProperty> myShadingFaceProp;
PAppendFilter myAppendFilter;
PPolyDataMapper myPolyDataMapper;
virtual void SetMapper(vtkMapper*);
GEOM_Actor(const GEOM_Actor&);
void operator=(const GEOM_Actor&);
};
#endif //GEOM_ACTOR_H

View File

@ -70,7 +70,7 @@ void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp,
vtkProperty* VertexProp,
vtkProperty* IsoPVProp,
vtkProperty* EdgePVProp,
vtkProperty* VertexPVProp)
vtkProperty* VertexPVProp)
{
// Shading like default OCC material
FaceProp->SetRepresentationToSurface();
@ -191,8 +191,28 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap
Standard_Boolean forced,
Standard_Boolean isVector)
{
vtkActorCollection* AISActors = vtkActorCollection::New();
/*
vtkProperty* IsoProp = vtkProperty::New();
vtkProperty* FaceProp = vtkProperty::New();
vtkProperty* EdgeFProp = vtkProperty::New();
vtkProperty* EdgeSProp = vtkProperty::New();
vtkProperty* EdgeIProp = vtkProperty::New();
vtkProperty* VertexProp = vtkProperty::New();
vtkProperty* IsoPVProp = vtkProperty::New();
vtkProperty* EdgePVProp = vtkProperty::New();
vtkProperty* VertexPVProp = vtkProperty::New();
InitProperties(IsoProp,FaceProp,EdgeFProp,EdgeSProp,EdgeIProp,VertexProp,IsoPVProp,EdgePVProp,VertexPVProp);
*/
vtkActorCollection* AISActors = vtkActorCollection::New();
MeshShape(myShape,deflection,forced);
GEOM_Actor* aGeomActor = GEOM_Actor::New();
aGeomActor->SetShape(myShape,(float)deflection,false);
AISActors->AddItem(aGeomActor);
aGeomActor->Delete();
/*
if(myShape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator anItr(myShape);
for(; anItr.More(); anItr.Next()) {
@ -320,6 +340,8 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap
AISActors->AddItem(VertexActor);
}
*/
return AISActors;
@ -338,8 +360,7 @@ vtkAssembly* GEOM_AssemblyBuilder::BuildAssembly(const TopoDS_Shape& myShape,
// Create a new vtkAssembly
vtkAssembly* myVTKShape = vtkAssembly::New();
/*
// Create graphics properties
vtkProperty* IsoProp = vtkProperty::New();
@ -418,6 +439,8 @@ vtkAssembly* GEOM_AssemblyBuilder::BuildAssembly(const TopoDS_Shape& myShape,
}
myVTKShape->AddPart(myFaceAssembly);
}
*/
return myVTKShape;

83
src/OBJECT/GEOM_DeviceActor.cxx Executable file
View File

@ -0,0 +1,83 @@
#include "GEOM_DeviceActor.h"
#include <vtkObjectFactory.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkStripper.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolyDataNormals.h>
#include <vtkActor.h>
#include <vtkRenderer.h>
vtkStandardNewMacro(GEOM_DeviceActor);
GEOM_DeviceActor::GEOM_DeviceActor():
myStripper(vtkStripper::New(),true),
myPolyDataMapper(vtkPolyDataMapper::New(),true),
myPolyDataNormals(vtkPolyDataNormals::New(),true),
myActor(vtkActor::New(),true)
{
myStripper->SetInput(myPolyDataNormals->GetOutput());
myPolyDataMapper->SetInput(myStripper->GetOutput());
myActor->SetMapper(myPolyDataMapper.Get());
myActor->PickableOff();
}
GEOM_DeviceActor::~GEOM_DeviceActor()
{
}
void
GEOM_DeviceActor::
SetInput(vtkPolyData* thePolyData, bool theUseStripper)
{
if(theUseStripper)
myPolyDataNormals->SetInput(thePolyData);
else
myPolyDataMapper->SetInput(thePolyData);
}
void
GEOM_DeviceActor::
SetProperty(vtkProperty* theProperty)
{
myActor->SetProperty(theProperty);
}
vtkProperty*
GEOM_DeviceActor::
GetProperty()
{
return myActor->GetProperty();
}
void
GEOM_DeviceActor::
SetVisibility(int theVisibility)
{
myActor->SetVisibility(theVisibility);
}
int
GEOM_DeviceActor::
GetVisibility()
{
return myActor->GetVisibility();
}
void
GEOM_DeviceActor::
AddToRender(vtkRenderer* theRenderer)
{
theRenderer->AddActor(myActor.GetPointer());
}
void
GEOM_DeviceActor::
RemoveFromRender(vtkRenderer* theRenderer)
{
theRenderer->RemoveActor(myActor.GetPointer());
}

60
src/OBJECT/GEOM_DeviceActor.h Executable file
View File

@ -0,0 +1,60 @@
#ifndef GEOM_DEVICEACTOR_H
#define GEOM_DEVICEACTOR_H
#include "GEOM_SmartPtr.h"
class vtkPoints;
typedef GEOM_SmartPtr<vtkPoints> PPoints;
class vtkPolyData;
typedef GEOM_SmartPtr<vtkPolyData> PPolyData;
class vtkStripper;
typedef GEOM_SmartPtr<vtkStripper> PStripper;
class vtkPolyDataNormals;
typedef GEOM_SmartPtr<vtkPolyDataNormals> PPolyDataNormals;
class vtkActor;
typedef GEOM_SmartPtr<vtkActor> PActor;
class vtkProperty;
class vtkRenderer;
#include <vtkObject.h>
class VTK_EXPORT GEOM_DeviceActor: public vtkObject
{
public:
vtkTypeMacro(GEOM_DeviceActor,vtkObject);
static GEOM_DeviceActor* New();
void SetProperty(vtkProperty* theProperty);
vtkProperty* GetProperty();
void SetVisibility(int theVisibility);
int GetVisibility();
void SetInput(vtkPolyData* thePolyData, bool theUseStripper);
void AddToRender(vtkRenderer* theRenderer);
void RemoveFromRender(vtkRenderer* theRenderer);
protected:
PPolyDataNormals myPolyDataNormals;
PPolyDataMapper myPolyDataMapper;
PStripper myStripper;
PActor myActor;
GEOM_DeviceActor();
~GEOM_DeviceActor();
private:
// Not implememnted
GEOM_DeviceActor(const GEOM_DeviceActor&);
void operator=(const GEOM_DeviceActor&);
};
#endif //GEOM_DEVICEACTOR_H

130
src/OBJECT/GEOM_EdgeSource.cxx Executable file
View File

@ -0,0 +1,130 @@
#include "GEOM_EdgeSource.h"
#include <vtkObjectFactory.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <BRep_Tool.hxx>
#include <Poly_Polygon3D.hxx>
#include <Poly_Triangulation.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <vtkStripper.h>
#include <vtkPolyData.h>
vtkStandardNewMacro(GEOM_EdgeSource);
GEOM_EdgeSource::GEOM_EdgeSource()
{
}
GEOM_EdgeSource::~GEOM_EdgeSource()
{
}
void
GEOM_EdgeSource::
AddEdge(const TopoDS_Edge& theEdge)
{
myEdgeSet.Add(theEdge);
}
void
GEOM_EdgeSource::
Execute()
{
vtkPolyData* aPolyData = GetOutput();
aPolyData->Allocate();
vtkPoints* aPts = vtkPoints::New();
aPolyData->SetPoints(aPts);
aPts->Delete();
TEdgeSet::Iterator anIter(myEdgeSet);
for(; anIter.More(); anIter.Next()){
const TopoDS_Edge& anEdge = anIter.Value();
OCC2VTK(anEdge,aPolyData,aPts);
}
}
void
GEOM_EdgeSource::
OCC2VTK(const TopoDS_Edge& theEdge,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
Handle(Poly_PolygonOnTriangulation) aEdgePoly;
Standard_Integer i = 1;
Handle(Poly_Triangulation) T;
TopLoc_Location aEdgeLoc;
BRep_Tool::PolygonOnTriangulation(theEdge, aEdgePoly, T, aEdgeLoc, i);
Handle(Poly_Polygon3D) P;
if(aEdgePoly.IsNull())
P = BRep_Tool::Polygon3D(theEdge, aEdgeLoc);
if(P.IsNull() && aEdgePoly.IsNull())
return;
// Location edges
//---------------
gp_Trsf edgeTransf;
Standard_Boolean isidtrsf = true;
if(!aEdgeLoc.IsIdentity()) {
isidtrsf = false;
edgeTransf = aEdgeLoc.Transformation();
}
if (aEdgePoly.IsNull()) {
Standard_Integer aNbNodes = P->NbNodes();
const TColgp_Array1OfPnt& aNodesP = P->Nodes();
for(int j = 1; j < aNbNodes; j++){
gp_Pnt pt1 = aNodesP(j);
gp_Pnt pt2 = aNodesP(j+1);
if(!isidtrsf) {
// apply edge transformation
pt1.Transform(edgeTransf);
pt2.Transform(edgeTransf);
}
float aCoord1[3] = {pt1.X(), pt1.Y(), pt1.Z()};
vtkIdType anIds[2];
anIds[0] = thePts->InsertNextPoint(aCoord1);
float aCoord2[3] = {pt2.X(), pt2.Y(), pt2.Z()};
anIds[1] = thePts->InsertNextPoint(aCoord2);
thePolyData->InsertNextCell(VTK_LINE,2,anIds);
}
} else {
Standard_Integer aNbNodes = aEdgePoly->NbNodes();
const TColStd_Array1OfInteger& aNodeIds = aEdgePoly->Nodes();
const TColgp_Array1OfPnt& anId2Pnts = T->Nodes();
for(int j = 1; j < aNbNodes; j++) {
Standard_Integer id1 = aNodeIds(j);
Standard_Integer id2 = aNodeIds(j+1);
gp_Pnt pt1 = anId2Pnts(id1);
gp_Pnt pt2 = anId2Pnts(id2);
if(!isidtrsf) {
// apply edge transformation
pt1.Transform(edgeTransf);
pt2.Transform(edgeTransf);
}
float aCoord1[3] = {pt1.X(), pt1.Y(), pt1.Z()};
vtkIdType anIds[2];
anIds[0] = thePts->InsertNextPoint(aCoord1);
float aCoord2[3] = {pt2.X(), pt2.Y(), pt2.Z()};
anIds[1] = thePts->InsertNextPoint(aCoord2);
thePolyData->InsertNextCell(VTK_LINE,2,anIds);
}
}
}

43
src/OBJECT/GEOM_EdgeSource.h Executable file
View File

@ -0,0 +1,43 @@
#ifndef GEOM_EDGESOURCE_H
#define GEOM_EDGESOURCE_H
#include "GEOM_DeviceActor.h"
#include <TopoDS_Edge.hxx>
#include <NCollection_Set.hxx>
typedef NCollection_Set<TopoDS_Edge> TEdgeSet;
#include <vtkPolyDataSource.h>
class VTK_EXPORT GEOM_EdgeSource: public vtkPolyDataSource
{
public:
vtkTypeMacro(GEOM_EdgeSource,vtkPolyDataSource);
static GEOM_EdgeSource* New();
void AddEdge(const TopoDS_Edge& theEdge);
void Clear(){ myEdgeSet.Clear();}
static
void OCC2VTK(const TopoDS_Edge& theEdge,
vtkPolyData* thePolyData,
vtkPoints* thePts);
protected:
TEdgeSet myEdgeSet;
void Execute();
GEOM_EdgeSource();
~GEOM_EdgeSource();
private:
// Not implememnted
GEOM_EdgeSource(const GEOM_EdgeSource&);
void operator=(const GEOM_EdgeSource&);
};
#endif //GEOM_EDGESOURCE_H

44
src/OBJECT/GEOM_FaceSource.cxx Executable file
View File

@ -0,0 +1,44 @@
#include "GEOM_FaceSource.h"
#include <vtkObjectFactory.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolyData.h>
GEOM_FaceSource::GEOM_FaceSource()
{
}
GEOM_FaceSource::~GEOM_FaceSource()
{
}
void
GEOM_FaceSource::
AddFace(const TopoDS_Face& theFace)
{
myFaceSet.Add(theFace);
}
void
GEOM_FaceSource::
MoveTo(gp_Pnt thePnt,
vtkPoints* thePts)
{
thePts->InsertNextPoint(thePnt.X(), thePnt.Y(), thePnt.Z());
}
void
GEOM_FaceSource::
DrawTo(gp_Pnt thePnt,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
vtkIdType anId =
thePts->InsertNextPoint(thePnt.X(), thePnt.Y(), thePnt.Z());
vtkIdType anIds[2] = {anId-1, anId};
thePolyData->InsertNextCell(VTK_LINE,2,anIds);
}

47
src/OBJECT/GEOM_FaceSource.h Executable file
View File

@ -0,0 +1,47 @@
#ifndef GEOM_FACESOURCE_H
#define GEOM_FACESOURCE_H
#include "GEOM_DeviceActor.h"
#include <gp_Pnt.hxx>
#include <TopoDS_Face.hxx>
#include <NCollection_Set.hxx>
typedef NCollection_Set<TopoDS_Face> TFaceSet;
#include <vtkPolyDataSource.h>
class GEOM_FaceSource;
typedef GEOM_SmartPtr<GEOM_FaceSource> PFaceSource;
class VTK_EXPORT GEOM_FaceSource: public vtkPolyDataSource
{
public:
vtkTypeMacro(GEOM_FaceSource,vtkPolyDataSource);
void AddFace(const TopoDS_Face& theFace);
void Clear(){ myFaceSet.Clear();}
protected:
TFaceSet myFaceSet;
static
void MoveTo(gp_Pnt thePnt,
vtkPoints* thePts);
static
void DrawTo(gp_Pnt thePnt,
vtkPolyData* thePolyData,
vtkPoints* thePts);
GEOM_FaceSource();
~GEOM_FaceSource();
private:
// Not implememnted
GEOM_FaceSource(const GEOM_FaceSource&);
void operator=(const GEOM_FaceSource&);
};
#endif //GEOM_FACESOURCE_H

84
src/OBJECT/GEOM_ShadingFace.cxx Executable file
View File

@ -0,0 +1,84 @@
#include "GEOM_ShadingFace.h"
#include <vtkObjectFactory.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolyData.h>
#include <BRep_Tool.hxx>
#include <Poly_Triangulation.hxx>
vtkStandardNewMacro(GEOM_ShadingFace);
GEOM_ShadingFace::GEOM_ShadingFace()
{
}
GEOM_ShadingFace::~GEOM_ShadingFace()
{
}
void
GEOM_ShadingFace::
Execute()
{
vtkPolyData* aPolyData = GetOutput();
aPolyData->Allocate();
vtkPoints* aPts = vtkPoints::New();
aPolyData->SetPoints(aPts);
aPts->Delete();
TFaceSet::Iterator anIter(myFaceSet);
for(; anIter.More(); anIter.Next()){
const TopoDS_Face& aFace = anIter.Value();
OCC2VTK(aFace,aPolyData,aPts);
}
}
void
GEOM_ShadingFace::
OCC2VTK(const TopoDS_Face& theFace,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(theFace,aLoc);
if(aPoly.IsNull())
return;
else{
gp_Trsf myTransf;
Standard_Boolean identity = true;
if(!aLoc.IsIdentity()){
identity = false;
myTransf = aLoc.Transformation();
}
Standard_Integer i;
int aNbOfNodes = thePts->GetNumberOfPoints();
const TColgp_Array1OfPnt& Nodes = aPoly->Nodes();
Standard_Integer nbNodesInFace = aPoly->NbNodes();
for(i = 1; i <= nbNodesInFace; i++) {
gp_Pnt P = Nodes(i);
if(!identity)
P.Transform(myTransf);
thePts->InsertNextPoint(P.X(),P.Y(),P.Z());
}
const Poly_Array1OfTriangle& Triangles = aPoly->Triangles();
Standard_Integer nbTriInFace = aPoly->NbTriangles();
for(i = 1; i <= nbTriInFace; i++){
// Get the triangle
Standard_Integer N1,N2,N3;
Triangles(i).Get(N1,N2,N3);
N1 += aNbOfNodes - 1;
N2 += aNbOfNodes - 1;
N3 += aNbOfNodes - 1;
vtkIdType anIds[3] = {N1, N2, N3};
thePolyData->InsertNextCell(VTK_TRIANGLE,3,anIds);
}
}
}

31
src/OBJECT/GEOM_ShadingFace.h Executable file
View File

@ -0,0 +1,31 @@
#ifndef GEOM_SHADINGFACE_H
#define GEOM_SHADINGFACE_H
#include "GEOM_FaceSource.h"
class VTK_EXPORT GEOM_ShadingFace: public GEOM_FaceSource
{
public:
vtkTypeMacro(GEOM_ShadingFace,GEOM_FaceSource);
static GEOM_ShadingFace* New();
static
void OCC2VTK(const TopoDS_Face& theFace,
vtkPolyData* theCells,
vtkPoints* thePts);
protected:
void Execute();
GEOM_ShadingFace();
~GEOM_ShadingFace();
private:
// Not implememnted
GEOM_ShadingFace(const GEOM_ShadingFace&);
void operator=(const GEOM_ShadingFace&);
};
#endif //GEOM_SHADINGFACE_H

33
src/OBJECT/GEOM_SmartPtr.h Executable file
View File

@ -0,0 +1,33 @@
#ifndef GEOM_SMARTPTR_H
#define GEOM_SMARTPTR_H
#include <vtkSmartPointer.h>
template <class T>
class GEOM_SmartPtr: public vtkSmartPointer<T>
{
public:
GEOM_SmartPtr() {}
GEOM_SmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) {
if(r && theIsOwner)
r->Delete();
}
GEOM_SmartPtr& operator()(T* r, bool theIsOwner = false){
vtkSmartPointer<T>::operator=(r);
if(r && theIsOwner)
r->Delete();
return *this;
}
GEOM_SmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
T* Get() const { return this->GetPointer();}
};
class GEOM_DeviceActor;
typedef GEOM_SmartPtr<GEOM_DeviceActor> PDeviceActor;
class vtkPolyDataMapper;
typedef GEOM_SmartPtr<vtkPolyDataMapper> PPolyDataMapper;
#endif //GEOM_SMARTPTR_H

View File

@ -0,0 +1,56 @@
#include "GEOM_VertexSource.h"
#include <vtkObjectFactory.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx>
vtkStandardNewMacro(GEOM_VertexSource);
GEOM_VertexSource::GEOM_VertexSource()
{
}
GEOM_VertexSource::~GEOM_VertexSource()
{
}
void
GEOM_VertexSource::
AddVertex(const TopoDS_Vertex& theVertex)
{
myVertexSet.Add(theVertex);
}
void
GEOM_VertexSource::
Execute()
{
vtkPolyData* aPolyData = GetOutput();
aPolyData->Allocate();
vtkPoints* aPts = vtkPoints::New();
aPolyData->SetPoints(aPts);
aPts->Delete();
TVertexSet::Iterator anIter(myVertexSet);
for(; anIter.More(); anIter.Next()){
const TopoDS_Vertex& aVertex = anIter.Value();
OCC2VTK(aVertex,aPolyData,aPts);
}
}
void
GEOM_VertexSource::
OCC2VTK(const TopoDS_Vertex& theVertex,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
gp_Pnt aPnt = BRep_Tool::Pnt(theVertex);
vtkIdType anId = thePts->InsertNextPoint(aPnt.X(),aPnt.Y(),aPnt.Z());
thePolyData->InsertNextCell(VTK_VERTEX,1,&anId);
}

43
src/OBJECT/GEOM_VertexSource.h Executable file
View File

@ -0,0 +1,43 @@
#ifndef GEOM_VERTEXSOURCE_H
#define GEOM_VERTEXSOURCE_H
#include "GEOM_DeviceActor.h"
#include <TopoDS_Vertex.hxx>
#include <NCollection_Set.hxx>
typedef NCollection_Set<TopoDS_Vertex> TVertexSet;
#include <vtkPolyDataSource.h>
class VTK_EXPORT GEOM_VertexSource: public vtkPolyDataSource
{
public:
vtkTypeMacro(GEOM_VertexSource,vtkPolyDataSource);
static GEOM_VertexSource* New();
void AddVertex(const TopoDS_Vertex& theVertex);
void Clear(){ myVertexSet.Clear();}
static
void OCC2VTK(const TopoDS_Vertex& theVertex,
vtkPolyData* thePolyData,
vtkPoints* thePts);
protected:
TVertexSet myVertexSet;
void Execute();
GEOM_VertexSource();
~GEOM_VertexSource();
private:
// Not implememnted
GEOM_VertexSource(const GEOM_VertexSource&);
void operator=(const GEOM_VertexSource&);
};
#endif //GEOM_VERTEXSOURCE_H

466
src/OBJECT/GEOM_WireframeFace.cxx Executable file
View File

@ -0,0 +1,466 @@
#include "GEOM_WireframeFace.h"
#include <vtkObjectFactory.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkPolyDataMapper.h>
#include <vtkPolyData.h>
#include <Precision.hxx>
#include <BRepTools.hxx>
#include <TopExp_Explorer.hxx>
#include <Geom2dHatch_Hatcher.hxx>
#include <Geom2dHatch_Intersector.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <BRep_Tool.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Line.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Pnt2d.hxx>
#include <Geom2dHatch_Hatcher.hxx>
#include <HatchGen_Domain.hxx>
#include <Adaptor3d_HCurve.hxx>
vtkStandardNewMacro(GEOM_WireframeFace);
GEOM_WireframeFace::GEOM_WireframeFace():
NbIso(1),
Discret(15)
{
}
GEOM_WireframeFace::~GEOM_WireframeFace()
{
}
void
GEOM_WireframeFace::
Execute()
{
vtkPolyData* aPolyData = GetOutput();
aPolyData->Allocate();
vtkPoints* aPts = vtkPoints::New();
aPolyData->SetPoints(aPts);
aPts->Delete();
TFaceSet::Iterator anIter(myFaceSet);
for(; anIter.More(); anIter.Next()){
const TopoDS_Face& aFace = anIter.Value();
OCC2VTK(aFace,aPolyData,aPts,NbIso,Discret);
}
}
void
GEOM_WireframeFace::
OCC2VTK(const TopoDS_Face& theFace,
vtkPolyData* thePolyData,
vtkPoints* thePts,
const int theNbIso,
const int theDiscret)
{
TopoDS_Face aFace = theFace;
aFace.Orientation(TopAbs_FORWARD);
CreateIso(aFace,theNbIso,theDiscret,thePolyData,thePts);
}
void
GEOM_WireframeFace::
CreateIso(const TopoDS_Face& theFace,
const int theNbIso,
const int theDiscret,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
// Constants for iso building
static Standard_Real INTERSECTOR_CONFUSION = 1.e-10 ; // -8 ;
static Standard_Real INTERSECTOR_TANGENCY = 1.e-10 ; // -8 ;
static Standard_Real HATHCER_CONFUSION_2D = 1.e-8 ;
static Standard_Real HATHCER_CONFUSION_3D = 1.e-8 ;
Geom2dHatch_Hatcher
aHatcher(Geom2dHatch_Intersector(INTERSECTOR_CONFUSION,
INTERSECTOR_TANGENCY),
HATHCER_CONFUSION_2D,
HATHCER_CONFUSION_3D,
Standard_True,
Standard_False);
Standard_Real anUMin, anUMax, aVMin, aVMax;
TColStd_Array1OfReal anUPrm(1, theNbIso), aVPrm(1, theNbIso);
TColStd_Array1OfInteger anUInd(1, theNbIso), aVInd(1, theNbIso);
anUInd.Init(0);
aVInd.Init(0);
//-----------------------------------------------------------------------
// If the Min Max bounds are infinite, there are bounded to Infinite
// value.
//-----------------------------------------------------------------------
BRepTools::UVBounds(theFace, anUMin, anUMax, aVMin, aVMax) ;
Standard_Boolean InfiniteUMin = Precision::IsNegativeInfinite (anUMin) ;
Standard_Boolean InfiniteUMax = Precision::IsPositiveInfinite (anUMax) ;
Standard_Boolean InfiniteVMin = Precision::IsNegativeInfinite (aVMin) ;
Standard_Boolean InfiniteVMax = Precision::IsPositiveInfinite (aVMax) ;
static float VTKINFINITE = 1.0E38;
if(InfiniteUMin && InfiniteUMax){
anUMin = - VTKINFINITE ;
anUMax = VTKINFINITE ;
}else if(InfiniteUMin){
anUMin = anUMax - VTKINFINITE ;
}else if(InfiniteUMax){
anUMax = anUMin + VTKINFINITE ;
}
if(InfiniteVMin && InfiniteVMax){
aVMin = - VTKINFINITE ;
aVMax = VTKINFINITE ;
}else if(InfiniteVMin){
aVMin = aVMax - VTKINFINITE ;
}else if(InfiniteVMax){
aVMax = aVMin + VTKINFINITE ;
}
//-----------------------------------------------------------------------
// Retreiving the edges and loading them into the hatcher.
//-----------------------------------------------------------------------
TopExp_Explorer ExpEdges(theFace, TopAbs_EDGE);
for(; ExpEdges.More(); ExpEdges.Next()){
const TopoDS_Edge& anEdge = TopoDS::Edge(ExpEdges.Current());
Standard_Real U1, U2 ;
const Handle(Geom2d_Curve) PCurve =
BRep_Tool::CurveOnSurface(anEdge, theFace, U1, U2) ;
if(PCurve.IsNull() || U1 == U2)
return;
//-- Test if a TrimmedCurve is necessary
if(Abs(PCurve->FirstParameter()-U1) <= Precision::PConfusion() &&
Abs(PCurve->LastParameter()-U2) <= Precision::PConfusion())
{
aHatcher.AddElement(PCurve, anEdge.Orientation()) ;
}else{
if(!PCurve->IsPeriodic()){
Handle(Geom2d_TrimmedCurve) TrimPCurve =
Handle(Geom2d_TrimmedCurve)::DownCast(PCurve);
if(!TrimPCurve.IsNull()){
Handle_Geom2d_Curve aBasisCurve = TrimPCurve->BasisCurve();
if(aBasisCurve->FirstParameter()-U1 > Precision::PConfusion() ||
U2-aBasisCurve->LastParameter() > Precision::PConfusion())
{
aHatcher.AddElement(PCurve, anEdge.Orientation()) ;
return;
}
}else{
if(PCurve->FirstParameter()-U1 > Precision::PConfusion()){
U1=PCurve->FirstParameter();
}
if(U2-PCurve->LastParameter() > Precision::PConfusion()){
U2=PCurve->LastParameter();
}
}
}
Handle(Geom2d_TrimmedCurve) TrimPCurve =
new Geom2d_TrimmedCurve(PCurve, U1, U2);
aHatcher.AddElement(TrimPCurve, anEdge.Orientation());
}
}
//-----------------------------------------------------------------------
// Loading and trimming the hatchings.
//-----------------------------------------------------------------------
Standard_Integer IIso;
Standard_Real DeltaU = Abs(anUMax - anUMin) ;
Standard_Real DeltaV = Abs(aVMax - aVMin) ;
Standard_Real confusion = Min(DeltaU, DeltaV) * HATHCER_CONFUSION_3D ;
aHatcher.Confusion3d (confusion) ;
Standard_Real StepU = DeltaU / (Standard_Real)theNbIso;
if(StepU > confusion){
Standard_Real UPrm = anUMin + StepU / 2.;
gp_Dir2d Dir(0., 1.) ;
for(IIso = 1 ; IIso <= theNbIso ; IIso++) {
anUPrm(IIso) = UPrm ;
gp_Pnt2d Ori (UPrm, 0.) ;
Geom2dAdaptor_Curve HCur (new Geom2d_Line (Ori, Dir)) ;
anUInd(IIso) = aHatcher.AddHatching (HCur) ;
UPrm += StepU ;
}
}
Standard_Real StepV = DeltaV / (Standard_Real) theNbIso ;
if(StepV > confusion){
Standard_Real VPrm = aVMin + StepV / 2.;
gp_Dir2d Dir(1., 0.);
for(IIso = 1 ; IIso <= theNbIso ; IIso++){
aVPrm(IIso) = VPrm;
gp_Pnt2d Ori (0., VPrm);
Geom2dAdaptor_Curve HCur(new Geom2d_Line (Ori, Dir));
aVInd(IIso) = aHatcher.AddHatching (HCur) ;
VPrm += StepV ;
}
}
//-----------------------------------------------------------------------
// Computation.
//-----------------------------------------------------------------------
aHatcher.Trim() ;
Standard_Integer aNbDom = 0 ; // for debug purpose
for(IIso = 1 ; IIso <= theNbIso ; IIso++){
Standard_Integer Index ;
Index = anUInd(IIso) ;
if(Index != 0){
if(aHatcher.TrimDone(Index) && !aHatcher.TrimFailed(Index)){
aHatcher.ComputeDomains(Index);
if(aHatcher.IsDone (Index))
aNbDom = aHatcher.NbDomains (Index);
}
}
Index = aVInd(IIso);
if(Index != 0){
if(aHatcher.TrimDone (Index) && !aHatcher.TrimFailed(Index)){
aHatcher.ComputeDomains (Index);
if(aHatcher.IsDone (Index))
aNbDom = aHatcher.NbDomains (Index);
}
}
}
//-----------------------------------------------------------------------
// Push iso lines in vtk kernel
//-----------------------------------------------------------------------
for(Standard_Integer UIso = anUPrm.Lower() ; UIso <= anUPrm.Upper(); UIso++){
Standard_Integer UInd = anUInd.Value(UIso);
if(UInd != 0){
Standard_Real UPrm = anUPrm.Value(UIso);
if(aHatcher.IsDone(UInd)){
Standard_Integer NbDom = aHatcher.NbDomains(UInd);
for(Standard_Integer IDom = 1 ; IDom <= NbDom ; IDom++){
const HatchGen_Domain& Dom = aHatcher.Domain(UInd, IDom) ;
Standard_Real V1 = Dom.HasFirstPoint()? Dom.FirstPoint().Parameter(): aVMin - VTKINFINITE;
Standard_Real V2 = Dom.HasSecondPoint()? Dom.SecondPoint().Parameter(): aVMax + VTKINFINITE;
CreateIso_(theFace, GeomAbs_IsoU, UPrm, V1, V2, theDiscret, thePolyData, thePts);
}
}
}
}
for(Standard_Integer VIso = aVPrm.Lower() ; VIso <= aVPrm.Upper(); VIso++){
Standard_Integer VInd = aVInd.Value(VIso);
if(VInd != 0){
Standard_Real VPrm = aVPrm.Value(VIso);
if(aHatcher.IsDone (VInd)){
Standard_Integer NbDom = aHatcher.NbDomains(VInd);
for (Standard_Integer IDom = 1 ; IDom <= NbDom ; IDom++){
const HatchGen_Domain& Dom = aHatcher.Domain(VInd, IDom);
Standard_Real U1 = Dom.HasFirstPoint()? Dom.FirstPoint().Parameter(): aVMin - VTKINFINITE;
Standard_Real U2 = Dom.HasSecondPoint()? Dom.SecondPoint().Parameter(): aVMax + VTKINFINITE;
CreateIso_(theFace, GeomAbs_IsoV, VPrm, U1, U2, theDiscret, thePolyData, thePts);
}
}
}
}
}
void
GEOM_WireframeFace::
CreateIso_(const TopoDS_Face& theFace,
GeomAbs_IsoType theIsoType,
Standard_Real Par,
Standard_Real T1,
Standard_Real T2,
const int theDiscret,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
Standard_Real U1, U2, V1, V2, stepU=0., stepV=0.;
Standard_Integer j;
gp_Pnt P;
TopLoc_Location aLoc;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(theFace,aLoc);
if(!S.IsNull()){
BRepAdaptor_Surface S(theFace,Standard_False);
GeomAbs_SurfaceType SurfType = S.GetType();
GeomAbs_CurveType CurvType = GeomAbs_OtherCurve;
Standard_Integer Intrv, nbIntv;
Standard_Integer nbUIntv = S.NbUIntervals(GeomAbs_CN);
Standard_Integer nbVIntv = S.NbVIntervals(GeomAbs_CN);
TColStd_Array1OfReal TI(1,Max(nbUIntv, nbVIntv)+1);
if(theIsoType == GeomAbs_IsoU){
S.VIntervals(TI, GeomAbs_CN);
V1 = Max(T1, TI(1));
V2 = Min(T2, TI(2));
U1 = Par;
U2 = Par;
stepU = 0;
nbIntv = nbVIntv;
}else{
S.UIntervals(TI, GeomAbs_CN);
U1 = Max(T1, TI(1));
U2 = Min(T2, TI(2));
V1 = Par;
V2 = Par;
stepV = 0;
nbIntv = nbUIntv;
}
S.D0(U1,V1,P);
MoveTo(P,thePts);
for(Intrv = 1; Intrv <= nbIntv; Intrv++){
if(TI(Intrv) <= T1 && TI(Intrv + 1) <= T1)
continue;
if(TI(Intrv) >= T2 && TI(Intrv + 1) >= T2)
continue;
if(theIsoType == GeomAbs_IsoU){
V1 = Max(T1, TI(Intrv));
V2 = Min(T2, TI(Intrv + 1));
stepV = (V2 - V1) / theDiscret;
}else{
U1 = Max(T1, TI(Intrv));
U2 = Min(T2, TI(Intrv + 1));
stepU = (U2 - U1) / theDiscret;
}
switch (SurfType) {
case GeomAbs_Plane :
break;
case GeomAbs_Cylinder :
case GeomAbs_Cone :
if(theIsoType == GeomAbs_IsoV){
for(j = 1; j < theDiscret; j++){
U1 += stepU;
V1 += stepV;
S.D0(U1,V1,P);
DrawTo(P,thePolyData,thePts);
}
}
break;
case GeomAbs_Sphere :
case GeomAbs_Torus :
case GeomAbs_OffsetSurface :
case GeomAbs_OtherSurface :
for(j = 1; j < theDiscret; j++){
U1 += stepU;
V1 += stepV;
S.D0(U1,V1,P);
DrawTo(P,thePolyData,thePts);
}
break;
case GeomAbs_BezierSurface :
case GeomAbs_BSplineSurface :
for(j = 1; j <= theDiscret/2; j++){
Standard_Real aStep = (theIsoType == GeomAbs_IsoV) ? stepU*2. : stepV*2.;
CreateIso__(S, theIsoType, U1, V1, aStep, thePolyData, thePts);
U1 += stepU*2.;
V1 += stepV*2.;
}
break;
case GeomAbs_SurfaceOfExtrusion :
case GeomAbs_SurfaceOfRevolution :
if((theIsoType == GeomAbs_IsoV && SurfType == GeomAbs_SurfaceOfRevolution) ||
(theIsoType == GeomAbs_IsoU && SurfType == GeomAbs_SurfaceOfExtrusion))
{
if(SurfType == GeomAbs_SurfaceOfExtrusion)
break;
for(j = 1; j < theDiscret; j++){
U1 += stepU;
V1 += stepV;
S.D0(U1,V1,P);
DrawTo(P,thePolyData,thePts);
}
}else{
CurvType = (S.BasisCurve())->GetType();
switch(CurvType){
case GeomAbs_Line :
break;
case GeomAbs_Circle :
case GeomAbs_Ellipse :
for (j = 1; j < theDiscret; j++) {
U1 += stepU;
V1 += stepV;
S.D0(U1,V1,P);
DrawTo(P,thePolyData,thePts);
}
break;
case GeomAbs_Parabola :
case GeomAbs_Hyperbola :
case GeomAbs_BezierCurve :
case GeomAbs_BSplineCurve :
case GeomAbs_OtherCurve :
for(j = 1; j <= theDiscret/2; j++){
Standard_Real aStep = (theIsoType == GeomAbs_IsoV) ? stepU*2. : stepV*2.;
CreateIso__(S, theIsoType, U1, V1, aStep, thePolyData, thePts);
U1 += stepU*2.;
V1 += stepV*2.;
}
break;
}
}
}
}
S.D0(U2,V2,P);
DrawTo(P,thePolyData,thePts);
}
}
void
GEOM_WireframeFace::
CreateIso__(const BRepAdaptor_Surface& theSurface,
GeomAbs_IsoType theIsoType,
Standard_Real& theU,
Standard_Real& theV,
Standard_Real theStep,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
gp_Pnt Pl, Pr, Pm;
if (theIsoType == GeomAbs_IsoU) {
theSurface.D0(theU, theV, Pl);
theSurface.D0(theU, theV + theStep/2., Pm);
theSurface.D0(theU, theV + theStep, Pr);
} else {
theSurface.D0(theU, theV, Pl);
theSurface.D0(theU + theStep/2., theV, Pm);
theSurface.D0(theU + theStep, theV, Pr);
}
static Standard_Real ISO_RATIO = 1.001;
if (Pm.Distance(Pl) + Pm.Distance(Pr) <= ISO_RATIO*Pl.Distance(Pr)) {
DrawTo(Pr,thePolyData,thePts);
} else {
if (theIsoType == GeomAbs_IsoU) {
CreateIso__(theSurface, theIsoType, theU, theV, theStep/2, thePolyData, thePts);
Standard_Real aLocalV = theV + theStep/2 ;
CreateIso__(theSurface, theIsoType, theU, aLocalV , theStep/2, thePolyData, thePts);
} else {
CreateIso__(theSurface, theIsoType, theU, theV, theStep/2, thePolyData, thePts);
Standard_Real aLocalU = theU + theStep/2 ;
CreateIso__(theSurface, theIsoType, aLocalU , theV, theStep/2, thePolyData, thePts);
}
}
}

75
src/OBJECT/GEOM_WireframeFace.h Executable file
View File

@ -0,0 +1,75 @@
#ifndef GEOM_WIREFRAME_FACE_H
#define GEOM_WIREFRAME_FACE_H
#include "GEOM_FaceSource.h"
#include <GeomAbs_IsoType.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <vtkPolyDataSource.h>
class VTK_EXPORT GEOM_WireframeFace: public GEOM_FaceSource
{
public:
vtkTypeMacro(GEOM_WireframeFace,GEOM_FaceSource);
static GEOM_WireframeFace* New();
vtkSetMacro(NbIso,int);
vtkGetMacro(NbIso,int);
vtkSetMacro(Discret,int);
vtkGetMacro(Discret,int);
static
void OCC2VTK(const TopoDS_Face& theFace,
vtkPolyData* thePolyData,
vtkPoints* thePts,
int theNbIso = 1,
int theDiscret = 15);
protected:
int NbIso, Discret;
static
void
CreateIso(const TopoDS_Face& theFace,
const int theNbIso,
const int theDiscret,
vtkPolyData* thePolyData,
vtkPoints* thePts);
static
void
CreateIso_(const TopoDS_Face& theFace,
GeomAbs_IsoType theIsoType,
Standard_Real Par,
Standard_Real T1,
Standard_Real T2,
const int theDiscret,
vtkPolyData* thePolyData,
vtkPoints* thePts);
static
void
CreateIso__(const BRepAdaptor_Surface& theSurface,
GeomAbs_IsoType theIsoType,
Standard_Real& theU,
Standard_Real& theV,
Standard_Real theStep,
vtkPolyData* thePolyData,
vtkPoints* thePts);
void Execute();
GEOM_WireframeFace();
~GEOM_WireframeFace();
private:
// Not implememnted
GEOM_WireframeFace(const GEOM_WireframeFace&);
void operator=(const GEOM_WireframeFace&);
};
#endif //GEOM_WFACEACTOR_H

View File

@ -39,7 +39,14 @@ salomeinclude_HEADERS = \
GEOM_AISTrihedron.hxx \
GEOM_VTKTrihedron.hxx \
GEOM_AISVector.hxx \
GEOM_OBJECT_defs.hxx
GEOM_OBJECT_defs.hxx \
GEOM_SmartPtr.h \
GEOM_DeviceActor.h \
GEOM_EdgeSource.h \
GEOM_FaceSource.h \
GEOM_ShadingFace.h \
GEOM_VertexSource.h \
GEOM_WireframeFace.h
# Libraries targets
lib_LTLIBRARIES = libGEOMObject.la
@ -52,7 +59,13 @@ dist_libGEOMObject_la_SOURCES = \
GEOM_InteractiveObject.cxx \
GEOM_AISTrihedron.cxx \
GEOM_VTKTrihedron.cxx \
GEOM_AISVector.cxx
GEOM_AISVector.cxx \
GEOM_DeviceActor.cxx \
GEOM_EdgeSource.cxx \
GEOM_FaceSource.cxx \
GEOM_ShadingFace.cxx \
GEOM_VertexSource.cxx \
GEOM_WireframeFace.cxx
libGEOMObject_la_CPPFLAGS = \