1 // Created on: 1995-09-21
2 // Created by: Philippe GIRODENGO
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _StlMesh_Mesh_HeaderFile
18 #define _StlMesh_Mesh_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Integer.hxx>
24 #include <StlMesh_SequenceOfMeshDomain.hxx>
26 #include <MMgt_TShared.hxx>
27 #include <Standard_Real.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <StlMesh_SequenceOfMeshTriangle.hxx>
30 #include <TColgp_SequenceOfXYZ.hxx>
31 class Standard_NegativeValue;
32 class Standard_NullValue;
33 class Standard_NoSuchObject;
38 DEFINE_STANDARD_HANDLE(StlMesh_Mesh, MMgt_TShared)
40 //! Mesh definition. The mesh contains one or several
41 //! domains. Each mesh domain contains a set of
42 //! triangles. Each domain can have its own deflection
44 class StlMesh_Mesh : public MMgt_TShared
50 //! Creates an empty mesh.
51 Standard_EXPORT StlMesh_Mesh();
53 //! Adds a new mesh domain. The mesh deflection is
54 //! defaulted to Confusion from package Precision.
55 Standard_EXPORT virtual void AddDomain();
57 //! Adds a new mesh domain.
58 //! Raised if the deflection is lower than zero
59 //! Raised if the deflection is lower than Confusion
60 //! from package Precision
61 Standard_EXPORT virtual void AddDomain (const Standard_Real Deflection);
63 //! Build a triangle with the triplet of vertices (V1,
64 //! V2, V3). This triplet defines the indexes of the
65 //! vertex in the current domain The coordinates Xn,
66 //! Yn, Zn defines the normal direction to the
67 //! triangle. Returns the range of the triangle in
68 //! the current domain.
69 Standard_EXPORT virtual Standard_Integer AddTriangle (const Standard_Integer V1, const Standard_Integer V2, const Standard_Integer V3, const Standard_Real Xn, const Standard_Real Yn, const Standard_Real Zn);
71 //! Returns the range of the vertex in the current
73 Standard_EXPORT virtual Standard_Integer AddVertex (const Standard_Real X, const Standard_Real Y, const Standard_Real Z);
75 //! Returns the range of the vertex in the current
76 //! domain. The current vertex is not inserted in the
77 //! mesh if it already exist.
78 Standard_EXPORT virtual Standard_Integer AddOnlyNewVertex (const Standard_Real X, const Standard_Real Y, const Standard_Real Z);
80 //! Each vertex of the mesh verifies the following
82 //! XYZMin.X() <= X <= XYZMax.X()
83 //! XYZMin.Y() <= Y <= XYZMax.y()
84 //! XYZMin.Z() <= Z <= XYZMax.Z()
85 Standard_EXPORT virtual void Bounds (gp_XYZ& XYZmax, gp_XYZ& XYZmin) const;
87 Standard_EXPORT virtual void Clear();
89 //! Returns the deflection of the mesh of the domain
90 //! of range <DomainIndex>.
91 //! Raised if <DomainIndex> is lower than 1 or greater
92 //! than the number of domains.
93 Standard_EXPORT virtual Standard_Real Deflection (const Standard_Integer DomainIndex) const;
95 virtual Standard_Boolean IsEmpty() const;
97 //! Number of domains in the mesh.
98 virtual Standard_Integer NbDomains() const;
100 //! Cumulative Number of triangles in the mesh.
101 Standard_Integer NbTriangles() const;
103 //! Number of triangles in the domain of range
105 //! Raised if <DomainIndex> is lower than 1 or greater
106 //! than the number of domains.
107 Standard_EXPORT virtual Standard_Integer NbTriangles (const Standard_Integer DomainIndex) const;
109 //! Cumulative Number of vertices in the mesh.
110 virtual Standard_Integer NbVertices() const;
112 //! Number of vertices in the domain of range
114 //! Raised if <DomainIndex> is lower than 1 or greater
115 //! than the number of domains.
116 Standard_EXPORT virtual Standard_Integer NbVertices (const Standard_Integer DomainIndex) const;
118 //! Returns the set of triangle of the mesh domain of range
120 //! Raised if <DomainIndex> is lower than 1 or greater
121 //! than the number of domains.
122 Standard_EXPORT virtual const StlMesh_SequenceOfMeshTriangle& Triangles (const Standard_Integer DomainIndex = 1) const;
124 //! Returns the coordinates of the vertices of the
125 //! mesh domain of range <DomainIndex>. {XV1, YV1,
126 //! ZV1, XV2, YV2, ZV2, XV3,.....}
127 //! Raised if <DomainIndex> is lower than 1 or greater
128 //! than the number of domains.
129 Standard_EXPORT virtual const TColgp_SequenceOfXYZ& Vertices (const Standard_Integer DomainIndex = 1) const;
134 DEFINE_STANDARD_RTTIEXT(StlMesh_Mesh,MMgt_TShared)
139 Standard_Integer nbTriangles;
140 Standard_Integer nbVertices;
141 StlMesh_SequenceOfMeshDomain domains;
154 #include <StlMesh_Mesh.lxx>
160 #endif // _StlMesh_Mesh_HeaderFile