1 
2 /* *****************************************************************
3     MESQUITE -- The Mesh Quality Improvement Toolkit
4 
5     Copyright 2004 Lawrence Livermore National Laboratory.  Under
6     the terms of Contract B545069 with the University of Wisconsin --
7     Madison, Lawrence Livermore National Laboratory retains certain
8     rights in this software.
9 
10     This library is free software; you can redistribute it and/or
11     modify it under the terms of the GNU Lesser General Public
12     License as published by the Free Software Foundation; either
13     version 2.1 of the License, or (at your option) any later version.
14 
15     This library is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18     Lesser General Public License for more details.
19 
20     You should have received a copy of the GNU Lesser General Public License
21     (lgpl.txt) along with this library; if not, write to the Free Software
22     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 
24     kraftche@cae.wisc.edu
25 
26   ***************************************************************** */
27 /*!
28   \file   MsqIGeom.hpp
29   \brief  MBMesquite::MeshDomain implemented on ITAPS iGeom API
30   \author Jason Kraftcheck
31   \date   2007-08-14
32 */
33 
34 #ifndef MSQ_IGEOM_HPP
35 #define MSQ_IGEOM_HPP
36 
37 #include "Mesquite.hpp"
38 #include "MeshInterface.hpp"
39 #include "iGeom.h"
40 #include <vector>
41 
42 namespace MBMesquite
43 {
44 
45 /**\brief Common code for specific implementations of MeshDomain on ITAPS interfaces.
46  *
47  * This class contains the common functionality used by concrete implementations
48  * of MeshDomain on the ITAPS geometry interface.
49  */
50 class MsqCommonIGeom : public MeshDomain
51 {
52 public:
53 
54     /**\param geom The ITAPS geometry interface implementation to query */
55   MsqCommonIGeom( iGeom_Instance geom );
56 
57   virtual ~MsqCommonIGeom();
58 
59     /** Evaluate the closest point to the input position on the specified
60      *  geometric entity and return the result in the passed position
61      *  argument (move the passed position onto the geometry.)
62      */
63   int move_to( iBase_EntityHandle geom_handle, Vector3D& coord ) const;
64 
65     /** Given a geometric entity and a position, evaluate the normal
66      *  on the geometric entity at the closest point on that entity
67      *  to the input position, and pass back the result in the input
68      *  coord vector.
69      */
70   int normal ( iBase_EntityHandle geom_handle, Vector3D& coord ) const ;
71 
72     /** Given a geometric entity and a position, evaluate the normal
73      *  on the geometric entity at the closest point on that entity
74      *  to the input position, and pass back the result in the input
75      *  coord vector.
76      */
77   int normal ( iBase_EntityHandle geom_handle, Vector3D coords[], unsigned count ) const;
78 
79     /** Given a geometric entity and a position, evaluate the normal
80      *  on the geometric entity at the closest point on that entity
81      *  to the input position, and pass back the result in the input
82      *  coord vector.
83      */
84   int normal ( const iBase_EntityHandle geom_handles[], Vector3D coords[], unsigned count ) const;
85 
86     /** Given a geometric entity and a position, get point on
87      *  the geometric entity closest to the input position, and
88      *  the surface normal at that position.
89      */
90   int closest_and_normal( iBase_EntityHandle geom_handle,
91                            const Vector3D& position,
92                            Vector3D& closest,
93                            Vector3D& normal ) const;
94 
95   int get_dimension( iBase_EntityHandle const* geom_handle,
96                       unsigned short* dof_out,
97                       size_t count ) const ;
98 
99   iGeom_Instance geomIFace;
100 
101 private:
102   mutable std::vector<iBase_EntityHandle> geomHandles;
103   mutable std::vector<double> coordArray;
104   mutable std::vector<int> typeArray;
105 };
106 
107 
108 /**\brief A MBMesquite::MeshDomain implemented on top of the ITAPS iGeom API.
109  *
110  * Simple MeshDomain class implementatation that queries a single iGeom
111  * entity for all geometric queries.  Suitable for use when the entire
112  * mesh to be smoothed lies on a single geometric surface.
113  */
114 class MsqIGeom : public MsqCommonIGeom
115 {
116 public:
117 
118   MsqIGeom( iGeom_Instance geom,
119             iBase_EntityHandle geom_ent_handle );
120 
121   virtual ~MsqIGeom();
122 
123   void snap_to( Mesh::VertexHandle entity_handle,
124                 Vector3D& coordinat ) const;
125 
126   void vertex_normal_at( Mesh::VertexHandle entity_handle,
127                          Vector3D& coordinate ) const;
128 
129   void element_normal_at( Mesh::ElementHandle entity_handle,
130                           Vector3D& coordinate ) const;
131 
132   void vertex_normal_at( const Mesh::VertexHandle* handles,
133                          Vector3D coordinates[],
134                          unsigned count,
135                          MsqError& err ) const;
136 
137   void closest_point( Mesh::VertexHandle handle,
138                       const Vector3D& position,
139                       Vector3D& closest,
140                       Vector3D& normal,
141                       MsqError& err ) const;
142 
143   void domain_DoF( const Mesh::VertexHandle* handle_array,
144                    unsigned short* dof_array,
145                    size_t num_vertices,
146                    MsqError& err ) const;
147 private:
148 
149     /** A handle for the geometry entity to evaluate */
150   iBase_EntityHandle geomEntHandle;
151 };
152 
153 }
154 
155 #endif
156