1 /*---------------------------------------------------------------------------*\
2 * OpenSG NURBS Library *
5 * Copyright (C) 2001-2006 by the University of Bonn, Computer Graphics Group*
7 * http://cg.cs.uni-bonn.de/ *
9 * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
38 #ifndef _OSG_DCTPMESH_H_
39 #define _OSG_DCTPMESH_H_
44 #include "OSGDrawableDef.h"
45 #include "OSGConfig.h"
54 #include "OSGdctptypes.h"
56 #include "OSGDCTPFace.h"
57 #include "OSGDCTPEdge.h"
58 #include "OSGDCTPVertex.h"
62 class OSG_DRAWABLE_DLLMAPPING DCTPMesh
68 DCTPVertex
* AddVertex(Vec3d v
);
69 DCTPEdge
* AddEdge(DCTPVertex
*v1
, DCTPVertex
*v2
, int orient
);
70 DCTPFace
* AddFace(void);
71 int AddTriangle(Vec3d v1
, Vec3d v2
, Vec3d v3
, double norm
);
72 int AddQuadTreeLeaf(Vec3d ul
, Vec3d lr
, bool *sides
, double norm
);
73 DCTPFace
* AddQuad(Vec3d v1
, Vec3d v2
, Vec3d v3
, Vec3d v4
, double norm
);
74 int SubdivideQuad(DCTPFace
*f
);
75 int SubdivideQuadNS(DCTPFace
*f
);
76 int SubdivideQuadEW(DCTPFace
*f
);
77 int SubdivideQuadNS(DCTPFace
*f
, double dRatio
);
78 int SubdivideQuadEW(DCTPFace
*f
, double dRatio
);
79 DCTPVertex
* SplitEdge(DCTPEdge
*edge
, double t
);
80 DCTPVertex
* SplitEdge(DCTPEdge
*edge
, const Vec3d
& p
);
81 #ifndef OSG_INTEGER_MESH
82 int SplitFace(DCTPEdge
*edge
, DCTPVec3dvector
&points
, dctpvertexvector
&res
);
83 DCTPVertex
* SplitFace(DCTPEdge
*edge
, const Vec3d
& p
);
84 void SplitOneFace(DCTPFace
*f
, DCTPEdge
*edge
, DCTPVertex
*nv
);
86 int MoveVertex(DCTPVertex
*vert
, Vec3d
&newpos
);
87 // void dump( char *fname );
88 // int write( std::ostream &);
89 // void writeInvalid( std::ostream &);
90 bool isInvalid(void); // whether the current mesh is invalid
91 // int read( std::istream &infile );
92 #ifdef OSG_INTEGER_MESH
93 int directEdge(vec3i
& from
, vec3i
& into
);
95 int directEdge(Vec3d
& from
, Vec3d
& into
);
97 DCTPVertex
* findVertex(const Vec3d
& v
);
98 DCTPEdge
* findEdge(const Vec3d
&vc1
, const Vec3d
&vc2
);
99 DCTPEdge
* findEdge(DCTPVertex
*v1
, DCTPVertex
*v2
);
100 unsigned long getNumOfVertices(void);
101 unsigned long getNumOfFaces(void);
103 double computeEdgePointDst(DCTPEdge
*edg
, Vec3d
& pnt
);
105 void removeFace(unsigned int ui_face
);
107 //file format constants
108 static const char ff_const_1
[];
109 static const char ff_const_2
[];
115 dctpvertexset vertices
;
116 #ifdef OSG_NO_EDGE_SET
117 dctpedgevector edges
;
121 dctpfacevector faces
;
123 int AddQuadSide(DCTPVertex
*l
, DCTPVertex
*r
, DCTPVertex
*m
, DCTPFace
*nf
);
124 void setupSides(DCTPFace
*f
, std::vector
<DCTPVertex
*> * sides
, double dXRatio
, double dYRatio
);
125 void sortSides(DCTPFace
*f
, std::vector
<DCTPVertex
*> * sides
);
126 DCTPEdge
*getEdgeFromFace(DCTPFace
*f
, DCTPVertex
*v1
, DCTPVertex
*v2
);
127 void buildNewFaces(DCTPFace
*f
, DCTPVertex
*np
, DCTPVertex
*sp
, DCTPVertex
*wp
, DCTPVertex
*ep
);
128 void buildNewFacesNS(DCTPFace
*f
, DCTPVertex
*wp
, DCTPVertex
*ep
);
129 void buildNewFacesEW(DCTPFace
*f
, DCTPVertex
*np
, DCTPVertex
*sp
);
130 void buildNewFacesNS(DCTPFace
*f
, DCTPVertex
*wp
, DCTPVertex
*ep
, double dRatio
);
131 void buildNewFacesEW(DCTPFace
*f
, DCTPVertex
*np
, DCTPVertex
*sp
, double dRatio
);
132 DCTPFace
*buildQuadFace(std::vector
<DCTPVertex
*> &verts
, DCTPFace
*f
);
133 unsigned long vertex_count
;
134 unsigned long edge_count
;
135 unsigned long face_count
;
136 bool invalid
; // true if no mesh loaded or invalid (null) mesh read from file
141 bool operator()(DCTPVertex
*v1
, DCTPVertex
*v2
)
143 return (v1
->coords
[0] < v2
->coords
[0]);
149 bool operator()(DCTPVertex
*v1
, DCTPVertex
*v2
)
151 return (v1
->coords
[0] > v2
->coords
[0]);
157 bool operator()(DCTPVertex
*v1
, DCTPVertex
*v2
)
159 return (v1
->coords
[1] > v2
->coords
[1]);
165 bool operator()(DCTPVertex
*v1
, DCTPVertex
*v2
)
167 return (v1
->coords
[1] < v2
->coords
[1]);
171 typedef std::vector
<DCTPMesh
*> mesh_vector
;