b311480e |
1 | // Created on: 2007-08-04 |
2 | // Created by: Alexander GRIGORIEV |
3 | // Copyright (c) 2007-2012 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
7fd59977 |
20 | |
21 | |
22 | #ifndef VrmlData_ShapeConvert_HeaderFile |
23 | #define VrmlData_ShapeConvert_HeaderFile |
24 | |
25 | #include <VrmlData_Geometry.hxx> |
26 | #include <VrmlData_Appearance.hxx> |
27 | #include <NCollection_List.hxx> |
28 | #include <TopoDS_Shape.hxx> |
29 | |
30 | class VrmlData_Scene; |
31 | class TopoDS_Face; |
32 | class Handle_Poly_Triangulation; |
33 | class Handle_Poly_Polygon3D; |
34 | class Handle_VrmlData_Coordinate; |
35 | /** |
36 | * Algorithm converting one shape or a set of shapes to VrmlData_Scene. |
37 | */ |
38 | |
39 | class VrmlData_ShapeConvert |
40 | { |
41 | public: |
42 | |
43 | typedef struct { |
44 | TCollection_AsciiString Name; |
45 | TopoDS_Shape Shape; |
46 | Handle(VrmlData_Node) Node; |
47 | } ShapeData; |
48 | |
49 | // ---------- PUBLIC METHODS ---------- |
50 | |
51 | |
52 | /** |
53 | * Constructor. |
54 | * @param theScene |
55 | * Scene receiving all Vrml data. |
56 | * @param theScale |
57 | * Scale factor, considering that VRML standard specifies coordinates in |
58 | * meters. So if your data are in mm, you should provide theScale=0.001 |
59 | */ |
60 | inline VrmlData_ShapeConvert (VrmlData_Scene& theScene, |
61 | const Standard_Real theScale = 1.) |
62 | : myScene (theScene), |
63 | myScale (theScale) |
64 | {} |
65 | |
66 | /** |
67 | * Add one shape to the internal list, may be called several times with |
68 | * different shapes. |
69 | */ |
70 | Standard_EXPORT void AddShape (const TopoDS_Shape& theShape, |
71 | const char * theName = 0L); |
72 | |
73 | /** |
74 | * Convert all accumulated shapes and store them in myScene. |
75 | * The internal data structures are cleared in the end of convertion. |
76 | * @param theExtractFaces |
77 | * If True, converter extracst faces from the shapes. |
78 | * @param theExtractEdges |
79 | * If True, converter extracts edges from the shapes. |
80 | * @param theDeflection |
81 | * Deflection for tessellation of geometrical lines/surfaces. Existing mesh |
82 | * is used if its deflection is smaller than the one given by this |
83 | * parameter. |
84 | * @param theDeflAngle |
85 | * Angular deflection for tessellation of geometrical lines. |
86 | */ |
87 | Standard_EXPORT void Convert (const Standard_Boolean theExtractFaces, |
88 | const Standard_Boolean theExtractEdges, |
89 | const Standard_Real theDeflection = 0.01, |
c6541a0c |
90 | const Standard_Real theDeflAngle = 20.*M_PI/180.); |
7fd59977 |
91 | //this value of theDeflAngle is used by default |
92 | //for tesselation while shading (Drawer->HLRAngle()) |
7fd59977 |
93 | protected: |
94 | // ---------- PROTECTED METHODS ---------- |
95 | |
96 | Handle_VrmlData_Geometry triToIndexedFaceSet |
97 | (const Handle_Poly_Triangulation&, |
98 | const TopoDS_Face&, |
99 | const Handle_VrmlData_Coordinate&); |
100 | |
101 | Handle_VrmlData_Geometry polToIndexedLineSet |
102 | (const Handle_Poly_Polygon3D&); |
103 | |
104 | Handle_VrmlData_Appearance defaultMaterialFace () const; |
105 | |
106 | Handle_VrmlData_Appearance defaultMaterialEdge () const; |
107 | |
108 | private: |
109 | // ---------- PRIVATE FIELDS ---------- |
110 | |
111 | VrmlData_Scene& myScene; |
112 | Standard_Real myScale; |
113 | NCollection_List <ShapeData> myShapes; |
d390b166 |
114 | // ---------- PRIVATE METHODS ---------- |
115 | void operator= (const VrmlData_ShapeConvert&); |
7fd59977 |
116 | }; |
117 | |
118 | #endif |