Code Monkey home page Code Monkey logo

danny02 / openctm Goto Github PK

View Code? Open in Web Editor NEW
93.0 15.0 34.0 2.56 MB

OpenCTM is a file format, a software library and a tool set for compression of 3D triangle meshes. The geometry is compressed to a fraction of comparable file formats (3DS, STL, COLLADA...), and the format is accessible through a simple, portable API

Home Page: http://openctm.sourceforge.net

License: zlib License

Pascal 0.18% JavaScript 0.13% Python 0.88% Shell 6.23% C 76.60% C++ 10.22% CMake 0.06% Objective-C 1.81% Makefile 1.24% Roff 0.72% M4 0.23% SAS 0.30% Smalltalk 0.05% WebAssembly 0.30% Assembly 0.18% Module Management System 0.29% HTML 0.16% GLSL 0.08% Objective-C++ 0.09% Inno Setup 0.27%

openctm's Introduction

1. INTRODUCTION

Welcome to OpenCTM!

OpenCTM is a file format, a software library and a tool set for compression of 3D triangle meshes. The geometry is compressed to a fraction of comparable file formats (3DS, STL, COLLADA, VRML...), and the format is easily accessible through a simple, portable API.

The library is written in portable C (C99), and should compile nicely on any 32/64-bit system regardless of endianity (big endian or little endian).

Build Status

2. LICENSE

The OpenCTM API and the OpenCTM tools are released under the zlib/libpng license (see LICENSE.txt).

3. CREDITS

Many people have helped out in the development process of OpenCTM, with valuable feedback, programming efforts, test models and conceptual ideas. Also, OpenCTM relies heavily on many other open source projects.

Here is an incomplete list of persons that deserve credit:

  • Igor Pavlov (LZMA library)
  • Jonas Innala (COLLADA importer, Maya exporter plugin)
  • Ilian Dinev (help with the OpenCTM file format design and the LWO loader)
  • Lee Thomason (TinyXML)
  • Diego Nehab (RPly - for loading PLY files)
  • Lev Povalahev, Marcelo E. Magallon, Milan Ikits (GLEW)
  • Thomas G. Lane, Guido Vollbeding (libjpeg)
  • Jean-loup Gailly, Mark Adler (zlib)
  • Daniel Karling (pnglite)

During the development of OpenCTM, the following software has been used extensively:

Legal notices:

  • This software is based in part on the work of the Independent JPEG Group.

4. CHANGES

v1.0.3 - 2010.01.15

  • Added support for PNG format textures (ctmviewer).

  • Added support for LightWave LWO files (ctmconv and ctmviewer).

  • Added support for Geomview OFF files, e.g. as used by the Princeton Shape Benchmark (ctmconv and ctmviewer).

  • Improved the OBJ file loader (ctmviewer and ctmconv).

  • Experimental support for VRML 2.0 files - export only (ctmconv and ctmviewer).

  • Made it possible to run ctmviewer without command line arguments.

  • Improved the normal calculation algorithm (ctmviewer and ctmconv).

  • Normals are no longer exported if no normals were present in the input file (ctmviewer).

v1.0.2 - 2009.12.13

  • Added an OpenCTM exporter plugin for Maya [Jonas Innala].

  • Added the possiblity to save and load files from ctmviewer, effectively turning it into a quick and simple converter tool (without all the options in the ctmconv program, though).

  • Added a function to load texture files from ctmviewer.

  • Improved the camera control in ctmviewer (panning with the right mouse button, zooming with the middle mouse button and the mouse wheel, feature focusing by double clicking, Y/Z up axis selection and "fit to screen" function).

  • Added a GUI dialog for showing errors in ctmviewer (this is especially useful under Windows, where console output is disabeled).

  • Added an option for calculating the normals in ctmconv (if the input file does not have normals).

  • Added options for turning off normals, texture coordinates and/or vertex colors for the output file in ctmconv.

  • Added manuals for ctmviewer and ctmconv (man pages).

  • Added a "make install" build target for Mac OS X and Linux for simple system wide installation (see COMPILING.txt).

  • NOTE: The Linux/X11 version of ctmviewer now reqires GTK+ 2.0.

