Main Page   Namespace List   Class Hierarchy   Compound List   File List   Header Files   Sources   Namespace Members   Compound Members   File Members  

assoc.cpp

00001 //$Header: /home/ben/Mapper/c++/RCS/assoc.cpp,v 6.4 2002/06/14 23:23:14 ben Exp $
00002 // Copyright Benedict Adamson 2002.
00003 // This file is part of Mapper.
00004 
00005 // Mapper is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 
00010 // Mapper is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 
00015 // You should have received a copy of the GNU General Public License
00016 // along with Mapper; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00028 #include <cassert>
00029 
00030 #include "angle_constraint.h"
00031 #include "assoc.h"
00032 #include "bearing_constraint.h"
00033 #include "curve.h"
00034 #include "distance_constraint.h"
00035 #include "vector2.h"
00036 #include "through_constraint.h"
00037 #include "vector_constraint.h"
00038 
00039 
00040 
00041 void assoc(
00042    angle_constraint &c,
00043    vector2 &p0,
00044    vector2 &p1,
00045    vector2 &p2
00046    )
00047 {
00048    {//preconditions:
00049       assert( !c.points()[0] );
00050       assert( !c.points()[1] );
00051       assert( !c.points()[2] );
00052    };
00053    c.points_[0] = &p0;
00054    c.points_[1] = &p1;
00055    c.points_[2] = &p2;
00056    {//postconditions:
00057       assert( c.points()[0] == &p0 );
00058       assert( c.points()[1] == &p1 );
00059       assert( c.points()[2] == &p2 );
00060    };
00061 }
00062 
00063 
00064 
00065 void unassoc(
00066    angle_constraint &c
00067    )
00068 {
00069    if( c.points_[0] ){
00070       c.points_[0] = 0;
00071       c.points_[1] = 0;
00072       c.points_[2] = 0;
00073    }
00074    {//postconditions
00075       assert( !c.points()[0] );
00076       assert( !c.points()[1] );
00077       assert( !c.points()[2] );
00078    };
00079 }
00080 
00081 
00082 
00083 void assoc(
00084    bearing_constraint &c,
00085    vector2 &p0,
00086    vector2 &p1
00087    )
00088 {
00089    {//preconditions:
00090       assert( !c.points()[0] );
00091       assert( !c.points()[1] );
00092    };
00093    c.points_[0] = &p0;
00094    c.points_[1] = &p1;
00095    {//postconditions:
00096       assert( c.points()[0] == &p0 );
00097       assert( c.points()[1] == &p1 );
00098    };
00099 }
00100 
00101 
00102 
00103 void unassoc(
00104    bearing_constraint &c
00105    )
00106 {
00107    if( c.points_[0] ){
00108       c.points_[0] = 0;
00109       c.points_[1] = 0;
00110    }
00111    {//postconditions
00112       assert( !c.points()[0] );
00113       assert( !c.points()[1] );
00114    };
00115 }
00116 
00117 
00118 
00119 void assoc(
00120    distance_constraint &c,
00121    vector2 &p0,
00122    vector2 &p1
00123    )
00124 {
00125    {//preconditions:
00126       assert( !c.points()[0] );
00127       assert( !c.points()[1] );
00128    };
00129    c.points_[0] = &p0;
00130    c.points_[1] = &p1;
00131    {//postconditions:
00132       assert( c.points()[0] == &p0 );
00133       assert( c.points()[1] == &p1 );
00134    };
00135 }
00136 
00137 
00138 
00139 void unassoc(
00140    distance_constraint &c
00141    )
00142 {
00143    if( c.points_[0] ){
00144       c.points_[0] = 0;
00145       c.points_[1] = 0;
00146    }
00147    {//postconditions
00148       assert( !c.points()[0] );
00149       assert( !c.points()[1] );
00150    };
00151 }
00152 
00153 
00154 
00155 void assoc(
00156    through_constraint &tc,
00157    curve &cu,
00158    vector2 &p
00159    )
00160 {
00161    {//preconditions:
00162       assert( !tc.constrained_curve() );
00163       assert( tc.points().empty() );
00164       assert( 2 <= cu.param.size() );
00165    };
00166    tc.constrained_curve_ = &cu;
00167    const unsigned n = cu.param.size();
00168    tc.points().reserve( n+1 ); //optimisation
00169    tc.points().push_back( &p );
00170    for( unsigned i = 0; i < n; i++ ){
00171       assert( cu.param[i] );
00172       tc.points().push_back( cu.param[i] );
00173    };
00174    {//postconditions:
00175       assert( tc.constrained_curve() == &cu );
00176       assert( tc.points()[0] == &p );
00177       assert( tc.points().size() == cu.param.size()+1 );
00178       //tc.points[i+1] == tc.param[i] for i in [0 .. tc.param.size()-1];
00179    };
00180 }
00181 
00182 
00183 
00184 void assoc(
00185    vector_constraint &c,
00186    vector2 &p0,
00187    vector2 &p1
00188    )
00189 {
00190    {//preconditions:
00191       assert( !c.points()[0] );
00192    };
00193    c.points_[0] = &p0;
00194    c.points_[1] = &p1;
00195    {//postconditions:
00196       assert( c.points()[0] == &p0 );
00197       assert( c.points()[1] == &p1 );
00198    };
00199 }
00200 
00201 
00202 
00203 void unassoc(
00204    vector_constraint &c
00205    )
00206 {
00207    if( c.points_[0] ){
00208       c.points_[0] = 0;
00209       c.points_[1] = 0;
00210    }
00211    {//postconditions
00212       assert( !c.points()[0] );
00213       assert( !c.points()[1] );
00214    };
00215 }
00216 
00217 
00218 

Generated at Sun Jul 14 20:38:06 2002 for Mapper by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999