1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00
occt/src/IVtkVTK/IVtkVTK_ShapeData.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

151 lines
5.8 KiB
C++

// Created on: 2011-10-14
// 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 <IVtkVTK_ShapeData.hxx>
// prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER
#pragma warning(push)
#endif
#include <vtkCellData.h>
#include <vtkDoubleArray.h>
#include <vtkIdList.h>
#include <vtkIdTypeArray.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
IMPLEMENT_STANDARD_RTTIEXT(IVtkVTK_ShapeData,IVtk_IShapeData)
//================================================================
// Function : Constructor
// Purpose :
//================================================================
IVtkVTK_ShapeData::IVtkVTK_ShapeData()
{
myPolyData = vtkSmartPointer<vtkPolyData>::New();
myPolyData->Allocate();
myPolyData->SetPoints (vtkSmartPointer<vtkPoints>::New());
mySubShapeIDs = vtkSmartPointer<vtkIdTypeArray>::New();
mySubShapeIDs->SetName (IVtkVTK_ShapeData::ARRNAME_SUBSHAPE_IDS());
mySubShapeIDs->SetNumberOfComponents (1);
myPolyData->GetCellData()->AddArray (mySubShapeIDs);
myMeshTypes = vtkSmartPointer<vtkIdTypeArray>::New();
myMeshTypes->SetName (IVtkVTK_ShapeData::ARRNAME_MESH_TYPES());
myMeshTypes->SetNumberOfComponents (1);
myPolyData->GetCellData()->AddArray (myMeshTypes);
}
//================================================================
// Function : Destructor
// Purpose :
//================================================================
IVtkVTK_ShapeData::~IVtkVTK_ShapeData()
{ }
//================================================================
// Function : InsertCoordinate
// Purpose :
//================================================================
IVtk_PointId IVtkVTK_ShapeData::InsertCoordinate (double theX,
double theY,
double theZ)
{
return myPolyData->GetPoints()->InsertNextPoint (theX, theY, theZ);
}
//================================================================
// Function : InsertVertex
// Purpose :
//================================================================
void IVtkVTK_ShapeData::InsertVertex (const IVtk_IdType theShapeID,
const IVtk_PointId thePointId,
const IVtk_MeshType theMeshType)
{
vtkIdType aPointIdVTK = thePointId;
myPolyData->InsertNextCell (VTK_VERTEX, 1, &aPointIdVTK);
const vtkIdType aShapeIDVTK = theShapeID;
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
const vtkIdType aType = theMeshType;
myMeshTypes->InsertNextTupleValue (&aType);
}
//================================================================
// Function : InsertLine
// Purpose :
//================================================================
void IVtkVTK_ShapeData::InsertLine (const IVtk_IdType theShapeID,
const IVtk_PointId thePointId1,
const IVtk_PointId thePointId2,
const IVtk_MeshType theMeshType)
{
vtkIdType aPoints[2] = { thePointId1, thePointId2 };
myPolyData->InsertNextCell (VTK_LINE, 2, aPoints);
const vtkIdType aShapeIDVTK = theShapeID;
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
const vtkIdType aType = theMeshType;
myMeshTypes->InsertNextTupleValue (&aType);
}
//================================================================
// Function : InsertLine
// Purpose :
//================================================================
void IVtkVTK_ShapeData::InsertLine (const IVtk_IdType theShapeID,
const IVtk_PointIdList* thePointIds,
const IVtk_MeshType theMeshType)
{
if (!thePointIds->IsEmpty())
{
vtkSmartPointer<vtkIdList> anIdList = vtkSmartPointer<vtkIdList>::New();
// Fill the vtk id list by ids from IVtk_PointIdList.
IVtk_PointIdList::Iterator anIterOfIds =
IVtk_PointIdList::Iterator(*thePointIds);
anIdList->Allocate(thePointIds->Extent());
for(; anIterOfIds.More(); anIterOfIds.Next())
{
anIdList->InsertNextId (anIterOfIds.Value());
}
myPolyData->InsertNextCell (VTK_POLY_LINE, anIdList);
const vtkIdType aShapeIDVTK = theShapeID;
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
const vtkIdType aType = theMeshType;
myMeshTypes->InsertNextTupleValue (&aType);
}
}
//================================================================
// Function : InsertTriangle
// Purpose :
//================================================================
void IVtkVTK_ShapeData::InsertTriangle (const IVtk_IdType theShapeID,
const IVtk_PointId thePointId1,
const IVtk_PointId thePointId2,
const IVtk_PointId thePointId3,
const IVtk_MeshType theMeshType)
{
vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
myPolyData->InsertNextCell (VTK_TRIANGLE, 3, aPoints);
const vtkIdType aShapeIDVTK = theShapeID;
mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
const vtkIdType aType = theMeshType;
myMeshTypes->InsertNextTupleValue (&aType);
}