v1.0.1 - 2009.11.15

  • Notable reduction of the memory footprint by tuning of the LZMA compression parameters.

  • Added a Wavefront OBJ file importer/exporter.

  • Some improvements to ctmviewer and ctmconv.

  • Some directory structure and build system cleanups.

v1.0 - 2009.11.09

  • Added a COLLADA converter module to the ctmconv program [Jonas Innala].

  • Added Python bindings and a demo Python program.

  • Improved the internal mesh integrity checking, to minimize the risk of invalid data processing.

  • Improved the file format specification document.

v0.8 (beta) - 2009.09.14

  • Introduced a new API function for controlling the compression level (ctmCompressionLevel), and set the default compression level to 5 (rather than 9, which would eat a lot of memory, usally without much difference).

  • Changed the name "texture map" in the API to "UV map" (and all corresponding constant and function names). This is more in line with the nomenclature of most 3D authoring software, and avoids the confusion with the term texture mapping in 3D hardware (which is not limited to 2D UV mapping coordinates).

  • A few updates to the documentation.

v0.7 (beta) - 2009.08.29

  • This was the first public release of OpenCTM.

openctm's People

Contributors

danny02 avatar dmrub avatar jiloc avatar projedi avatar valette avatar yonkahlon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openctm's Issues

Read .obj and converted to ctm but failed to load in three.js

When I read the .obj file and convert to Mesh
to generate ctm File
it was created but failed to load in three.js

it show following message

Uncaught Error in data stream
*** sample .obj file is uploaded

