#######################################################################
#
# $Id: GeometryObjectPatch.py,v 1.2 2008-02-07 05:45:25 lorenz Exp $
# 
# Copyright (C) 2004-2008 Petr Lorenz
# All rights reserved.
# 
# ##### BEGIN LICENSE BLOCK #####
#
# Version: MPL 1.1 / GPL 2.0 / LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
# 
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
# 
# The Original Code is Petr Lorenz emGine Graphical User Interface (GUI).
# 
# The Initial Developer of the Original Code is Petr Lorenz.
# Portions created by the Initial Developer are Copyright (C) 2004-2008.
# All Rights Reserved.
# 
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the  "GPL"), or the
# GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which
# case the provisions of the GPL or the LGPL are applicable instead of those
# above.  If you wish to allow use of your version of this file only under the
# terms of either the GPL or the LGPL and not to allow others to use your
# version of this file under the MPL, indicate your decision by deleting the
# provisions above and replace them with the notice and other provisions
# required by the GPL or LGPL.  If you do not delete the provisions above, a
# recipient may use your version of this file under the terms of any one of the
# MPL License, the GPL or the LGPL.
#
# ##### END LICENSE BLOCK #####
#
#######################################################################
# 
# $Log: GeometryObjectPatch.py,v $
# Revision 1.2  2008-02-07 05:45:25  lorenz
# * Fixed 'Simulation Boundary View' check problem
#   when closing a project.
#
# * Fixed Bounding Box problems when moving/editing a geometry.
#
# Revision 1.1.1.1  2008-01-28 06:15:35  lorenz
# Import emGine GUI v. 0.7.1
#
# Revision 1.2  2007-07-02 06:37:17  lorenz
# Clean up of old code.
#
# Revision 1.1.1.1  2007-05-08 06:22:35  lorenz
# Initial Import
#
#######################################################################

# July 2006 - January 2008

from GeometryObject import GeometryObject

class GeometryObjectPatch(GeometryObject):
  # Description:
  # p1 - point1
  # p2 - point2
  # orientation as default is with z normal
  def __init__(self, name_, p1_ = [0,0,0], p2_ = [0,0,0], material_ = None):
    GeometryObject.__init__(self, name_, "GeometryObjectPatch", material_)

    # check p1_ and p2_ for correct values

    for i in range(len(p1_)): 
      if (p1_[i] > p2_[i]):
        dummy = p1_[i]
        p1_[i] = p2_[i]
        p2_[i] = dummy

    self.p1 = p1_
    self.p2 = p2_
    self.normal = [0,0,1]
    self.bbox = (p1_, p2_)

  def get_discretization_points(self):
    return (self.p1, self.p2)

  def get_info(self):
    info = GeometryObject.get_info(self)
    info += "This patch has : \n"
    info += "p1 : " + str(self.p1) + "; p2 : " + str(self.p2) + "; normal : " + str(self.normal) + "\n"
    return info


###############################################
if __name__ == '__main__':
  print "Testing GeometryObjectPatch Module..."

  patch1 = GeometryObjectPatch("Patch1", [0,0,0], [1,1,1])
  patch2 = GeometryObjectPatch("Patch2", [1,1,1], [0,0,0])
  patch3 = GeometryObjectPatch("Patch3", [0,1,0], [1,0,0])
