1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +03:00

0024904: Visualization - Integration of VIS component:

Added new toolkit TKIVtk:
- TKIVtk toolkit includes IVtkVTK, IVtkTools, IVtkOCC, IVtk packages.
- TKIVtk provides OCC interface for VTK library functionality: it allows to use VTK window and event managment for OCC objects (shapes)

Porting on VTK 6:
- shape source inherits vtkPolyDataAlgorithm now (vtkPolyDataSource was removed form VTK as deprecated functionality).
- added factory auto-initialization in IVtkVTK_View
- remove using of deprecated methods of pipeline mechanism.

Get rid from warning in SelectMgr_SelectableObject. Removed firendship from  SelectMgr_SelectableObject.

Corrected projector parameters for selection algorithm.

Removed unneeded picking algorithm modification.
This commit is contained in:
aba
2014-09-11 13:34:30 +04:00
committed by bugmaster
parent 1ffd3d70c2
commit 913a4c4ab0
54 changed files with 5581 additions and 21 deletions

124
src/IVtkTools/IVtkTools.cxx Normal file
View File

@@ -0,0 +1,124 @@
// Created on: 2011-12-20
// Created by: Roman KOZLOV
// Copyright (c) 2011-2014 OPEN CASCADE SAS
//
//This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <IVtkTools.hxx>
#include <IVtkVTK_ShapeData.hxx>
#include <vtkLookupTable.h>
#include <vtkMapper.h>
namespace IVtkTools
{
//============================================================================
// Method: InitLookupTable
// Purpose: Returns vtkLookupTable instance initialized by standrad OCCT colors.
//============================================================================
vtkLookupTable* InitLookupTable()
{
vtkLookupTable* aColorTable = vtkLookupTable::New();
// Set colors table for 3D shapes
double aRange[2];
aRange[0] = MT_Undefined;
aRange[1] = MT_ShadedFace;
aColorTable->Allocate (9);
aColorTable->SetNumberOfTableValues (9);
aColorTable->SetTableRange (aRange);
aColorTable->SetValueRange (0, 1);
/*
MT_Undefined = -1 Undefined
MT_IsoLine = 0 IsoLine
MT_FreeVertex = 1 Free vertex
MT_SharedVertex = 2 Shared vertex
MT_FreeEdge = 3 Free edge
MT_BoundaryEdge = 4 Boundary edge (related to a single face)
MT_SharedEdge = 5 Shared edge (related to several faces)
MT_WireFrameFace = 6 Wireframe face
MT_ShadedFace = 7 Shaded face
*/
aColorTable->SetTableValue (0, 0, 0, 0); // Undefined
aColorTable->SetTableValue (1, 0.5, 0.5, 0.5); // gray for IsoLine
aColorTable->SetTableValue (2, 1, 0, 0); // red for Free vertex
aColorTable->SetTableValue (3, 1, 1, 0); // yellow for Shared vertex
aColorTable->SetTableValue (4, 1, 0, 0); // red for Free edge
aColorTable->SetTableValue (5, 0, 1, 0); // green for Boundary edge (related to a single face)
aColorTable->SetTableValue (6, 1, 1, 0); // yellow for Shared edge (related to several faces)
aColorTable->SetTableValue (7, 1, 1, 0); // yellow for Wireframe face
aColorTable->SetTableValue (8, 1, 1, 0); // yellow for Shaded face
return aColorTable;
}
//============================================================================
// Method: SetLookupTableColor
// Purpose: Set a color for given type of sub-shapes.
//============================================================================
void SetLookupTableColor (vtkLookupTable* theColorTable,
const IVtk_MeshType theColorRole,
const double theR, const double theG, const double theB,
const double /*theA*/)
{
theColorTable->SetTableValue (theColorRole + 1, theR, theG, theB);
}
//============================================================================
// Method: GetLookupTableColor
// Purpose: Get a color for given type of sub-shapes.
//============================================================================
void GetLookupTableColor (vtkLookupTable* theColorTable,
const IVtk_MeshType theColorRole,
double &theR, double &theG, double &theB)
{
double aRgb[3];
theColorTable->GetColor (theColorRole + 1, aRgb);
theR = aRgb[0];
theG = aRgb[1];
theB = aRgb[2];
}
//============================================================================
// Method: GetLookupTableColor
// Purpose: Get a color for given type of sub-shapes.
//============================================================================
void GetLookupTableColor (vtkLookupTable* theColorTable,
const IVtk_MeshType theColorRole,
double &theR, double &theG, double &theB,
double &theA)
{
theA = theColorTable->GetOpacity (theColorRole + 1);
GetLookupTableColor (theColorTable, theColorRole, theR, theG, theB);
}
//============================================================================
// Method: InitShapeMapper
// Purpose: Set up the initial shape mapper parameters with default OCC colors.
//============================================================================
void InitShapeMapper (vtkMapper* theMapper)
{
InitShapeMapper (theMapper, InitLookupTable());
}
//============================================================================
// Method: InitShapeMapper
// Purpose: Set up the initial shape mapper parameters with user colors.
//============================================================================
void InitShapeMapper (vtkMapper* theMapper, vtkLookupTable* theColorTable)
{
theMapper->ScalarVisibilityOn();
theMapper->SetScalarModeToUseCellFieldData();
theMapper->SelectColorArray (IVtkVTK_ShapeData::ARRNAME_MESH_TYPES);
theMapper->SetColorModeToMapScalars();
theMapper->SetScalarRange (theColorTable->GetRange());
theMapper->SetLookupTable (theColorTable);
theMapper->Update();
}
};