`using OpenCTM;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{

class Program
{
    private static float[] vert = new float[]{  0,0,0,
                                                1,0,0,
                                                1,1,0,
                                                0,1,0};//v
    private static float[] normals = new float[]{1,1,1,
                                                1,1,1,
                                                1,1,1,
                                                1,1,1};//vn
    private static AttributeData[] uvad = { new AttributeData ("uv1", "test",
                                                                AttributeData.STANDARD_UV_PRECISION,
                                                                new float[]{0.0034f, 0.1f,
                                                                            0.8f, 1.0f,
                                                                            0.351f, 0.612f,
                                                                            0.1229f, 0.91224f}) };//vt
    private static int[] ind = new int[] { 0, 1, 2, 0, 2, 3 };//f
    private static Mesh quad = new Mesh(vert, normals, ind, uvad, new AttributeData[0]);
    
    
    public void rawTest()
    {
        testEncoder(new RawEncoder());
    }

    public void mg1Test()
    {
        testEncoder(new MG1Encoder());
    }

    public void mg2Test()
    {
        testEncoder(new MG2Encoder(MG2Encoder.STANDARD_VERTEX_PRECISION, MG2Encoder.STANDARD_NORMAL_PRECISION));
    }

    private void testEncoder(MeshEncoder encoder)
    {
        MemoryStream memory = new MemoryStream();
        CtmFileWriter writer = new CtmFileWriter(memory, encoder);
        writer.encode(quad, null);

        memory.Seek(0, SeekOrigin.Begin);
        using (FileStream file = new FileStream("mayu.ctm", FileMode.Create, System.IO.FileAccess.Write))
            memory.CopyTo(file);
        Stream readMemory = new MemoryStream(memory.ToArray());
        CtmFileReader reader = new CtmFileReader(readMemory);
        Mesh m = reader.decode();

        m.checkIntegrity();

        //MG2Encoder mg2 = encoder as MG2Encoder;

        //Chech file integirty
        //MemoryStream ms = new MemoryStream();
        //using (FileStream file = new FileStream("col.ctm", FileMode.Open, FileAccess.Read))
        //    file.CopyTo(ms);

        //Stream readMemory1 = new MemoryStream(ms.ToArray());
        //CtmFileReader reader1 = new CtmFileReader(readMemory1);
        //Mesh m2 = reader1.decode();

        //m2.checkIntegrity();
        //float[] v = m2.vertices;
        //float[] n = m2.normals;
        //AttributeData []ad = m2.texcoordinates;
        //int[] index = m2.indices;
        //var t= m2.getVertexCount();
        //var c = m2.getTriangleCount();

        
    }

    static void Main(string[] args)
    {
        Program p = new ConsoleApplication1.Program();

        var filrread = File.ReadAllLines(@"D:\\collar.obj");
       //var filrread = File.ReadAllLines(@"D:\\Box.obj");
       // var filrread = File.ReadAllLines(@"D:\\boxxxx.obj");

        var ctmName = filrread.Where(x => x.Contains("object")).Select(x => x.Split(' ')[2]).FirstOrDefault();

        var vcount = Convert.ToInt32(filrread.Where(x => x.Contains("vertices")).Select(x => x.Split(' ')[1]).FirstOrDefault())*3;
        var vncount = Convert.ToInt32(filrread.Where(x => x.Contains("normals")).Select(x => x.Split(' ')[1]).FirstOrDefault())*3;
        var vtcount = Convert.ToInt32(filrread.Where(x => x.Contains("texture")).Select(x => x.Split(' ')[1]).FirstOrDefault())*3;

        var fcount = Convert.ToInt32(filrread.Where(x => x.Contains("triangles")).Select(x => x.Split(' ')[4]).FirstOrDefault());

        var v = filrread.Where(x => x.StartsWith("v ")).Select(x => x.Replace("v  ", string.Empty).Split(' ').ToList()).ToList();
        var vn = filrread.Where(x => x.StartsWith("vn ")).Select(x => x.Replace("vn ", string.Empty).Split(' ').ToList()).ToList();
        var vt = filrread.Where(x => x.StartsWith("vt ")).Select(x => x.Replace("vt ", string.Empty).Split(' ').ToList()).ToList();

        var f = filrread.Where(x => x.StartsWith("f ")).Select(x => x.Replace("f ", string.Empty).TrimEnd().Split(' ').ToList().Select(ac => ac.Split('/')[0])).ToList();

        List<float> vertex = new List<float>();
        List<float> normal = new List<float>();
        List<float> uv = new List<float>();
        List<int> index = new List<int>();

        int cnt = 0;
        foreach (var item in v)
        {
            foreach (var itemList in item)
            {
                vertex.Add(Convert.ToSingle(itemList));
                //normal.Add(cnt);
                //uv.Add(cnt);
                //cnt++;
            }
        }

        foreach (var item in vn)
        {
            foreach (var itemList in item)
            {
                normal.Add(Convert.ToSingle(itemList));
            }
        }

        foreach (var item in vt)
        {
            //foreach (var itemList in item)
            for (int i = 0; i < item.Count - 1; i++)
            {
                //uv.Add(Convert.ToSingle(itemList[i]));
                uv.Add(Convert.ToSingle(item[i]));
            }
        }

        foreach (var item in f)
        {
            foreach (var itemList in item)
            {
                index.Add(Convert.ToInt32(itemList)-1);  // remove -1 For Face adjustment
            }
        }

        //if (vertex.Count == vcount && normal.Count == vncount && uv.Count == (vtcount-vt.Count) && f.Count == fcount)
        {

            vert = vertex.ToArray();
            normals = normal.ToArray();
            AttributeData ad = new AttributeData(ctmName, "1", AttributeData.STANDARD_UV_PRECISION, uv.ToArray());
            List<AttributeData> adlist = new List<AttributeData>();
            adlist.Add(ad);
            ind = index.ToArray();

            quad = new Mesh(vert, normals, ind, adlist.ToArray(), new AttributeData[0]);
        }


        p.mg2Test();
    }
}

}
collar.obj.txt
`

ctmconv combines all meshes from .obj file into one large mesh

Hi Daniel,

I am trying to import a complex model in a Wavefront obj file into FreeCAD, but since I am having trouble in that department, I thought I'd convert it to a different format first. That path led me here.

