ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/applications/nanoRodBuilder/GeometryBuilder.cpp
(Generate patch)

Comparing trunk/OOPSE-3.0/src/applications/nanoRodBuilder/GeometryBuilder.cpp (file contents):
Revision 2204 by gezelter, Fri Apr 15 22:04:00 2005 UTC vs.
Revision 2215 by chuckv, Thu Apr 28 00:24:11 2005 UTC

# Line 60 | Line 60
60   #include <CGAL/aff_transformation_tags.h>
61   #include <iostream>
62   #include <algorithm>
63 + #include <fstream>
64 + #include <math.h>
65  
66 + using namespace std;
67   using namespace oopse;
68  
69   //typedef CGAL::Homogeneous<int>              Kernel;
# Line 100 | Line 103 | class Build_nanorod : public CGAL::Modifier_base<HDS>
103    Vertex_handle neight1;
104    Vertex_handle end2;
105    Vertex_handle neight2;
106 +  Vertex_handle neight3;
107    
108    Build_nanorod() {}
109    void operator()( HDS& hds) {
# Line 117 | Line 121 | class Build_nanorod : public CGAL::Modifier_base<HDS>
121      B.add_vertex( Point(-0.4874571845316,    0.4874571845315,  0.6709272557930));
122      B.add_vertex( Point(-0.7887222926324,   -0.4874571845315, -0.2562714077342)); //End vertex
123      end1 = B.add_vertex( Point( 0.0000000000000,    1.0000000000000,  0.0000000000000));
124 <    B.add_vertex( Point(-0.4874571845315,    -0.4874571845316,  0.6709272557930));
124 >    neight3 = B.add_vertex( Point(-0.4874571845315,    -0.4874571845316,  0.6709272557930));
125      neight1 = B.add_vertex( Point(-0.0000000000000,    0.4874571845316, -0.8293116961175));
126      B.add_vertex( Point( 0.0000000000000,    -0.4874571845316, -0.8293116961175));
127      B.add_vertex( Point( 0.4874571845315,    0.4874571845316,  0.6709272557930));
# Line 270 | Line 274 | GeometryBuilder::GeometryBuilder(double length,double
274    
275    double y1 = nanorod.end1->point().y() - nanorod.neight1->point().y();
276    double y2 = nanorod.end2->point().y() - nanorod.neight2->point().y();
277 <        
277 >  
278 >  double endDist = sqrt(pow(nanorod.neight2->point().x() - nanorod.neight3->point().x(),2)+
279 >                        pow(nanorod.neight2->point().y() - nanorod.neight3->point().y(),2)+
280 >                        pow(nanorod.neight2->point().z() - nanorod.neight3->point().z(),2));
281 >  
282 >  double endRatio1 = y1/endDist;
283 >  double endRatio2 = y2/endDist;
284 >  
285 >  std::cout << "End dist is " << endDist <<" ratio " << endRatio1 << std::endl;
286 >  
287    CGAL::Aff_transformation_3<Kernel> aff_tranformation( width,
288                                                          0.0,
289                                                          0.0,
# Line 285 | Line 298 | GeometryBuilder::GeometryBuilder(double length,double
298                                                          0.0);  
299    std::transform( nanoRodPolyhedron.points_begin(), nanoRodPolyhedron.points_end(), nanoRodPolyhedron.points_begin(), aff_tranformation);
300          
301 <  Point_3 point1(nanorod.end1->point().x(), y1 + nanorod.neight1->point().y(), nanorod.end1->point().z());
302 <  Point_3 point2(nanorod.end2->point().x(), y2+ nanorod.neight2->point().y(), nanorod.end2->point().z());
301 >  
302 >  double endDist2 = sqrt(pow(nanorod.neight2->point().x() - nanorod.neight3->point().x(),2)+
303 >                        pow(nanorod.neight2->point().y() - nanorod.neight3->point().y(),2)+
304 >                        pow(nanorod.neight2->point().z() - nanorod.neight3->point().z(),2));
305 >  
306 >  Point_3 point1(nanorod.end1->point().x(), endDist2*endRatio1 + nanorod.neight1->point().y(), nanorod.end1->point().z());
307 >  Point_3 point2(nanorod.end2->point().x(), endDist2*endRatio2 + nanorod.neight2->point().y(), nanorod.end2->point().z());
308    nanorod.end1->point() = point1;
309    nanorod.end2->point() = point2;
310          
311    // Construct normal vector for each face.
312    std::transform( nanoRodPolyhedron.facets_begin(), nanoRodPolyhedron.facets_end(), nanoRodPolyhedron.planes_begin(),
313                    Normal_vector());
314 <        
314 > }      
315 >  void GeometryBuilder::dumpGeometry(const std::string& geomFileName){
316 >    
317 >     std::ofstream newGeomFile;
318 >    
319 >     //create new .md file based on old .md file
320 >     newGeomFile.open(geomFileName.c_str());
321 >    
322 >     // Write polyhedron in Object File Format (OFF).
323 >     CGAL::set_ascii_mode( std::cout);
324 >     newGeomFile << "OFF" << std::endl << nanoRodPolyhedron.size_of_vertices() << ' '
325 >        << nanoRodPolyhedron.size_of_facets() << " 0" << std::endl;
326 >     std::copy( nanoRodPolyhedron.points_begin(), nanoRodPolyhedron.points_end(),
327 >                std::ostream_iterator<Point_3>( newGeomFile, "\n"));
328 >     for (  Facet_iterator i = nanoRodPolyhedron.facets_begin(); i != nanoRodPolyhedron.facets_end(); ++i) {
329 >        Halfedge_facet_circulator j = i->facet_begin();
330 >        // Facets in polyhedral surfaces are at least triangles.
331 >        CGAL_assertion( CGAL::circulator_size(j) >= 3);
332 >        newGeomFile << CGAL::circulator_size(j) << ' ';
333 >        do {
334 >           newGeomFile << ' ' << std::distance(nanoRodPolyhedron.vertices_begin(), j->vertex());
335 >        } while ( ++j != i->facet_begin());
336 >        newGeomFile << std::endl;
337 >     }
338 >    
339 >     newGeomFile.close();
340 >    
341 >    
342    
343          
344 < }
344 >  }
345  
346 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines