2 * Project Info: http://jcae.sourceforge.net
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 * (C) Copyright 2007, by EADS France
21 package org.jcae.opencascade.jni;
23 import static org.junit.Assert.*;
24 import org.junit.Test;
27 import java.io.IOException;
28 import java.util.logging.Level;
29 import java.util.logging.Logger;
30 import org.jcae.opencascade.Utilities;
34 * @author Jerome Robert
36 public class FixSmallEdges {
38 private static int countSmallEdges(TopoDS_Shape shape, double minLength)
40 TopExp_Explorer exp = new TopExp_Explorer(shape, TopAbs_ShapeEnum.EDGE);
41 GProp_GProps property=new GProp_GProps();
47 TopoDS_Edge edge = (TopoDS_Edge) exp.current();
48 BRepGProp.linearProperties(edge, property);
49 double l = property.mass();
52 System.out.println(index+" "+l);
61 public static void main(String[] args)
65 if (args.length != 3) displayHelp();
66 if (!new File(args[0]).canRead())
68 System.out.println("Cannot open " + args[0]);
75 tolerance = Double.parseDouble(args[1]);
77 catch (NumberFormatException ex)
83 if (!new File(args[2]).createNewFile())
85 System.out.println("Cannot create " + args[2]);
89 TopoDS_Shape shape = Utilities.readFile(args[0]);
90 System.out.println("Number of small edges before: " +
91 countSmallEdges(shape, tolerance));
92 ShapeFix_Wireframe fix =
93 new ShapeFix_Wireframe(shape);
94 fix.setPrecision(tolerance);
97 System.out.println("Number of small edges after: " +
98 countSmallEdges(shape, tolerance));
99 BRepTools.write(shape, args[2]);
101 catch (IOException ex)
103 Logger.getLogger(FixSmallEdges.class.getName()).
104 log(Level.SEVERE, null, ex);
108 private static void displayHelp()
110 System.out.println("Syntax: fixsmalledge <input file> <tolerance> <output file>");