1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00
occt/src/IVtkTools/IVtkTools.cxx
abv 68df847802 0022651: Impossible to build OCC as static library due to using Standard_EXPORT instead of Standard_API
All library-specific macros for defining export / import properties of symbols on Windows (like Standard_API, __Draw_API, _math_API etc.) are eliminated.
Common macro Standard_EXPORT is used in all places where it is necessary.

New macro OCCT_STATIC_BUILD is defined for disabling Standard_EXPORT, to be used instead of HAVE_NO_DLL, though the latter is still supported as well (for compatibility).

To allow building OCCT in static mode on Windows after these changes:
- Files OSD_WNT_1.hxx and OSD_WNT_BREAK.hxx are removed; useful declarations are moved to OSD_WNT.hxx
- In the class IVtkVTK_ShapeData, static fields ARRNAME_MESH_TYPES and ARRNAME_SUBSHAPE_IDS are converted to static inline functions
- Global array ChoixRef defined in IntImp_ComputeTangence.cxx is converted to static function returning element of the array by index
- Unused class Quantity_Convert is removed (it had static field accessed by inline method)
- Struct Approx_Data defined in the same way in BRepApprox_Approx.hxx and GeomInt_WLApprox.hxx is made private member of these classes to avoid name clash
- Some C++ files producing no object code are removed
- In NCollection_EBTree.hxx and StdLPersistent_Collectio.hxx, definition of template virtual method is moved to class definition to avoid MSVC linker warnings on unused symbols
2018-03-19 13:13:39 +03:00

135 lines
5.4 KiB
C++

// 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>
// prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER
#pragma warning(push)
#endif
#include <vtkLookupTable.h>
#include <vtkMapper.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
namespace IVtkTools
{
//============================================================================
// Method: InitLookupTable
// Purpose: Returns vtkLookupTable instance initialized by standrad OCCT colors.
//============================================================================
vtkSmartPointer<vtkLookupTable> InitLookupTable()
{
vtkSmartPointer<vtkLookupTable> aColorTable =
vtkSmartPointer<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();
}
} // namespace IVtkTools