I am able to see that the .obj file contains many separate meshes, but when I convert it to .stl (FreeCAD's STL handling is robust), all the meshes are combined into one large mesh. I tried a few other formats as well, all with the same result.

Is this behaviour expected, or are there some tricks I can try? My understanding of the OpenCTM specification is non-existent and I may be barking up the wrong tree.

Thanks in advance!
Rhianne

The CTM export routine for ctmconv can access out of bounds

The easiest way to observe this is to compile with libstdc++ assertions enabled. In Makefile.linux, add -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS to the CPPFLAGS. (This is part of the distribution default compiler flags in Fedora).

Now,

$ make -f Makefile.linux
$ curl -L -O https://github.com/gazebosim/gazebo-classic/raw/gazebo10_10.1.0/media/models/sitting.dae
$ LD_LIBRARY_PATH="$PWD/lib" ./tools/ctmconv sitting.dae sitting.ctm
Loading sitting.dae... 47.15 ms
Saving sitting.ctm... /usr/include/c++/13/bits/stl_vector.h:1125: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.
Aborted (core dumped)

If we remove -s so the executable is not stripped of debug symbols:

$(CPP) -s -o $@ -L$(OPENCTMDIR) -L$(TINYXMLDIR) $(CTMCONVOBJS) -Wl,-rpath,. -lopenctm -ltinyxml

…and furthermore add -g -Og to the CPPFLAGS, then recompile, then we can try again with gdb and get a really nice backtrace:

$ LD_LIBRARY_PATH="$PWD/lib" gdb --args ./tools/ctmconv sitting.dae sitting.ctm
[…]
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff7aae8a3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff7a5c8ee in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff7a448ff in __GI_abort () at abort.c:79
#4  0x00007ffff7cd95b0 in std::__glibcxx_assert_fail (file=file@entry=0x4250e8 "/usr/include/c++/13/bits/stl_vector.h", line=line@entry=1125, 
    function=function@entry=0x425110 "std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]", condition=condition@entry=0x425010 "__n < this->size()") at ../../../../../libstdc++-v3/src/c++11/assert_fail.cc:41
#5  0x00000000004062d9 in std::vector<int, std::allocator<int> >::operator[] (this=this@entry=0x7fffffffd298, __n=__n@entry=0) at /usr/include/c++/13/bits/stl_vector.h:1125
#6  0x0000000000409890 in Export_CTM (aFileName=aFileName@entry=0x7fffffffd340 "sitting.ctm", aMesh=aMesh@entry=0x7fffffffd250, aOptions=...) at ctm.cpp:127
#7  0x000000000040921a in ExportMesh (aFileName=0x7fffffffd340 "sitting.ctm", aMesh=aMesh@entry=0x7fffffffd250, aOptions=...) at meshio.cpp:82
#8  0x0000000000405c64 in main (argc=3, argv=0x7fffffffd538) at /usr/include/c++/13/bits/basic_string.h:222
(gdb) frame 6
#6  0x0000000000409890 in Export_CTM (aFileName=aFileName@entry=0x7fffffffd340 "sitting.ctm", aMesh=aMesh@entry=0x7fffffffd250, aOptions=...) at ctm.cpp:127
127                      (const CTMuint*) &aMesh->mIndices[0], aMesh->mIndices.size() / 3,
 print *aMesh
$2 = {mOriginalNormals = true, mComment = "", mTexFileName = "", mIndices = std::vector of length 0, capacity 0, mVertices = std::vector of length 0, capacity 0, 
  mNormals = std::vector of length 0, capacity 0, mColors = std::vector of length 0, capacity 0, mAttributes = std::vector of length 0, capacity 0, mTexCoords = std::vector of length 0, capacity 0, 
  attributesName = 0x0}

Something has apparently gone wrong in importing the mesh, which might be its own bug, and the aMesh structure has all empty vectors. The problem then is that the export code unconditionally takes the addresses of the first elements in

OpenCTM/tools/ctm.cpp

Lines 126 to 128 in 91b3b71

