mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-15 10:08:35 +05:00
RNV: Improve "deflection algorithm" for the VTK viewer.
This commit is contained in:
parent
fae650357c
commit
20c08bd101
@ -37,7 +37,6 @@
|
|||||||
#include <GEOM_OCCFilter.h>
|
#include <GEOM_OCCFilter.h>
|
||||||
|
|
||||||
#include <GEOM_Actor.h>
|
#include <GEOM_Actor.h>
|
||||||
#include <GEOM_AssemblyBuilder.h>
|
|
||||||
#include <GEOM_AISShape.hxx>
|
#include <GEOM_AISShape.hxx>
|
||||||
#include <GEOM_AISVector.hxx>
|
#include <GEOM_AISVector.hxx>
|
||||||
#include <GEOM_AISTrihedron.hxx>
|
#include <GEOM_AISTrihedron.hxx>
|
||||||
@ -84,6 +83,7 @@
|
|||||||
#include <TopTools_MapOfShape.hxx>
|
#include <TopTools_MapOfShape.hxx>
|
||||||
#include <TopTools_ListOfShape.hxx>
|
#include <TopTools_ListOfShape.hxx>
|
||||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
|
||||||
// VTK Includes
|
// VTK Includes
|
||||||
#include <vtkActorCollection.h>
|
#include <vtkActorCollection.h>
|
||||||
@ -980,17 +980,24 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
|
|||||||
theActors->AddItem( aTrh );
|
theActors->AddItem( aTrh );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True, myType == GEOM_VECTOR );
|
PropMap aDefPropMap = getDefaultPropepryMap(SVTK_Viewer::Type());
|
||||||
|
|
||||||
QString anEntry;
|
QString anEntry;
|
||||||
if(!myIO.IsNull()) {
|
if(!myIO.IsNull()) {
|
||||||
aMgrId = getViewManagerId(myViewFrame);
|
aMgrId = getViewManagerId(myViewFrame);
|
||||||
anEntry = myIO->getEntry();
|
anEntry = myIO->getEntry();
|
||||||
}
|
}
|
||||||
useStudy = !anEntry.isEmpty() && aMgrId != -1;
|
useStudy = !anEntry.isEmpty() && aMgrId != -1;
|
||||||
|
|
||||||
|
|
||||||
|
theActors = vtkActorCollection::New();
|
||||||
|
GEOM_Actor* aGeomActor = GEOM_Actor::New();
|
||||||
|
aGeomActor->SetShape(myShape,aDefPropMap.value(DEFLECTION_COEFF_PROP).toDouble(),myType == GEOM_VECTOR);
|
||||||
|
theActors->AddItem(aGeomActor);
|
||||||
|
aGeomActor->Delete();
|
||||||
|
|
||||||
if(useStudy){
|
if(useStudy){
|
||||||
aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
|
aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
|
||||||
PropMap aDefPropMap = getDefaultPropepryMap(SVTK_Viewer::Type());
|
|
||||||
bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
|
bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
|
||||||
if(isDiff)
|
if(isDiff)
|
||||||
aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
|
aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
|
||||||
@ -1048,8 +1055,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
|
|||||||
aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
|
aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
|
||||||
aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
|
aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
|
||||||
aGeomGActor->setDisplayMode(aPropMap.value(DISPLAY_MODE_PROP).toInt());
|
aGeomGActor->setDisplayMode(aPropMap.value(DISPLAY_MODE_PROP).toInt());
|
||||||
//VSR: do not set deflection until OCC2VTK algo is not improved (to keep performance)
|
aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble());
|
||||||
//aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble(), aGeomGActor->GetIsRelative());
|
|
||||||
|
|
||||||
vtkFloatingPointType aColor[3] = {1.,0.,0.};
|
vtkFloatingPointType aColor[3] = {1.,0.,0.};
|
||||||
if(aPropMap.contains(COLOR_PROP)) {
|
if(aPropMap.contains(COLOR_PROP)) {
|
||||||
@ -1691,12 +1697,13 @@ PropMap GEOM_Displayer::getDefaultPropepryMap(const QString& viewer_type){
|
|||||||
|
|
||||||
//7. Deflection Coeff
|
//7. Deflection Coeff
|
||||||
double aDC;
|
double aDC;
|
||||||
//rnv: Currently deflection coefficient is not supported by VTK viewer.
|
|
||||||
if(viewer_type == SOCC_Viewer::Type()) {
|
if(viewer_type == SOCC_Viewer::Type()) {
|
||||||
aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
|
aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
|
||||||
} else if( viewer_type==SVTK_Viewer::Type()) {
|
} else if( viewer_type==SVTK_Viewer::Type()) {
|
||||||
aDC = 0.0;
|
aDC = 0.001;
|
||||||
}
|
}
|
||||||
|
|
||||||
aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
|
aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
|
||||||
|
|
||||||
return aDefaultMap;
|
return aDefaultMap;
|
||||||
|
@ -1123,7 +1123,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
|
mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
|
||||||
mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpIsos ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
|
||||||
mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
|
mgr->insert( action( GEOMOp::OpDeflection ), -1, -1 ); // deflection
|
||||||
mgr->setRule( action( GEOMOp::OpDeflection ), "selcount>0 and isVisible and client='OCCViewer'", QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpDeflection ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule );
|
||||||
mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
|
mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
|
||||||
//mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
|
//mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
|
||||||
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
|
||||||
|
@ -769,8 +769,7 @@ void GEOMToolsGUI::OnDeflection()
|
|||||||
while (anAct != NULL) {
|
while (anAct != NULL) {
|
||||||
if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
|
if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
|
||||||
// There are no casting to needed actor.
|
// There are no casting to needed actor.
|
||||||
bool isRel = anActor->GetIsRelative();
|
anActor->SetDeflection(aDC);
|
||||||
anActor->SetDeflection(aDC, isRel);
|
|
||||||
appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
|
appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
|
||||||
}
|
}
|
||||||
anAct = aCollection->GetNextActor();
|
anAct = aCollection->GetNextActor();
|
||||||
|
@ -353,20 +353,21 @@ GEOM_Actor
|
|||||||
|
|
||||||
void
|
void
|
||||||
GEOM_Actor::
|
GEOM_Actor::
|
||||||
SetDeflection(float theDeflection, bool theIsRelative)
|
SetDeflection(float theDeflection)
|
||||||
{
|
{
|
||||||
|
if( myDeflection == theDeflection )
|
||||||
|
return;
|
||||||
|
|
||||||
myDeflection = theDeflection;
|
myDeflection = theDeflection;
|
||||||
myIsRelative = theIsRelative;
|
|
||||||
|
|
||||||
GEOM::MeshShape2(myShape,myDeflection,myIsRelative);
|
|
||||||
|
|
||||||
|
GEOM::MeshShape(myShape,myDeflection);
|
||||||
|
|
||||||
SetModified();
|
SetModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
|
void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
|
||||||
float theDeflection,
|
float theDeflection,
|
||||||
bool theIsRelative,
|
bool theIsVector)
|
||||||
bool theIsVector)
|
|
||||||
{
|
{
|
||||||
myShape = theShape;
|
myShape = theShape;
|
||||||
|
|
||||||
@ -383,7 +384,8 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
|
|||||||
const TopoDS_Vertex& aVertex = TopoDS::Vertex(aVertexExp.Current());
|
const TopoDS_Vertex& aVertex = TopoDS::Vertex(aVertexExp.Current());
|
||||||
myVertexSource->AddVertex(aVertex);
|
myVertexSource->AddVertex(aVertex);
|
||||||
}
|
}
|
||||||
SetDeflection(theDeflection, theIsRelative);
|
|
||||||
|
SetDeflection(theDeflection);
|
||||||
|
|
||||||
// look if edges are free or shared
|
// look if edges are free or shared
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
||||||
@ -414,7 +416,7 @@ void GEOM_Actor::setDeflection(double adef) {
|
|||||||
#ifdef MYDEBUG
|
#ifdef MYDEBUG
|
||||||
MESSAGE ( "GEOM_Actor::setDeflection" );
|
MESSAGE ( "GEOM_Actor::setDeflection" );
|
||||||
#endif
|
#endif
|
||||||
SetDeflection((float)adef,GetIsRelative());
|
SetDeflection((float)adef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -539,7 +541,7 @@ void GEOM_Actor::ShallowCopy(vtkProp *prop)
|
|||||||
GEOM_Actor *f = GEOM_Actor::SafeDownCast(prop);
|
GEOM_Actor *f = GEOM_Actor::SafeDownCast(prop);
|
||||||
if ( f != NULL )
|
if ( f != NULL )
|
||||||
{
|
{
|
||||||
this->SetShape(f->getTopo(),f->GetDeflection(),f->GetIsRelative());
|
this->SetShape(f->getTopo(),f->GetDeflection());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now do superclass
|
// Now do superclass
|
||||||
|
@ -63,13 +63,11 @@ public:
|
|||||||
static GEOM_Actor* New();
|
static GEOM_Actor* New();
|
||||||
|
|
||||||
void SetShape(const TopoDS_Shape& theShape,
|
void SetShape(const TopoDS_Shape& theShape,
|
||||||
float theDeflection,
|
float theDeflection,
|
||||||
bool theIsRelative,
|
bool theIsVector = false);
|
||||||
bool theIsVector = false);
|
|
||||||
|
|
||||||
void SetDeflection(float theDeflection, bool theIsRelative);
|
void SetDeflection(float theDeflection);
|
||||||
float GetDeflection() const{ return myDeflection;}
|
float GetDeflection() const{ return myDeflection;}
|
||||||
bool GetIsRelative() const{ return myIsRelative;}
|
|
||||||
|
|
||||||
void AddToRender(vtkRenderer* theRenderer);
|
void AddToRender(vtkRenderer* theRenderer);
|
||||||
void RemoveFromRender(vtkRenderer* theRenderer);
|
void RemoveFromRender(vtkRenderer* theRenderer);
|
||||||
@ -186,7 +184,6 @@ private:
|
|||||||
bool isOnlyVertex;
|
bool isOnlyVertex;
|
||||||
|
|
||||||
float myDeflection;
|
float myDeflection;
|
||||||
bool myIsRelative;
|
|
||||||
bool myIsForced;
|
bool myIsForced;
|
||||||
|
|
||||||
// EDisplayMode myDisplayMode;
|
// EDisplayMode myDisplayMode;
|
||||||
|
@ -1,438 +0,0 @@
|
|||||||
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
|
||||||
//
|
|
||||||
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
||||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation; either
|
|
||||||
// version 2.1 of the License.
|
|
||||||
//
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
//
|
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
||||||
//
|
|
||||||
|
|
||||||
// GEOM OBJECT : interactive object for Geometry entities visualization
|
|
||||||
// File : GEOM_AssemblyBuilder.cxx
|
|
||||||
// Author : Christophe ATTANASIO
|
|
||||||
// Module : GEOM
|
|
||||||
// $Header$
|
|
||||||
//
|
|
||||||
/*!
|
|
||||||
\class GEOM_AssemblyBuilder GEOM_AssemblyBuilder.h
|
|
||||||
\brief ....
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "GEOM_AssemblyBuilder.h"
|
|
||||||
#include "GEOM_Actor.h"
|
|
||||||
|
|
||||||
#include <OCC2VTK_Tools.h>
|
|
||||||
|
|
||||||
#include <SUIT_Session.h>
|
|
||||||
#include <SUIT_ResourceMgr.h>
|
|
||||||
|
|
||||||
#include <vtkProperty.h>
|
|
||||||
#include <vtkAssembly.h>
|
|
||||||
#include <vtkActorCollection.h>
|
|
||||||
|
|
||||||
// Open CASCADE Includes
|
|
||||||
#include <TopExp_Explorer.hxx>
|
|
||||||
#include <BRep_Tool.hxx>
|
|
||||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
|
||||||
#include <TopExp.hxx>
|
|
||||||
#include <TopoDS_Iterator.hxx>
|
|
||||||
|
|
||||||
// Qt includes
|
|
||||||
#include <QColor>
|
|
||||||
|
|
||||||
#include "utilities.h"
|
|
||||||
|
|
||||||
void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp,
|
|
||||||
vtkProperty* FaceProp,
|
|
||||||
vtkProperty* EdgeFProp,
|
|
||||||
vtkProperty* EdgeSProp,
|
|
||||||
vtkProperty* EdgeIProp,
|
|
||||||
vtkProperty* VertexProp,
|
|
||||||
vtkProperty* IsoPVProp,
|
|
||||||
vtkProperty* EdgePVProp,
|
|
||||||
vtkProperty* VertexPVProp)
|
|
||||||
{
|
|
||||||
// Shading like default OCC material
|
|
||||||
FaceProp->SetRepresentationToSurface();
|
|
||||||
FaceProp->SetInterpolationToGouraud();
|
|
||||||
FaceProp->SetAmbient(1.0);
|
|
||||||
FaceProp->SetDiffuse(1.0);
|
|
||||||
FaceProp->SetSpecular(0.4);
|
|
||||||
FaceProp->SetAmbientColor(0.329412, 0.223529, 0.027451);
|
|
||||||
FaceProp->SetDiffuseColor(0.780392, 0.568627, 0.113725);
|
|
||||||
FaceProp->SetSpecularColor(0.992157, 0.941176, 0.807843);
|
|
||||||
|
|
||||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
|
||||||
QColor aColor;
|
|
||||||
|
|
||||||
// Wireframe for iso
|
|
||||||
aColor = aResMgr->colorValue( "Geometry", "isos_color", QColor( int(0.5*255), int(0.5*255), int(0.5*255) ) );
|
|
||||||
float red = aColor.red()/255.0;
|
|
||||||
float green = aColor.green()/255.0;
|
|
||||||
float blue = aColor.blue()/255.0;
|
|
||||||
IsoProp->SetRepresentationToWireframe();
|
|
||||||
IsoProp->SetAmbientColor(red, green, blue);
|
|
||||||
IsoProp->SetDiffuseColor(red, green, blue);
|
|
||||||
IsoProp->SetSpecularColor(red, green, blue);
|
|
||||||
|
|
||||||
// Wireframe for iso
|
|
||||||
IsoPVProp->SetRepresentationToWireframe();
|
|
||||||
IsoPVProp->SetAmbientColor(0, 1, 1);
|
|
||||||
IsoPVProp->SetDiffuseColor(0, 1, 1);
|
|
||||||
IsoPVProp->SetSpecularColor(0, 1, 1);
|
|
||||||
|
|
||||||
// Wireframe for shared edge
|
|
||||||
aColor = aResMgr->colorValue( "Geometry", "wireframe_color", QColor( 255, 255, 0 ) );
|
|
||||||
red = aColor.red()/255.0;
|
|
||||||
green = aColor.green()/255.0;
|
|
||||||
blue = aColor.blue()/255.0;
|
|
||||||
EdgeSProp->SetRepresentationToWireframe();
|
|
||||||
EdgeSProp->SetAmbientColor(red, green, blue);
|
|
||||||
EdgeSProp->SetDiffuseColor(red, green, blue);
|
|
||||||
EdgeSProp->SetSpecularColor(red, green, blue);
|
|
||||||
|
|
||||||
// Wireframe for free edge
|
|
||||||
aColor = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) );
|
|
||||||
red = aColor.red()/255.0;
|
|
||||||
green = aColor.green()/255.0;
|
|
||||||
blue = aColor.blue()/255.0;
|
|
||||||
EdgeFProp->SetRepresentationToWireframe();
|
|
||||||
EdgeFProp->SetAmbientColor(red, green, blue);
|
|
||||||
EdgeFProp->SetDiffuseColor(red, green, blue);
|
|
||||||
EdgeFProp->SetSpecularColor(red, green, blue);
|
|
||||||
|
|
||||||
// Wireframe for isolated edge
|
|
||||||
aColor = aResMgr->colorValue( "Geometry", "line_color", QColor( 255, 0, 0 ) );
|
|
||||||
red = aColor.red()/255.0;
|
|
||||||
green = aColor.green()/255.0;
|
|
||||||
blue = aColor.blue()/255.0;
|
|
||||||
EdgeIProp->SetRepresentationToWireframe();
|
|
||||||
EdgeIProp->SetAmbientColor(red, green, blue);
|
|
||||||
EdgeIProp->SetDiffuseColor(red, green, blue);
|
|
||||||
|
|
||||||
// Wireframe for Preview edge
|
|
||||||
EdgePVProp->SetRepresentationToWireframe();
|
|
||||||
EdgePVProp->SetAmbientColor(1, 1, 0);
|
|
||||||
EdgePVProp->SetDiffuseColor(1, 1, 0);
|
|
||||||
EdgePVProp->SetSpecularColor(1, 1, 0);
|
|
||||||
|
|
||||||
// Wireframe for vertex
|
|
||||||
aColor = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) );
|
|
||||||
red = aColor.red()/255.0;
|
|
||||||
green = aColor.green()/255.0;
|
|
||||||
blue = aColor.blue()/255.0;
|
|
||||||
VertexProp->SetRepresentationToWireframe();
|
|
||||||
VertexProp->SetAmbientColor(red, green, blue);
|
|
||||||
VertexProp->SetDiffuseColor(red, green, blue);
|
|
||||||
VertexProp->SetSpecularColor(red, green, blue);
|
|
||||||
|
|
||||||
// Wireframe for vertex
|
|
||||||
VertexPVProp->SetRepresentationToWireframe();
|
|
||||||
VertexPVProp->SetAmbientColor(0, 1, 1);
|
|
||||||
VertexPVProp->SetDiffuseColor(0, 1, 1);
|
|
||||||
VertexPVProp->SetSpecularColor(0, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShape,
|
|
||||||
Standard_Real deflection,
|
|
||||||
Standard_Integer mode,
|
|
||||||
Standard_Boolean forced,
|
|
||||||
Standard_Boolean isVector)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
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();
|
|
||||||
GEOM::MeshShape(myShape,deflection,forced);
|
|
||||||
GEOM_Actor* aGeomActor = GEOM_Actor::New();
|
|
||||||
aGeomActor->SetShape(myShape,(float)deflection,false,isVector);
|
|
||||||
AISActors->AddItem(aGeomActor);
|
|
||||||
|
|
||||||
aGeomActor->Delete();
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(myShape.ShapeType() == TopAbs_COMPOUND) {
|
|
||||||
TopoDS_Iterator anItr(myShape);
|
|
||||||
for(; anItr.More(); anItr.Next()) {
|
|
||||||
vtkActorCollection* theActors =
|
|
||||||
GEOM_AssemblyBuilder::BuildActors(anItr.Value(), deflection, mode, forced);
|
|
||||||
theActors->InitTraversal();
|
|
||||||
vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
|
|
||||||
while(!(anActor==NULL)) {
|
|
||||||
AISActors->AddItem(anActor);
|
|
||||||
anActor = (vtkActor*)theActors->GetNextActor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Create graphics properties
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
MeshShape(myShape,deflection,forced);
|
|
||||||
|
|
||||||
if ( myShape.ShapeType() <= 4 && myShape.ShapeType() != TopAbs_COMPOUND) {
|
|
||||||
|
|
||||||
// FACE Actor
|
|
||||||
// look if edges are free or shared
|
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape edgemap;
|
|
||||||
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
|
|
||||||
|
|
||||||
TopExp_Explorer ex;
|
|
||||||
|
|
||||||
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
|
|
||||||
|
|
||||||
GEOM_Actor* FaceActor = GEOM_Actor::New();
|
|
||||||
FaceActor->SetShadingProperty(FaceProp);
|
|
||||||
FaceActor->SetWireframeProperty(IsoProp);
|
|
||||||
|
|
||||||
FaceActor->SetPreviewProperty(IsoPVProp);
|
|
||||||
|
|
||||||
FaceActor->setInputShape(ex.Current(),deflection,mode);
|
|
||||||
|
|
||||||
AISActors->AddItem(FaceActor);
|
|
||||||
|
|
||||||
TopExp_Explorer ex2;
|
|
||||||
for (ex2.Init(ex.Current(), TopAbs_EDGE); ex2.More(); ex2.Next()) {
|
|
||||||
const TopoDS_Edge& aEdge = TopoDS::Edge(ex2.Current());
|
|
||||||
|
|
||||||
if (BRep_Tool::Degenerated(aEdge)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute the number of faces
|
|
||||||
Standard_Integer nbf = edgemap.FindFromKey(ex2.Current()).Extent();
|
|
||||||
GEOM_Actor* EdgeActor = GEOM_Actor::New();
|
|
||||||
EdgeActor->SubShapeOn();
|
|
||||||
EdgeActor->setInputShape(ex2.Current(),deflection,mode);
|
|
||||||
|
|
||||||
switch (nbf) {
|
|
||||||
|
|
||||||
case 0 : // isolated edge
|
|
||||||
{
|
|
||||||
EdgeActor->SetShadingProperty(EdgeIProp);
|
|
||||||
EdgeActor->SetWireframeProperty(EdgeIProp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1 :// edge in only one face
|
|
||||||
{
|
|
||||||
EdgeActor->SetShadingProperty(EdgeFProp);
|
|
||||||
EdgeActor->SetWireframeProperty(EdgeFProp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default : // edge shared by at least two faces
|
|
||||||
{
|
|
||||||
EdgeActor->SetShadingProperty(EdgeSProp);
|
|
||||||
EdgeActor->SetWireframeProperty(EdgeSProp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeActor->SetPreviewProperty(EdgePVProp);
|
|
||||||
AISActors->AddItem(EdgeActor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ( myShape.ShapeType() == TopAbs_WIRE ) { // WIRE Actor
|
|
||||||
TopExp_Explorer ex;
|
|
||||||
for (ex.Init(myShape, TopAbs_EDGE); ex.More(); ex.Next()) {
|
|
||||||
const TopoDS_Edge& aEdge = TopoDS::Edge(ex.Current());
|
|
||||||
|
|
||||||
if (BRep_Tool::Degenerated(aEdge)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
GEOM_Actor* EdgeActor = GEOM_Actor::New();
|
|
||||||
EdgeActor->setInputShape(ex.Current(),deflection,mode);
|
|
||||||
EdgeActor->SetShadingProperty(EdgeIProp);
|
|
||||||
EdgeActor->SetWireframeProperty(EdgeIProp);
|
|
||||||
EdgeActor->SetPreviewProperty(EdgePVProp);
|
|
||||||
|
|
||||||
AISActors->AddItem(EdgeActor);
|
|
||||||
}
|
|
||||||
} else if ( myShape.ShapeType() == TopAbs_EDGE ) { // EDGE Actor
|
|
||||||
GEOM_Actor* EdgeActor = GEOM_Actor::New();
|
|
||||||
EdgeActor->setInputShape(myShape,deflection,mode,isVector);
|
|
||||||
EdgeActor->SetShadingProperty(EdgeIProp);
|
|
||||||
EdgeActor->SetWireframeProperty(EdgeIProp);
|
|
||||||
EdgeActor->SetPreviewProperty(EdgePVProp);
|
|
||||||
|
|
||||||
AISActors->AddItem(EdgeActor);
|
|
||||||
} else if ( myShape.ShapeType() == TopAbs_VERTEX ) { // VERTEX Actor
|
|
||||||
GEOM_Actor* VertexActor = GEOM_Actor::New();
|
|
||||||
VertexActor->setInputShape(myShape,deflection,mode);
|
|
||||||
VertexActor->SetShadingProperty(VertexProp);
|
|
||||||
VertexActor->SetWireframeProperty(VertexProp);
|
|
||||||
VertexActor->SetPreviewProperty(VertexPVProp);
|
|
||||||
|
|
||||||
AISActors->AddItem(VertexActor);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
return AISActors;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
|
||||||
// BUILD ASSEMBLY
|
|
||||||
//-------------------------------------------------------------
|
|
||||||
vtkAssembly* GEOM_AssemblyBuilder::BuildAssembly(const TopoDS_Shape& myShape,
|
|
||||||
Standard_Real deflection,
|
|
||||||
Standard_Integer mode,
|
|
||||||
Standard_Boolean forced)
|
|
||||||
{
|
|
||||||
// Create a new vtkAssembly
|
|
||||||
|
|
||||||
vtkAssembly* myVTKShape = vtkAssembly::New();
|
|
||||||
/*
|
|
||||||
// Create graphics properties
|
|
||||||
|
|
||||||
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* EdgePVProp = vtkProperty::New();
|
|
||||||
vtkProperty* VertexPVProp = vtkProperty::New();
|
|
||||||
vtkProperty* IsoPVProp = vtkProperty::New();
|
|
||||||
|
|
||||||
InitProperties(IsoProp,FaceProp,EdgeFProp,EdgeSProp,EdgeIProp,VertexProp,IsoPVProp,EdgePVProp,VertexPVProp);
|
|
||||||
|
|
||||||
MeshShape(myShape,deflection,forced);
|
|
||||||
|
|
||||||
|
|
||||||
// FACE Actor
|
|
||||||
|
|
||||||
// look if edges are free or shared
|
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape edgemap;
|
|
||||||
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,edgemap);
|
|
||||||
|
|
||||||
TopExp_Explorer ex;
|
|
||||||
|
|
||||||
for (ex.Init(myShape, TopAbs_FACE); ex.More(); ex.Next()) {
|
|
||||||
//const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
|
|
||||||
|
|
||||||
GEOM_Actor* FaceActor = GEOM_Actor::New();
|
|
||||||
FaceActor->SetShadingProperty(FaceProp);
|
|
||||||
FaceActor->SetWireframeProperty(IsoProp);
|
|
||||||
|
|
||||||
vtkAssembly* myFaceAssembly = vtkAssembly::New();
|
|
||||||
|
|
||||||
|
|
||||||
FaceActor->setInputShape(ex.Current(),deflection,mode);
|
|
||||||
myFaceAssembly->AddPart(FaceActor);
|
|
||||||
|
|
||||||
TopExp_Explorer ex2;
|
|
||||||
for (ex2.Init(ex.Current(), TopAbs_EDGE); ex2.More(); ex2.Next()) {
|
|
||||||
const TopoDS_Edge& aEdge = TopoDS::Edge(ex2.Current());
|
|
||||||
|
|
||||||
if (BRep_Tool::Degenerated(aEdge)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// compute the number of faces
|
|
||||||
Standard_Integer nbf = edgemap.FindFromKey(ex2.Current()).Extent();
|
|
||||||
GEOM_Actor* EdgeActor = GEOM_Actor::New();
|
|
||||||
switch (nbf) {
|
|
||||||
|
|
||||||
case 0 : // isolated edge
|
|
||||||
{
|
|
||||||
EdgeActor->SetShadingProperty(EdgeIProp);
|
|
||||||
EdgeActor->SetWireframeProperty(EdgeIProp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1 :// edge in only one face
|
|
||||||
{
|
|
||||||
EdgeActor->SetShadingProperty(EdgeFProp);
|
|
||||||
EdgeActor->SetWireframeProperty(EdgeFProp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default : // edge shared by at least two faces
|
|
||||||
{
|
|
||||||
EdgeActor->SetShadingProperty(EdgeSProp);
|
|
||||||
EdgeActor->SetWireframeProperty(EdgeSProp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EdgeActor->setInputShape(ex2.Current(),deflection,mode);
|
|
||||||
myFaceAssembly->AddPart(EdgeActor);
|
|
||||||
}
|
|
||||||
myVTKShape->AddPart(myFaceAssembly);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
return myVTKShape;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
|
||||||
// CHANGE SPECIFIC DISPLAY MODE
|
|
||||||
//-------------------------------------------------------------
|
|
||||||
void GEOM_AssemblyBuilder::SwitchDisplayMode(vtkAssembly* aOCCAssembly)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void GEOM_AssemblyBuilder::SwitchDisplayMode(vtkActorCollection* aOCCAssembly)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
|
||||||
// DISPLAY/ERASE
|
|
||||||
//-------------------------------------------------------------
|
|
||||||
|
|
||||||
void GEOM_AssemblyBuilder::DisplayErase(vtkAssembly* mySALOMEAssembly)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GEOM_AssemblyBuilder::DisplayErase(vtkActorCollection* mySALOMEActors)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
|||||||
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
|
|
||||||
//
|
|
||||||
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
||||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation; either
|
|
||||||
// version 2.1 of the License.
|
|
||||||
//
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
//
|
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
||||||
//
|
|
||||||
|
|
||||||
// GEOM OBJECT : interactive object for Geometry entities visualization
|
|
||||||
// File : GEOM_AssemblyBuilder.h
|
|
||||||
// Author : Christophe ATTANASIO
|
|
||||||
// Module : GEOM
|
|
||||||
// $Header$
|
|
||||||
//
|
|
||||||
#include "GEOM_OBJECT_defs.hxx"
|
|
||||||
|
|
||||||
class vtkProperty;
|
|
||||||
class vtkAssembly;
|
|
||||||
class vtkActorCollection;
|
|
||||||
|
|
||||||
// Open CASCADE Inlcudes
|
|
||||||
#include <TopoDS.hxx>
|
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
|
|
||||||
class GEOM_OBJECT_EXPORT GEOM_AssemblyBuilder {
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
static void InitProperties(vtkProperty* IsoProp,
|
|
||||||
vtkProperty* FaceProp,
|
|
||||||
vtkProperty* EdgeFProp,
|
|
||||||
vtkProperty* EdgeSProp,
|
|
||||||
vtkProperty* EdgeIProp,
|
|
||||||
vtkProperty* VertexProp,
|
|
||||||
vtkProperty* IsoPVProp,
|
|
||||||
vtkProperty* EdgePVProp,
|
|
||||||
vtkProperty* VertePVProp);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
// WARNING! Poor graphic performance :-( use BuildActors instead
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
static vtkAssembly* BuildAssembly(const TopoDS_Shape& myShape,
|
|
||||||
Standard_Real deflection,
|
|
||||||
Standard_Integer amode,
|
|
||||||
Standard_Boolean forced);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
// Good performance
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
static vtkActorCollection* BuildActors(const TopoDS_Shape& myShape,
|
|
||||||
Standard_Real deflection,
|
|
||||||
Standard_Integer amode,
|
|
||||||
Standard_Boolean forced,
|
|
||||||
Standard_Boolean isVector = Standard_False);
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
// Change mode - Not implemented !!
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
static void SwitchDisplayMode(vtkAssembly* mySALOMEAssembly);
|
|
||||||
static void SwitchDisplayMode(vtkActorCollection* mySALOMEActors);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
// Erase/Display - Not implemented !!
|
|
||||||
//------------------------------------------------------------------
|
|
||||||
|
|
||||||
static void DisplayErase(vtkAssembly* mySALOMEAssembly);
|
|
||||||
static void DisplayErase(vtkActorCollection* mySALOMEActors);
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
@ -28,7 +28,6 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am
|
|||||||
# header files
|
# header files
|
||||||
salomeinclude_HEADERS = \
|
salomeinclude_HEADERS = \
|
||||||
GEOM_Actor.h \
|
GEOM_Actor.h \
|
||||||
GEOM_AssemblyBuilder.h \
|
|
||||||
GEOM_AISShape.hxx \
|
GEOM_AISShape.hxx \
|
||||||
GEOM_AISShape.ixx \
|
GEOM_AISShape.ixx \
|
||||||
GEOM_AISShape.jxx \
|
GEOM_AISShape.jxx \
|
||||||
@ -51,7 +50,6 @@ lib_LTLIBRARIES = libGEOMObject.la
|
|||||||
dist_libGEOMObject_la_SOURCES = \
|
dist_libGEOMObject_la_SOURCES = \
|
||||||
GEOM_Actor.cxx \
|
GEOM_Actor.cxx \
|
||||||
GEOM_OCCReader.cxx \
|
GEOM_OCCReader.cxx \
|
||||||
GEOM_AssemblyBuilder.cxx \
|
|
||||||
GEOM_AISShape.cxx \
|
GEOM_AISShape.cxx \
|
||||||
GEOM_InteractiveObject.cxx \
|
GEOM_InteractiveObject.cxx \
|
||||||
GEOM_AISTrihedron.cxx \
|
GEOM_AISTrihedron.cxx \
|
||||||
|
@ -53,7 +53,6 @@ win32:DEFINES += WIN32
|
|||||||
DEFINES += OBJECT_EXPORTS OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS OMNIORB_VERSION=4 __x86__ __linux__ COMP_CORBA_DOUBLE COMP_CORBA_LONG
|
DEFINES += OBJECT_EXPORTS OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS OMNIORB_VERSION=4 __x86__ __linux__ COMP_CORBA_DOUBLE COMP_CORBA_LONG
|
||||||
|
|
||||||
HEADERS = GEOM_Actor.h
|
HEADERS = GEOM_Actor.h
|
||||||
HEADERS += GEOM_AssemblyBuilder.h
|
|
||||||
HEADERS += GEOM_AISShape.hxx
|
HEADERS += GEOM_AISShape.hxx
|
||||||
HEADERS += Handle_GEOM_AISShape.hxx
|
HEADERS += Handle_GEOM_AISShape.hxx
|
||||||
HEADERS += GEOM_InteractiveObject.hxx
|
HEADERS += GEOM_InteractiveObject.hxx
|
||||||
@ -65,7 +64,6 @@ HEADERS += GEOM_OBJECT_defs.hxx
|
|||||||
|
|
||||||
SOURCES = GEOM_Actor.cxx
|
SOURCES = GEOM_Actor.cxx
|
||||||
SOURCES += GEOM_OCCReader.cxx
|
SOURCES += GEOM_OCCReader.cxx
|
||||||
SOURCES += GEOM_AssemblyBuilder.cxx
|
|
||||||
SOURCES += GEOM_AISShape.cxx
|
SOURCES += GEOM_AISShape.cxx
|
||||||
SOURCES += GEOM_InteractiveObject.cxx
|
SOURCES += GEOM_InteractiveObject.cxx
|
||||||
SOURCES += GEOM_AISTrihedron.cxx
|
SOURCES += GEOM_AISTrihedron.cxx
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
|
||||||
#include <BRepBndLib.hxx>
|
#include <BRepBndLib.hxx>
|
||||||
#include <BRepMesh_IncrementalMesh.hxx>
|
#include <BRepMesh_IncrementalMesh.hxx>
|
||||||
#include <Poly_Triangulation.hxx>
|
#include <Poly_Triangulation.hxx>
|
||||||
@ -36,62 +38,51 @@
|
|||||||
#define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
|
#define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
|
||||||
#define MAX3(X, Y, Z) (MAX2(MAX2(X,Y), Z))
|
#define MAX3(X, Y, Z) (MAX2(MAX2(X,Y), Z))
|
||||||
|
|
||||||
|
|
||||||
|
#define DEFAULT_DEFLECTION 0.001
|
||||||
|
|
||||||
namespace GEOM
|
namespace GEOM
|
||||||
{
|
{
|
||||||
void MeshShape(const TopoDS_Shape theShape,
|
void MeshShape(const TopoDS_Shape theShape,
|
||||||
Standard_Real theDeflection,
|
float& theDeflection,
|
||||||
Standard_Boolean theForced)
|
bool theForced ) {
|
||||||
{
|
|
||||||
// Mesh the shape if necessary
|
Standard_Real aDeflection = theDeflection <= 0 ? DEFAULT_DEFLECTION : theDeflection;
|
||||||
Standard_Boolean alreadymesh = Standard_True;
|
|
||||||
|
//If deflection <= 0, than return default deflection
|
||||||
|
if(theDeflection <= 0)
|
||||||
|
theDeflection = aDeflection;
|
||||||
|
|
||||||
|
// Is shape triangulated?
|
||||||
|
Standard_Boolean alreadymeshed = Standard_True;
|
||||||
TopExp_Explorer ex;
|
TopExp_Explorer ex;
|
||||||
TopLoc_Location aLoc;
|
TopLoc_Location aLoc;
|
||||||
|
|
||||||
for (ex.Init(theShape, TopAbs_FACE); ex.More(); ex.Next()) {
|
for (ex.Init(theShape, TopAbs_FACE); ex.More(); ex.Next()) {
|
||||||
const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
|
const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
|
||||||
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
|
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
|
||||||
if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
|
if(aPoly.IsNull()) {
|
||||||
}
|
alreadymeshed = Standard_False;
|
||||||
|
break;
|
||||||
if(!alreadymesh || theForced) {
|
|
||||||
if(theDeflection<=0) {
|
|
||||||
// Compute default deflection
|
|
||||||
Bnd_Box B;
|
|
||||||
BRepBndLib::Add(theShape, B);
|
|
||||||
if ( B.IsVoid() ) return; // NPAL15983 (Bug when displaying empty groups)
|
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
|
||||||
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
|
||||||
theDeflection = MAX3(aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * 0.001 * 4;
|
|
||||||
}
|
}
|
||||||
BRepMesh_IncrementalMesh MESH(theShape,theDeflection);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void MeshShape2(const TopoDS_Shape& theShape,
|
if(!alreadymeshed || theForced) {
|
||||||
float& theDeflection,
|
|
||||||
bool theIsRelative)
|
|
||||||
{
|
|
||||||
static Standard_Real RELATIVE_DEFLECTION = 0.0001;
|
|
||||||
Standard_Real aDeflection = theDeflection;
|
|
||||||
|
|
||||||
if(theDeflection <= 0) { // Compute default theDeflection
|
|
||||||
Bnd_Box B;
|
Bnd_Box B;
|
||||||
BRepBndLib::Add(theShape, B);
|
BRepBndLib::Add(theShape, B);
|
||||||
|
if ( B.IsVoid() )
|
||||||
|
return; // NPAL15983 (Bug when displaying empty groups)
|
||||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||||
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||||
Standard_Real aDiagonal = (aXmax-aXmin)*(aXmax-aXmin) +
|
|
||||||
(aYmax-aYmin)*(aYmax-aYmin) +
|
|
||||||
(aZmax-aZmin)*(aZmax-aZmin);
|
|
||||||
aDiagonal = sqrt(aDiagonal);
|
|
||||||
aDeflection = aDiagonal*RELATIVE_DEFLECTION;
|
|
||||||
|
|
||||||
if(theIsRelative)
|
// This magic line comes from Prs3d_ShadedShape.gxx in OCCT
|
||||||
theDeflection = RELATIVE_DEFLECTION;
|
aDeflection = MAX3(aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * aDeflection * 4;
|
||||||
else
|
|
||||||
theDeflection = aDeflection;
|
//Clean triangulation before compute incremental mesh
|
||||||
|
BRepTools::Clean(theShape);
|
||||||
|
|
||||||
|
//Compute triangulation
|
||||||
|
BRepMesh_IncrementalMesh MESH(theShape,aDeflection);
|
||||||
}
|
}
|
||||||
|
|
||||||
BRepMesh_IncrementalMesh aMesh(theShape,aDeflection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetShape(const TopoDS_Shape& theShape,
|
void SetShape(const TopoDS_Shape& theShape,
|
||||||
@ -140,6 +131,7 @@ namespace GEOM
|
|||||||
const TopoDS_Face& aFace = TopoDS::Face(aFaceExp.Current());
|
const TopoDS_Face& aFace = TopoDS::Face(aFaceExp.Current());
|
||||||
theWireframeFaceSource->AddFace(aFace);
|
theWireframeFaceSource->AddFace(aFace);
|
||||||
theShadingFaceSource->AddFace(aFace);
|
theShadingFaceSource->AddFace(aFace);
|
||||||
|
std::cout<<"RNV face Added!!!!"<<std::endl;
|
||||||
TopExp_Explorer anEdgeExp(aFaceExp.Current(), TopAbs_EDGE);
|
TopExp_Explorer anEdgeExp(aFaceExp.Current(), TopAbs_EDGE);
|
||||||
for(; anEdgeExp.More(); anEdgeExp.Next()) {
|
for(; anEdgeExp.More(); anEdgeExp.Next()) {
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
|
const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current());
|
||||||
|
@ -33,14 +33,9 @@ namespace GEOM
|
|||||||
{
|
{
|
||||||
// moved from GEOM_AssemblyBuilder
|
// moved from GEOM_AssemblyBuilder
|
||||||
OCC2VTK_EXPORT void MeshShape(const TopoDS_Shape theShape,
|
OCC2VTK_EXPORT void MeshShape(const TopoDS_Shape theShape,
|
||||||
Standard_Real theDeflection,
|
float& theDeflection,
|
||||||
Standard_Boolean theForced);
|
bool theForced = true);
|
||||||
|
|
||||||
// moved from GEOM_Actor
|
|
||||||
OCC2VTK_EXPORT void MeshShape2(const TopoDS_Shape& theShape,
|
|
||||||
float& theDeflection,
|
|
||||||
bool theIsRelative);
|
|
||||||
|
|
||||||
// moved from GEOM_Actor
|
// moved from GEOM_Actor
|
||||||
OCC2VTK_EXPORT void SetShape(const TopoDS_Shape& theShape,
|
OCC2VTK_EXPORT void SetShape(const TopoDS_Shape& theShape,
|
||||||
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
|
const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
|
||||||
|
@ -42,6 +42,9 @@
|
|||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <Poly_Triangulation.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <BRepTools.hxx>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# if defined VTKEXPORT_EXPORTS || defined VTKExport_EXPORTS
|
# if defined VTKEXPORT_EXPORTS || defined VTKExport_EXPORTS
|
||||||
@ -85,12 +88,23 @@ extern "C"
|
|||||||
//myAppendFilter->AddInput( myWireframeFaceSource->GetOutput() ); // iso-lines are unnecessary
|
//myAppendFilter->AddInput( myWireframeFaceSource->GetOutput() ); // iso-lines are unnecessary
|
||||||
myAppendFilter->AddInput( myShadingFaceSource->GetOutput() );
|
myAppendFilter->AddInput( myShadingFaceSource->GetOutput() );
|
||||||
|
|
||||||
float aDeflection = 1.0;
|
float aDeflection = 0.001;
|
||||||
bool anIsForced = true;
|
|
||||||
bool anIsRelative = false;
|
|
||||||
bool anIsVector = false;
|
bool anIsVector = false;
|
||||||
|
|
||||||
GEOM::MeshShape( theShape, aDeflection, anIsForced );
|
// Is shape triangulated?
|
||||||
|
bool wasMeshed = true;
|
||||||
|
TopExp_Explorer ex;
|
||||||
|
TopLoc_Location aLoc;
|
||||||
|
for (ex.Init(theShape, TopAbs_FACE); ex.More(); ex.Next()) {
|
||||||
|
const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
|
||||||
|
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
|
||||||
|
if(aPoly.IsNull()) {
|
||||||
|
wasMeshed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GEOM::MeshShape( theShape, aDeflection );
|
||||||
|
|
||||||
TopExp_Explorer aVertexExp( theShape, TopAbs_VERTEX );
|
TopExp_Explorer aVertexExp( theShape, TopAbs_VERTEX );
|
||||||
for( ; aVertexExp.More(); aVertexExp.Next() )
|
for( ; aVertexExp.More(); aVertexExp.Next() )
|
||||||
@ -99,8 +113,6 @@ extern "C"
|
|||||||
myVertexSource->AddVertex( aVertex );
|
myVertexSource->AddVertex( aVertex );
|
||||||
}
|
}
|
||||||
|
|
||||||
GEOM::MeshShape2( theShape, aDeflection, anIsRelative );
|
|
||||||
|
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
|
||||||
TopExp::MapShapesAndAncestors( theShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap );
|
TopExp::MapShapesAndAncestors( theShape, TopAbs_EDGE, TopAbs_FACE, anEdgeMap );
|
||||||
|
|
||||||
@ -133,6 +145,9 @@ extern "C"
|
|||||||
|
|
||||||
myAppendFilter->Delete();
|
myAppendFilter->Delete();
|
||||||
|
|
||||||
|
if(!wasMeshed)
|
||||||
|
BRepTools::Clean(theShape);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
catch(Standard_Failure)
|
catch(Standard_Failure)
|
||||||
|
Loading…
Reference in New Issue
Block a user