#include <HYDROData_Iterator.h>
#include <HYDROData_Tool.h>
#include <AIS_DisplayMode.hxx>
-#include <Prs3d.hxx>
-#include <Prs3d_IsoAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Prs3d_ShadingAspect.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
+#include <Poly_Triangulation.hxx>
+#include <Prs3d_Root.hxx>
#include <Select3D_SensitiveBox.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_WFShape.hxx>
-#include <StdSelect.hxx>
#include <StdSelect_BRepOwner.hxx>
-#include <StdSelect_BRepSelectionTool.hxx>
#include <TopoDS_Face.hxx>
#include <QColor>
#include <QString>
-IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_Shape )
-IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_Shape )
+IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_InteractiveObject )
+IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_InteractiveObject )
HYDROGUI_LandCoverMapPrs::HYDROGUI_LandCoverMapPrs( const Handle(HYDROData_LandCoverMap)& theMap )
- : AIS_Shape( TopoDS_Shape() )
+ : AIS_InteractiveObject()
{
SetLandCoverMap( theMap );
}
void HYDROGUI_LandCoverMapPrs::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
{
myLCMap = theMap;
- Set( theMap->GetShape() );
}
Handle(Aspect_ColorScale) HYDROGUI_LandCoverMapPrs::GetColorScale() const
return Quantity_Color();
}
+void DrawTriangulation( const Handle(Prs3d_Presentation)& thePresentation,
+ const Handle(Poly_Triangulation)& theTriangulation,
+ const Quantity_Color& theColor )
+{
+ const TColgp_Array1OfPnt& aNodesArray = theTriangulation->Nodes();
+ int aNbNodes = aNodesArray.Length();
+
+ const Poly_Array1OfTriangle& aTrianglesArray = theTriangulation->Triangles();
+ int aNbTriangles = aTrianglesArray.Length();
+
+ Handle( Graphic3d_ArrayOfTriangles ) anArray = new Graphic3d_ArrayOfTriangles
+ ( aNbNodes, aNbTriangles * 3, Standard_True, Standard_True, Standard_False );
+
+ Prs3d_Root::NewGroup( thePresentation );
+ Handle( Graphic3d_Group ) aGroup = Prs3d_Root::CurrentGroup( thePresentation );
+ Handle( Graphic3d_AspectFillArea3d ) anAspect = new Graphic3d_AspectFillArea3d();
+ Graphic3d_MaterialAspect aMaterialAspect( Graphic3d_NOM_PLASTIC );
+ aMaterialAspect.SetColor( theColor );
+ anAspect->SetFrontMaterial( aMaterialAspect );
+ anAspect->SetBackMaterial( aMaterialAspect );
+
+ Standard_Integer i;
+
+ for( i = aNodesArray.Lower(); i <= aNodesArray.Upper(); i++ )
+ {
+ anArray->AddVertex( aNodesArray( i ), theColor );
+ anArray->SetVertexNormal( i, 0, 0, 1 );
+ }
+
+ Standard_Integer anIndexTriangle[3] = { 0, 0, 0 };
+ for( i = aTrianglesArray.Lower(); i<= aTrianglesArray.Upper(); i++ )
+ {
+ aTrianglesArray( i ).Get( anIndexTriangle[0], anIndexTriangle[1], anIndexTriangle[2] );
+ anArray->AddEdge( anIndexTriangle[0] );
+ anArray->AddEdge( anIndexTriangle[1] );
+ anArray->AddEdge( anIndexTriangle[2] );
+ }
+ aGroup->AddPrimitiveArray( anArray );
+ //aGroup->SetGroupPrimitivesAspect( anAspect );
+}
+
void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode )
return;
thePresentation->Clear();
- SetMaterial( Graphic3d_NOM_PLASTIC );
-
- Quantity_Color anEdgeColor = Quantity_NOC_WHITE;
- myDrawer->LineAspect()->SetColor( anEdgeColor );
- myDrawer->FaceBoundaryAspect()->SetColor( anEdgeColor );
- myDrawer->FreeBoundaryAspect()->SetColor( anEdgeColor );
- myDrawer->UIsoAspect()->SetNumber( 0 );
- myDrawer->VIsoAspect()->SetNumber( 0 );
+ const double aLinearDeflection = 1E-2;
+ BRepMesh_IncrementalMesh aMesh( myLCMap->GetShape(), aLinearDeflection );
+ aMesh.Perform();
+ bool isOK = aMesh.IsDone();
switch( theMode )
{
- case AIS_WireFrame:
case AIS_Shaded:
{
- bool isShaded = theMode==AIS_Shaded;
HYDROData_LandCoverMap::Iterator anIt( myLCMap );
for( ; anIt.More(); anIt.Next() )
{
TopoDS_Face aFace = anIt.Face();
- if( isShaded )
- {
- QString aStricklerType = anIt.StricklerType();
- Quantity_Color aColor = GetColor( aStricklerType );
- Handle(Graphic3d_AspectFillArea3d) anAspect = new Graphic3d_AspectFillArea3d();
- Graphic3d_MaterialAspect aMaterialAspect( Graphic3d_NOM_PLASTIC );
- aMaterialAspect.SetColor( aColor );
- anAspect->SetFrontMaterial( aMaterialAspect );
- anAspect->SetBackMaterial( aMaterialAspect );
-
- Handle(Graphic3d_AspectFillArea3d) aGlobalAspect = myDrawer->ShadingAspect()->Aspect();
- myDrawer->ShadingAspect()->SetAspect( anAspect );
- StdPrs_ShadedShape::Add( thePresentation, aFace, myDrawer );
- myDrawer->ShadingAspect()->SetAspect( aGlobalAspect );
-
- StdPrs_WFShape::Add( thePresentation, aFace, myDrawer );
- }
- else
- {
- StdPrs_WFShape::Add( thePresentation, aFace, myDrawer );
- }
+ QString aStricklerType = anIt.StricklerType();
+ Quantity_Color aColor = GetColor( aStricklerType );
+
+ TopLoc_Location aLocation;
+ Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation( aFace, aLocation );
+ DrawTriangulation( thePresentation, aTriangulation, aColor );
}
}
break;
if( theMode==0 )
{
- theSelection->Clear();
+ /*theSelection->Clear();
Bnd_Box B = BoundingBox();
Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner( myLCMap->GetShape(), this );
Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, B );
- theSelection->Add( aSensitiveBox );
+ theSelection->Add( aSensitiveBox );*/
}
else
{
- Standard_Real aDeflection = Prs3d::GetDeflection( myLCMap->GetShape(), myDrawer );
- HYDROData_LandCoverMap::Iterator anIt( myLCMap );
- for( ; anIt.More(); anIt.Next() )
- {
- StdSelect_BRepSelectionTool::Load( theSelection,
- this,
- anIt.Face(),
- TopAbs_FACE,
- aDeflection,
- myDrawer->HLRAngle(),
- myDrawer->IsAutoTriangulation());
- }
- StdSelect::SetDrawerForBRepOwner( theSelection, myDrawer );
+ //TODO
}
}