fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Drawables / Nurbs / Internal / OSGDCTPMesh.h
blob028d6e376611c77d05e5fdd3dcfcae256f773610
1 /*---------------------------------------------------------------------------*\
2 * OpenSG NURBS Library *
3 * *
4 * *
5 * Copyright (C) 2001-2006 by the University of Bonn, Computer Graphics Group*
6 * *
7 * http://cg.cs.uni-bonn.de/ *
8 * *
9 * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
38 #ifndef _OSG_DCTPMESH_H_
39 #define _OSG_DCTPMESH_H_
40 #ifdef __sgi
41 #pragma once
42 #endif
44 #include "OSGDrawableDef.h"
45 #include "OSGConfig.h"
47 #include <iostream>
48 #include <fstream>
49 #include <iomanip>
50 #include <set>
51 #include <algorithm>
52 #include <vector>
54 #include "OSGdctptypes.h"
56 #include "OSGDCTPFace.h"
57 #include "OSGDCTPEdge.h"
58 #include "OSGDCTPVertex.h"
60 OSG_BEGIN_NAMESPACE
62 class OSG_DRAWABLE_DLLMAPPING DCTPMesh
64 public:
65 DCTPMesh();
66 ~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);
85 #endif
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);
94 #else
95 int directEdge(Vec3d& from, Vec3d& into);
96 #endif
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);
102 void reinit(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[];
112 private:
113 public:
115 dctpvertexset vertices;
116 #ifdef OSG_NO_EDGE_SET
117 dctpedgevector edges;
118 #else
119 dctpedgeset edges;
120 #endif
121 dctpfacevector faces;
122 protected:
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
139 struct sortnorth
141 bool operator()(DCTPVertex *v1, DCTPVertex *v2)
143 return (v1->coords[0] < v2->coords[0]);
147 struct sortsouth
149 bool operator()(DCTPVertex *v1, DCTPVertex *v2)
151 return (v1->coords[0] > v2->coords[0]);
155 struct sorteast
157 bool operator()(DCTPVertex *v1, DCTPVertex *v2)
159 return (v1->coords[1] > v2->coords[1]);
163 struct sortwest
165 bool operator()(DCTPVertex *v1, DCTPVertex *v2)
167 return (v1->coords[1] < v2->coords[1]);
171 typedef std::vector<DCTPMesh *> mesh_vector;
173 OSG_END_NAMESPACE
175 #endif // DCTPMesh.h