ctm.DefineMesh((CTMfloat *) &aMesh->mVertices[0].x, aMesh->mVertices.size(),
(const CTMuint*) &aMesh->mIndices[0], aMesh->mIndices.size() / 3,
normals);

which is undefined on an empty/zero-element vector even if the pointer is never dereferenced. For &aMesh->mIndices[0], we could use amesh->mIndices.data(), which should be at least be OK to call on an empty vector, but we can’t apply an offset to the result to replace &aMesh->mVertices[0].x.

One workaround could be to define “dummy” CTMFloat and CTMuint values locally, and point to them when the vertex and index vectors are empty, respectively.

primitive support?

does this format support more than just triangle primitives??

tri-strips, tri-fans, quad-strips, and polygons reduce a heck of alot of data used by triangles alone.

I'm considering downloading this, but I NEED support for those primitives...
does this have it??

ctmLoad method should be cancellable

I use OpenCTM to get triangulation from CTM file in a WPF application.
I would like to have a feature which allows cancelling of load operation.
This requires ctmLoad method to have an abort boolean pointer which when true the operation can exit.

Raw to MG2 does not work for some cases.

Not sure if there is a body to look at this...
I export a mesh in Raw ctm file, and it looks well in OpenCTM desktop viewer, but it messed up in desktop viewer when I extract the mesh from Raw ctm file and encode to the MG2 ctm file.
Here are the raw and raw2mg2 images
raw
raw2mg2

Here is the code snippet to reproduce this issue.
FileStream fileStream = new FileStream(@".\TestData\raw.ctm", FileMode.Open);
OpenCTM.CtmFileReader reader = new OpenCTM.CtmFileReader(fileStream);

     Mesh mesh = reader.decode();

     FileStream newfs = new FileStream(@".\TestData\raw2gm2.ctm", FileMode.OpenOrCreate);
     CtmFileWriter fw = new CtmFileWriter(newfs, new MG2Encoder());
     fw.encode(mesh, "reproduce error.");
     newfs.Close();

I uploaded the raw.ctm file here, and please rename it to raw.ctm.
raw

Error:st9bad_alloc

Opening 500MB OBJ file results in error.
Event Viewer: RADAR_PRE_LEAK_WOW64
P1: ctmviewer.exe
P2: 1.0.3.0
P3: 10.0.19043.2.0.0

PLY read doesn't work for headers with \r\n

Simple bug - line 307 in tools\rply\rply.c:

if (strcmp(magic, "ply\n")) {
        fclose(fp);
        error_cb("Not a PLY file. Expected magic number 'ply\\n'");
        return NULL;
    }

On Windows PCL is saving the ply header using \r\n, i.e:

ply\r\n
format ascii 1.0\r\n
... ect

I've forked to fix it on my side, but maybe you can fix it here?

The OFF import routine for ctmconv can access out of bounds

The easiest way to observe this is to compile with libstdc++ assertions enabled. In Makefile.linux, add -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS to the CPPFLAGS. (This is part of the distribution default compiler flags in Fedora).

Now,

$ make -f Makefile.linux
$ curl -L -O https://github.com/mikedh/trimesh/raw/4.2.4/models/headless.ctm
$ LD_LIBRARY_PATH="$PWD/lib" ./tools/ctmconv headless.ctm headless.off
Loading headless.ctm... 3.775 ms
Saving headless.off... 87.118 ms
$ LD_LIBRARY_PATH="$PWD/lib" ./tools/ctmconv headless.off foo.ctm
Loading headless.off... /usr/include/c++/13/bits/basic_string.h:1238: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; const_reference = const char&; size_type = long unsigned int]: Assertion '__pos <= size()' failed.
Aborted (core dumped)

If we remove -s so the executable is not stripped of debug symbols:

$(CPP) -s -o $@ -L$(OPENCTMDIR) -L$(TINYXMLDIR) $(CTMCONVOBJS) -Wl,-rpath,. -lopenctm -ltinyxml

