├── .gitattributes ├── .gitignore ├── plugin.cmake ├── OCCReaderUserInterfaceSources.xml ├── OCC2VTK.h ├── GEOM_ShadingFace.h ├── README.md ├── GEOM_FaceSource.cxx ├── GEOM_FaceSource.h ├── GEOM_VertexSource.h ├── GEOM_EdgeSource.h ├── GEOM_VertexSource.cxx ├── OCCReaderServerManager.xml ├── CMakeLists.txt ├── vtkOCCReader.h ├── GEOM_WireframeFace.h ├── GEOM_ShadingFace.cxx ├── FindCAS.cmake ├── GEOM_EdgeSource.cxx ├── README_Install.md ├── vtkOCCReader.cxx └── GEOM_WireframeFace.cxx /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | CMakeLists.txt~ 45 | FindCAS.cmake.bak 46 | *.user 47 | CMakeLists.txt.bak 48 | *.bak 49 | -------------------------------------------------------------------------------- /plugin.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014-2015 KIT-INR/NK 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2.1 of the License. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the Free Software 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | # 17 | # 18 | 19 | pv_plugin(OCCReader 20 | DESCRIPTION "Fetch CAD data from BREP, IGES, and STEP files" 21 | DEFAULT_ENABLED 22 | ) 23 | -------------------------------------------------------------------------------- /OCCReaderUserInterfaceSources.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /OCC2VTK.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #ifndef OCC2VTK_H 20 | #define OCC2VTK_H 21 | 22 | #if defined WIN32 23 | # if defined OCC2VTK_EXPORTS 24 | # define OCC2VTK_EXPORT __declspec( dllexport ) 25 | # elif defined OCCReader_EXPORTS 26 | # define OCC2VTK_EXPORT __declspec( dllexport ) 27 | # else 28 | # define OCC2VTK_EXPORT __declspec( dllimport ) 29 | # endif 30 | #else 31 | # define OCC2VTK_EXPORT 32 | #endif 33 | 34 | #endif // OCC2VTK_H 35 | -------------------------------------------------------------------------------- /GEOM_ShadingFace.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #ifndef GEOM_SHADINGFACE_H 20 | #define GEOM_SHADINGFACE_H 21 | #ifdef WNT 22 | #define OCCReader_EXPORTS 23 | #endif 24 | #include "OCC2VTK.h" 25 | #include "GEOM_FaceSource.h" 26 | 27 | class OCC2VTK_EXPORT GEOM_ShadingFace: public GEOM_FaceSource 28 | { 29 | public: 30 | vtkTypeMacro(GEOM_ShadingFace,GEOM_FaceSource); 31 | static GEOM_ShadingFace* New(); 32 | 33 | static 34 | void OCC2VTK(const TopoDS_Face& theFace, 35 | vtkPolyData* theCells, 36 | vtkPoints* thePts); 37 | 38 | protected: 39 | virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 40 | 41 | GEOM_ShadingFace(); 42 | ~GEOM_ShadingFace(); 43 | 44 | private: 45 | // Not implememnted 46 | GEOM_ShadingFace(const GEOM_ShadingFace&); 47 | void operator=(const GEOM_ShadingFace&); 48 | }; 49 | 50 | 51 | #endif //GEOM_SHADINGFACE_H 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ******************************************************************************** 2 | OCCReader --- 3 | A plugin for visualizing CAD file in STEP,IGES and BREP format in ParaView. 4 | ******************************************************************************** 5 | 6 | OCCReader is a ParaView plugin for importing CAD files in Open CASCADE (OCC) 7 | open-source format STEP, IGES and BREP and visualizing in ParaView. This 8 | plugin facetes CAD solids into VTK Polydata. With this plugin, the CAD 9 | geometry can be visualized together with physical fields, so that the 10 | traditional way of using STL file to visualizing geometry can be avoided. 11 | Three dispaly modes are provided-- wireframe(mode 1), shading(mode 2) and 12 | wireframe+shading (mode 3). The faceting accuracy can by increase by 13 | adjusting the "Deflection" parameter. This document provides instrutions for 14 | compiling the plugin. 15 | 16 | This plugin is developed based on the open-source SALOME platform with 17 | reuesage of classes. The LGPL lincese should be obeyed, see detail License 18 | Agreement of this plugin. 19 | 20 | Compiling this plugin ONLY IF the provided pre-compiled binary libraries are 21 | not suitable for your platform. This compilation is not straight-forward. Pre- 22 | compiled binary libraries are provided in the Github named as 23 | "OCCReader_Binaries". For compilation, see README_Install for more information. 24 | 25 | For any questions related to the use of this software/library you may contact 26 | Ulrich Fischer(ulrich.fischer@kit.edu) or, for technical assistance, contact 27 | Yuefeng Qiu (Yuefeng.qiu@kit.edu). 28 | 29 | Have fun playing with it! :) 30 | 31 | 32 | -------------------------------------------------------------------------------- /GEOM_FaceSource.cxx: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #include "GEOM_FaceSource.h" 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | GEOM_FaceSource::GEOM_FaceSource() 30 | { 31 | this->SetNumberOfInputPorts(0); 32 | } 33 | 34 | GEOM_FaceSource::~GEOM_FaceSource() 35 | { 36 | } 37 | 38 | void 39 | GEOM_FaceSource:: 40 | AddFace(const TopoDS_Face& theFace) 41 | { 42 | myFaceSet.Add(theFace); 43 | } 44 | 45 | void 46 | GEOM_FaceSource:: 47 | MoveTo(gp_Pnt thePnt, 48 | vtkPoints* thePts) 49 | { 50 | thePts->InsertNextPoint(thePnt.X(), thePnt.Y(), thePnt.Z()); 51 | } 52 | 53 | void 54 | GEOM_FaceSource:: 55 | DrawTo(gp_Pnt thePnt, 56 | vtkPolyData* thePolyData, 57 | vtkPoints* thePts) 58 | { 59 | vtkIdType anId = 60 | thePts->InsertNextPoint(thePnt.X(), thePnt.Y(), thePnt.Z()); 61 | vtkIdType anIds[2] = {anId-1, anId}; 62 | thePolyData->InsertNextCell(VTK_LINE,2,anIds); 63 | } 64 | -------------------------------------------------------------------------------- /GEOM_FaceSource.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #ifndef GEOM_FACESOURCE_H 20 | #define GEOM_FACESOURCE_H 21 | #ifdef WNT 22 | #define OCCReader_EXPORTS 23 | #endif 24 | #include "OCC2VTK.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | typedef NCollection_Set TFaceSet; 32 | 33 | #include 34 | #include 35 | 36 | class vtkPolyData; 37 | 38 | class OCC2VTK_EXPORT GEOM_FaceSource: public vtkPolyDataAlgorithm 39 | { 40 | public: 41 | vtkTypeMacro(GEOM_FaceSource,vtkPolyDataAlgorithm); 42 | 43 | void AddFace(const TopoDS_Face& theFace); 44 | void Clear(){ myFaceSet.Clear();} 45 | bool IsEmpty(){return myFaceSet.IsEmpty();} 46 | 47 | protected: 48 | TFaceSet myFaceSet; 49 | 50 | static 51 | void MoveTo(gp_Pnt thePnt, 52 | vtkPoints* thePts); 53 | static 54 | void DrawTo(gp_Pnt thePnt, 55 | vtkPolyData* thePolyData, 56 | vtkPoints* thePts); 57 | 58 | GEOM_FaceSource(); 59 | ~GEOM_FaceSource(); 60 | 61 | private: 62 | // Not implememnted 63 | GEOM_FaceSource(const GEOM_FaceSource&); 64 | void operator=(const GEOM_FaceSource&); 65 | }; 66 | 67 | 68 | #endif //GEOM_FACESOURCE_H 69 | -------------------------------------------------------------------------------- /GEOM_VertexSource.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #ifndef GEOM_VERTEXSOURCE_H 20 | #define GEOM_VERTEXSOURCE_H 21 | #ifdef WNT 22 | #define OCCReader_EXPORTS 23 | #endif 24 | #include "OCC2VTK.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | typedef NCollection_Set TVertexSet; 31 | 32 | #include 33 | #include 34 | 35 | class vtkPolyData; 36 | 37 | class OCC2VTK_EXPORT GEOM_VertexSource: public vtkPolyDataAlgorithm 38 | { 39 | public: 40 | vtkTypeMacro(GEOM_VertexSource,vtkPolyDataAlgorithm); 41 | static GEOM_VertexSource* New(); 42 | 43 | void AddVertex(const TopoDS_Vertex& theVertex); 44 | void Clear(){ myVertexSet.Clear();} 45 | 46 | static 47 | void OCC2VTK(const TopoDS_Vertex& theVertex, 48 | vtkPolyData* thePolyData, 49 | vtkPoints* thePts); 50 | 51 | protected: 52 | TVertexSet myVertexSet; 53 | 54 | virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 55 | 56 | GEOM_VertexSource(); 57 | ~GEOM_VertexSource(); 58 | 59 | private: 60 | // Not implememnted 61 | GEOM_VertexSource(const GEOM_VertexSource&); 62 | void operator=(const GEOM_VertexSource&); 63 | }; 64 | 65 | 66 | #endif //GEOM_VERTEXSOURCE_H 67 | -------------------------------------------------------------------------------- /GEOM_EdgeSource.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #ifndef GEOM_EDGESOURCE_H 20 | #define GEOM_EDGESOURCE_H 21 | #ifdef WNT 22 | #define OCCReader_EXPORTS 23 | #endif 24 | #include "OCC2VTK.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | typedef NCollection_Set TEdgeSet; 31 | 32 | #include 33 | #include 34 | 35 | class vtkPolyData; 36 | 37 | class OCC2VTK_EXPORT GEOM_EdgeSource: public vtkPolyDataAlgorithm 38 | { 39 | public: 40 | vtkTypeMacro(GEOM_EdgeSource,vtkPolyDataAlgorithm); 41 | static GEOM_EdgeSource* New(); 42 | 43 | void AddEdge (const TopoDS_Edge& theEdge, 44 | bool theIsVector = false); 45 | void Clear(){ myEdgeSet.Clear();} 46 | 47 | void SetVectorMode(bool); 48 | 49 | bool GetVectorMode(); 50 | 51 | static 52 | void OCC2VTK(const TopoDS_Edge& theEdge, 53 | vtkPolyData* thePolyData, 54 | vtkPoints* thePts, 55 | bool theIsVector = false); 56 | 57 | bool IsEmpty(){return myEdgeSet.IsEmpty();} 58 | 59 | 60 | protected: 61 | TEdgeSet myEdgeSet; 62 | // The flag is common for all edges, because the shape, 63 | // representing a vector, can have only one edge. 64 | bool myIsVector, myIsVectorMode; 65 | 66 | virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 67 | 68 | GEOM_EdgeSource(); 69 | ~GEOM_EdgeSource(); 70 | 71 | private: 72 | // Not implememnted 73 | GEOM_EdgeSource(const GEOM_EdgeSource&); 74 | void operator=(const GEOM_EdgeSource&); 75 | }; 76 | 77 | 78 | #endif //GEOM_EDGESOURCE_H 79 | -------------------------------------------------------------------------------- /GEOM_VertexSource.cxx: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #include "GEOM_VertexSource.h" 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | vtkStandardNewMacro(GEOM_VertexSource); 34 | 35 | GEOM_VertexSource::GEOM_VertexSource() 36 | { 37 | this->SetNumberOfInputPorts(0); 38 | } 39 | 40 | GEOM_VertexSource::~GEOM_VertexSource() 41 | { 42 | } 43 | 44 | void 45 | GEOM_VertexSource:: 46 | AddVertex(const TopoDS_Vertex& theVertex) 47 | { 48 | myVertexSet.Add(theVertex); 49 | } 50 | 51 | int GEOM_VertexSource::RequestData(vtkInformation *vtkNotUsed(request), 52 | vtkInformationVector **vtkNotUsed(inputVector), 53 | vtkInformationVector *outputVector) 54 | { 55 | vtkInformation *outInfo = outputVector->GetInformationObject(0); 56 | vtkPolyData *aPolyData = vtkPolyData::SafeDownCast( 57 | outInfo->Get(vtkDataObject::DATA_OBJECT())); 58 | 59 | aPolyData->Allocate(); 60 | vtkPoints* aPts = vtkPoints::New(); 61 | aPolyData->SetPoints(aPts); 62 | aPts->Delete(); 63 | 64 | TVertexSet::Iterator anIter(myVertexSet); 65 | for(; anIter.More(); anIter.Next()){ 66 | const TopoDS_Vertex& aVertex = anIter.Value(); 67 | OCC2VTK(aVertex,aPolyData,aPts); 68 | } 69 | return 1; 70 | } 71 | 72 | void 73 | GEOM_VertexSource:: 74 | OCC2VTK(const TopoDS_Vertex& theVertex, 75 | vtkPolyData* thePolyData, 76 | vtkPoints* thePts) 77 | { 78 | gp_Pnt aPnt = BRep_Tool::Pnt(theVertex); 79 | vtkIdType anId = thePts->InsertNextPoint(aPnt.X(),aPnt.Y(),aPnt.Z()); 80 | thePolyData->InsertNextCell(VTK_VERTEX,1,&anId); 81 | } 82 | -------------------------------------------------------------------------------- /OCCReaderServerManager.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 21 | 22 | 25 | 28 | Reading CAD data from BREP, IGES, and STEP files. 29 | 30 | 35 | 36 | 37 | This property specifies the file name for the table reader. 38 | 39 | 40 | 45 | 46 | 47 | This property specifies the dispaly mode, 1 is wireframe , 48 | 2 is shading, and 3 is wireframe + shading. 49 | 50 | 51 | 52 | 57 | 58 | 59 | This property specifies smoothing of the shading. 60 | 61 | 62 | 63 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014-2015 KIT-INR/NK 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2.1 of the License. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # 14 | # You should have received a copy of the GNU Lesser General Public 15 | # License along with this library; if not, write to the Free Software 16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | # 18 | # 19 | 20 | PROJECT( OCCReader ) 21 | 22 | CMAKE_MINIMUM_REQUIRED( VERSION 2.8.7 ) 23 | 24 | 25 | 26 | SET(CMAKE_BUILD_TYPE Release) 27 | MARK_AS_ADVANCED( 28 | LIBRARY_OUTPUT_PATH 29 | EXECUTABLE_OUTPUT_PATH 30 | ) 31 | #Package ParaView is under build folder. 32 | SET(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}) 33 | 34 | IF(WIN32) 35 | MESSAGE( Windows system ) 36 | SET(WINDOWS TRUE) 37 | ADD_DEFINITIONS(-DWNT) 38 | ENDIF(WIN32) 39 | 40 | FIND_PACKAGE( ParaView COMPONENTS pqCore NO_MODULE) 41 | 42 | IF( ParaView_FOUND ) 43 | 44 | INCLUDE(${OCCReader_SOURCE_DIR}/FindCAS.cmake) 45 | INCLUDE_DIRECTORIES( ${CAS_INCLUDE_DIRS}) 46 | 47 | INCLUDE( ${PARAVIEW_USE_FILE} ) 48 | 49 | 50 | 51 | FIND_PACKAGE( VTK COMPONENTS vtkClientServer NO_MODULE) 52 | FIND_PACKAGE( VTK COMPONENTS vtkCommonDataModel NO_MODULE) 53 | FIND_PACKAGE( VTK COMPONENTS vtkCommonExecutionModel NO_MODULE) 54 | INCLUDE( ${VTK_USE_FILE} ) 55 | 56 | SET( OCCREADER_SRCS 57 | ${OCCReader_SOURCE_DIR}/vtkOCCReader.cxx 58 | ${OCCReader_SOURCE_DIR}/GEOM_EdgeSource.cxx 59 | ${OCCReader_SOURCE_DIR}/GEOM_FaceSource.cxx 60 | ${OCCReader_SOURCE_DIR}/GEOM_ShadingFace.cxx 61 | ${OCCReader_SOURCE_DIR}/GEOM_VertexSource.cxx 62 | ${OCCReader_SOURCE_DIR}/GEOM_WireframeFace.cxx 63 | ) 64 | 65 | 66 | 67 | ADD_PARAVIEW_PLUGIN( OCCReader "1.0" 68 | SERVER_MANAGER_XML OCCReaderServerManager.xml 69 | SERVER_MANAGER_SOURCES ${OCCREADER_SRCS} 70 | REQUIRED_ON_SERVER) 71 | 72 | TARGET_LINK_LIBRARIES(OCCReader 73 | vtkCommonDataModel 74 | vtkCommonExecutionModel 75 | vtkClientServer 76 | pqCore 77 | ${TKG3d} 78 | ${TKGeomBase} 79 | ${TKGeomAlgo} 80 | ${TKBRep} 81 | ${TKTopAlgo} 82 | ${TKG2d} 83 | ${TKMesh} 84 | ${TKSTEP} 85 | ${TKCAF} 86 | ${TKLCAF} 87 | ${TKSTEPBase} 88 | ${TKIGES} 89 | ) 90 | 91 | 92 | ENDIF( ParaView_FOUND ) 93 | 94 | -------------------------------------------------------------------------------- /vtkOCCReader.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | 20 | #ifndef __vtkOCCReader_h 21 | #define __vtkOCCReader_h 22 | 23 | #define OCCReader_EXPORTS 24 | 25 | #include "OCC2VTK.h" 26 | #include "vtkPolyDataAlgorithm.h" 27 | #include 28 | //#include 29 | 30 | #include "GEOM_VertexSource.h" 31 | #include "GEOM_EdgeSource.h" 32 | #include "GEOM_WireframeFace.h" 33 | #include "GEOM_ShadingFace.h" 34 | #include 35 | 36 | //#include 37 | class vtkDoubleArray; 38 | class vtkUnstructuredGrid; 39 | 40 | 41 | class vtkOCCReader : public vtkAlgorithm // 42 | { 43 | public: 44 | vtkTypeMacro(vtkOCCReader, vtkAlgorithm) 45 | OCC2VTK_EXPORT static vtkOCCReader* New(); 46 | virtual void PrintSelf( ostream& os, vtkIndent indent ); 47 | // virtual const char *GetFileName(); 48 | // virtual void SetFileName(const char *FileName); 49 | // Specifies the name of the file 50 | vtkGetStringMacro(FileName); 51 | vtkSetStringMacro(FileName); 52 | // void SetBufferingPolicy(int pol); 53 | // int GetBufferingPolicy(); 54 | void SetMode(int dispMode); 55 | int getMode(); 56 | void SetDeflection(double aDeflection); 57 | double getDeflection(); 58 | protected: 59 | vtkOCCReader(); 60 | virtual ~vtkOCCReader(); 61 | int FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info); 62 | int ProcessRequest(vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector); 63 | virtual int RequestData( vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo ); 64 | int DispMode; //1-wireframe 2-shading 65 | float myDeflection; //for adjusting the smoothing of the shading 66 | 67 | vtkPointData *MyDataSet; 68 | // std::string myFileName; 69 | // name of the file to read 70 | char* FileName; 71 | //not clean but to avoid to include CORBA.h in this *.h 72 | static void *Orb; 73 | 74 | vtkOCCReader( const vtkOCCReader& ); // Not implemented. 75 | void operator = ( const vtkOCCReader& ); // Not implemented. 76 | }; 77 | 78 | #endif // __vtkOCCReader_h 79 | 80 | -------------------------------------------------------------------------------- /GEOM_WireframeFace.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #ifndef GEOM_WIREFRAME_FACE_H 20 | #define GEOM_WIREFRAME_FACE_H 21 | #ifdef WNT 22 | #define OCCReader_EXPORTS 23 | #endif 24 | #include "OCC2VTK.h" 25 | #include "GEOM_FaceSource.h" 26 | 27 | #include 28 | #include 29 | 30 | class vtkPolyData; 31 | 32 | class OCC2VTK_EXPORT GEOM_WireframeFace: public GEOM_FaceSource 33 | { 34 | public: 35 | vtkTypeMacro(GEOM_WireframeFace,GEOM_FaceSource); 36 | static GEOM_WireframeFace* New(); 37 | 38 | /* vtkSetMacro(NbIso,int); 39 | vtkGetMacro(NbIso,int);*/ 40 | 41 | vtkSetMacro(Discret,int); 42 | vtkGetMacro(Discret,int); 43 | 44 | static 45 | void OCC2VTK(const TopoDS_Face& theFace, 46 | vtkPolyData* thePolyData, 47 | vtkPoints* thePts, 48 | const int theNbIso[2], 49 | const int theDiscret = 15); 50 | 51 | //! IsoLines management 52 | // theNb[0] - number of U lines 53 | // theNb[1] - number of V lines 54 | virtual void SetNbIso(const int theNb[2]); 55 | virtual void GetNbIso(int &theNbU,int &theNbV); 56 | 57 | protected: 58 | int NbIso[2], Discret; 59 | 60 | static 61 | void 62 | CreateIso(const TopoDS_Face& theFace, 63 | const int theNbIso[2], 64 | const int theDiscret, 65 | vtkPolyData* thePolyData, 66 | vtkPoints* thePts); 67 | 68 | static 69 | void 70 | CreateIso_(const TopoDS_Face& theFace, 71 | GeomAbs_IsoType theIsoType, 72 | Standard_Real Par, 73 | Standard_Real T1, 74 | Standard_Real T2, 75 | const int theDiscret, 76 | vtkPolyData* thePolyData, 77 | vtkPoints* thePts); 78 | 79 | static 80 | void 81 | CreateIso__(const BRepAdaptor_Surface& theSurface, 82 | GeomAbs_IsoType theIsoType, 83 | Standard_Real& theU, 84 | Standard_Real& theV, 85 | Standard_Real theStep, 86 | vtkPolyData* thePolyData, 87 | vtkPoints* thePts); 88 | 89 | virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 90 | 91 | GEOM_WireframeFace(); 92 | ~GEOM_WireframeFace(); 93 | 94 | private: 95 | // Not implememnted 96 | GEOM_WireframeFace(const GEOM_WireframeFace&); 97 | void operator=(const GEOM_WireframeFace&); 98 | }; 99 | 100 | 101 | #endif //GEOM_WFACEACTOR_H 102 | -------------------------------------------------------------------------------- /GEOM_ShadingFace.cxx: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #include "GEOM_ShadingFace.h" 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | 35 | vtkStandardNewMacro(GEOM_ShadingFace); 36 | 37 | GEOM_ShadingFace::GEOM_ShadingFace() 38 | { 39 | this->SetNumberOfInputPorts(0); 40 | } 41 | 42 | GEOM_ShadingFace::~GEOM_ShadingFace() 43 | { 44 | } 45 | 46 | int GEOM_ShadingFace::RequestData(vtkInformation *vtkNotUsed(request), 47 | vtkInformationVector **vtkNotUsed(inputVector), 48 | vtkInformationVector *outputVector) 49 | { 50 | vtkInformation *outInfo = outputVector->GetInformationObject(0); 51 | vtkPolyData *aPolyData = vtkPolyData::SafeDownCast( 52 | outInfo->Get(vtkDataObject::DATA_OBJECT())); 53 | 54 | aPolyData->Allocate(); 55 | vtkPoints* aPts = vtkPoints::New(); 56 | aPolyData->SetPoints(aPts); 57 | aPts->Delete(); 58 | 59 | TFaceSet::Iterator anIter(myFaceSet); 60 | for(; anIter.More(); anIter.Next()){ 61 | const TopoDS_Face& aFace = anIter.Value(); 62 | OCC2VTK(aFace,aPolyData,aPts); 63 | } 64 | return 1; 65 | } 66 | 67 | void 68 | GEOM_ShadingFace:: 69 | OCC2VTK(const TopoDS_Face& theFace, 70 | vtkPolyData* thePolyData, 71 | vtkPoints* thePts) 72 | { 73 | TopLoc_Location aLoc; 74 | Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(theFace,aLoc); 75 | if(aPoly.IsNull()) 76 | return; 77 | else{ 78 | gp_Trsf myTransf; 79 | Standard_Boolean identity = true; 80 | if(!aLoc.IsIdentity()){ 81 | identity = false; 82 | myTransf = aLoc.Transformation(); 83 | } 84 | 85 | Standard_Integer i; 86 | int aNbOfNodes = thePts->GetNumberOfPoints(); 87 | const TColgp_Array1OfPnt& Nodes = aPoly->Nodes(); 88 | Standard_Integer nbNodesInFace = aPoly->NbNodes(); 89 | for(i = 1; i <= nbNodesInFace; i++) { 90 | gp_Pnt P = Nodes(i); 91 | if(!identity) 92 | P.Transform(myTransf); 93 | thePts->InsertNextPoint(P.X(),P.Y(),P.Z()); 94 | } 95 | 96 | const Poly_Array1OfTriangle& Triangles = aPoly->Triangles(); 97 | Standard_Integer nbTriInFace = aPoly->NbTriangles(); 98 | for(i = 1; i <= nbTriInFace; i++){ 99 | // Get the triangle 100 | Standard_Integer N1,N2,N3; 101 | Triangles(i).Get(N1,N2,N3); 102 | N1 += aNbOfNodes - 1; 103 | N2 += aNbOfNodes - 1; 104 | N3 += aNbOfNodes - 1; 105 | vtkIdType anIds[3] = {N1, N2, N3}; 106 | thePolyData->InsertNextCell(VTK_TRIANGLE,3,anIds); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /FindCAS.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014-2015 KIT-INR/NK 2 | # 3 | # This library is free software; you can redistribute it and/or 4 | # modify it under the terms of the GNU Lesser General Public 5 | # License as published by the Free Software Foundation; either 6 | # version 2.1 of the License. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public 14 | # License along with this library; if not, write to the Free Software 15 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | # 17 | 18 | #SET(CASROOT $ENV{CAS_ROOT_DIR}) 19 | SET(CASROOT $ENV{CASROOT}) 20 | MESSAGE( ${CASROOT} ) 21 | # SET(OCC_VERSION_MAJOR 6) 22 | # SET(OCC_VERSION_MINOR 7) 23 | # SET(OCC_VERSION_MAINTENANCE 10) 24 | SET(CAS_VERSION_DEVELOPMENT 0) 25 | 26 | FIND_FILE(ff Standard_Version.hxx ${CASROOT}/include/opencascade ${CASROOT}/inc) 27 | IF(ff) 28 | FILE(STRINGS ${ff} CAS_VERSION_DEVELOPMENT_STR 29 | REGEX "^ *#define OCC_VERSION_DEVELOPMENT *\"dev\".*$") 30 | IF(CAS_VERSION_DEVELOPMENT_STR) 31 | SET(CAS_VERSION_DEVELOPMENT 1) 32 | ENDIF(CAS_VERSION_DEVELOPMENT_STR) 33 | ENDIF(ff) 34 | 35 | SET(CAS_CPPFLAGS) 36 | # SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DOCC_VERSION_MAJOR=${OCC_VERSION_MAJOR}) 37 | # SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DOCC_VERSION_MINOR=${OCC_VERSION_MINOR}) 38 | # SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DOCC_VERSION_MAINTENANCE=${OCC_VERSION_MAINTENANCE}) 39 | SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DLIN -DLINTEL -DCSFDB) 40 | SET(CAS_DEFINITIONS "-DLIN -DLINTEL -DCSFDB") 41 | SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DNo_exception) 42 | SET(CAS_DEFINITIONS "${CAS_DEFINITIONS} -DNo_exception") 43 | SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DHAVE_CONFIG_H) 44 | SET(CAS_DEFINITIONS "${CAS_DEFINITIONS} -DHAVE_CONFIG_H") 45 | SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -DHAVE_LIMITS_H) 46 | SET(CAS_DEFINITIONS "${CAS_DEFINITIONS} -DHAVE_LIMITS_H") 47 | SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -I${CASROOT}/inc) # to be removed 48 | SET(CAS_INCLUDE_DIRS ${CASROOT}/inc) 49 | MESSAGE( ${CAS_INCLUDE_DIRS} ) 50 | 51 | IF(CMAKE_SIZEOF_VOID_P STREQUAL 8) 52 | SET(CAS_CPPFLAGS ${CAS_CPPFLAGS} -D_OCC64) 53 | ENDIF(CMAKE_SIZEOF_VOID_P STREQUAL 8) 54 | 55 | IF(CAS_VERSION_DEVELOPMENT STREQUAL 1) 56 | SET(CAS_CPPFLAGS "${CAS_CPPFLAGS} -DCAS_VERSION_DEVELOPMENT") 57 | ENDIF(CAS_VERSION_DEVELOPMENT STREQUAL 1) 58 | 59 | IF(WINDOWS) 60 | # IF(PARAVIEW_BUILD_ARCHITECTURE STREQUAL 32) 61 | # SET(CASROOT_LIBDIR ${CASROOT}/win32/vc10/lib) 62 | # ELSE(PARAVIEW_BUILD_ARCHITECTURE STREQUAL 64) 63 | SET(CASROOT_LIBDIR ${CASROOT}/win64/vc10/lib) 64 | # ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug) 65 | # SET(CASROOT_LIBDIR ${CASROOT}/win32/lib) 66 | ELSE(WINDOWS) 67 | SET(CASROOT_LIBDIR ${CASROOT}/lib) 68 | ENDIF(WINDOWS) 69 | MESSAGE( ${CASROOT_LIBDIR} ) 70 | 71 | SET(CMAKE_LIBRARY_PATH ${CASROOT_LIBDIR}) 72 | 73 | IF(NOT WINDOWS) 74 | FIND_LIBRARY(Xmu Xmu) 75 | IF(Xmu) 76 | SET(CAS_LDPATH ${Xmu}) 77 | ENDIF(Xmu) 78 | ENDIF(NOT WINDOWS) 79 | 80 | #FIND_LIBRARY(BinLPlugin BinLPlugin) 81 | #FIND_LIBRARY(BinPlugin BinPlugin) 82 | #FIND_LIBRARY(BinTObjPlugin BinTObjPlugin) 83 | #FIND_LIBRARY(BinXCAFPlugin BinXCAFPlugin) 84 | FIND_LIBRARY(FWOSPlugin FWOSPlugin) 85 | # FIND_LIBRARY(mscmd mscmd) 86 | FIND_LIBRARY(PTKernel PTKernel) 87 | FIND_LIBRARY(StdLPlugin StdLPlugin) 88 | FIND_LIBRARY(StdPlugin StdPlugin) 89 | FIND_LIBRARY(TKAdvTools TKAdvTools) 90 | FIND_LIBRARY(TKBin TKBin) 91 | FIND_LIBRARY(TKBinL TKBinL) 92 | FIND_LIBRARY(TKBinTObj TKBinTObj) 93 | FIND_LIBRARY(TKBinXCAF TKBinXCAF) 94 | FIND_LIBRARY(TKBO TKBO) 95 | FIND_LIBRARY(TKBool TKBool) 96 | FIND_LIBRARY(TKBRep TKBRep) 97 | FIND_LIBRARY(TKCAF TKCAF) 98 | FIND_LIBRARY(TKCDF TKCDF) 99 | # FIND_LIBRARY(TKCDLFront TKCDLFront) 100 | # FIND_LIBRARY(TKCPPClient TKCPPClient) 101 | # FIND_LIBRARY(TKCPPExt TKCPPExt) 102 | # FIND_LIBRARY(TKCPPIntExt TKCPPIntExt) 103 | # FIND_LIBRARY(TKCPPJini TKCPPJini) 104 | # FIND_LIBRARY(TKCSFDBSchema TKCSFDBSchema) 105 | # FIND_LIBRARY(TKDCAF TKDCAF) 106 | # FIND_LIBRARY(TKDraw TKDraw) 107 | FIND_LIBRARY(TKernel TKernel) 108 | FIND_LIBRARY(TKFeat TKFeat) 109 | FIND_LIBRARY(TKFillet TKFillet) 110 | FIND_LIBRARY(TKG2d TKG2d) 111 | FIND_LIBRARY(TKG3d TKG3d) 112 | FIND_LIBRARY(TKGeomAlgo TKGeomAlgo) 113 | FIND_LIBRARY(TKGeomBase TKGeomBase) 114 | FIND_LIBRARY(TKHLR TKHLR) 115 | # FIND_LIBRARY(TKIDLFront TKIDLFront) 116 | FIND_LIBRARY(TKIGES TKIGES) 117 | FIND_LIBRARY(TKLCAF TKLCAF) 118 | FIND_LIBRARY(TKMath TKMath) 119 | FIND_LIBRARY(TKMesh TKMesh) 120 | FIND_LIBRARY(TKMeshVS TKMeshVS) 121 | FIND_LIBRARY(TKNIS TKNIS) 122 | FIND_LIBRARY(TKOffset TKOffset) 123 | FIND_LIBRARY(TKOpenGl TKOpenGl) 124 | FIND_LIBRARY(TKPCAF TKPCAF) 125 | FIND_LIBRARY(TKPLCAF TKPLCAF) 126 | FIND_LIBRARY(TKPrim TKPrim) 127 | FIND_LIBRARY(TKPShape TKPShape) 128 | FIND_LIBRARY(TKService TKService) 129 | FIND_LIBRARY(TKShapeSchema TKShapeSchema) 130 | FIND_LIBRARY(TKShHealing TKShHealing) 131 | FIND_LIBRARY(TKStdLSchema TKStdLSchema) 132 | FIND_LIBRARY(TKStdSchema TKStdSchema) 133 | FIND_LIBRARY(TKSTEP TKSTEP) 134 | FIND_LIBRARY(TKSTEP209 TKSTEP209) 135 | FIND_LIBRARY(TKSTEPAttr TKSTEPAttr) 136 | FIND_LIBRARY(TKSTEPBase TKSTEPBase) 137 | FIND_LIBRARY(TKSTL TKSTL) 138 | # FIND_LIBRARY(TKTCPPExt TKTCPPExt) 139 | FIND_LIBRARY(TKTObj TKTObj) 140 | # FIND_LIBRARY(TKTObjDRAW TKTObjDRAW) 141 | FIND_LIBRARY(TKTopAlgo TKTopAlgo) 142 | # FIND_LIBRARY(TKTopTest TKTopTest) 143 | FIND_LIBRARY(TKV2d TKV2d) 144 | FIND_LIBRARY(TKV3d TKV3d) 145 | # FIND_LIBRARY(TKViewerTest TKViewerTest) 146 | FIND_LIBRARY(TKVRML TKVRML) 147 | # FIND_LIBRARY(TKWOK TKWOK) 148 | # FIND_LIBRARY(TKWOKTcl TKWOKTcl) 149 | FIND_LIBRARY(TKXCAF TKXCAF) 150 | FIND_LIBRARY(TKXCAFSchema TKXCAFSchema) 151 | # FIND_LIBRARY(TKXDEDRAW TKXDEDRAW) 152 | FIND_LIBRARY(TKXDEIGES TKXDEIGES) 153 | FIND_LIBRARY(TKXDESTEP TKXDESTEP) 154 | FIND_LIBRARY(TKXMesh TKXMesh) 155 | FIND_LIBRARY(TKXml TKXml) 156 | FIND_LIBRARY(TKXmlL TKXmlL) 157 | FIND_LIBRARY(TKXmlTObj TKXmlTObj) 158 | FIND_LIBRARY(TKXmlXCAF TKXmlXCAF) 159 | FIND_LIBRARY(TKXSBase TKXSBase) 160 | # FIND_LIBRARY(TKXSDRAW TKXSDRAW) 161 | # FIND_LIBRARY(wokcmd wokcmd) 162 | # FIND_LIBRARY(wokdeliverysteps wokdeliverysteps) 163 | # FIND_LIBRARY(wokdfltsteps wokdfltsteps) 164 | # FIND_LIBRARY(wokobjssteps wokobjssteps) 165 | # FIND_LIBRARY(wokorbixsteps wokorbixsteps) 166 | # FIND_LIBRARY(woksteps woksteps) 167 | # FIND_LIBRARY(woktoolscmd woktoolscmd) 168 | # FIND_LIBRARY(wokutilscmd wokutilscmd) 169 | FIND_LIBRARY(XCAFPlugin XCAFPlugin) 170 | FIND_LIBRARY(XmlLPlugin XmlLPlugin) 171 | FIND_LIBRARY(XmlPlugin XmlPlugin) 172 | FIND_LIBRARY(XmlTObjPlugin XmlTObjPlugin) 173 | FIND_LIBRARY(XmlXCAFPlugin XmlXCAFPlugin) 174 | 175 | SET(CAS_KERNEL ${TKernel} ${TKMath}) 176 | SET(CAS_OCAF ${TKernel} ${TKMath} ${TKCDF} ${TKLCAF}) 177 | SET(CAS_VIEWER ${TKService} ${TKV3d} ${TKG3d} ${TKGeomBase} ${TKBRep}) 178 | SET(CAS_OCAFVIS ${TKCAF} ${TKBRep} ${TKG2d}) 179 | SET(CAS_MODELER ${TKG3d} ${TKGeomBase} ${TKGeomAlgo} ${TKBRep} ${TKTopAlgo} ${TKG2d}) 180 | 181 | SET(TKV3d_EA ${TKernel} ${TKMath} ${TKV3d}) 182 | SET(TKBool_EA ${TKernel} ${TKMath} ${TKBRep} ${TKG2d} ${TKG3d} ${TKGeomBase} ${TKGeomAlgo} ${TKTopAlgo} ${TKBool}) 183 | SET(TKBRep_EA ${TKernel} ${TKMath} ${TKBRep}) 184 | SET(TKIGES_EA ${TKernel} ${TKMath} ${TKXSBase} ${TKBRep} ${TKIGES}) 185 | SET(TKSTEP_EA ${TKernel} ${TKMath} ${TKXSBase} ${TKBRep} ${TKSTEP}) 186 | SET(TKSTL_EA ${TKernel} ${TKMath} ${TKSTL}) 187 | SET(TKCAF_EA ${TKPrim} ${TKCAF}) 188 | 189 | SET(TKV3d ${TKV3d_EA}) 190 | SET(TKBool ${TKBool_EA}) 191 | SET(TKBRep ${TKBRep_EA}) 192 | SET(TKIGES ${TKIGES_EA}) 193 | SET(TKSTEP ${TKSTEP_EA}) 194 | SET(TKSTL ${TKSTL_EA}) 195 | SET(TKCAF ${TKCAF_EA}) 196 | 197 | IF(StdPlugin) 198 | SET(CAS_STDPLUGIN StdPlugin) 199 | ELSE(StdPlugin) 200 | IF(TKStdLSchema) 201 | SET(CAS_STDPLUGIN TKStdSchema) 202 | ENDIF(TKStdLSchema) 203 | ENDIF(StdPlugin) 204 | -------------------------------------------------------------------------------- /GEOM_EdgeSource.cxx: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #include "GEOM_EdgeSource.h" 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | vtkStandardNewMacro(GEOM_EdgeSource); 40 | 41 | GEOM_EdgeSource::GEOM_EdgeSource() : 42 | myIsVector(false) 43 | { 44 | this->SetNumberOfInputPorts(0); 45 | } 46 | 47 | GEOM_EdgeSource::~GEOM_EdgeSource() 48 | { 49 | } 50 | 51 | void GEOM_EdgeSource::AddEdge (const TopoDS_Edge& theEdge, 52 | bool theIsVector) 53 | { 54 | myEdgeSet.Add(theEdge); 55 | myIsVector = theIsVector; 56 | } 57 | 58 | int GEOM_EdgeSource::RequestData(vtkInformation *vtkNotUsed(request), 59 | vtkInformationVector **vtkNotUsed(inputVector), 60 | vtkInformationVector *outputVector) 61 | { 62 | vtkInformation *outInfo = outputVector->GetInformationObject(0); 63 | vtkPolyData *aPolyData = vtkPolyData::SafeDownCast( 64 | outInfo->Get(vtkDataObject::DATA_OBJECT())); 65 | 66 | aPolyData->Allocate(); 67 | vtkPoints* aPts = vtkPoints::New(); 68 | aPolyData->SetPoints(aPts); 69 | aPts->Delete(); 70 | 71 | TEdgeSet::Iterator anIter (myEdgeSet); 72 | for (; anIter.More(); anIter.Next()) { 73 | TopoDS_Edge anEdge = anIter.Value(); 74 | if ( !myIsVector ) 75 | // draw curve direction (issue 0021087) 76 | anEdge.Orientation( TopAbs_FORWARD ); 77 | OCC2VTK(anEdge,aPolyData,aPts,myIsVector||myIsVectorMode); 78 | } 79 | return 1; 80 | } 81 | 82 | void GEOM_EdgeSource::OCC2VTK (const TopoDS_Edge& theEdge, 83 | vtkPolyData* thePolyData, 84 | vtkPoints* thePts, 85 | bool theIsVector) 86 | { 87 | Handle(Poly_PolygonOnTriangulation) aEdgePoly; 88 | Standard_Integer i = 1; 89 | Handle(Poly_Triangulation) T; 90 | TopLoc_Location aEdgeLoc; 91 | BRep_Tool::PolygonOnTriangulation(theEdge, aEdgePoly, T, aEdgeLoc, i); 92 | 93 | Handle(Poly_Polygon3D) P; 94 | if(aEdgePoly.IsNull()) 95 | P = BRep_Tool::Polygon3D(theEdge, aEdgeLoc); 96 | 97 | if(P.IsNull() && aEdgePoly.IsNull()) 98 | return; 99 | 100 | // Location edges 101 | //--------------- 102 | gp_Trsf edgeTransf; 103 | Standard_Boolean isidtrsf = true; 104 | if(!aEdgeLoc.IsIdentity()) { 105 | isidtrsf = false; 106 | edgeTransf = aEdgeLoc.Transformation(); 107 | } 108 | 109 | gp_Pnt aP1, aP2; 110 | 111 | if (aEdgePoly.IsNull()) { 112 | Standard_Integer aNbNodes = P->NbNodes(); 113 | const TColgp_Array1OfPnt& aNodesP = P->Nodes(); 114 | 115 | aP1 = aNodesP(1); 116 | aP2 = aNodesP(aNbNodes); 117 | 118 | for (int j = 1; j < aNbNodes; j++) { 119 | gp_Pnt pt1 = aNodesP(j); 120 | gp_Pnt pt2 = aNodesP(j+1); 121 | 122 | if (!isidtrsf) { 123 | // apply edge transformation 124 | pt1.Transform(edgeTransf); 125 | pt2.Transform(edgeTransf); 126 | } 127 | 128 | float aCoord1[3] = {pt1.X(), pt1.Y(), pt1.Z()}; 129 | vtkIdType anIds[2]; 130 | anIds[0] = thePts->InsertNextPoint(aCoord1); 131 | 132 | float aCoord2[3] = {pt2.X(), pt2.Y(), pt2.Z()}; 133 | anIds[1] = thePts->InsertNextPoint(aCoord2); 134 | 135 | thePolyData->InsertNextCell(VTK_LINE,2,anIds); 136 | } 137 | } else { 138 | Standard_Integer aNbNodes = aEdgePoly->NbNodes(); 139 | const TColStd_Array1OfInteger& aNodeIds = aEdgePoly->Nodes(); 140 | const TColgp_Array1OfPnt& anId2Pnts = T->Nodes(); 141 | 142 | aP1 = anId2Pnts(aNodeIds(1)); 143 | aP2 = anId2Pnts(aNodeIds(aNbNodes)); 144 | 145 | for(int j = 1; j < aNbNodes; j++) { 146 | Standard_Integer id1 = aNodeIds(j); 147 | Standard_Integer id2 = aNodeIds(j+1); 148 | 149 | gp_Pnt pt1 = anId2Pnts(id1); 150 | gp_Pnt pt2 = anId2Pnts(id2); 151 | 152 | if(!isidtrsf) { 153 | // apply edge transformation 154 | pt1.Transform(edgeTransf); 155 | pt2.Transform(edgeTransf); 156 | } 157 | 158 | float aCoord1[3] = {pt1.X(), pt1.Y(), pt1.Z()}; 159 | vtkIdType anIds[2]; 160 | anIds[0] = thePts->InsertNextPoint(aCoord1); 161 | 162 | float aCoord2[3] = {pt2.X(), pt2.Y(), pt2.Z()}; 163 | anIds[1] = thePts->InsertNextPoint(aCoord2); 164 | 165 | thePolyData->InsertNextCell(VTK_LINE,2,anIds); 166 | } 167 | } 168 | 169 | 170 | // vector representation has an arrow on its end 171 | if (theIsVector) 172 | { 173 | if (!isidtrsf) { 174 | // apply edge transformation 175 | aP1.Transform(edgeTransf); 176 | aP2.Transform(edgeTransf); 177 | } 178 | 179 | // draw an arrow 180 | 181 | double fp,lp; 182 | gp_Vec aDirVec; 183 | Handle(Geom_Curve) C = BRep_Tool::Curve(theEdge,fp,lp); 184 | if ( theEdge.Orientation() == TopAbs_FORWARD ) { 185 | C->D1(lp, aP2, aDirVec); 186 | } else { 187 | C->D1(fp, aP1, aDirVec); 188 | aP2 = aP1; 189 | } 190 | 191 | GeomAdaptor_Curve aAdC; 192 | aAdC.Load(C, fp, lp); 193 | Standard_Real aDist = GCPnts_AbscissaPoint::Length(aAdC, fp, lp); 194 | if (aDist < gp::Resolution()) return; 195 | 196 | gp_Dir aDirection; 197 | 198 | if ( theEdge.Orientation() == TopAbs_FORWARD ) 199 | aDirection = aDirVec; 200 | else 201 | aDirection = -aDirVec; 202 | 203 | Standard_Real anAngle = M_PI/180.*5.; 204 | Standard_Real aLength = aDist/10.; 205 | 206 | Standard_Real dx,dy,dz; 207 | aDirection.Coord(dx,dy,dz); 208 | 209 | // Arrow Point 210 | Standard_Real xo,yo,zo; 211 | aP2.Coord(xo,yo,zo); 212 | 213 | // Center of circle that arrow based 214 | gp_XYZ aPc = aP2.XYZ() - aDirection.XYZ() * aLength; 215 | 216 | // Construction of the base vectors for the arrow circle 217 | gp_Dir aDirN; 218 | if (Abs(dx) <= Abs(dy) && Abs(dx) <= Abs(dz)) aDirN = gp::DX(); 219 | else if (Abs(dy) <= Abs(dz) && Abs(dy) <= Abs(dx)) aDirN = gp::DY(); 220 | else aDirN = gp::DZ(); 221 | 222 | gp_Dir aDirI = aDirection ^ aDirN; 223 | gp_Dir aDirJ = aDirection ^ aDirI; 224 | 225 | // Add points and segments, composing the arrow 226 | Standard_Real cosinus, sinus, Tg = tan(anAngle); 227 | 228 | float coord[3] = {xo, yo, zo}; 229 | 230 | vtkIdType ptLoc = thePts->InsertNextPoint(coord); 231 | vtkIdType ptFirst = 0; 232 | vtkIdType ptPrev = 0; 233 | vtkIdType ptCur = 0; 234 | 235 | vtkIdType pts[2]; 236 | 237 | int NbPoints = 15; 238 | for (int i = 1; i <= NbPoints; i++, ptPrev = ptCur) 239 | { 240 | cosinus = cos(2. * M_PI / NbPoints * (i-1)); 241 | sinus = sin(2. * M_PI / NbPoints * (i-1)); 242 | 243 | gp_XYZ aP = aPc + (aDirI.XYZ() * cosinus + aDirJ.XYZ() * sinus) * aLength * Tg; 244 | coord[0] = aP.X(); 245 | coord[1] = aP.Y(); 246 | coord[2] = aP.Z(); 247 | 248 | // insert pts 249 | ptCur = thePts->InsertNextPoint(coord); 250 | pts[0] = ptCur; 251 | 252 | if (i == 1) { 253 | ptFirst = ptCur; 254 | } 255 | else { 256 | // insert line (ptCur,ptPrev) 257 | pts[1] = ptPrev; 258 | thePolyData->InsertNextCell(VTK_LINE,2,pts); 259 | } 260 | 261 | // insert line (ptCur,ptLoc) 262 | pts[1] = ptLoc; 263 | thePolyData->InsertNextCell(VTK_LINE,2,pts); 264 | } 265 | 266 | // insert line (ptCur,ptFirst) 267 | pts[0] = ptCur; 268 | pts[1] = ptFirst; 269 | thePolyData->InsertNextCell(VTK_LINE,2,pts); 270 | } 271 | } 272 | 273 | void GEOM_EdgeSource::SetVectorMode (bool theMode) 274 | { 275 | myIsVectorMode = theMode; 276 | } 277 | 278 | bool GEOM_EdgeSource::GetVectorMode () 279 | { 280 | return !myIsVector && myIsVectorMode; 281 | } 282 | -------------------------------------------------------------------------------- /README_Install.md: -------------------------------------------------------------------------------- 1 | ******************************************************************************** 2 | OCCReader --- 3 | A plugin for visualizing CAD file in STEP,IGES and BREP format in ParaView. 4 | ******************************************************************************** 5 | 6 | 7 | ******************************************************************************** 8 | ******************** Compile in Linux system ********************************** 9 | 10 | This compilation process was tested in Ubutun 14.04 system. Remember to change 11 | all the abbreviation (for example $PVBUILD)to the actual folder name. 12 | 13 | ****Step 1. Download ParaView source and depended dependencies on the plugin. 14 | 15 | ->Download the ParaView source package from www.paraview.org/download. 16 | Upzip it into a folder (Here brief as $PVSRC): 17 | tar zxvf ParaView-v*.*.*-source.tar.gz -C $PVSRC 18 | 19 | ->Download the SALOME-platfrom. Because this plugin compilation depends on many 20 | open-source toolkit, for example OCC, QT, VTK, meanwhile these toolkit also 21 | depend on other libraries, a efficient solution is installing SALOME-platform 22 | which includes all these libraries and toolkits in a whole package. 23 | 24 | -> In http://www.salome-platform.org/downloads/current-version, download the 25 | version which is closest to your system. 26 | 27 | -> Upzip it: 28 | tar zxvf InstallWizard_*.*.*_Ubuntu_**.**_**bit.tar.gz 29 | 30 | -> run the installation script "runInstall". 31 | 32 | -> Find a folder to install SALOME, here brief as $SALOME. 33 | 34 | -> Keep the all the settings by default, only pay attention to installation 35 | step 5 "Choice of the products be installed". In this page, DESELECT all the 36 | modules because we don't need them. Then click the "Prerequistes", and 37 | select "Qt" and "OpenCascade", which are dependencies we needed. Keep 38 | clicking "NEXT" and finished the installation. 39 | 40 | 41 | 42 | ****Step 2. Compile ParaView with the plugin 43 | -> Copy the OCCReader folder to $PVSRC/Plugins, so that we have all the files in 44 | $PVSRC/Plugins/OCCReader folder 45 | 46 | -> Create a new folder ( Here brief as $PVBUILD) for compiling ParaView: 47 | mkdir ParaView-v*.*.*-build. 48 | 49 | -> First offer the suitable environment for compiling ParaView: 50 | source $SALOME/env_products.sh 51 | 52 | -> Go to the $PVBUILD: 53 | cd $PVBUILD 54 | 55 | -> configure paraview: 56 | ccmake $PVSRC 57 | 58 | -> Set the CMAKE_INSTALL_PREFIX to a desire installation folder (brief as $PVINSTALL) 59 | 60 | -> press "c" to configure, and "g" to generate 61 | 62 | -> If errors, check the environment setting. 63 | 64 | -> compile and install the ParaView: 65 | make install 66 | 67 | You can find a file named "libOCCReader.so" under the $PVINSTALL/lib/paraview-*.* . 68 | 69 | 70 | 71 | ****Step 3. Run ParaView with this plugin 72 | 73 | To run ParaView with this plugin, you need to run it under proper environment. 74 | 75 | -> set the environment variable: source $SALOME/env_products.sh 76 | 77 | -> then run ParaView binary in the $PVINSTALL/bin 78 | 79 | You can write a bash script to make it easier. for example: 80 | 81 | #!/bin/bash 82 | source $SALOME/env_products.sh 83 | $PVINSTALL/bin/paraview 84 | 85 | Copy the plugin library "libOCCReader.so" to the $PVINSTALL/lib. You need to load 86 | this library manually for the first time. In ParaView menu Tools->Manage 87 | Plugins, click "Load New" to load the "libOCCReader.so" in the $PVINSTALL/lib/paraview-*.*/, and 88 | select "Auto Load" to load it automatically. 89 | 90 | 91 | 92 | ******************************************************************************** 93 | ******************** Compile in Windows system ******************************** 94 | 95 | 96 | The tested system is Windows7. You need cmake for generating the project, and 97 | Visual Studio for compilation. The current tested version is Visual studio 2010. 98 | Download cmake from http://www.cmake.org/download and choose Win32 installer, 99 | and install it in a folder brief as $CMAKE. Remember to change all the 100 | abbreviation to the actual folder name. 101 | 102 | 103 | ****Step 1. Download ParaView source and depended dependencies on the plugin. 104 | 105 | ->Download the ParaView source package from www.paraview.org/download. Upzip it 106 | into a folder (Here brief as $PVSRC). You need tools like 7zip to unzip the 107 | package. 108 | 109 | ->Download the SALOME-platfrom. Because this plugin compilation depends on many 110 | open-source toolkit, for example OCC, QT, VTK, meanwhile these toolkits also 111 | depend on other libraries, a efficient solution is installing SALOME-platform 112 | which includes all these libraries and toolkits. 113 | 114 | -> In http://www.salome-platform.org/downloads/current-version, download the 115 | Windows SDK version of SALOME. The tested version is SALOME_7.4.0_32bit. 116 | 117 | ->Extract it in a folder, here brief as $SALOME. 118 | 119 | ->Copy the "compile.bat" under $SALOME\WORK and rename it as 120 | "compile_env.bat", we are going to use the environment setting in this file 121 | for compiling ParaView. 122 | 123 | -> Remove the following line from the file "compile_env.bat", since we 124 | don't need to run the compilation of SALOME: 125 | %PYTHONBIN% compile.py %* 126 | 127 | 128 | ****Step 2. Compile ParaView with the plugin 129 | 130 | ->Open a windows dos terminal, change to the $SALOME\WORK folder 131 | cd $SALOME\WORK 132 | then execute the "compile_env.bat" 133 | 134 | ->In the same terminal, change folder to $CMAKE 135 | cd $CMAKE 136 | 137 | ->Open the "cmake-gui.exe". 138 | 139 | -> Specify the folder containing the ParaView Source $PVSRC 140 | 141 | -> Create a new folder ( Here brief as $PVBUILD) for compiling ParaView, and 142 | specify it in cmake. 143 | 144 | -> Click "Configure", choose the Visual Studio version you installed. If you 145 | are going to build a 64bit version, choose the versions with "Win64". 146 | Leave other option by default. NOTED that the OCC library 147 | in SALOME Windows SDK is 32bit only, which means that you have to choose 32bit 148 | version. If you decide to build a 64bit version, then you need to download and 149 | compile a new OCC libaray in 64bit version. 150 | 151 | ->If no problem in configuration, then click "Generate" to generated the 152 | project files. 153 | 154 | -> Go to $PVBUILD, you will find a "ALL_BUILD.vcxproj". Open it with Visual 155 | Studio, and build. You can find the compiled ParaView under the 156 | $PVBUILD\bin\Debug(Release). 157 | 158 | -> Trouble-shoting in Compilation 159 | 160 | -> You might have the problem in finding OCC libraries in Cmake configuration. 161 | The OCC change folder structure unregularly, thus you need to pay attention on 162 | the "IF(WINDOWS)" block of the file "FindCAS.cmake", and modify it manually if 163 | necessary to help Cmake finding the correct folder of the OCC. In any case, 164 | you can include this folder in the system environent variable "lib". 165 | 166 | -> The environment variable for OCC is "CAS_ROOT_DIR" in SALOME platform, 167 | but "CASROOT" in a self-installed OCC library. Check the 168 | "SET(CASROOT $ENV{CAS_ROOT_DIR})" at the beginning of the "FindCAS.cmake", 169 | and change it appropriately. 170 | 171 | -> Keeping in mind to build the 32bit/64bit version consistent with the library you used. 172 | For example, if you are compiling a 32bit version of ParaView, then use 32bit version 173 | of OCC library and also 32bit Qt library. Otherwise errors in linking libraries. 174 | 175 | 176 | ****Step 3. Run ParaView with this plugin 177 | 178 | -> ParaView needs OCC and Qt runtime library for loading the plugin. There are 179 | two approaches, one is setting correct environment variable for finding these 180 | libraries, Or another way is copy all the necessary libraries into the folder of 181 | ParaView executable. 182 | 183 | -> 1st way: Right-click "Computer", then Properties->Anvanced system settings- 184 | >Environment variables, find the "Path" in the system variable and add for 185 | example ";$SALOME\PRODUCTS\OCCT-*.*.*\Win32\bin;$SALOME\PRODUCTS\qt- 186 | *.*.*\bin;$SALOME\PRODUCTS\tbb\bin;;$SALOME\PRODUCTS\tbb\bin\irml" (Change 187 | the $SALOME and "*" to the corresponding text). This requires administrator 188 | right. 189 | 190 | ->2nd way: Copy all the dependent libraries to the folder $PVBUILD\bin\Debug(or 191 | Release). These dependent libraries can be found in the above folders which 192 | asked to added into the "Path" variable. These dependent libraries are : 193 | 194 | OCCReader.dll Qt3Support4.dll QtCLucene4.dll QtCore4.dll QtDeclarative4.dll 195 | QtDesigner4.dll QtDesignerComponents4.dll QtGui4.dll QtHelp4.dll 196 | QtMultimedia4.dll QtNetwork4.dll QtOpenGL4.dll QtScript4.dll 197 | QtScriptTools4.dll QtSql4.dll QtSvg4.dll QtTest4.dll QtWebKit4.dll 198 | QtXml4.dll QtXmlPatterns4.dll TKBO.dll TKBRep.dll TKBool.dll TKG2d.dll 199 | TKG3d.dll TKGeomAlgo.dll TKGeomBase.dll TKIGES.dll TKMath.dll TKMesh.dll 200 | TKOffset.dll TKPrim.dll TKSTEP.dll TKSTEP209.dll TKSTEPAttr.dll 201 | TKSTEPBase.dll TKShHealing.dll TKTopAlgo.dll TKXSBase.dll TKernel.dll 202 | irml.dll msvcp100.dll(optional) msvcr100.dll(Optional) tbb.dll 203 | tbbmalloc.dll 204 | 205 | -> After the above step, open paraview.exe, You need to load this library 206 | manually for the first time. In ParaView menu Tools->Manage Plugins, click "Load 207 | New" to load the "OCCReader.dll" in the some folder as paraview.exe , and select 208 | "Auto Load" to load it automatically. 209 | 210 | 211 | ******************** How to use this plugin *********************************** 212 | ******************************************************************************** 213 | 214 | This plugin is used like other ParaView Reader plugin. In ParaView, click "Open" 215 | button, you can find "OpenCASCADE CAD file(*.step,*.stp,*.igs,*.iges,*.brep)" in 216 | The draw-down list. If yes, you can import any CAD files in those formats. If not, 217 | please make sure that the plugin is loaded correctly. 218 | 219 | -> Loading a CAD file, click "Apply" to process the model. 220 | 221 | -> Display mode is for setting the display effect: 222 | 223 | ->mode 1: wireframe mode 224 | ->mode 2: shading mode 225 | ->mode 3: wireframe & shading 226 | 227 | ->Deflection is for adjusting the display precision. The smaller deflection means 228 | smaller tolerance, thus higher precision. 229 | 230 | ->After changing the parameters, click "Apply" to take effect. 231 | 232 | 233 | 234 | Have fun playing with it! :) 235 | -------------------------------------------------------------------------------- /vtkOCCReader.cxx: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #include "vtkOCCReader.h" 20 | 21 | #include "vtkPoints.h" 22 | #include "vtkIntArray.h" 23 | #include "vtkCellData.h" 24 | #include "vtkCellTypes.h" 25 | #include "vtkCharArray.h" 26 | #include "vtkPointData.h" 27 | #include "vtkDoubleArray.h" 28 | #include "vtkMultiBlockDataSet.h" 29 | #include "vtkUnstructuredGrid.h" 30 | #include "vtkAppendPolyData.h" 31 | #include "vtkPolyDataWriter.h" 32 | // 33 | #include "vtkStreamingDemandDrivenPipeline.h" 34 | #include "vtkGenericAttributeCollection.h" 35 | #include "vtkInformationVector.h" 36 | #include "vtkObjectFactory.h" 37 | #include "vtkInformation.h" 38 | // 39 | #include "vtksys/stl/string" 40 | #include "vtksys/ios/fstream" 41 | #include "vtksys/stl/algorithm" 42 | 43 | 44 | 45 | //Work with IOR. 46 | //#include 47 | //#include 48 | //#include 49 | 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | #include 56 | #include 57 | #include 58 | 59 | #include 60 | #include 61 | #include 62 | #include "BRep_Builder.hxx" 63 | #include "IGESControl_Reader.hxx" 64 | #include "STEPControl_Reader.hxx" 65 | 66 | #define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y)) 67 | #define MAX3(X, Y, Z) (MAX2(MAX2(X,Y), Z)) 68 | 69 | // 70 | 71 | vtkStandardNewMacro(vtkOCCReader); 72 | //vtkCxxRevisionMacro(vtkOCCReader,"$Revision: 1.2.2.2 $"); 73 | 74 | 75 | vtkOCCReader::vtkOCCReader() 76 | { 77 | // this->myFileName = ""; 78 | this->FileName = NULL; 79 | this->MyDataSet=0; 80 | this->DispMode = 2; //default shading 81 | this->myDeflection = 0.001; 82 | 83 | this->SetNumberOfInputPorts(0); 84 | this->SetNumberOfOutputPorts(1); 85 | 86 | } 87 | 88 | vtkOCCReader::~vtkOCCReader() 89 | { 90 | this->SetFileName(0); 91 | } 92 | 93 | void vtkOCCReader::PrintSelf(ostream& os, vtkIndent indent) 94 | { 95 | this->Superclass::PrintSelf( os, indent ); 96 | os << "Data: " << this->MyDataSet << "\n"; 97 | } 98 | 99 | //const char *vtkOCCReader::GetFileName() 100 | //{ 101 | // return myFileName.c_str(); 102 | //} 103 | 104 | //void vtkOCCReader::SetFileName(const char *FileName) 105 | //{ 106 | // vtkWarningMacro("File name seting!") 107 | // if(!FileName) 108 | // return; 109 | // if(FileName[0]=='\0') 110 | // return; 111 | // int length=strlen(FileName); 112 | // myFileName.copy((char *)FileName,length); 113 | // this->Modified(); 114 | //} 115 | 116 | //void vtkOCCReader::SetBufferingPolicy(int pol) 117 | //{ 118 | // BufferingPolicy=pol; 119 | //} 120 | 121 | //int vtkOCCReader::GetBufferingPolicy() 122 | //{ 123 | // return BufferingPolicy; 124 | //} 125 | 126 | void vtkOCCReader::SetMode(int dispMode) 127 | { 128 | //display mode: 1- wireframe; 2-shading 3-wireframe+shading 129 | DispMode = (dispMode > 0 && dispMode < 4) ? dispMode : 2; 130 | this->Modified(); //invoke update 131 | } 132 | 133 | void vtkOCCReader::SetDeflection(double aDeflection) 134 | { 135 | //smoothing 136 | myDeflection = ( aDeflection>= 0.00001 && aDeflection <= 0.001) ? aDeflection : 0.001; 137 | this->Modified(); //invoke update 138 | } 139 | 140 | int vtkOCCReader::getMode() 141 | { 142 | return DispMode; 143 | } 144 | double vtkOCCReader::getDeflection() 145 | { 146 | return myDeflection; 147 | } 148 | //int vtkOCCReader::RequestUpdateExtent( vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outInfo ) 149 | //{ 150 | //return this->Superclass::RequestUpdateExtent(request,inInfo,outInfo); 151 | 152 | /*vtkOCC2VTKCorbaDataSet* output = vtkOCC2VTKCorbaDataSet::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT() ) ); 153 | if ( ! output ) 154 | { 155 | output = vtkOCC2VTKCorbaDataSet::New(); 156 | output->SetPipelineInformation( info ); 157 | output->Delete(); 158 | this->GetOutputPortInformation( 0 )->Set( vtkDataObject::DATA_EXTENT_TYPE(), output->GetExtentType() ); 159 | }*/ 160 | 161 | // return 1; 162 | //} 163 | 164 | int vtkOCCReader::ProcessRequest(vtkInformation* request, 165 | vtkInformationVector** inputVector, 166 | vtkInformationVector* outputVector) 167 | { 168 | // generate the data 169 | if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) 170 | { 171 | return this->RequestData(request, inputVector, outputVector); 172 | } 173 | return this->Superclass::ProcessRequest(request, inputVector, outputVector); 174 | } 175 | 176 | int vtkOCCReader::FillOutputPortInformation(int vtkNotUsed(port), vtkInformation* info) 177 | { 178 | info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkPolyData"); 179 | return 1; 180 | } 181 | 182 | void MeshShape(const TopoDS_Shape theShape, 183 | float& theDeflection, 184 | bool theForced ) 185 | { 186 | 187 | Standard_Real aDeflection = theDeflection <= 0 ? 0.0001 : theDeflection; 188 | 189 | //If deflection <= 0, than return default deflection 190 | if(theDeflection <= 0) 191 | theDeflection = aDeflection; 192 | 193 | // Is shape triangulated? 194 | Standard_Boolean alreadymeshed = Standard_True; 195 | TopExp_Explorer ex; 196 | TopLoc_Location aLoc; 197 | for (ex.Init(theShape, TopAbs_FACE); ex.More(); ex.Next()) { 198 | const TopoDS_Face& aFace = TopoDS::Face(ex.Current()); 199 | Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc); 200 | if(aPoly.IsNull()) { 201 | alreadymeshed = Standard_False; 202 | break; 203 | } 204 | } 205 | 206 | if(!alreadymeshed || theForced) { 207 | Bnd_Box B; 208 | BRepBndLib::Add(theShape, B); 209 | if ( B.IsVoid() ) 210 | return; // NPAL15983 (Bug when displaying empty groups) 211 | Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; 212 | B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); 213 | 214 | // This magic line comes from Prs3d_ShadedShape.gxx in OCCT 215 | aDeflection = MAX3(aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * aDeflection * 4; 216 | 217 | //Clean triangulation before compute incremental mesh 218 | BRepTools::Clean(theShape); 219 | 220 | //Compute triangulation 221 | BRepMesh_IncrementalMesh MESH(theShape,aDeflection); 222 | } 223 | } 224 | 225 | void SetShape(const TopoDS_Shape& theShape, 226 | const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap, 227 | bool theIsVector, 228 | GEOM_EdgeSource* theIsolatedEdgeSource, 229 | GEOM_EdgeSource* theOneFaceEdgeSource, 230 | GEOM_EdgeSource* theSharedEdgeSource, 231 | GEOM_WireframeFace* theWireframeFaceSource, 232 | GEOM_ShadingFace* theShadingFaceSource) 233 | { 234 | if (theShape.ShapeType() == TopAbs_COMPOUND) { 235 | TopoDS_Iterator anItr(theShape); 236 | for (; anItr.More(); anItr.Next()) { 237 | SetShape(anItr.Value(),theEdgeMap,theIsVector, 238 | theIsolatedEdgeSource, 239 | theOneFaceEdgeSource, 240 | theSharedEdgeSource, 241 | theWireframeFaceSource, 242 | theShadingFaceSource); 243 | } 244 | } 245 | 246 | switch (theShape.ShapeType()) { 247 | case TopAbs_WIRE: { 248 | TopExp_Explorer anEdgeExp(theShape,TopAbs_EDGE); 249 | for (; anEdgeExp.More(); anEdgeExp.Next()){ 250 | const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current()); 251 | if (!BRep_Tool::Degenerated(anEdge)) 252 | theIsolatedEdgeSource->AddEdge(anEdge,theIsVector); 253 | } 254 | break; 255 | } 256 | case TopAbs_EDGE: { 257 | const TopoDS_Edge& anEdge = TopoDS::Edge(theShape); 258 | if (!BRep_Tool::Degenerated(anEdge)) 259 | theIsolatedEdgeSource->AddEdge(anEdge,theIsVector); 260 | break; 261 | } 262 | case TopAbs_VERTEX: { 263 | break; 264 | } 265 | default: { 266 | TopExp_Explorer aFaceExp (theShape,TopAbs_FACE); 267 | for(; aFaceExp.More(); aFaceExp.Next()) { 268 | const TopoDS_Face& aFace = TopoDS::Face(aFaceExp.Current()); 269 | theWireframeFaceSource->AddFace(aFace); 270 | theShadingFaceSource->AddFace(aFace); 271 | TopExp_Explorer anEdgeExp(aFaceExp.Current(), TopAbs_EDGE); 272 | for(; anEdgeExp.More(); anEdgeExp.Next()) { 273 | const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current()); 274 | if(!BRep_Tool::Degenerated(anEdge)){ 275 | // compute the number of faces 276 | int aNbOfFaces = theEdgeMap.FindFromKey(anEdge).Extent(); 277 | switch(aNbOfFaces){ 278 | case 0: // isolated edge 279 | theIsolatedEdgeSource->AddEdge(anEdge,theIsVector); 280 | break; 281 | case 1: // edge in only one face 282 | theOneFaceEdgeSource->AddEdge(anEdge,theIsVector); 283 | break; 284 | default: // edge shared by at least two faces 285 | theSharedEdgeSource->AddEdge(anEdge,theIsVector); 286 | } 287 | } 288 | } 289 | } 290 | } 291 | } 292 | } 293 | 294 | 295 | int vtkOCCReader::RequestData(vtkInformation* request, vtkInformationVector** inInfo, vtkInformationVector* outputVector) 296 | { 297 | vtkInformation *outInfo=outputVector->GetInformationObject(0); 298 | // 299 | vtkPolyData *ret0=vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); //pointer for output data 300 | 301 | //read the GEOM file 302 | TopoDS_Shape aShape ; 303 | 304 | 305 | if (!this->FileName) 306 | { 307 | vtkWarningMacro("File name Empty!"); 308 | return 0; 309 | 310 | } 311 | // vtkWarningMacro("File name :" <AddInputConnection(theIsolatedEdgeSource->GetOutputPort()); //for display bounday frame 397 | appendPolyData->AddInputConnection(theOneFaceEdgeSource->GetOutputPort());//for display bounday frame 398 | appendPolyData->AddInputConnection(theSharedEdgeSource->GetOutputPort());//for display bounday frame 399 | // appendPolyData->AddInputConnection(theWireframeFaceSource->GetOutputPort()); //no need to display 400 | } 401 | else if (DispMode == 2) 402 | { 403 | appendPolyData->AddInputConnection(theShadingFaceSource->GetOutputPort());//for display faces 404 | } 405 | else if (DispMode == 3) 406 | { 407 | appendPolyData->AddInputConnection(theIsolatedEdgeSource->GetOutputPort()); //for display bounday frame 408 | appendPolyData->AddInputConnection(theOneFaceEdgeSource->GetOutputPort());//for display bounday frame 409 | appendPolyData->AddInputConnection(theSharedEdgeSource->GetOutputPort());//for display bounday frame 410 | appendPolyData->AddInputConnection(theShadingFaceSource->GetOutputPort());//for display faces 411 | } 412 | else 413 | return 0; 414 | 415 | appendPolyData->Update(); 416 | ret0->ShallowCopy(appendPolyData->GetOutput()); 417 | 418 | theIsolatedEdgeSource->Delete(); 419 | theOneFaceEdgeSource->Delete(); 420 | theSharedEdgeSource->Delete(); 421 | theWireframeFaceSource->Delete(); 422 | theShadingFaceSource->Delete(); 423 | return 1; 424 | } 425 | 426 | 427 | 428 | 429 | 430 | -------------------------------------------------------------------------------- /GEOM_WireframeFace.cxx: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014-2015 KIT-INR/NK 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 | // 17 | // 18 | 19 | #include "GEOM_WireframeFace.h" 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #include 48 | #include 49 | 50 | #include 51 | 52 | vtkStandardNewMacro(GEOM_WireframeFace); 53 | 54 | GEOM_WireframeFace::GEOM_WireframeFace(): 55 | Discret(15) 56 | { 57 | NbIso[0] = 1; 58 | NbIso[1] = 1; 59 | 60 | this->SetNumberOfInputPorts(0); 61 | } 62 | 63 | GEOM_WireframeFace::~GEOM_WireframeFace() 64 | { 65 | } 66 | 67 | int GEOM_WireframeFace::RequestData(vtkInformation *vtkNotUsed(request), 68 | vtkInformationVector **vtkNotUsed(inputVector), 69 | vtkInformationVector *outputVector) 70 | { 71 | vtkInformation *outInfo = outputVector->GetInformationObject(0); 72 | vtkPolyData *aPolyData = vtkPolyData::SafeDownCast( 73 | outInfo->Get(vtkDataObject::DATA_OBJECT())); 74 | 75 | aPolyData->Allocate(); 76 | vtkPoints* aPts = vtkPoints::New(); 77 | aPolyData->SetPoints(aPts); 78 | aPts->Delete(); 79 | 80 | TFaceSet::Iterator anIter(myFaceSet); 81 | for(; anIter.More(); anIter.Next()){ 82 | const TopoDS_Face& aFace = anIter.Value(); 83 | OCC2VTK(aFace,aPolyData,aPts,NbIso,Discret); 84 | } 85 | return 1; 86 | } 87 | 88 | void GEOM_WireframeFace::SetNbIso(const int theNb[2]) 89 | { 90 | if ( theNb[0] == NbIso[0] && theNb[1] == NbIso[1]) 91 | return; 92 | 93 | NbIso[0] = theNb[0]; 94 | NbIso[1] = theNb[1]; 95 | 96 | Modified(); 97 | } 98 | 99 | void GEOM_WireframeFace::GetNbIso(int &theNbU,int &theNbV) 100 | { 101 | theNbU = NbIso[0]; 102 | theNbV = NbIso[1]; 103 | } 104 | 105 | void 106 | GEOM_WireframeFace:: 107 | OCC2VTK(const TopoDS_Face& theFace, 108 | vtkPolyData* thePolyData, 109 | vtkPoints* thePts, 110 | const int theNbIso[2], 111 | const int theDiscret) 112 | { 113 | TopoDS_Face aFace = theFace; 114 | aFace.Orientation(TopAbs_FORWARD); 115 | CreateIso(aFace,theNbIso,theDiscret,thePolyData,thePts); 116 | } 117 | 118 | void 119 | GEOM_WireframeFace:: 120 | CreateIso(const TopoDS_Face& theFace, 121 | const int theNbIso[2], 122 | const int theDiscret, 123 | vtkPolyData* thePolyData, 124 | vtkPoints* thePts) 125 | { 126 | // Constants for iso building 127 | static Standard_Real INTERSECTOR_CONFUSION = 1.e-10 ; // -8 ; 128 | static Standard_Real INTERSECTOR_TANGENCY = 1.e-10 ; // -8 ; 129 | 130 | static Standard_Real HATHCER_CONFUSION_2D = 1.e-8 ; 131 | static Standard_Real HATHCER_CONFUSION_3D = 1.e-8 ; 132 | 133 | Geom2dHatch_Hatcher 134 | aHatcher(Geom2dHatch_Intersector(INTERSECTOR_CONFUSION, 135 | INTERSECTOR_TANGENCY), 136 | HATHCER_CONFUSION_2D, 137 | HATHCER_CONFUSION_3D, 138 | Standard_True, 139 | Standard_False); 140 | 141 | Standard_Real anUMin, anUMax, aVMin, aVMax; 142 | TColStd_Array1OfReal anUPrm(0, theNbIso[0]), aVPrm(0, theNbIso[1]); 143 | TColStd_Array1OfInteger anUInd(0, theNbIso[0]), aVInd(0, theNbIso[1]); 144 | 145 | anUInd.Init(0); 146 | aVInd.Init(0); 147 | 148 | //----------------------------------------------------------------------- 149 | // If the Min Max bounds are infinite, there are bounded to Infinite 150 | // value. 151 | //----------------------------------------------------------------------- 152 | BRepTools::UVBounds(theFace, anUMin, anUMax, aVMin, aVMax) ; 153 | Standard_Boolean InfiniteUMin = Precision::IsNegativeInfinite (anUMin) ; 154 | Standard_Boolean InfiniteUMax = Precision::IsPositiveInfinite (anUMax) ; 155 | Standard_Boolean InfiniteVMin = Precision::IsNegativeInfinite (aVMin) ; 156 | Standard_Boolean InfiniteVMax = Precision::IsPositiveInfinite (aVMax) ; 157 | 158 | static float VTKINFINITE = 1.0E38; 159 | if(InfiniteUMin && InfiniteUMax){ 160 | anUMin = - VTKINFINITE ; 161 | anUMax = VTKINFINITE ; 162 | }else if(InfiniteUMin){ 163 | anUMin = anUMax - VTKINFINITE ; 164 | }else if(InfiniteUMax){ 165 | anUMax = anUMin + VTKINFINITE ; 166 | } 167 | 168 | if(InfiniteVMin && InfiniteVMax){ 169 | aVMin = - VTKINFINITE ; 170 | aVMax = VTKINFINITE ; 171 | }else if(InfiniteVMin){ 172 | aVMin = aVMax - VTKINFINITE ; 173 | }else if(InfiniteVMax){ 174 | aVMax = aVMin + VTKINFINITE ; 175 | } 176 | 177 | //----------------------------------------------------------------------- 178 | // Retreiving the edges and loading them into the hatcher. 179 | //----------------------------------------------------------------------- 180 | TopExp_Explorer ExpEdges(theFace, TopAbs_EDGE); 181 | for(; ExpEdges.More(); ExpEdges.Next()){ 182 | const TopoDS_Edge& anEdge = TopoDS::Edge(ExpEdges.Current()); 183 | Standard_Real U1, U2 ; 184 | const Handle(Geom2d_Curve) PCurve = 185 | BRep_Tool::CurveOnSurface(anEdge, theFace, U1, U2) ; 186 | 187 | if(PCurve.IsNull() || U1 == U2) 188 | return; 189 | 190 | //-- Test if a TrimmedCurve is necessary 191 | if(Abs(PCurve->FirstParameter()-U1) <= Precision::PConfusion() && 192 | Abs(PCurve->LastParameter()-U2) <= Precision::PConfusion()) 193 | { 194 | aHatcher.AddElement(PCurve, anEdge.Orientation()) ; 195 | }else{ 196 | if(!PCurve->IsPeriodic()){ 197 | Handle(Geom2d_TrimmedCurve) TrimPCurve = 198 | Handle(Geom2d_TrimmedCurve)::DownCast(PCurve); 199 | if(!TrimPCurve.IsNull()){ 200 | Handle_Geom2d_Curve aBasisCurve = TrimPCurve->BasisCurve(); 201 | if(aBasisCurve->FirstParameter()-U1 > Precision::PConfusion() || 202 | U2-aBasisCurve->LastParameter() > Precision::PConfusion()) 203 | { 204 | aHatcher.AddElement(PCurve, anEdge.Orientation()) ; 205 | return; 206 | } 207 | }else{ 208 | if(PCurve->FirstParameter()-U1 > Precision::PConfusion()){ 209 | U1=PCurve->FirstParameter(); 210 | } 211 | if(U2-PCurve->LastParameter() > Precision::PConfusion()){ 212 | U2=PCurve->LastParameter(); 213 | } 214 | } 215 | } 216 | Handle(Geom2d_TrimmedCurve) TrimPCurve = 217 | new Geom2d_TrimmedCurve(PCurve, U1, U2); 218 | aHatcher.AddElement(TrimPCurve, anEdge.Orientation()); 219 | } 220 | } 221 | 222 | 223 | //----------------------------------------------------------------------- 224 | // Loading and trimming the hatchings. 225 | //----------------------------------------------------------------------- 226 | Standard_Integer IIso; 227 | Standard_Real DeltaU = Abs(anUMax - anUMin) ; 228 | Standard_Real DeltaV = Abs(aVMax - aVMin) ; 229 | Standard_Real confusion = Min(DeltaU, DeltaV) * HATHCER_CONFUSION_3D ; 230 | aHatcher.Confusion3d (confusion) ; 231 | 232 | if ( theNbIso[0] ) { 233 | Standard_Real StepU = DeltaU / (Standard_Real)theNbIso[0]; 234 | if(StepU > confusion){ 235 | Standard_Real UPrm = anUMin + StepU / 2.; 236 | gp_Dir2d Dir(0., 1.) ; 237 | for(IIso = 1 ; IIso <= theNbIso[0] ; IIso++) { 238 | anUPrm(IIso) = UPrm ; 239 | gp_Pnt2d Ori (UPrm, 0.) ; 240 | Geom2dAdaptor_Curve HCur (new Geom2d_Line (Ori, Dir)) ; 241 | anUInd(IIso) = aHatcher.AddHatching (HCur) ; 242 | UPrm += StepU ; 243 | } 244 | } 245 | } 246 | 247 | if ( theNbIso[1] ) { 248 | Standard_Real StepV = DeltaV / (Standard_Real) theNbIso[1] ; 249 | if(StepV > confusion){ 250 | Standard_Real VPrm = aVMin + StepV / 2.; 251 | gp_Dir2d Dir(1., 0.); 252 | for(IIso = 1 ; IIso <= theNbIso[1] ; IIso++){ 253 | aVPrm(IIso) = VPrm; 254 | gp_Pnt2d Ori (0., VPrm); 255 | Geom2dAdaptor_Curve HCur(new Geom2d_Line (Ori, Dir)); 256 | aVInd(IIso) = aHatcher.AddHatching (HCur) ; 257 | VPrm += StepV ; 258 | } 259 | } 260 | } 261 | 262 | //----------------------------------------------------------------------- 263 | // Computation. 264 | //----------------------------------------------------------------------- 265 | aHatcher.Trim() ; 266 | 267 | Standard_Integer aNbDom = 0 ; // for debug purpose 268 | Standard_Integer Index ; 269 | 270 | for(IIso = 1 ; IIso <= theNbIso[0] ; IIso++){ 271 | Index = anUInd(IIso) ; 272 | if(Index != 0){ 273 | if(aHatcher.TrimDone(Index) && !aHatcher.TrimFailed(Index)){ 274 | aHatcher.ComputeDomains(Index); 275 | if(aHatcher.IsDone (Index)) 276 | aNbDom = aHatcher.NbDomains (Index); 277 | } 278 | } 279 | } 280 | 281 | for(IIso = 1 ; IIso <= theNbIso[1] ; IIso++){ 282 | Index = aVInd(IIso); 283 | if(Index != 0){ 284 | if(aHatcher.TrimDone (Index) && !aHatcher.TrimFailed(Index)){ 285 | aHatcher.ComputeDomains (Index); 286 | if(aHatcher.IsDone (Index)) 287 | aNbDom = aHatcher.NbDomains (Index); 288 | } 289 | } 290 | } 291 | 292 | //----------------------------------------------------------------------- 293 | // Push iso lines in vtk kernel 294 | //----------------------------------------------------------------------- 295 | for(Standard_Integer UIso = anUPrm.Lower() ; UIso <= anUPrm.Upper(); UIso++){ 296 | Standard_Integer UInd = anUInd.Value(UIso); 297 | if(UInd != 0){ 298 | Standard_Real UPrm = anUPrm.Value(UIso); 299 | if(aHatcher.IsDone(UInd)){ 300 | Standard_Integer NbDom = aHatcher.NbDomains(UInd); 301 | for(Standard_Integer IDom = 1 ; IDom <= NbDom ; IDom++){ 302 | const HatchGen_Domain& Dom = aHatcher.Domain(UInd, IDom) ; 303 | Standard_Real V1 = Dom.HasFirstPoint()? Dom.FirstPoint().Parameter(): aVMin - VTKINFINITE; 304 | Standard_Real V2 = Dom.HasSecondPoint()? Dom.SecondPoint().Parameter(): aVMax + VTKINFINITE; 305 | CreateIso_(theFace, GeomAbs_IsoU, UPrm, V1, V2, theDiscret, thePolyData, thePts); 306 | } 307 | } 308 | } 309 | } 310 | 311 | for(Standard_Integer VIso = aVPrm.Lower() ; VIso <= aVPrm.Upper(); VIso++){ 312 | Standard_Integer VInd = aVInd.Value(VIso); 313 | if(VInd != 0){ 314 | Standard_Real VPrm = aVPrm.Value(VIso); 315 | if(aHatcher.IsDone (VInd)){ 316 | Standard_Integer NbDom = aHatcher.NbDomains(VInd); 317 | for (Standard_Integer IDom = 1 ; IDom <= NbDom ; IDom++){ 318 | const HatchGen_Domain& Dom = aHatcher.Domain(VInd, IDom); 319 | Standard_Real U1 = Dom.HasFirstPoint()? Dom.FirstPoint().Parameter(): aVMin - VTKINFINITE; 320 | Standard_Real U2 = Dom.HasSecondPoint()? Dom.SecondPoint().Parameter(): aVMax + VTKINFINITE; 321 | CreateIso_(theFace, GeomAbs_IsoV, VPrm, U1, U2, theDiscret, thePolyData, thePts); 322 | } 323 | } 324 | } 325 | } 326 | } 327 | 328 | 329 | 330 | void 331 | GEOM_WireframeFace:: 332 | CreateIso_(const TopoDS_Face& theFace, 333 | GeomAbs_IsoType theIsoType, 334 | Standard_Real Par, 335 | Standard_Real T1, 336 | Standard_Real T2, 337 | const int theDiscret, 338 | vtkPolyData* thePolyData, 339 | vtkPoints* thePts) 340 | { 341 | Standard_Real U1, U2, V1, V2, stepU=0., stepV=0.; 342 | Standard_Integer j; 343 | gp_Pnt P; 344 | 345 | TopLoc_Location aLoc; 346 | const Handle(Geom_Surface)& S = BRep_Tool::Surface(theFace,aLoc); 347 | 348 | if(!S.IsNull()){ 349 | BRepAdaptor_Surface S(theFace,Standard_False); 350 | 351 | GeomAbs_SurfaceType SurfType = S.GetType(); 352 | 353 | GeomAbs_CurveType CurvType = GeomAbs_OtherCurve; 354 | 355 | Standard_Integer Intrv, nbIntv; 356 | Standard_Integer nbUIntv = S.NbUIntervals(GeomAbs_CN); 357 | Standard_Integer nbVIntv = S.NbVIntervals(GeomAbs_CN); 358 | TColStd_Array1OfReal TI(1,Max(nbUIntv, nbVIntv)+1); 359 | 360 | if(theIsoType == GeomAbs_IsoU){ 361 | S.VIntervals(TI, GeomAbs_CN); 362 | V1 = Max(T1, TI(1)); 363 | V2 = Min(T2, TI(2)); 364 | U1 = Par; 365 | U2 = Par; 366 | stepU = 0; 367 | nbIntv = nbVIntv; 368 | }else{ 369 | S.UIntervals(TI, GeomAbs_CN); 370 | U1 = Max(T1, TI(1)); 371 | U2 = Min(T2, TI(2)); 372 | V1 = Par; 373 | V2 = Par; 374 | stepV = 0; 375 | nbIntv = nbUIntv; 376 | } 377 | 378 | S.D0(U1,V1,P); 379 | MoveTo(P,thePts); 380 | 381 | for(Intrv = 1; Intrv <= nbIntv; Intrv++){ 382 | if(TI(Intrv) <= T1 && TI(Intrv + 1) <= T1) 383 | continue; 384 | if(TI(Intrv) >= T2 && TI(Intrv + 1) >= T2) 385 | continue; 386 | if(theIsoType == GeomAbs_IsoU){ 387 | V1 = Max(T1, TI(Intrv)); 388 | V2 = Min(T2, TI(Intrv + 1)); 389 | stepV = (V2 - V1) / theDiscret; 390 | }else{ 391 | U1 = Max(T1, TI(Intrv)); 392 | U2 = Min(T2, TI(Intrv + 1)); 393 | stepU = (U2 - U1) / theDiscret; 394 | } 395 | 396 | switch (SurfType) { 397 | case GeomAbs_Plane : 398 | break; 399 | case GeomAbs_Cylinder : 400 | case GeomAbs_Cone : 401 | if(theIsoType == GeomAbs_IsoV){ 402 | for(j = 1; j < theDiscret; j++){ 403 | U1 += stepU; 404 | V1 += stepV; 405 | S.D0(U1,V1,P); 406 | DrawTo(P,thePolyData,thePts); 407 | } 408 | } 409 | break; 410 | case GeomAbs_Sphere : 411 | case GeomAbs_Torus : 412 | case GeomAbs_OffsetSurface : 413 | case GeomAbs_OtherSurface : 414 | for(j = 1; j < theDiscret; j++){ 415 | U1 += stepU; 416 | V1 += stepV; 417 | S.D0(U1,V1,P); 418 | DrawTo(P,thePolyData,thePts); 419 | } 420 | break; 421 | case GeomAbs_BezierSurface : 422 | case GeomAbs_BSplineSurface : 423 | for(j = 1; j <= theDiscret/2; j++){ 424 | Standard_Real aStep = (theIsoType == GeomAbs_IsoV) ? stepU*2. : stepV*2.; 425 | CreateIso__(S, theIsoType, U1, V1, aStep, thePolyData, thePts); 426 | U1 += stepU*2.; 427 | V1 += stepV*2.; 428 | } 429 | break; 430 | case GeomAbs_SurfaceOfExtrusion : 431 | case GeomAbs_SurfaceOfRevolution : 432 | if((theIsoType == GeomAbs_IsoV && SurfType == GeomAbs_SurfaceOfRevolution) || 433 | (theIsoType == GeomAbs_IsoU && SurfType == GeomAbs_SurfaceOfExtrusion)) 434 | { 435 | if(SurfType == GeomAbs_SurfaceOfExtrusion) 436 | break; 437 | for(j = 1; j < theDiscret; j++){ 438 | U1 += stepU; 439 | V1 += stepV; 440 | S.D0(U1,V1,P); 441 | DrawTo(P,thePolyData,thePts); 442 | } 443 | }else{ 444 | CurvType = (S.BasisCurve())->GetType(); 445 | switch(CurvType){ 446 | case GeomAbs_Line : 447 | break; 448 | case GeomAbs_Circle : 449 | case GeomAbs_Ellipse : 450 | for (j = 1; j < theDiscret; j++) { 451 | U1 += stepU; 452 | V1 += stepV; 453 | S.D0(U1,V1,P); 454 | DrawTo(P,thePolyData,thePts); 455 | } 456 | break; 457 | case GeomAbs_Parabola : 458 | case GeomAbs_Hyperbola : 459 | case GeomAbs_BezierCurve : 460 | case GeomAbs_BSplineCurve : 461 | case GeomAbs_OtherCurve : 462 | for(j = 1; j <= theDiscret/2; j++){ 463 | Standard_Real aStep = (theIsoType == GeomAbs_IsoV) ? stepU*2. : stepV*2.; 464 | CreateIso__(S, theIsoType, U1, V1, aStep, thePolyData, thePts); 465 | U1 += stepU*2.; 466 | V1 += stepV*2.; 467 | } 468 | break; 469 | } 470 | } 471 | } 472 | } 473 | S.D0(U2,V2,P); 474 | DrawTo(P,thePolyData,thePts); 475 | } 476 | } 477 | 478 | 479 | 480 | 481 | void 482 | GEOM_WireframeFace:: 483 | CreateIso__(const BRepAdaptor_Surface& theSurface, 484 | GeomAbs_IsoType theIsoType, 485 | Standard_Real& theU, 486 | Standard_Real& theV, 487 | Standard_Real theStep, 488 | vtkPolyData* thePolyData, 489 | vtkPoints* thePts) 490 | { 491 | gp_Pnt Pl, Pr, Pm; 492 | if (theIsoType == GeomAbs_IsoU) { 493 | theSurface.D0(theU, theV, Pl); 494 | theSurface.D0(theU, theV + theStep/2., Pm); 495 | theSurface.D0(theU, theV + theStep, Pr); 496 | } else { 497 | theSurface.D0(theU, theV, Pl); 498 | theSurface.D0(theU + theStep/2., theV, Pm); 499 | theSurface.D0(theU + theStep, theV, Pr); 500 | } 501 | 502 | static Standard_Real ISO_RATIO = 1.001; 503 | if (Pm.Distance(Pl) + Pm.Distance(Pr) <= ISO_RATIO*Pl.Distance(Pr)) { 504 | DrawTo(Pr,thePolyData,thePts); 505 | } else { 506 | if (theIsoType == GeomAbs_IsoU) { 507 | CreateIso__(theSurface, theIsoType, theU, theV, theStep/2, thePolyData, thePts); 508 | Standard_Real aLocalV = theV + theStep/2 ; 509 | CreateIso__(theSurface, theIsoType, theU, aLocalV , theStep/2, thePolyData, thePts); 510 | } else { 511 | CreateIso__(theSurface, theIsoType, theU, theV, theStep/2, thePolyData, thePts); 512 | Standard_Real aLocalU = theU + theStep/2 ; 513 | CreateIso__(theSurface, theIsoType, aLocalU , theV, theStep/2, thePolyData, thePts); 514 | } 515 | } 516 | } 517 | --------------------------------------------------------------------------------