…and furthermore add -g -Og to the CPPFLAGS, then recompile, then we can try again with gdb and get a really nice backtrace:

$ LD_LIBRARY_PATH="$PWD/lib" gdb --args ./tools/ctmconv headless.off foo.ctm
[…]
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff7aae8a3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff7a5c8ee in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff7a448ff in __GI_abort () at abort.c:79
#4  0x00007ffff7cd95b0 in std::__glibcxx_assert_fail (file=file@entry=0x4258c0 "/usr/include/c++/13/bits/basic_string.h", line=line@entry=1238,
    function=function@entry=0x4258e8 "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) const [with _CharT = char; _Traits = std::char_traits<ch"..., condition=condition@entry=0x425798 "__pos <= size()") at ../../../../../libstdc++-v3/src/c++11/assert_fail.cc:41
#5  0x0000000000406ad0 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[] (this=this@entry=0x7fffffffcc30, __pos=__pos@entry=18446744073709551615)
    at /usr/include/c++/13/bits/basic_string.h:1238
#6  0x000000000040689b in TrimString (aString="") at common.cpp:48
#7  0x000000000041be16 in ReadNextLine (aStream=..., aResult="OFF", aComment="Binary STL output from Blender: /home/marcus/Projekt/OpenCTM/tools/headlessgiant") at off.cpp:72
#8  0x000000000041c023 in Import_OFF (aFileName=aFileName@entry=0x7fffffffd370 "headless.off", aMesh=aMesh@entry=0x7fffffffd260) at off.cpp:114
#9  0x000000000040907f in ImportMesh (aFileName=0x7fffffffd370 "headless.off", aMesh=aMesh@entry=0x7fffffffd260) at meshio.cpp:68
#10 0x0000000000405b87 in main (argc=3, argv=0x7fffffffd548) at /usr/include/c++/13/bits/basic_string.h:222
(gdb) frame 6
#6  0x000000000040689b in TrimString (aString="") at common.cpp:48
48        while((p2 > p1) && IsWhiteSpace(aString[p2]))
(gdb) info locals
l = <optimized out>
p1 = 0
p2 = 18446744073709551615
(gdb) info args
aString = ""
(gdb) frame 7
#7  0x000000000041be16 in ReadNextLine (aStream=..., aResult="OFF", aComment="Binary STL output from Blender: /home/marcus/Projekt/OpenCTM/tools/headlessgiant") at off.cpp:72
72          aResult = TrimString(line);
(gdb) info locals
line = ""
commentPos = 0

We can see that when TrimString is passed an empty string, p2 wraps around to the largest size_t value…

OpenCTM/tools/common.cpp

Lines 42 to 45 in 91b3b71

string TrimString(const string &aString)
{
size_t l = aString.size();
size_t p1 = 0, p2 = l - 1;

…and the following loop accesses many bytes from the string…

OpenCTM/tools/common.cpp

Lines 46 to 47 in 91b3b71

while((p1 < p2) && IsWhiteSpace(aString[p1]))
++ p1;

…which is of course very bad, because the string is empty.

blender v2.64

Hi. this script for blender v2.48. Do you have any time to new blender versions?

Please consider versioning the shared library

I’m aware that this library is not actively maintained. If work on it ever picks up again, it would be really helpful if shared library versioning could be added to one or more of the build systems (Makefiles, CMake).

Typically (especially for projects like this one with C API/ABIs), the ABI version is a single integer that starts at 1 and is incremented each time a backwards-incompatible ABI change is made (like removing a function, or changing the type of one of its arguments). The value is encoded in the SONAME field of the shared library file using a linker flag, e.g. N=1; gcc $CFLAGS -Wl,-soname,libfoo.so.$N -o libfoo.so.$N. Then an unversioned symbolic link would be created that points at the versioned shared library.

All of this is important for packaging OpenCTM in Linux distributions. In the case of Fedora, we can add the SONAME version downstream if necessary, but one managed upstream is much better, as it benefits everyone and ensures consistency across distribution.

In CMake, shared library versioning is even more straightforward.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.